Skip to content

Commit

Permalink
Fix kubernetes_state avoid tags collision
Browse files Browse the repository at this point in the history
  • Loading branch information
clamoriniere committed Jul 19, 2019
1 parent caa8e83 commit be47667
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ def _filter_metric(self, metric, scraper_config):
if len(name_part) < 2:
return False
family = name_part[1]
tags = ["name:" + family]
tags = ["resource_name:" + family]
for sample in metric.samples:
if "namespace" in sample[self.SAMPLE_LABELS]:
ns = sample[self.SAMPLE_LABELS]["namespace"]
tags.append("kube_namespace:" + ns)
tags.append("resource_namespace:" + ns)
break
self._send_telemetry_counter(
'collector.metrics.count', len(metric.samples), scraper_config, extra_tags=tags
Expand Down
4 changes: 2 additions & 2 deletions kubernetes_state/tests/test_kubernetes_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,11 +401,11 @@ def test_telemetry(aggregator, instance):
aggregator.assert_metric(NAMESPACE + '.telemetry.metrics.ignored.count', tags=['optional:tag1'], value=76.0)
aggregator.assert_metric(
NAMESPACE + '.telemetry.collector.metrics.count',
tags=['name:pod', 'kube_namespace:default', 'optional:tag1'],
tags=['resource_name:pod', 'resource_namespace:default', 'optional:tag1'],
value=600.0,
)
aggregator.assert_metric(
NAMESPACE + '.telemetry.collector.metrics.count',
tags=['name:hpa', 'kube_namespace:ns1', 'optional:tag1'],
tags=['resource_name:hpa', 'resource_namespace:ns1', 'optional:tag1'],
value=8.0,
)

0 comments on commit be47667

Please sign in to comment.