Skip to content

Expose only topk metrics to Prometheus #205

@phihos

Description

@phihos

When having a lot of label combinations for a metric but only the metrics with large values are of interest (e.g. a url label) it might make sense to restrict the metrics presented by the HTTP server only to "topk" values with k being configurable on a per-metric basis. I think this only makes sense for gauges and counters.

I already looked up how it can be done and I am willing to implement it including tests. For that to work we need to introduce and own data store based on the default data store.
In it we would need to add a metric setting "topk" which makes all_metrics return just the top k metrics instead of all. If topk is not set all_metrics should return all metrics.
Finally we need to set that data store as default in the plugin code and add a topk option when initializing a metric.

Is that something you would consider accepting into your code base?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions