Skip to content

Commit

Permalink
PMM-9870 fix collstats indexSizes metrics.
Browse files Browse the repository at this point in the history
  • Loading branch information
BupycHuk committed Nov 8, 2024
1 parent 73fd414 commit 6907552
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
9 changes: 8 additions & 1 deletion exporter/collstats_collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ func TestCollStatsCollector(t *testing.T) {
ti := labelsGetterMock{}

collection := []string{"testdb.testcol_00", "testdb.testcol_01", "testdb.testcol_02"}
c := newCollectionStatsCollector(ctx, client, logrus.New(), false, false, ti, collection)
logger := logrus.New()
c := newCollectionStatsCollector(ctx, client, logger, false, false, ti, collection)

// The last \n at the end of this string is important
expected := strings.NewReader(`
Expand All @@ -67,6 +68,11 @@ mongodb_collstats_latencyStats_commands_latency{collection="testcol_02",database
mongodb_collstats_latencyStats_transactions_ops{collection="testcol_00",database="testdb"} 0
mongodb_collstats_latencyStats_transactions_ops{collection="testcol_01",database="testdb"} 0
mongodb_collstats_latencyStats_transactions_ops{collection="testcol_02",database="testdb"} 0
# HELP mongodb_collstats_storageStats_indexSizes collstats.storageStats.indexSizes.
# TYPE mongodb_collstats_storageStats_indexSizes untyped
mongodb_collstats_storageStats_indexSizes{collection="testcol_00",database="testdb",index_name="_id_"} 4096
mongodb_collstats_storageStats_indexSizes{collection="testcol_01",database="testdb",index_name="_id_"} 4096
mongodb_collstats_storageStats_indexSizes{collection="testcol_02",database="testdb",index_name="_id_"} 4096
# HELP mongodb_collstats_storageStats_capped collstats.storageStats.
# TYPE mongodb_collstats_storageStats_capped untyped
mongodb_collstats_storageStats_capped{collection="testcol_00",database="testdb"} 0
Expand All @@ -81,6 +87,7 @@ mongodb_collstats_storageStats_capped{collection="testcol_02",database="testdb"}
filter := []string{
"mongodb_collstats_latencyStats_commands_latency",
"mongodb_collstats_storageStats_capped",
"mongodb_collstats_storageStats_indexSizes",
"mongodb_collstats_latencyStats_transactions_ops",
}
err := testutil.CollectAndCompare(c, expected, filter...)
Expand Down
3 changes: 2 additions & 1 deletion exporter/dbstats_collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ func TestDBStatsCollector(t *testing.T) {

ti := labelsGetterMock{}

c := newDBStatsCollector(ctx, client, logrus.New(), false, ti, []string{dbName}, false)
logger := logrus.New()
c := newDBStatsCollector(ctx, client, logger, false, ti, []string{dbName}, false)
expected := strings.NewReader(`
# HELP mongodb_dbstats_collections dbstats.
# TYPE mongodb_dbstats_collections untyped
Expand Down
1 change: 1 addition & 0 deletions exporter/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ var (
"serverStatus.queues.execution.": "txn_rw_type",
"serverStatus.wiredTiger.perf.": "perf_bucket",
"systemMetrics.disks.": "device_name",
"collstats.storageStats.indexSizes.": "index_name",
}

// Regular expressions used to make the metric name Prometheus-compatible
Expand Down

0 comments on commit 6907552

Please sign in to comment.