Skip to content

Commit

Permalink
Merge pull request #11381 from vkuznet/metrics-dashes
Browse files Browse the repository at this point in the history
Replace dash in exporter name
  • Loading branch information
amaltaro authored Dec 1, 2022
2 parents efd8db5 + 1e87cad commit a293975
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/python/Utils/CPMetrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ def promMetrics(data, exporter):
"""
Provide cherrypy stats prometheus metrics for given exporter name.
"""
# exporter name should not contain dashes, see
# https://its.cern.ch/jira/browse/CMSMONIT-514
exporter = exporter.replace("-", "_")
metrics = flattenStats(data)
if isinstance(metrics, str):
metrics = json.loads(metrics)
Expand Down
4 changes: 2 additions & 2 deletions test/python/Utils_t/CPMetrics_t.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ def testPromMetrics(self):
"""
Test the flattenStats function
"""
data = promMetrics(self.testData, 'test')
data = promMetrics(self.testData, 'test-exporter')
self.assertEqual("# HELP" in data, True)
self.assertEqual("# TYPE" in data, True)
self.assertEqual("test_cherrypy_app_bytes_read_request" in data, True)
self.assertEqual("test_exporter_cherrypy_app_bytes_read_request" in data, True)
self.assertEqual("bla-bla" in data, False)


Expand Down

0 comments on commit a293975

Please sign in to comment.