Skip to content

Instantly share code, notes, and snippets.

@monadplus
Created August 10, 2022 16:02
Show Gist options
  • Save monadplus/daf1c762182a58bdf55afb9dd9e3630d to your computer and use it in GitHub Desktop.
Save monadplus/daf1c762182a58bdf55afb9dd9e3630d to your computer and use it in GitHub Desktop.
Prometheus: docker-compose & Haskell example

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: warning

Run prometheus and check it is working:

docker-compose up -d 
firefox http://localhost:9090/graph

Download example, compile it and run it (you main need to downgrade to GHC 8.10.7).

cabal run
firefox http://localhost:3000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment