Prometheus and metric_relabel_configs

43 views
Skip to first unread message

Thomas Berger

unread,
Aug 15, 2020, 6:33:59 PM8/15/20
to Prometheus Users
Hello everybody,

with the exporters i get a large number of metrics.
However, I don't need all of them.
I don't want to save these and remove them from the DB.
This is described in the documentation with metric_relabel_configs.

Example to remove all go:. * metrics:

    metric_relabel_configs:
    - source_labels: [__name__]
      regex: (go_.*)
      action: drop

My question:
Can I test the regex beforehand?
Is there a way to display all metrics by specifying this regex?

Best regards
Thomas.

Christian Hoffmann

unread,
Aug 16, 2020, 5:36:44 AM8/16/20
to Thomas Berger, Prometheus Users
Hi,
I think you should be able to test this via a regular PromQL query. The
metric name is stored in the magic label __name__:

{__name__=~"go_.*"}

Kind regards,
Christian

Thomas Berger

unread,
Aug 16, 2020, 2:43:44 PM8/16/20
to Prometheus Users
I already searched for it (HTTP API), but found no information about it.
However, under localhost: 9090 (insert metric at cursor) all metrics are displayed.
Above the Execute button, the input field says Expession,
but i don't know how can formulate the query . No chance.
Do you have any idea??

Kind regards,
Thomas.

Christian Hoffmann

unread,
Aug 16, 2020, 2:56:23 PM8/16/20
to Thomas Berger, Prometheus Users
Hi,

On 8/16/20 8:43 PM, Thomas Berger wrote:
> I already searched for it (HTTP API), but found no information about it.
> However, under localhost: 9090 (insert metric at cursor) all metrics are
> displayed.
> Above the Execute button, the input field says Expession,
> but i don't know how can formulate the query . No chance.
> Do you have any idea??

This exactly the right place. The "Expression" field takes PromQL
syntax. You can just copy and paste what I suggested.

Kind regards,
Christian

Thomas Berger

unread,
Aug 16, 2020, 3:54:13 PM8/16/20
to Prometheus Users
Hi Christian...

My Mistake:

Had already tried everything but it didn't work.
But since I didn't know that this was the right way, I didn't continue.
Now I know why - I forgot the tilde - laugh ...
Thank you very much

Kind regards,
Thomas
Reply all
Reply to author
Forward
0 new messages