Monitoring
The service exposes Prometheus metrics at /metrics. See Service Metrics
for a full reference of available metrics.
Configuration
METRICS_SCRAPE_KEY is a required environment variable. The service will
refuse to start without it. Generate the key and store it safely.
The /metrics endpoint is protected by authentication. Every
request must include the header:
Authorization: Bearer <METRICS_SCRAPE_KEY>
Example: Prometheus Scrape Job
Add a scrape job to your Prometheus configuration:
scrape_configs:
- job_name: 'ai-inference'
static_configs:
- targets: ['localhost:8000']
authorization:
type: Bearer
credentials: <METRICS_SCRAPE_KEY>
The easiest way is a separate docker-compose.yml on the same host. Use
network_mode: "host" so Prometheus sees the service on localhost:
services:
prometheus:
image: prom/prometheus:latest
container_name: prometheus
network_mode: "host"
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
- ./data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
Place your prometheus.yml (with the scrape job above) in the same directory
and start with docker compose up -d. Prometheus will be reachable on
localhost:9090.
Example 2: Grafana Dashboard
Point a Grafana instance at the Prometheus data source to build dashboards for request rate, latency histograms, error ratios, and Go runtime metrics.
A sample dashboard JSON can be exported from Grafana after setting up the
desired panels — the Prometheus label structure (method, path, status) is
stable and can be relied on for alerts and dashboards.