SOLR-17587: (9x backport) wt=prometheus fix duplicate TYPE information #3006
+147
−101
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
https://issues.apache.org/jira/browse/SOLR-17587
Description
Solr's Prometheus writer duplicates
# TYPE <metric name> <prometheus metric type>
in it's exposition format forcore
registry metrics.This is an illegal format and depending on the technologies prometheus exposition verification for example
Telegraf
, this will fail. For Prometheus server itself, this still passes and collects the metrics just fine for some reason.This is because the Prometheus Writer takes Dropwizard registries and exports them to Prometheus Registries to expose them in Prometheus format. Solr creates Dropwizard registry for every
core
and differentiates the metrics that way even though they have the same metric names.For prometheus, this creates an issue in that metrics should be differentiated in it's attributes and tags. So when the metrics are output with the Prometheus response writer, it duplicates the
TYPE
information because it is a registry for everycore
and doesn't know that the othercore
registries have the same metric name and results in duplicateTYPE
information.Solution
When metrics are going to be exported for prometheus, we merge all the
core
Dropwizard metric registries into a single registry and export that registry into prometheus. Duplicate metric names in a registry is not allowed in prometheus, so we will also append the core name to the Dropwizard metric to differentiate which metric belongs to what core and parse the labels accordingly.This also allowed to clean up and simply some of the
SolrPrometheusCoreFormatter
code.Tests
Updated the test accordingly with the coreName existing in the Dropwizard metric names and it's parsing.
Also added an assert in
testPrometheusStructureOutput
to confirm there is no duplicateTYPE
information in prometheus output.Checklist
Please review the following and check all that apply:
main
branch../gradlew check
.