Re: [prometheus-developers] match a metric path and split it on a colon (:)

26 views
Skip to first unread message

Matthias Rampke

unread,
Apr 7, 2020, 11:53:42 AM4/7/20
to Panem78, Prometheus Users
This question is better suited to the prometheus-users mailing list, I'm moving it there.

From the config I take it you are trying to achieve this in the graphite exporter?

What you are trying will not be possible using the (faster) glob match type. You are on the right track with using match_type: regex, only your regex is not quite right.

Try

mappings:
- match: 'panos\.(.*):(.*)'
  match_type: regex
  name: test_graphite_metric
  labels:
    device: $1
    job: test_graphite
    entity: $2


With this it works for me:

[I] ~/s/g/p/graphite_exporter (master|✔) $ echo "panos.device1:entity1 1234 "(date +%s) | nc localhost 9109
[I] ~/s/g/p/graphite_exporter (master|✔) $ curl -sSf http://127.0.0.1:9108/metrics | fgrep test
# HELP test_graphite_metric Graphite metric test_graphite_metric
# TYPE test_graphite_metric gauge
test_graphite_metric{device="device1",entity="entity1",job="test_graphite"} 1234

Hope that helps!
MR

On Tue, Apr 7, 2020 at 11:05 AM Panem78 <pan...@gmail.com> wrote:
Hello everyone,
I am looking to match a metric path such as 
"panos.device1:entity1
in order to be translated into prometheus labels such as :
test_graphite_metric{device="device1",entity="entity1",instance="localhost:9108",job="test_graphite",tsdb="prometheus"}

Can i achieve this somehow with a regex or '*'s act as wildcards for ONLY dot-separated metrics ?

Some of my non successful attempts include the following mapping (mentioning it here to be somewhat more clear what i want to achieve)

- match: panos.*\\:*
  match_type: regex
  name: test_graphite_metric
  labels:
    device: $1
    job: test_graphite
    entity: $2

Thanks in advance!


--
You received this message because you are subscribed to the Google Groups "Prometheus Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-devel...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-developers/d99475a4-f3df-40d0-84e1-38478c74c2d9%40googlegroups.com.

Panem78

unread,
Apr 14, 2020, 4:43:04 AM4/14/20
to Prometheus Developers
Yes, i figured it out a bit after i posted my question, but your comments were more than welcome to understand it in a better way.
Thanks a lot.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-developers+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages