Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PMM-2203 v0.5.0 #98

Merged
merged 38 commits into from
May 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
23ce6f9
Support integration tests against non-locahost db
bz2 Jan 13, 2018
c7535b5
Add vim temp files to .gitignore
bz2 Jan 13, 2018
37de392
Bump version.
AlekSi Jan 17, 2018
3bf17c2
Ensure that vendor/ is in sync with code and Gopkg
AlekSi Jan 17, 2018
d3187ea
Use dep 0.4.1.
AlekSi Jan 25, 2018
3497c47
PMM-1956: Check connection with exporter.
arvenil Mar 1, 2018
9834d67
cleanups
arvenil Mar 1, 2018
0aa029b
hmmm
arvenil Mar 1, 2018
001b361
Add log.
arvenil Mar 1, 2018
8f13816
Wait for MongoDB.
arvenil Mar 1, 2018
1339b61
Fix order.
arvenil Mar 1, 2018
7b61165
Allow perconalab/percona-server-mongodb:3.6 to fail.
arvenil Mar 1, 2018
365f74f
Disable email notifications.
arvenil Mar 1, 2018
dbd0e56
correct a typo
xgt001 Feb 19, 2018
60c8211
PMM-1956: CR fixes.
arvenil Mar 6, 2018
3676eb1
Merge pull request #92 from percona/PMM-1956_Check_connection_with_ex…
arvenil Mar 7, 2018
3b4648f
PMM-2203 Fix typo.
AlekSi Mar 7, 2018
b049b42
Test with Go 1.10, do not test with MongoDB 3.0.
AlekSi Mar 20, 2018
3228f5c
Merge branch 'test_mongodb_url' of https://github.com/bz2/mongodb_exp…
AlekSi Mar 21, 2018
f5d1a20
Minor style fixes.
AlekSi Mar 21, 2018
3fbcf1a
Export mongodb version as a metric
bz2 Jan 13, 2018
d1c9d7b
Update dependencies, prune used files.
AlekSi Mar 21, 2018
e7b06a4
Add dependencies.
AlekSi Mar 21, 2018
b614820
Actually collect version information.
AlekSi Mar 21, 2018
d5eab5d
Add deps.
AlekSi Mar 21, 2018
93494ee
Use exporter_shared package.
AlekSi Mar 21, 2018
20684c2
Fix flags descriptions.
AlekSi Mar 21, 2018
f4c4567
Use pointers for large structs.
AlekSi Mar 21, 2018
199266b
Fix dep checksum.
AlekSi Mar 21, 2018
4d833cc
Add comments to more queries.
AlekSi Mar 21, 2018
04d8fab
Redact MongoURI
unguiculus Apr 12, 2018
5264c5a
Merge branch 'master' into develop
arvenil May 14, 2018
234a527
Comment.
arvenil May 15, 2018
7292b0a
PMM-2384: Add test for MongoSession.
arvenil May 15, 2018
829be4d
Merge pull request #101 from unguiculus/feature/redact-uri
arvenil May 15, 2018
7d937a1
PMM-2533: More tests.
arvenil May 15, 2018
826a245
Use percona/percona-server-mongodb:3.6 instead of perconalab image.
arvenil May 15, 2018
8c13d69
Fix Gopkg.lock.
arvenil May 15, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# editor temp files
*.sw[nop]

# build artifacts
mongodb_exporter
coverage.txt
coverage_temp.txt
25 changes: 23 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,40 @@ matrix:
- go: master

env:
- MONGODB_IMAGE=mongo:3.2
- MONGODB_IMAGE=mongo:3.4
- MONGODB_IMAGE=mongo:3.6
- MONGODB_IMAGE=percona/percona-server-mongodb:3.2
- MONGODB_IMAGE=percona/percona-server-mongodb:3.4
- MONGODB_IMAGE=perconalab/percona-server-mongodb:3.6
- MONGODB_IMAGE=percona/percona-server-mongodb:3.6

services:
- docker

before_script:
# Start docker containers.
- docker-compose up -d
# Wait for MongoDB to become available.
- |
until docker-compose exec mongo mongo --quiet --eval 'db.runCommand("ping").ok' > /dev/null; do
>&2 echo "MongoDB is unavailable - sleeping"
sleep 1
done
>&2 echo "MongoDB is up"
# Display logs for debug purposes.
- docker-compose logs
# Display versions.
- docker --version
- docker-compose --version
- docker-compose up -d
- docker-compose exec mongo mongo --version

script:
# ensure that vendor/ is in sync with code and Gopkg.*
- curl https://github.com/golang/dep/releases/download/v0.4.1/dep-linux-amd64 -L -o ~/dep && chmod +x ~/dep
- rm -fr vendor/
- ~/dep ensure -v
- git diff --exit-code

- make format build testall

after_success:
Expand All @@ -37,3 +57,4 @@ notifications:
on_failure: always
rooms:
secure: updWrOALfF29z30ogJ4m21WX0oOSYbRX/+abuEqXCC9zZ2QI7EoRR61hrAgNXJXUTffmUIM0vCrToYlybMsdcZHwCXWN8vr2yW3fyypfs/+rUng1qigEy1wVVIFgAC/6NruhmuUMWo1qwe4tUenQmegBiSpYRVRI10Qsnj6TggCNVz0cuoxpmzpVvNH78s1elnU4P1REWhjStuqQvKgG5cWOsvI+9l2Z+t9HdpYE7E7N3Ec73t2Z4wKhlpScbLF+mhnTWV6zgCkLaVdMshFeBEuYWmRr3D2QJWMntl/DrVaRoW76kX9nm2PQ/P4q0BdQslf5WsAiONWPOOWqK6n9RM9SegGSEXnXiqkWtmJQspa3zhjkNZStaD/g5E4yP5QnTbk4WP8ma18yQfMthXeQiQOEWj6zOTzBslu6Iyyc9QzbNijnYy3ZBBBAWGaKjFKmTrMTgl19SbAsvgi41A+zrVL5LeCwAR0/2QUdMegHZSla9WBiURgT/quA8EnA3N+ObNQBpqBETJmSPpJbqrkZI8+7oo4nFxLkwCRVyI4/XInTl5aKsRNYP95kPX3zJuUEe8x39qYhG5QcGV8G8AK0B+jrGoEB2qSN2p+Ye1XE6+Z38KktVzM3GmMOt/v+ts1ZjiaZvK0zlb7vRTMuiBmAjAnB5l5vmNSjkP6+ZL832Og=
email: false
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog

## v0.4.0 (2017-01-17)
## v0.5.0 (not released yet)

* Removed tests for EOL'ed MongoDB 3.0 and Percona Server for MongoDB 3.0.

## v0.4.0 (2018-01-17)

* New flags `-collect.database` and `-collect.collection` can be used to enable collection of database and collection
metrics. They are disabled by default.
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ The easiest way to make a local development setup is to use Docker Compose.
```
docker-compose up
make all testall
export MONGODB_URL='mongodb://localhost:27017'
./mongodb_exporter
```

`testall` make target will run integration tests.
`testall` make target will run integration tests against MongoDB instance specified in
`TEST_MONGODB_URL` environment variable (defaults to `mongodb://localhost:27017`).


## Vendoring
Expand Down
92 changes: 75 additions & 17 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 4 additions & 20 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,4 @@
# Gopkg.toml example
#
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"
[prune]
go-tests = true
non-go = true
unused-packages = true
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ mongodb://CN=myName,OU=myOrgUnit,O=myOrg,L=myLocality,ST=myState,C=myCountry@loc

## Note about how this works

Point the process to any mongo port and it will detect if it is a mongos, replicaset member, or stand alone mongod and return the appropriate metrics for that type of node. This was done to preent the need to an exporter per type of process.
Point the process to any mongo port and it will detect if it is a mongos, replicaset member, or stand alone mongod and return the appropriate metrics for that type of node. This was done to prevent the need to an exporter per type of process.

## Roadmap

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.4.0
0.5.0
10 changes: 10 additions & 0 deletions collector/mongod/server_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ import (
)

var (
versionInfo = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: "version",
Name: "info",
Help: "Software version information for mongodb process.",
}, []string{"mongodb"})
instanceUptimeSeconds = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: Namespace,
Subsystem: "instance",
Expand All @@ -46,6 +52,7 @@ var (

// ServerStatus keeps the data returned by the serverStatus() method.
type ServerStatus struct {
Version string `bson:"version"`
Uptime float64 `bson:"uptime"`
UptimeEstimate float64 `bson:"uptimeEstimate"`
LocalTime time.Time `bson:"localTime"`
Expand Down Expand Up @@ -83,9 +90,11 @@ type ServerStatus struct {

// Export exports the server status to be consumed by prometheus.
func (status *ServerStatus) Export(ch chan<- prometheus.Metric) {
versionInfo.WithLabelValues(status.Version).Set(1)
instanceUptimeSeconds.Set(status.Uptime)
instanceUptimeEstimateSeconds.Set(status.Uptime)
instanceLocalTime.Set(float64(status.LocalTime.Unix()))
versionInfo.Collect(ch)
instanceUptimeSeconds.Collect(ch)
instanceUptimeEstimateSeconds.Collect(ch)
instanceLocalTime.Collect(ch)
Expand Down Expand Up @@ -156,6 +165,7 @@ func (status *ServerStatus) Export(ch chan<- prometheus.Metric) {

// Describe describes the server status for prometheus.
func (status *ServerStatus) Describe(ch chan<- *prometheus.Desc) {
versionInfo.Describe(ch)
instanceUptimeSeconds.Describe(ch)
instanceUptimeEstimateSeconds.Describe(ch)
instanceLocalTime.Describe(ch)
Expand Down
4 changes: 4 additions & 0 deletions collector/mongod/server_status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ func TestParserServerStatus(t *testing.T) {
serverStatus := &ServerStatus{}
loadServerStatusFromBson(data, serverStatus)

if serverStatus.Version != "2.6.7" {
t.Errorf("Server version incorrect: %s", serverStatus.Version)
}

if serverStatus.Asserts == nil {
t.Error("Asserts group was not loaded")
}
Expand Down
10 changes: 5 additions & 5 deletions collector/mongodb_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ type MongodbCollectorOpts struct {
CollectCollectionMetrics bool
}

func (in MongodbCollectorOpts) toSessionOps() shared.MongoSessionOpts {
return shared.MongoSessionOpts{
func (in *MongodbCollectorOpts) toSessionOps() *shared.MongoSessionOpts {
return &shared.MongoSessionOpts{
URI: in.URI,
TLSConnection: in.TLSConnection,
TLSCertificateFile: in.TLSCertificateFile,
Expand All @@ -57,7 +57,7 @@ func (in MongodbCollectorOpts) toSessionOps() shared.MongoSessionOpts {

// MongodbCollector is in charge of collecting mongodb's metrics.
type MongodbCollector struct {
Opts MongodbCollectorOpts
Opts *MongodbCollectorOpts

scrapesTotal prometheus.Counter
scrapeErrorsTotal prometheus.Counter
Expand All @@ -70,7 +70,7 @@ type MongodbCollector struct {
}

// NewMongodbCollector returns a new instance of a MongodbCollector.
func NewMongodbCollector(opts MongodbCollectorOpts) *MongodbCollector {
func NewMongodbCollector(opts *MongodbCollectorOpts) *MongodbCollector {
exporter := &MongodbCollector{
Opts: opts,

Expand Down Expand Up @@ -190,7 +190,7 @@ func (exporter *MongodbCollector) scrape(ch chan<- prometheus.Metric) {

mongoSess := exporter.getSession()
if mongoSess == nil {
err = fmt.Errorf("Can't create mongo session to %s", exporter.Opts.URI)
err = fmt.Errorf("Can't create mongo session to %s", shared.RedactMongoUri(exporter.Opts.URI))
log.Error(err)
exporter.mongoUp.Set(0)
return
Expand Down
Loading