Include the following in your docker-compose.yml services:
Prometheus client library for PHP:
https://github.com/Jimdo/prometheus_client_php
pushgateway: | |
image: prom/pushgateway | |
ports: | |
- 9091:9091 |
https://github.com/Jimdo/prometheus_client_php/blob/master/examples/pushgateway.php
configure the push_gateway IP address to be whatever the push gateway IP address and port you used in pushgateway service in docker-compose.yml
Set prometheus alert rules based on time:
https://medium.com/@tom.fawcett/time-of-day-based-notifications-with-prometheus-and-alertmanager-1bf7a23b7695
https://prometheus.io/docs/prometheus/latest/querying/functions/#hour()
https://www.robustperception.io/combining-alert-conditions
Prometheus has hour(), and day_of_month() built in function, just use them in prometheus alert.rules file . For example:
- alert: high_load
expr: node_load1 > 0.5 and hour() >= 16 and day_of_week() == 6
for: 2m
labels:
severity: critical
annotations:
summary: "Instance {{ $labels.instance }} under high load"
description: "{{ $labels.instance }} of job {{ $labels.job }} is under high load."
No comments:
Post a Comment