Skip to content
A Prometheus exporter for MongoDB including sharding, replication and storage engines
Branch: master
Clone or download
DexterHD Merge pull request #137 from CodeLingoBot/rewrite
Fix function comments based on best practices from Effective Go
Latest commit 45b9aa5 Mar 18, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Add CODEOWNERS. Feb 18, 2019
collector Fix function comments based on best practices from Effective Go Mar 15, 2019
scripts PMM-3513 Make releases with GoReleaser (#132) Mar 5, 2019
shared PMM-2591: Move TestConnection func to shared/ Jun 13, 2018
testdata
vendor PMM-3513 Make releases with GoReleaser (#132) Mar 5, 2019
.gitignore
.goreleaser.yml PMM-3513 Make releases with GoReleaser (#132) Mar 5, 2019
.travis.yml
CHANGELOG.md Release 0.7.0 Mar 11, 2019
CONTRIBUTING.md
Dockerfile
Gopkg.lock
Gopkg.toml
LICENSE
Makefile PMM-3513 Make releases with GoReleaser (#132) Mar 5, 2019
NOTICE Apply Apache 2.0 license. Jul 4, 2017
README.md PMM-3513 Make releases with GoReleaser (#132) Mar 5, 2019
VERSION
docker-compose.yml
go.mod Add go.mod as feature request Feb 27, 2019
go.sum Add go.mod as feature request Feb 27, 2019
groups.yml Initial Data load Apr 6, 2016
mongodb_exporter.go
mongodb_exporter_test.go PMM-3513 Make releases with GoReleaser (#132) Mar 5, 2019

README.md

Percona MongoDB Exporter

Release Build Status codecov.io Code Coverage Go Report Card CLA assistant

Based on MongoDB exporter by David Cuadrado (@dcu), but forked for full sharded support and structure changes.

Features

  • MongoDB Server Status metrics (cursors, operations, indexes, storage, etc)
  • MongoDB Replica Set metrics (members, ping, replication lag, etc)
  • MongoDB Replication Oplog metrics (size, length in time, etc)
  • MongoDB Sharding metrics (shards, chunks, db/collections, balancer operations)
  • MongoDB RocksDB storage-engine metrics (levels, compactions, cache usage, i/o rates, etc)
  • MongoDB WiredTiger storage-engine metrics (cache, blockmanger, tickets, etc)
  • MongoDB Top Metrics per collection (writeLock, readLock, query, etc*)

Building and running

Building

Just run make. It will install all needed tools, format code with go fmt, build a binary for your OS inside ./dist directory and runs tests.

Note: You need to have docker installed to run tests as it uses mongodb. Also port 27017 must been freed as docker-compos maps this port into your host OS while testing.

make

If you want just build a binary for your OS without codestyle checks and tests you can run command below:

make build

If you don't have or don't want to install the whole GO stuff, use this docker build that creates a container with a freshly built mongodb_exporter binary:

make docker

Running

To define your own MongoDB URL, use environment variable MONGODB_URI. If set this variable takes precedence over --mongodb.uri flag.

To enable HTTP basic authentication, set environment variable HTTP_AUTH to user:password pair. Alternatively, you can use YAML file with server_user and server_password fields.

export MONGODB_URI='mongodb://localhost:27017'
export HTTP_AUTH='user:password'
./bin/mongodb_exporter [<flags>]

Flags

See the help page with -h.

If you use MongoDB Authorization, you must:

  1. Create a user with 'clusterMonitor' role and 'read' on the 'local' database, like the following (replace username/password!):
db.getSiblingDB("admin").createUser({
    user: "mongodb_exporter",
    pwd: "s3cr3tpassw0rd",
    roles: [
        { role: "clusterMonitor", db: "admin" },
        { role: "read", db: "local" }
    ]
})
  1. Set environment variable MONGODB_URI before starting the exporter:
export MONGODB_URI=mongodb://mongodb_exporter:s3cr3tpassw0rd@localhost:27017

If you use x.509 Certificates to Authenticate Clients, pass in username and authMechanism via connection options to the MongoDB uri. Eg:

mongodb://CN=myName,OU=myOrgUnit,O=myOrg,L=myLocality,ST=myState,C=myCountry@localhost:27017/?authMechanism=MONGODB-X509

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 prevent the need to an exporter per type of process.

Roadmap

  • Document more configurations options here
  • Stabilize RocksDB and WiredTiger support
  • Move MongoDB user/password/authdb to a file (for security)
  • Write more go tests

Submitting Bug Reports

If you find a bug in Percona MongoDB Exporter or one of the related projects, you should submit a report to that project's JIRA issue tracker.

Your first step should be to search the existing set of open tickets for a similar report. If you find that someone else has already reported your problem, then you can upvote that report to increase its visibility.

If there is no existing report, submit a report following these steps:

  1. Sign in to Percona JIRA. You will need to create an account if you do not have one.
  2. Go to the Create Issue screen and select the relevant project.
  3. Fill in the fields of Summary, Description, Steps To Reproduce, and Affects Version to the best you can. If the bug corresponds to a crash, attach the stack trace from the logs.

An excellent resource is Elika Etemad's article on filing good bug reports..

As a general rule of thumb, please try to create bug reports that are:

  • Reproducible. Include steps to reproduce the problem.
  • Specific. Include as much detail as possible: which version, what environment, etc.
  • Unique. Do not duplicate existing tickets.
  • Scoped to a Single Bug. One bug per report.
You can’t perform that action at this time.