Skip to content

Q: filter results by label #698

@deniszh

Description

@deniszh

Hello,
I have quite unorthodox setup and wondering could promxy help me with it.
I'm wondering why metrics_relabel_configs do not support other actions, like "keep". Let me describe my use case in a bit more details.
We have prometheuses which contain data for many clusters, hence metric have "cluster" label applied. I want to have ability to filter results by this label, so, something like:

 server_groups:  
    - targets:
            - url1
    metrics_relabel_configs:
        - action: keep
          source_label: cluster
          regex: cluster1
    - targets:
            - url2
    metrics_relabel_configs:
        - action: keep
          source_label: cluster
          regex: cluster2

Then, results from url1 will contain only metrics with {cluster="cluster1"} and results from url2 will contain only metrics with {cluster="cluster2"}.

As far as I understand it's not possible in current implementation. But I'm wondering is it possible to implement this in theory and what's needed for this. I'm interested in implementing this by myself even, just need a hint where to go. I tried to add "relabel.Keep" to metric_relabel.go but it's not working properly.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions