Get the log line in alert of alertmanager

I have a Loki that gets logs from Promtail and send alerts to an Alertmanager. I have a rules that sends an alert to the AlertManager each time there is a new log line :

  • alert: SysMon_Critical_Error
    expr: sum by (job) (rate({job=“sysmon”} |~ “CRITICAL|EXP_C|LINKERR_C|NETERR_C|PROCERR_C”[1h]))>0.00
    severity: critical
    category: logs
    job: sysmon
    summary: SysMon Error Critical

What I would like is to display the log line that trigger the alert in a label or in the summary of the alert of AlertManager.
For example, when a log line is : “2021-04-14 13:56:00
2021-04-14 13:55:59 [EXP_C]”, I would like to have it written in a label or in the summary in the alertmanager (right now I didn’t find a solution) :

Is this possible ?
Thanks for your help

Just found the solution :
I have added this part in my promtail config :
- match:
selector: ‘{job=“sysmon”}’
- regex:
expression: ‘^(?P.*)$’
- labels:

And now I have the label in my alertmanager :

1 Like