summaryrefslogtreecommitdiff
path: root/ceilometer/publisher
diff options
context:
space:
mode:
authorYanos Angelopoulos <yanos@admin.grnet.gr>2019-10-03 12:49:39 +0300
committerYanos Angelopoulos <yanos@admin.grnet.gr>2019-10-03 12:54:18 +0300
commitab4b87bfc2a8c4a378ee83bb5b95e8c30bac6180 (patch)
tree9debddf88d05dde9dd2aa75a6707fa0f986f47f2 /ceilometer/publisher
parent8288ad511c54a1120fec9dd3ee950df6833272fe (diff)
downloadceilometer-ab4b87bfc2a8c4a378ee83bb5b95e8c30bac6180.tar.gz
Fix samples with dots in sample name
This patch fixes Prometheus publisher behavior when Ceilometer metric names contain dots by replacing them with underscores. Prometheus does not accept metrics with dots. Change-Id: If4799a1b17001c0535413a26ec5d2f427e52f168 Signed-off-by: Yanos Angelopoulos <yanos@admin.grnet.gr>
Diffstat (limited to 'ceilometer/publisher')
-rw-r--r--ceilometer/publisher/prometheus.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/ceilometer/publisher/prometheus.py b/ceilometer/publisher/prometheus.py
index 36f13a5e..973f8777 100644
--- a/ceilometer/publisher/prometheus.py
+++ b/ceilometer/publisher/prometheus.py
@@ -55,9 +55,11 @@ class PrometheusPublisher(http.HttpPublisher):
elif s.type == sample.TYPE_GAUGE:
metric_type = "gauge"
- if metric_type and s.name not in doc_done:
- data += "# TYPE %s %s\n" % (s.name, metric_type)
- doc_done.add(s.name)
+ curated_sname = s.name.replace(".", "_")
+
+ if metric_type and curated_sname not in doc_done:
+ data += "# TYPE %s %s\n" % (curated_sname, metric_type)
+ doc_done.add(curated_sname)
# NOTE(sileht): prometheus pushgateway doesn't allow to push
# timestamp_ms
@@ -67,10 +69,10 @@ class PrometheusPublisher(http.HttpPublisher):
# datetime.utcfromtimestamp(0)
# ).total_seconds() * 1000
# data += '%s{resource_id="%s"} %s %d\n' % (
- # s.name, s.resource_id, s.volume, timestamp_ms)
+ # curated_sname, s.resource_id, s.volume, timestamp_ms)
data += '%s{resource_id="%s"} %s\n' % (
- s.name, s.resource_id, s.volume)
+ curated_sname, s.resource_id, s.volume)
self._do_post(data)
@staticmethod