# Live metrics in Prometheus + Grafana — Artillery's
# `prometheus-grafana-dashboards`.
#
# loadr exposes a Prometheus scrape endpoint while the test runs; Prometheus
# scrapes it (see prometheus.yml) and Grafana graphs it (grafana-dashboard.json).
# For a push model instead, drop `listen` and set `remote_write_url:`.
#
#   docker compose -f examples/prometheus-grafana/docker-compose.yml up -d
#   loadr run examples/prometheus-grafana/loadr.yaml
#   # Grafana: http://localhost:3000  (import grafana-dashboard.json)
name: prometheus-grafana
description: expose loadr metrics to Prometheus for live Grafana dashboards

defaults:
  http:
    base_url: https://api.example.com

scenarios:
  load:
    executor: constant-vus
    vus: 25
    duration: 10m
    think_time: { type: uniform, min: 200ms, max: 800ms }
    flow:
      - request: { name: list, url: /api/items, checks: [ { type: status, equals: 200 } ] }
      - request: { name: detail, url: /api/items/1, checks: [ { type: status, equals: 200 } ] }

outputs:
  # Prometheus scrapes this endpoint. 0.0.0.0 so the container can reach it.
  - { type: prometheus, listen: 0.0.0.0:9091 }

thresholds:
  http_req_duration: [ "p(95)<400" ]
  http_req_failed: [ "rate<0.02" ]
