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

Restore server status collector #557

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

trvrnrth
Copy link
Contributor

@trvrnrth trvrnrth commented Sep 12, 2022

PMM-7947

This PR allows use of the serverStatus and replSetGetStatus collectors for scenarios where fetching all the data provided by getDiagnosticData is either not desirable (or in the case of mongos not possible).

Metric naming conventions and labels will now be consistent regardless of the collector in use (eg. metric prefixes will always be mongodb_ss_ and mongodb_rs_).

Note that this is a breaking change for users running with --collector.replicasetstatus as mongodb_members_uptime will now be mongodb_rs_members_uptime for example.

  • Links to other linked pull requests (optional).

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

Once all checks pass and the code is ready for review, please add pmm-review-exporters team as the reviewer. That would assign people from the review team automatically. Report any issues on our Forum or Discord.

logger.Debug("serverStatus result:")
debugResult(logger, m)

for _, metric := range makeMetrics("", bson.M{"serverStatus": m}, d.topologyInfo.baseLabels(), d.compatibleMode) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The nesting here facilitates the desired renaming and label management in makeMetrics in the same manner as when fetched via getDiagnosticData.

@@ -82,7 +82,7 @@ func (d *replSetGetStatusCollector) collect(ch chan<- prometheus.Metric) {
logger.Debug("replSetGetStatus result:")
debugResult(logger, m)

for _, metric := range makeMetrics("", m, d.topologyInfo.baseLabels(), d.compatibleMode) {
for _, metric := range makeMetrics("", bson.M{"replSetGetStatus": m}, d.topologyInfo.baseLabels(), d.compatibleMode) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The nesting here facilitates the desired renaming and label management in makeMetrics in the same manner as when fetched via getDiagnosticData.

This is a breaking change when running with --collector.replicasetstatus as these metrics were previously prefixed with mongodb_ and will now be prefixed with mongodb_rs_. This achieves parity with the metrics returned when using --collector.diagnosticdata and allows for easy switching between the collection methods.

@trvrnrth trvrnrth changed the title Restore server status collector Restore server status collector for use with mongos Sep 12, 2022
@trvrnrth trvrnrth changed the title Restore server status collector for use with mongos Restore server status collector Sep 12, 2022
@trvrnrth trvrnrth marked this pull request as ready for review September 12, 2022 14:40
@trvrnrth trvrnrth requested a review from a team as a code owner September 12, 2022 14:40
@trvrnrth trvrnrth requested review from ShashankSinha252 and tshcherban and removed request for a team September 12, 2022 14:40
@trvrnrth trvrnrth force-pushed the restore-server-status-collector branch 3 times, most recently from b0922b9 to 1837b57 Compare September 12, 2022 16:24
@percona-csalguero
Copy link
Contributor

@anton-bystrov How would this affect the dashboards?

@anton-bystrov
Copy link
Contributor

@anton-bystrov How would this affect the dashboards?

I think this is critical, because we have queries with mongodb_. mongodb_rs is another metric. But we can add "or" to prevent this.

@percona-csalguero
Copy link
Contributor

@ShashankSinha252 @denisok Please be careful before merging this since it will affect the dashboards

@trvrnrth trvrnrth force-pushed the restore-server-status-collector branch from 26df81e to 04f657a Compare May 30, 2023 08:16
@trvrnrth
Copy link
Contributor Author

@anton-bystrov @percona-csalguero @ShashankSinha252 @denisok Do you need anything from me to facilitate moving forward with this in order to restore the ability to fetch server status for mongos instances?

@denisok
Copy link
Contributor

denisok commented May 31, 2023

@rnovikovP please check

@trvrnrth trvrnrth force-pushed the restore-server-status-collector branch from 04f657a to 402af79 Compare September 28, 2023 16:52
@trvrnrth
Copy link
Contributor Author

@denisok @rnovikovP I've rebased to keep this PR up to date. Is this something that could be looked at?

This is useful when running the exporter against mongos instances where
getDiagnosticData is not available.
This change prevents running the replSetGetStatus or serverStatus
collectors if those data have been collected already via
getDiagnosticData.

Provide data from the replSetGetStatus and serverStatus collectors to
makeMetrics in a format such that the desired renames and label
management actions are carried out.

Note that this change is not backwards compatible for anyone running
with --collector.replicasetstatus as those metrics will now have a
prefix of mongodb_rs_ rather than just mongodb_
@trvrnrth trvrnrth force-pushed the restore-server-status-collector branch from 402af79 to 40a3201 Compare September 28, 2023 16:58
@denisok
Copy link
Contributor

denisok commented Sep 29, 2023

@BupycHuk please check it out

Grain-Yu added a commit to Grain-Yu/mongodb_exporter-withBackup that referenced this pull request Oct 20, 2023
@BupycHuk
Copy link
Member

BupycHuk commented Nov 8, 2024

Hello @trvrnrth, sorry for so long response.
I like the idea, but if metrics name will be the same as for diagnostic data we need to create a mechanism to not generate metrics twice in case of --collect-all flag is passed. Because in that case both collectors will be enabled and it will lead to conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants