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-3106: Be consistent and use MONGODB_URI everywhere. #116

Merged
merged 3 commits into from
Nov 21, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ make all testall
```

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


## Vendoring
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ make

### Running

To define your own MongoDB URL, use environment variable `MONGODB_URL`. If set this variable takes precedence over `-mongodb.uri` flag.
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.

```bash
export MONGODB_URL='mongodb://localhost:27017'
export MONGODB_URI='mongodb://localhost:27017'
export HTTP_AUTH='user:password'
./mongodb_exporter <flags>
```
Expand All @@ -59,10 +59,10 @@ db.getSiblingDB("admin").createUser({
})
```

2. Set environment variable `MONGODB_URL` before starting the exporter:
2. Set environment variable `MONGODB_URI` before starting the exporter:

```bash
export MONGODB_URL=mongodb://mongodb_exporter:s3cr3tpassw0rd@localhost:27017
export MONGODB_URI=mongodb://mongodb_exporter:s3cr3tpassw0rd@localhost:27017
```

If you use [x.509 Certificates to Authenticate Clients](https://docs.mongodb.com/manual/tutorial/configure-x509-client-authentication/), pass in username and `authMechanism` via [connection options](https://docs.mongodb.com/manual/reference/connection-string/#connections-connection-options) to the MongoDB uri. Eg:
Expand Down
2 changes: 1 addition & 1 deletion collector/mongodb_collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
)

func testMongoDBURL() string {
if u := os.Getenv("TEST_MONGODB_URL"); u != "" {
if u := os.Getenv("TEST_MONGODB_URI"); u != "" {
return u
}
return "mongodb://localhost:27017"
Expand Down
6 changes: 3 additions & 3 deletions mongodb_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ const (
program = "mongodb_exporter"
)

func defaultMongoDBURL() string {
if u := os.Getenv("MONGODB_URL"); u != "" {
func defaultMongoDBURI() string {
if u := os.Getenv("MONGODB_URI"); u != "" {
return u
}
return "mongodb://localhost:27017"
Expand All @@ -51,7 +51,7 @@ var (
collectTopF = flag.Bool("collect.topmetrics", false, "Enable collection of table top metrics")
collectIndexUsageF = flag.Bool("collect.indexusage", false, "Enable collection of per index usage stats")

uriF = flag.String("mongodb.uri", defaultMongoDBURL(), "MongoDB URI, format: [mongodb://][user:pass@]host1[:port1][,host2[:port2],...][/database][?options]")
uriF = flag.String("mongodb.uri", defaultMongoDBURI(), "MongoDB URI, format: [mongodb://][user:pass@]host1[:port1][,host2[:port2],...][/database][?options]")
tlsF = flag.Bool("mongodb.tls", false, "Enable tls connection with mongo server")
tlsCertF = flag.String("mongodb.tls-cert", "", "Path to PEM file that contains the certificate (and optionally also the decrypted private key in PEM format).\n"+
" \tThis should include the whole certificate chain.\n"+
Expand Down