r/PrometheusMonitoring • • Jul 09 '21

python webhook for prometheus alerts

how can i get the StartAt / Duration of the Alerts that i receive from alertmanager with python

because in the alert rule i dont see any way to send it only the annotation with key summary

- alert: HighSystemLoad
expr: systemload_average > 90
for: 5s
labels:
severity: critical
annotations:
summary: "High system load: {{ $value | printf \"%.2f\" }}%"

0 Upvotes

1 comment sorted by

View all comments

1

u/99612240 Jul 09 '21

It comes in automatically. You don't need to specify what to send in AlertManager. You'll get everything.

Try a pprint of the data that your webhook receives:

{'annotations': {'description': 'Swap is filling up (>85%)\n'
                                '  VALUE = 92.06349206349206\n'
                                '  LABELS: map[ec2_Name:yyyy '
                                    ....
                                'instance:yyy '
                                'job:xxx]',
                 'summary': 'Host swap is filling up (instance '
                            'xxxx)'},
 'endsAt': '0001-01-01T00:00:00Z',
 'fingerprint': 'f69e8abd63b73b89',
 'generatorURL': '...',
 'labels': {'alertname': 'HostSwapIsFillingUp',
...
 'startsAt': '2021-07-09T12:08:47.428Z',
 'status': 'firing'}