Using negative lookahead in jmx-exporter pattern

26 views
Skip to first unread message

Kaloyan Simitchiyski

unread,
Nov 22, 2020, 12:00:59 PM11/22/20
to Prometheus Users
Hi folks,

I'm using the jmx-exporter to collect metrics from Kafka brokers. However, I'm having a bit of trouble with a particular regex pattern:

- pattern: kafka.network<type=RequestMetrics, name=ErrorsPerSec, request=(.+), error=(^(?!NONE$).*)><>Count
    name: kafka_request_errors_total
    type: COUNTER
    cache: true
    labels:
        request: "$1"
        error: "$2"

I want to collect every sample except in the cases when the error attribute is NONE. The rule does not seem to work as the jmx-exporter stops returning the metric altogether. If I change the pattern to error=(.+) it works just fine.
Have you guys done something similar? Is something wrong with my approach?

Brian Brazil

unread,
Nov 22, 2020, 2:28:51 PM11/22/20
to Kaloyan Simitchiyski, Prometheus Users
The ^ and $ are anchoring to the whole line, so that can never match. Try without them.

Brian

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/9944a9e0-a3b1-4d6c-b6f9-e3ca14773922n%40googlegroups.com.

Kaloyan Simitchiyski

unread,
Nov 23, 2020, 2:00:29 AM11/23/20
to Prometheus Users
Hi Brian,

Makes sense why it didn't work... Everything is fine now. Thanks!
Reply all
Reply to author
Forward
0 new messages