Skip to content

Commit

Permalink
[prometheus check] Actually use provided "metrics_mapper" (#3446)
Browse files Browse the repository at this point in the history
The current implementation of the Prometheus check ignores completely the values of `metrics_mapper`, because the code is pretty much building it using the original metric names.

Instead, we should use the mappings provided by the user in the `metrics_mapper` dictionary. So given an example config like this:

```yml
    metrics:
      - cp_kafka_server_replicamanager_underreplicatedpartitions
    type_overrides:
      cp_kafka_server_replicamanager_underreplicatedpartitions: gauge
    metrics_mapper:
      cp_kafka_server_replicamanager_underreplicatedpartitions: server.replica_manager.under_replicated_partitions
```

We should emit metrics named `server.replica_manager.under_replicated_partitions` instead of `cp_kafka_server_replicamanager_underreplicatedpartitions` which is what the agent does currently.
  • Loading branch information
casidiablo authored and ofek committed Apr 22, 2019
1 parent ac6a6d1 commit 176b71d
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ def get_scraper(self, instance):
metrics_mapper[metric] = metric
else:
metrics_mapper.update(metric)
# update metrics mapper with values provided by user
metrics_mapper.update(instance.get("metrics_mapper", {}))

scraper.metrics_mapper = metrics_mapper
scraper.labels_mapper = default_instance.get("labels_mapper", {})
Expand Down

0 comments on commit 176b71d

Please sign in to comment.