Thursday, 1 August 2019

Prometheus docke-compose push gateway, client library for PHP, and alert rules based on hour and day

Promethesus push gateway is required for any promethesus client library to push metrics to:

Include the following in your docker-compose.yml services:

Prometheus client library for PHP:
image: prom/pushgateway
- 9091:9091
use push gateway example, can use in memory adapter if cron job or task is not a long running one

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:

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
      severity: critical
      summary: "Instance {{ $labels.instance }} under high load"
      description: "{{ $labels.instance }} of job {{ $labels.job }} is under high load."

No comments:

Post a comment