Skip to content

Commit c673d48

Browse files
Remove system colections from collstats (#917)
* Remove system colections from collstats See #893 When the database profiler is enabled a `system.profile` collection is created for which the collection of collstats is not possible. This results in `Unauthorized` errors. For example: ```Sep 23 11:39:03 db-01 mongodb_exporter[53912]: time="2024-09-23T11:39:03Z" level=error msg="cannot get $collstats cursor for collection <database>.system.profile: (Unauthorized) not authorized on <database> to execute command { aggregate: \"system.profile\", pipeline: [ { $collStats: { latencyStats: { histograms: false }, storageStats: { scale: 1 } } }, { $project: { storageStats.wiredTiger: 0, storageStats.indexDetails: 0 } } ], cursor: {}, lsid: { id: UUID("<lsid>" }, $clusterTime: { clusterTime: Timestamp(<timestamp>, 1099), signature: { hash: BinData(0, <signature>), keyId: <keyid> } }, $db: \"<database>\" }" collector=collstats``` Should be safe to filter out system collection when gathering collstats as it was already done for the indexstats collector. * Remove whitespaces --------- Co-authored-by: Jiří Čtvrtka <62988319+JiriCtvrtka@users.noreply.github.com>
1 parent ccd4f17 commit c673d48

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

exporter/collstats_collector.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ func (d *collstatsCollector) collect(ch chan<- prometheus.Metric) {
9292
database := parts[0]
9393
collection := strings.Join(parts[1:], ".") // support collections having a .
9494

95+
// exclude system collections
96+
if strings.HasPrefix(collection, "system.") {
97+
continue
98+
}
99+
95100
aggregation := bson.D{
96101
{
97102
Key: "$collStats", Value: bson.M{

0 commit comments

Comments
 (0)