forked from apache/pulsar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding back Prometheus TYPE definitions; fixed duplicate TYPE errors;…
… fixed format issue in metricWithRemoteCluster; added test for Prometheus types (apache#4183) Fixes apache#3112 ### Motivation In this pull request, I set out to fix apache#3112, which is caused by duplicate TYPE statements in the metrics output which leads to parsing of Prometheus metrics to fail in recent versions of Prometheus. Because of this, Prometheus will report the broker target as down. Since I started looking at this, the type definitions have been removed (apache#4136) from topics metric output. I think these types are useful in Prometheus and have added them back in. While testing this fix in my geo-replicated setup, I found a format in error (missing quote and comma) in the TopicStats.metricWithRemoteCluster method. This pull request includes a fix for that issue. I have also added a new test to PrometheusMetricsTest.java that fails without these changes but passed with them. ### Modifications I added a static HashMap to TopicStats to keep track of the TYPEs that have been output. All writing of the TYPE for topics and namespaces is done with the TopicStats.metricType method. I modified that method to update the HashMap and only print the TYPE out for the first occurrence of the metric name. I also added a method reset the HashMap, which gets called in NamespaceStatsAggregator.generate. ### Verifying this change This change added tests and can be verified as follows: - Added testDuplicateMetricTypeDefinitions which checks for: - duplicate TYPE definitions in the Prometheus output - validates that no TYPE definition appears after the first metric sample - ensures that all metrics have a defined type I execute the test twice to make sure the resetting of the HashMap of the already seen metric type definitions works correctly. This test passes for me reliably (both occurrences). I have confirmed using promtool that the metrics output will now parse without error using versions 2.7.1 and 2.9.2 (which is the latest). There are many warnings around missing HELP definitions and metrics using reserved suffixes (ex. _count), but no errors. In addition, I have patched 2.3.1 with this fix and am currently running it in my cluster. Prometheus (2.7.1) successfully parses the metrics and I am able to see namespace and topic-level metrics.
- Loading branch information
1 parent
bf94890
commit 8d32b58
Showing
3 changed files
with
125 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters