Skip to content

Commit 6d48a93

Browse files
authored
Drop Mongo URI from logs (#952)
It also adds basic documentation about the collections in the exporters and what they do.
1 parent 1e917bf commit 6d48a93

File tree

2 files changed

+38
-21
lines changed

2 files changed

+38
-21
lines changed

REFERENCE.md

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,52 @@
11
# Usage Reference
22

33
## Flags
4-
| Flag | Description | Example |
5-
|-----------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------|
6-
| -h, \-\-help | Show context-sensitive help | |
7-
| --[no-]compatible-mode | Enable old mongodb-exporter compatible metrics | |
8-
| --[no-]discovering-mode | Enable autodiscover collections | |
9-
| --mongodb.collstats-colls | List of comma separared databases.collections to get $collStats | --mongodb.collstats-colls=db1,db2.col2 |
10-
| --mongodb.indexstats-colls | List of comma separared databases.collections to get $indexStats | --mongodb.indexstats-colls=db1.col1,db2.col2 |
11-
| --[no-]mongodb.direct-connect | Whether or not a direct connect should be made. Direct connections are not valid if multiple hosts are specified or an SRV URI is used | |
12-
| --[no-]mongodb.global-conn-pool | Use global connection pool instead of creating new pool for each http request | |
13-
| --mongodb.uri | MongoDB connection URI ($MONGODB_URI) | --mongodb.uri=mongodb://user:pass@127.0.0.1:27017/admin?ssl=true |
14-
| --split-cluster | Whether to treat cluster members from the connection URI as separate targets |
15-
| --web.listen-address | Address to listen on for web interface and telemetry | --web.listen-address=":9216" |
16-
| --web.telemetry-path | Metrics expose path | --web.telemetry-path="/metrics" |
17-
| --web.config | Path to the file having Prometheus TLS config for basic auth | --web.config=STRING |
18-
| --web.timeout-offset | Offset to subtract from the timeout in seconds | --web.timeout-offset=1 |
19-
| --log.level | Only log messages with the given severity or above. Valid levels: [debug, info, warn, error, fatal] | --log.level="error" |
4+
| Flag | Description | Example |
5+
|-----------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------|
6+
| -h, \-\-help | Show context-sensitive help | |
7+
| --[no-]compatible-mode | Enable old mongodb-exporter compatible metrics | |
8+
| --[no-]discovering-mode | Enable autodiscover collections | |
9+
| --mongodb.collstats-colls | List of comma separared databases.collections to get $collStats | --mongodb.collstats-colls=db1,db2.col2 |
10+
| --mongodb.indexstats-colls | List of comma separared databases.collections to get $indexStats | --mongodb.indexstats-colls=db1.col1,db2.col2 |
11+
| --[no-]mongodb.direct-connect | Whether or not a direct connect should be made. Direct connections are not valid if multiple hosts are specified or an SRV URI is used | |
12+
| --[no-]mongodb.global-conn-pool | Use global connection pool instead of creating new pool for each http request | |
13+
| --mongodb.uri | MongoDB connection URI ($MONGODB_URI) | --mongodb.uri=mongodb://user:pass@127.0.0.1:27017/admin?ssl=true |
14+
| --split-cluster | Whether to treat cluster members from the connection URI as separate targets |
15+
| --web.listen-address | Address to listen on for web interface and telemetry | --web.listen-address=":9216" |
16+
| --web.telemetry-path | Metrics expose path | --web.telemetry-path="/metrics" |
17+
| --web.config | Path to the file having Prometheus TLS config for basic auth | --web.config=STRING |
18+
| --web.timeout-offset | Offset to subtract from the timeout in seconds | --web.timeout-offset=1 |
19+
| --log.level | Only log messages with the given severity or above. Valid levels: [debug, info, warn, error, fatal] | --log.level="error" |
2020
| --collector.diagnosticdata | Enable collecting metrics from getDiagnosticData |
2121
| --collector.replicasetstatus | Enable collecting metrics from replSetGetStatus |
22-
| --collector.dbstats | Enable collecting metrics from dbStats | |
23-
| --collector.dbstatsfreestorage | Enable collecting freeStorage metrics from dbStats. If the instance has a large number of collections or indexes, obtaining free space usage data may cause processing delays | |
22+
| --collector.dbstats | Enable collecting metrics from dbStats | |
23+
| --collector.dbstatsfreestorage | Enable collecting freeStorage metrics from dbStats. If the instance has a large number of collections or indexes, obtaining free space usage data may cause processing delays | |
2424
| --collector.topmetrics | Enable collecting metrics from top admin command |
2525
| --collector.currentopmetrics | Enable collecting metrics from currentop admin command |
2626
| --collector.indexstats | Enable collecting metrics from $indexStats |
2727
| --collector.collstats | Enable collecting metrics from $collStats |
2828
| --collect-all | Enable all collectors. Same as specifying all --collector.\<name\> |
2929
| --collector.collstats-limit=0 | Disable collstats, dbstats, topmetrics and indexstats collector if there are more than \<n\> collections. 0=No limit |
30-
| --collector.profile-time-ts=30 | Set time for scrape slow queries | This interval must be synchronized with the Prometheus scrape interval |
30+
| --collector.profile-time-ts=30 | Set time for scrape slow queries. This interval must be synchronized with the Prometheus scrape interval | |
3131
| --collector.profile | Enable collecting metrics from profile |
3232
| --collector.shards | Enable collecting metrics related to Mongo shards |
3333
| --collector.pbm | Enable collecting metrics related to Percona Backup for MongoDB |
3434
| --collector.fcv | Enable Feature Compatibility Version collector |
3535
| --metrics.overridedescendingindex | Enable descending index name override to replace -1 with _DESC |
3636
| --version | Show version and exit |
37+
38+
## Collectors
39+
| Collector Name | Description |
40+
|--------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
41+
| dbstats | Collects metrics from dbStats. If the instance has a large number of collections or indexes, obtaining free space usage data may cause processing delays |
42+
| dbstatsfreestorage | Collects freeStorage metrics from dbStats |
43+
| topmetrics | Collects metrics from top admin command |
44+
| currentopmetrics | Collects metrics from currentop admin command |
45+
| indexstats | Collects metrics from $indexStats |
46+
| collstats | Collects metrics from $collStats |
47+
| profile | Collects metrics from profile |
48+
| shards | Collects metrics related to Mongo shards |
49+
| pbm | Collects metrics related to Percona Backup for MongoDB. It will disable [direct connection](https://www.mongodb.com/docs/drivers/node/current/fundamentals/connection/connect/#direct-connection) if needed. Note that this only affects the URI used by this collector and not affect the global MongoDB URI |
50+
| fcv | Collects Feature Compatibility Version metrics |
51+
| diagnosticdata | Collects metrics from getDiagnosticData |
52+
| replicasetstatus | Collects metrics from replSetGetStatus |

exporter/pbm_collector.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,10 @@ func createPBMMetric(name, help string, value float64, labels map[string]string)
5454
}
5555

5656
func newPbmCollector(ctx context.Context, client *mongo.Client, mongoURI string, logger *logrus.Logger) *pbmCollector {
57-
// we can't get details of other cluster from PBM if directConnection is set to true,
57+
// we can't get details of other cluster members from PBM if directConnection is set to true,
5858
// we re-write it if that option is set (e.g from PMM).
5959
if strings.Contains(mongoURI, "directConnection=true") {
60+
logger.Debug("directConnection is enabled, will be disabled for PBM collector.")
6061
mongoURI = strings.ReplaceAll(mongoURI, "directConnection=true", "directConnection=false")
6162
}
6263
return &pbmCollector{
@@ -83,7 +84,7 @@ func (p *pbmCollector) collect(ch chan<- prometheus.Metric) {
8384
pbmEnabledMetric := 0
8485
pbmClient, err := sdk.NewClient(p.ctx, p.mongoURI)
8586
if err != nil {
86-
logger.Errorf("failed to create PBM client from uri %s: %s", p.mongoURI, err.Error())
87+
logger.Warnf("failed to create PBM client: %s", err.Error())
8788
return
8889
}
8990
defer func() {

0 commit comments

Comments
 (0)