Production Monitoring

The Docker Compose deployment includes an optional Prometheus and Grafana monitoring profile. It is disabled during the normal docker compose up so the default API deployment remains lightweight.

Start the monitoring stack

Set a unique Grafana administrator password in the uncommitted .env file. Create a private file containing the exact same API key configured in ADP_API_KEY; Compose mounts it into Prometheus as a file-backed secret:

GRAFANA_ADMIN_USER=admin
GRAFANA_ADMIN_PASSWORD=replace-with-a-long-random-password
ADP_API_KEY_FILE=.secrets/adp_api_key
set -a
. ./.env
set +a
umask 077
mkdir -p .secrets
chmod 700 .secrets
printf '%s' "$ADP_API_KEY" > .secrets/adp_api_key
chmod 444 .secrets/adp_api_key

Start the API, Prometheus and Grafana together:

docker compose --profile monitoring up --build -d
docker compose --profile monitoring ps

The services bind to loopback by default:

Override the host ports with GRAFANA_PORT and PROMETHEUS_PORT. Keep these interfaces private or place them behind an authenticated TLS-terminating reverse proxy before allowing remote access. Grafana anonymous access and self-registration are disabled. Change the initial administrator password before starting the monitoring profile.

Provisioned dashboards and metrics

Grafana automatically provisions the Prometheus datasource and the ADP Operations Overview dashboard. It includes:

  • HTTP request throughput and 4xx/5xx response rates

  • HTTP latency p50, p95 and p99

  • Current ingestion jobs by queued, running, succeeded and failed state

  • Managed worker running state

Prometheus scrapes the API’s protected /metrics endpoint every 15 seconds. It uses the same ADP_API_KEY configured for the API, provided to Prometheus as a file-backed Compose secret and sent as a Bearer token over the private Compose network. Keep the secret file out of version control and restrict its filesystem permissions. The key is not embedded in the Prometheus configuration or passed as a Prometheus process argument. The API continues to accept the X-API-Key header for existing clients and also accepts Authorization: Bearer for standard Prometheus authentication.

Prometheus evaluates the provisioned rules for API scrape failures, elevated 5xx rates, a sustained queue backlog and a stopped ingestion worker. These rules appear in the Prometheus Alerts page. This profile does not configure an Alertmanager receiver or send email, chat or paging notifications; configure and secure an Alertmanager integration separately when notification delivery is required.

Retention and persistence

Prometheus retains 15 days of time-series data by default. Its TSDB and Grafana’s state are stored in the named prometheus-data and grafana-data volumes. The application continues to use adp-data for its SQLite index and job queue.

Stop the stack without deleting data:

docker compose --profile monitoring down

To intentionally remove all application and monitoring state, including historical metrics and Grafana settings:

docker compose --profile monitoring down --volumes

Back up named volumes before destructive maintenance. For production use, also define a tested backup/restore procedure and externalize monitoring data if it must survive loss of the Docker host.