Théorie

groups:
  - name: AllInstances
    rules:
      - alert: InstanceDown
        expr: up == 0
        for: 1m
        labels:
          severity: critical
        annotations:
          title: 'Instance {{ $labels.instance }} down'
          description: '{{ $labels.instance }} of job {{ $labels.job }} has been down for more than 1 minute.'

rule_files:
  - "/etc/docker/prometheus/alert.rules.yml"
alertmanager:
    image: prom/alertmanager:latest
    container_name: alertmanager
    volumes:
      - ./alertmanager.yml:/etc/alertmanager/alertmanager.yml
      - alertmanager_data:/alertmanager
    ports:
      - 9093:9093
    command:
      - '--config.file=/etc/alertmanager/alertmanager.yml'
    restart: unless-stopped
benjojo/alertmanager-discord
  discord-relay:
    image: benjojo/alertmanager-discord
    container_name: discord-relay
    ports:
      - 9094:9094
    environment:
      - DISCORD_WEBHOOK=https://discord.com/api/webhooks/1374675268270030869/u6m9kU17eq_pxySj-S9JQa6tB1_cba-u4wCUPVViga3h3KlFhV-5MrIxOmUaEr1KLttc
    restart: unless-stopped
route:
  group_by: ['alertname']
  group_wait: 30s
  group_interval: 5m
  repeat_interval: 1h
  receiver: 'discord_webhook'
receivers:
  - name: 'discord_webhook'
    webhook_configs:
    - url: '<http://discord-relay:9094>'

Entire Files

version: '3.8'
services:
  prometheus:
    image: prom/prometheus
    container_name: prometheus
    command:
      - '--config.file=/etc/docker/prometheus/prometheus.yml'
    ports:
      - 9090:9090
    restart: unless-stopped
    volumes:
      - ./prometheus.yml:/etc/docker/prometheus/prometheus.yml
      - ./alert.rules.yml:/etc/docker/prometheus/alert.rules.yml
      - prom_data:/prometheus

  alertmanager:
    image: prom/alertmanager:latest
    container_name: alertmanager
    volumes:
      - ./alertmanager.yml:/etc/alertmanager/alertmanager.yml
      - alertmanager_data:/alertmanager
    ports:
      - 9093:9093
    command:
      - '--config.file=/etc/alertmanager/alertmanager.yml'
    restart: unless-stopped

  discord-relay:
    image: benjojo/alertmanager-discord
    container_name: discord-relay
    ports:
      - 9094:9094
    environment:
      - < Webhook d'intégration discord >
    restart: unless-stopped

volumes:
  prom_data:
  alertmanager_data: