I found example for grafana cloud agent:
# This stage will only run if the scraped target has a label "app"
# with a value of "some-app" and the log line doesn't contain the word "info"
- match:
selector: '{app="some-app"} != "info"'
stages:
# The regex stage tries to extract a Go panic by looking for panic:
# in the log message.
- regex:
expression: ".*(?P<panic>panic: .*)"
# The metrics stage is going to increment a panic_total metric counter
# which Promtail exposes. The counter is only incremented when panic
# was extracted from the regex stage.
- metrics:
panic_total:
type: Counter
description: "total count of panic"
source: panic
config:
action: inc
In my case I have a web servers which generated ton of logs and I would like to have custom metric to calculate each specific field in log record, like GET/POST/UPLOAD and etc. by separate metric value.
Is it possible?
Or I need to create a new match for each filed which I would like to calculate?