mongodb_exporter icon indicating copy to clipboard operation
mongodb_exporter copied to clipboard

Ascending and descending indexes not shown in mongodb_collstats_storageStats_indexSizes_<name>

Open pclaudinoo opened this issue 1 year ago • 0 comments

Describe the bug After the creation of an index with a field:1 and then the same field:-1, the -1 index is not shown in mongodb_collstats_storageStats_indexSizes_

When the $indextstas is run inside mongo shell, it shows the index

rsGREEN01:PRIMARY> db.MyColForExporter.aggregate( [ { $indexStats: { } } ] )
{ "name" : "foo_1", "key" : { "foo" : 1 }, "host" : "82f532a48d72:27017", "accesses" : { "ops" : NumberLong(0), "since" : ISODate("2023-07-25T10:08:32.355Z") }, "spec" : { "v" : 2, "key" : { "foo" : 1 }, "name" : "foo_1" } }
{ "name" : "_id_", "key" : { "_id" : 1 }, "host" : "82f532a48d72:27017", "accesses" : { "ops" : NumberLong(0), "since" : ISODate("2023-07-24T15:20:44.631Z") }, "spec" : { "v" : 2, "key" : { "_id" : 1 }, "name" : "_id_" } }
{ "name" : "foo_-1", "key" : { "foo" : -1 }, "host" : "82f532a48d72:27017", "accesses" : { "ops" : NumberLong(5), "since" : ISODate("2023-07-25T08:46:08.858Z") }, "spec" : { "v" : 2, "key" : { "foo" : -1 }, "name" : "foo_-1" } }

But the metric does not exist

[root@7b9f50bfa3f4 srv]# grep -i indexsize metrics.txt
# HELP mongodb_collstats_storageStats_indexSizes_foo_1 collstats.storageStats.indexSizes.
# TYPE mongodb_collstats_storageStats_indexSizes_foo_1 untyped
mongodb_collstats_storageStats_indexSizes_foo_1{cl_id="64b019a12951c4fc833ca7db",cl_role="",collection="MyColForExporter",database="myDBforExporter",rs_nm="rsGREEN01",rs_state="2"} 36864
# HELP mongodb_collstats_storageStats_indexSizes_id collstats.storageStats.indexSizes.
# TYPE mongodb_collstats_storageStats_indexSizes_id untyped
mongodb_collstats_storageStats_indexSizes_id{cl_id="64b019a12951c4fc833ca7db",cl_role="",collection="MyColForExporter",database="myDBforExporter",rs_nm="rsGREEN01",rs_state="2"} 36864
mongodb_collstats_storageStats_indexSizes_id{cl_id="64b019a12951c4fc833ca7db",cl_role="",collection="myCol",database="myDB",rs_nm="rsGREEN01",rs_state="2"} 36864
# HELP mongodb_collstats_storageStats_totalIndexSize collstats.storageStats.
# TYPE mongodb_collstats_storageStats_totalIndexSize untyped
mongodb_collstats_storageStats_totalIndexSize{cl_id="64b019a12951c4fc833ca7db",cl_role="",collection="MyColForExporter",database="myDBforExporter",rs_nm="rsGREEN01",rs_state="2"} 94208
mongodb_collstats_storageStats_totalIndexSize{cl_id="64b019a12951c4fc833ca7db",cl_role="",collection="myCol",database="myDB",rs_nm="rsGREEN01",rs_state="2"} 36864
# HELP mongodb_dbstats_indexSize dbstats.
# TYPE mongodb_dbstats_indexSize untyped
mongodb_dbstats_indexSize{cl_id="64b019a12951c4fc833ca7db",cl_role="",database="admin",rs_nm="rsGREEN01",rs_state="2"} 147456
mongodb_dbstats_indexSize{cl_id="64b019a12951c4fc833ca7db",cl_role="",database="config",rs_nm="rsGREEN01",rs_state="2"} 45056
mongodb_dbstats_indexSize{cl_id="64b019a12951c4fc833ca7db",cl_role="",database="local",rs_nm="rsGREEN01",rs_state="2"} 159744
mongodb_dbstats_indexSize{cl_id="64b019a12951c4fc833ca7db",cl_role="",database="myDB",rs_nm="rsGREEN01",rs_state="2"} 36864
mongodb_dbstats_indexSize{cl_id="64b019a12951c4fc833ca7db",cl_role="",database="myDBforExporter",rs_nm="rsGREEN01",rs_state="2"} 94208

To Reproduce Steps to reproduce the behavior:

  1. Create the index: db.MyColForExporter.createIndex({"foo":1})
  2. Create an homonimous index with descending order: db.MyColForExporter.createIndex({"foo":-1})
  3. Compare data exhibited in $indexStats and metrics generated by the exporter

Expected behavior To have one metric mongodb_collstats_storageStats_indexSizes_foo_1 and another mongodb_collstats_storageStats_indexSizes_foo_-1

Logs NA

Environment

  • OS: Centos 7.9
  • Environment: Docker
  • MongoDB version: Percona Server for MongoDB shell version v4.4.9-10
  • Exporter version: v0.39.0

Additional context Add any other context about the problem here.

pclaudinoo avatar Jul 25 '23 10:07 pclaudinoo