Example of prometheus-haskell
docker-compose.yaml:
version: '3'
services:
prometheus:
image: prom/prometheus:v2.30.3
# ports:
# - 9000:9090
volumes:
- ./prometheus:/etc/prometheus
- prometheus-data:/prometheus
command: --web.enable-lifecycle --config.file=/etc/prometheus/prometheus.yaml
network_mode: host
volumes:
prometheus-data:prometheus/prometheus.yaml:
global:
scrape_interval: 5s
scrape_timeout: 1s
evaluation_interval: 10s
rule_files:
- alert.yaml
scrape_configs:
- job_name: services
metrics_path: /metrics
static_configs:
- targets:
- 'localhost:3000'
- 'localhost:9090'
- 'idonotexists:564'prometheus/alert.yaml:
groups:
- name: demo-alerts
rules:
- alert: Instance down
expr: up{job="services"} == 0
for: 2m
labels:
severity: warningRun prometheus and check it is working:
docker-compose up -d
firefox http://localhost:9090/graphDownload example, compile it and run it (you main need to downgrade to GHC 8.10.7).
cabal run
firefox http://localhost:3000