Skip to content

Commit

Permalink
rptest: fix redpanda metrics filtering
Browse files Browse the repository at this point in the history
Updates the filter used when collecting metrics samples.

In some cases, the samples take the form:

Sample(name='redpanda_kafka_max_offset', labels={'redpanda_namespace': 'kafka', 'redpanda_partition': '5', 'redpanda_topic': 'panda-topic'}, value=0.0, ...
  • Loading branch information
andrwng committed Jan 24, 2024
1 parent 08583d5 commit e567d63
Showing 1 changed file with 38 additions and 8 deletions.
46 changes: 38 additions & 8 deletions tests/rptest/services/redpanda.py
Original file line number Diff line number Diff line change
Expand Up @@ -1066,10 +1066,25 @@ def metric_sum(self,
for sample in family.samples:
if sample.name != metric_name:
continue
if ns and sample.labels["namespace"] != ns:
continue
if topic and sample.labels["topic"] != topic:
continue
labels = sample.labels
if ns:
if "redpanda_namespace" in labels:
if labels["redpanda_namespace"] != ns:
continue
elif "namespace" in labels:
if labels["namespace"] != ns:
continue
else:
assert False, f"Missing namespace label: {sample}"
if topic:
if "redpanda_topic" in labels:
if labels["redpanda_topic"] != topic:
continue
elif "topic" in labels:
if labels["topic"] != topic:
continue
else:
assert False, f"Missing topic label: {sample}"
count += int(sample.value)
return count

Expand Down Expand Up @@ -1643,10 +1658,25 @@ def metric_sum(
metrics = self.metrics(None, metrics_endpoint=metrics_endpoint)
for family in metrics:
for sample in family.samples:
if ns and sample.labels["namespace"] != ns:
continue
if topic and sample.labels["topic"] != topic:
continue
labels = sample.labels
if ns:
if "redpanda_namespace" in labels:
if labels["redpanda_namespace"] != ns:
continue
elif "namespace" in labels:
if labels["namespace"] != ns:
continue
else:
assert False, f"Missing namespace label: {sample}"
if topic:
if "redpanda_topic" in labels:
if labels["redpanda_topic"] != topic:
continue
elif "topic" in labels:
if labels["topic"] != topic:
continue
else:
assert False, f"Missing topic label: {sample}"
if sample.name == metric_name:
count += int(sample.value)
return count
Expand Down

0 comments on commit e567d63

Please sign in to comment.