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

SOLR-16906: Correctly capture REPLICATION metrics in Prometheus config #1809

Merged

Conversation

osyoyu
Copy link
Contributor

@osyoyu osyoyu commented Jul 26, 2023

https://issues.apache.org/jira/browse/SOLR-16906

Description

The Prometheus exporter config provided with Solr seems to unintentionally ignore replication-related metrics. This change lets the Prometheus exporter correctly collect/expose them.

Solution

Fix the regex that intends to match REPLICATION category metrics. REPLICATION metrics start with REPLICATION./replication, but the previous regex misses the / (slash) and fails to match them.

Tests

Start a solr-exporter process and make a request to http://localhost:9983/metrics and confirm metrics such as solr_metrics_core_replication_leader or solr_metrics_core_requests_total{category="REPLICATION"} show up.

$ cd solr/packaging/build/dev
$ ./bin/solr start -f
$ ./bin/solr create -c films -s 2 -rf 2

# in an another shell
$ ./prometheus-exporter/bin/solr-exporter -f ../../../prometheus-exporter/build/packaging/conf/solr-exporter-config.xml --baseurl http://localhost:8983/solr

# another shell
$ curl -s http://localhost:8989 | grep REPLICATION
solr_metrics_core_replication_leader{category="REPLICATION",handler="/replication",core="films",base_url="http://localhost:8983/solr",cluster_id="a8ed8a12b2",} 1.0
solr_metrics_core_requests_total{category="REPLICATION",handler="/replication",internal="false",core="films",base_url="http://localhost:8983/solr",cluster_id="a8ed8a12b2",} 0.0
...

Checklist

Please review the following and check all that apply:

  • I have reviewed the guidelines for How to Contribute and my code conforms to the standards described there to the best of my ability.
  • I have created a Jira issue and added the issue ID to my pull request title.
  • I have given Solr maintainers access to contribute to my PR branch. (optional but recommended)
  • I have developed this patch against the main branch.
  • I have run ./gradlew check.
  • I have added tests for my changes.
  • I have added documentation for the Reference Guide

@osyoyu osyoyu force-pushed the prometheus-exporter-fix-replication-config branch from 36551e4 to 64af7bb Compare July 26, 2023 14:12
@HoustonPutman
Copy link
Contributor

Thank you for finding this! Would you mind creating a JIRA at https://issues.apache.org/jira/projects/SOLR/summary so that we can track this for the next release?

Otherwise I'll test locally and commit once the JIRA has been created 🙂

@osyoyu
Copy link
Contributor Author

osyoyu commented Jul 26, 2023

Sure 👍

REPLICATION metric keys start with REPLICATION./replication, not
REPLICATION.replication (note the slash).
This config change will let prometheus-exporter not ignore REPLICATION
metrics.
@osyoyu osyoyu force-pushed the prometheus-exporter-fix-replication-config branch from 64af7bb to 1eb4fa0 Compare July 26, 2023 15:54
@osyoyu osyoyu changed the title Correctly capture REPLICATION metrics in Prometheus config SOLR-16906: Correctly capture REPLICATION metrics in Prometheus config Jul 26, 2023
@osyoyu
Copy link
Contributor Author

osyoyu commented Jul 26, 2023

JIRA Issue created and commit message updated (force pushed). Let me know if I need to do something else!
https://issues.apache.org/jira/browse/SOLR-16906

@HoustonPutman
Copy link
Contributor

Let me know if you are ok with that name in the changelog entry.

@osyoyu
Copy link
Contributor Author

osyoyu commented Jul 27, 2023

No problems with me. Thanks!

@HoustonPutman HoustonPutman merged commit 9c7adc0 into apache:main Jul 27, 2023
2 checks passed
HoustonPutman pushed a commit that referenced this pull request Jul 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants