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

Remove system colections from index stats #893

Merged

Conversation

ramunas-omnisend
Copy link
Contributor

Details:
When a view is created inside a MongoDB database, a special collection named system.views is also created. Attempting to call IndexStats on system.views results in an Unauthorized error, even when executed with root privileges.

For example:

ERRO[0011] cannot get $indexStats cursor for collection <database>.system.views: 
(Unauthorized) not authorized on <database> to execute command { 
aggregate: "system.views", pipeline: [ { $indexStats: {} } ], cursor: {}, 
lsid: { id: UUID("<lsid>") }, $clusterTime: { clusterTime: Timestamp(<timestamp>, 1), 
signature: { hash: BinData(0, <signature>), keyId: <key-id> } }, $db: "<database>", 
$readPreference: { mode: "primaryPreferred" } }

This fix filters out system collections like system.views when gathering IndexStats, preventing these unnecessary errors from appearing in the logs.

@ramunas-omnisend ramunas-omnisend requested a review from a team as a code owner August 16, 2024 09:46
@ramunas-omnisend ramunas-omnisend requested review from ademidoff and JiriCtvrtka and removed request for a team August 16, 2024 09:46
@BupycHuk BupycHuk merged commit 8fa6455 into percona:main Aug 22, 2024
6 checks passed
JiriCtvrtka added a commit that referenced this pull request Sep 27, 2024
* 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 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants