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

Add storage stats to collection metrics #283

Merged
merged 3 commits into from
Jun 3, 2021

Conversation

masaruhoshi
Copy link
Contributor

@masaruhoshi masaruhoshi commented Jun 1, 2021

Includes additional information about collection stats about "storage".

# HELP mongodb_mydb_mycol_storageStats_avgObjSize mydb.mycol.storageStats.
# TYPE mongodb_mydb_mycol_storageStats_avgObjSize untyped
mongodb_mydb_mycol_storageStats_avgObjSize{cl_id="5f107dfb3a6fc97a81753480",cl_role="shardsvr",collection="mycol",database="mydb",rs_nm="shard-0",rs_state="1"} 238
# HELP mongodb_mydb_mycol_storageStats_capped mydb.mycol.storageStats.
# TYPE mongodb_mydb_mycol_storageStats_capped untyped
mongodb_mydb_mycol_storageStats_capped{cl_id="5f107dfb3a6fc97a81753480",cl_role="shardsvr",collection="mycol",database="mydb",rs_nm="shard-0",rs_state="1"} 0
# HELP mongodb_mydb_mycol_storageStats_count mydb.mycol.storageStats.
# TYPE mongodb_mydb_mycol_storageStats_count untyped
mongodb_mydb_mycol_storageStats_count{cl_id="5f107dfb3a6fc97a81753480",cl_role="shardsvr",collection="mycol",database="mydb",rs_nm="shard-0",rs_state="1"} 57
# HELP mongodb_mydb_mycol_storageStats_freeStorageSize mydb.mycol.storageStats.
# TYPE mongodb_mydb_mycol_storageStats_freeStorageSize untyped
mongodb_mydb_mycol_storageStats_freeStorageSize{cl_id="5f107dfb3a6fc97a81753480",cl_role="shardsvr",collection="mycol",database="mydb",rs_nm="shard-0",rs_state="1"} 0
# HELP mongodb_mydb_mycol_storageStats_indexSizes_id mydb.mycol.storageStats.indexSizes.
# TYPE mongodb_mydb_mycol_storageStats_indexSizes_id untyped
mongodb_mydb_mycol_storageStats_indexSizes_id{cl_id="5f107dfb3a6fc97a81753480",cl_role="shardsvr",collection="mycol",database="mydb",rs_nm="shard-0",rs_state="1"} 20480
# HELP mongodb_mydb_mycol_storageStats_nindexes mydb.mycol.storageStats.
# TYPE mongodb_mydb_mycol_storageStats_nindexes untyped
mongodb_mydb_mycol_storageStats_nindexes{cl_id="5f107dfb3a6fc97a81753480",cl_role="shardsvr",collection="mycol",database="mydb",rs_nm="shard-0",rs_state="1"} 1
# HELP mongodb_mydb_mycol_storageStats_scaleFactor mydb.mycol.storageStats.
# TYPE mongodb_mydb_mycol_storageStats_scaleFactor untyped
mongodb_mydb_mycol_storageStats_scaleFactor{cl_id="5f107dfb3a6fc97a81753480",cl_role="shardsvr",collection="mycol",database="mydb",rs_nm="shard-0",rs_state="1"} 1
# HELP mongodb_mydb_mycol_storageStats_size mydb.mycol.storageStats.
# TYPE mongodb_mydb_mycol_storageStats_size untyped
mongodb_mydb_mycol_storageStats_size{cl_id="5f107dfb3a6fc97a81753480",cl_role="shardsvr",collection="mycol",database="mydb",rs_nm="shard-0",rs_state="1"} 13591
# HELP mongodb_mydb_mycol_storageStats_storageSize mydb.mycol.storageStats.
# TYPE mongodb_mydb_mycol_storageStats_storageSize untyped
mongodb_mydb_mycol_storageStats_storageSize{cl_id="5f107dfb3a6fc97a81753480",cl_role="shardsvr",collection="mycol",database="mydb",rs_nm="shard-0",rs_state="1"} 20480
# HELP mongodb_mydb_mycol_storageStats_totalIndexSize mydb.mycol.storageStats.
# TYPE mongodb_mydb_mycol_storageStats_totalIndexSize untyped
mongodb_mydb_mycol_storageStats_totalIndexSize{cl_id="5f107dfb3a6fc97a81753480",cl_role="shardsvr",collection="mycol",database="mydb",rs_nm="shard-0",rs_state="1"} 20480
# HELP mongodb_mydb_mycol_storageStats_totalSize mydb.mycol.storageStats.
# TYPE mongodb_mydb_mycol_storageStats_totalSize untyped
mongodb_mydb_mycol_storageStats_totalSize{cl_id="5f107dfb3a6fc97a81753480",cl_role="shardsvr",collection="mycol",database="mydb",rs_nm="shard-0",rs_state="1"} 40960

This is intentionally filtering out any information from storageStats.wiredTiger and storageStats.indexDetails since it can lead to a high-cardinality issues

db.mycol.aggregate( [ { $collStats: { storageStats: { scale: 1 } } }, { "$project": { "storageStats.wiredTiger": 0, "storageStats.indexDetails": 0 } } ] ).pretty()
{
        "ns" : "mydb.mycol",
        "host" : "localhost:27017",
        "localTime" : ISODate("2021-06-02T02:02:59.173Z"),
        "storageStats" : {
                "size" : 7391055,
                "count" : 48265,
                "avgObjSize" : 153,
                "storageSize" : 4222976,
                "freeStorageSize" : 548864,
                "capped" : false,
                "nindexes" : 3,
                "indexBuilds" : [ ],
                "totalIndexSize" : 5398528,
                "totalSize" : 9621504,
                "indexSizes" : {
                        "_id_" : 2646016,
                        "key_1" : 2183168,
                        "licenseKey_1" : 569344
                },
                "scaleFactor" : 1
        }
}

  • Tests passed.
  • Fix conflicts with target branch.
  • Attach screenshots/console output to confirm new behavior to jira ticket, if applicable.

When all checks have passed and code is ready for the review, bot should add pmm-review-exporters team as the reviewer. That would assign people from the review team automatically. Report any issues on our Forums and Discord.

@masaruhoshi masaruhoshi force-pushed the additional-exporter-metrics branch from 0fc6535 to 317cea1 Compare June 2, 2021 00:33
@masaruhoshi masaruhoshi changed the title [WIP] Add additional collection metrics Add storage stats to collection metrics Jun 2, 2021
@masaruhoshi masaruhoshi marked this pull request as ready for review June 2, 2021 03:03
@denisok denisok requested review from a team, askomorokhov and percona-csalguero and removed request for a team June 2, 2021 05:19
Copy link
Contributor

@askomorokhov askomorokhov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributions.
Looks good to me. 👍

@percona-csalguero
Copy link
Contributor

Ran the tests manually and all are passing.
Also I see the metrics:

# HELP mongodb_test_c1_localTime test.c1.
# TYPE mongodb_test_c1_localTime untyped
mongodb_test_c1_localTime{cl_id="60b8cc6dc871fe9be7729427",cl_role="shardsvr",collection="c1",database="test",rs_nm="rs1",rs_state="1"} 1.622725322282e+12
# HELP mongodb_test_c1_storageStats_avgObjSize test.c1.storageStats.
# TYPE mongodb_test_c1_storageStats_avgObjSize untyped
mongodb_test_c1_storageStats_avgObjSize{cl_id="60b8cc6dc871fe9be7729427",cl_role="shardsvr",collection="c1",database="test",rs_nm="rs1",rs_state="1"} 34
# HELP mongodb_test_c1_storageStats_capped test.c1.storageStats.
# TYPE mongodb_test_c1_storageStats_capped untyped
mongodb_test_c1_storageStats_capped{cl_id="60b8cc6dc871fe9be7729427",cl_role="shardsvr",collection="c1",database="test",rs_nm="rs1",rs_state="1"} 0

Thanks for the contribution

@denisok denisok merged commit 797dff6 into percona:main Jun 3, 2021
percona-csalguero added a commit that referenced this pull request Jun 3, 2021
@percona-csalguero percona-csalguero mentioned this pull request Jun 3, 2021
@percona-csalguero
Copy link
Contributor

Hi @masaruhoshi,
I've created #287
Thanks for the help.

@masaruhoshi masaruhoshi deleted the additional-exporter-metrics branch June 3, 2021 14:42
percona-csalguero added a commit that referenced this pull request Jun 3, 2021
* Added changelog for release 0.20.6

* Updated changelog

* Updated version in changelog

* Updated changelog for PR #283
@denisok denisok added this to the v0.20.7 milestone Aug 9, 2021
@denisok denisok mentioned this pull request Aug 10, 2021
@denisok denisok added the award swag prize for the contributors. Please contact Percona if we can't reach you! label Dec 1, 2021
@Aleksa-del
Copy link

@masaruhoshi Hello! We would love to send you a gift from Percona for your contributions. Please, contact us at [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
award swag prize for the contributors. Please contact Percona if we can't reach you! community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants