Ad Widget

Collapse

Zabbix 6 regular expression for prometheus data via zabbix-agent2

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • czechsys
    Junior Member
    • Aug 2020
    • 6

    #1

    Zabbix 6 regular expression for prometheus data via zabbix-agent2

    Hi,

    i have this output from prometheus-postfix-exporter via web.page.get:

    Code:
    HTTP/1.1 200 OK
    
    Connection: close
    
    Transfer-Encoding: chunked
    
    Content-Type: text/plain; version=0.0.4; charset=utf-8
    
    Date: Thu, 30 Jun 2022 11:50:30 GMT
    
    
    
    4153
    
    # HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles.
    # TYPE go_gc_duration_seconds summary
    go_gc_duration_seconds{quantile="0"} 0.000197284
    go_gc_duration_seconds{quantile="0.25"} 0.001223867
    go_gc_duration_seconds{quantile="0.5"} 0.001429567
    go_gc_duration_seconds{quantile="0.75"} 0.001634543
    go_gc_duration_seconds{quantile="1"} 0.007528485
    go_gc_duration_seconds_sum 0.108661945
    go_gc_duration_seconds_count 69
    # HELP postfix_qmgr_messages_removed_total Total number of messages removed from mail queues.
    # TYPE postfix_qmgr_messages_removed_total counter
    postfix_qmgr_messages_removed_total 0
    # HELP promhttp_metric_handler_requests_total Total number of scrapes by HTTP status code.
    # TYPE promhttp_metric_handler_requests_total counter
    promhttp_metric_handler_requests_total{code="200"} 170
    promhttp_metric_handler_requests_total{code="500"} 0
    promhttp_metric_handler_requests_total{code="503"} 0
    
    
    0
    For getting values i need to remove headers on beginning and the trash on the end after metrics. But my regular preprocessing doesn't work:
    Option A:
    1. regex to remove headers - works
    2. regex to remove ending trash after metrics - works on preprocessing test, fail on collected item
    Code:
    266951:20220630:135630.589 item "host.example.com:web.page.get[{$PROMETHEUS_EXPORTER_HOST},{$PROMETHEUS_EXPORTER_ URL},{$PROMETHEUS_EXPORTER_PORT}]" became not supported: Preprocessing failed for: HTTP/1.1 200 OK..Connection: close..Transfer-Encoding: chunked..Content-Type: text/plain; version...
    1. Result: # HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles..# TYP...
    2. Failed: cannot perform regular expression "^[\s\S]*?(?=\n{2,})" match for value of type "string": pattern does not match
    Option B:
    1. regex to get all # and metrics only - fails on preprocessing tests
    Code:
    cannot perform regular expression "^(.*postfix_.*)$" match for value of type "string": pattern does not match
    cannot perform regular expression "^(\#?.*\_.*)$" match for value of type "string": pattern does not match
    Any idea? I don't want to use http agent.
    Thanks.
Working...