Skip to main content

Observability Stack

Zerq ships a ready-to-run monitoring stack in deploy/observability: Prometheus, Alertmanager, Grafana, Loki, Promtail, Tempo, the OpenTelemetry Collector and the Prometheus blackbox exporter for synthetic checks, with Zerq dashboards, alert rules, recording rules and datasources already provisioned. Use it as is for development and evaluation, or as the reference configuration for your own monitoring platform.

                 ┌──────────────── Grafana (dashboards, Explore) ────────────────┐
│ │ │ │
Prometheus ◄── remote write ── Tempo ◄── traces ── OTel Collector ── Loki ◄── Promtail
│ ▲ ▲ │ logs ▲ (backend JSON logs)
alerts │ │ scrape METRICS_ADDR (:9100) │ └───────────────┘
▼ │ │ OTLP/HTTP :4318
Alertmanager └────────────── Zerq backend ───────────────┘ (traces, request/audit log streams)

Start it​

docker compose -f deploy/observability/docker-compose.yml up -d
UIURL
Grafanahttp://localhost:3300 (anonymous viewer; admin / admin to edit)
Prometheushttp://localhost:9091
Alertmanagerhttp://localhost:9093

Point the backend at it:

METRICS_ADDR=:9100                                  # Prometheus scrapes host.docker.internal:9100
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 # traces
LOG_STREAM_OTLP_ENDPOINT=http://localhost:4318 # request and audit logs to Loki

The development stack (deploy/docker-compose.dev.yml) already sets METRICS_ADDR and links trace IDs in the console to Grafana (NEXT_PUBLIC_TRACE_URL_TEMPLATE). Export the two OTLP variables before docker compose up to also send traces and log streams. Backend log lines reach Loki through Promtail: from containers of the backend Compose service, or from *.log files in ZERQ_LOG_DIR (default deploy/observability/logs) when the backend runs outside Docker.

Dashboards​

All dashboards are in the Zerq folder and link to each other. They are generated by deploy/observability/grafana/generate-dashboards.py: change a dashboard there and run the script (CI fails when the JSON files are out of date).

DashboardWhat it answers
Zerq — Platform Overview (home)Every surface at a glance: API Gateway requests, 5xx ratio, p95 and rejections; AI Gateway requests, failures, spend per hour and p95; workflow runs and failures; MCP tool calls and failures; instances up, firing Zerq alerts, lost log writes and undelivered streamed logs; traffic and error ratio per surface over time; the list of firing alerts.
Zerq — API GatewayRequests per second, 5xx ratio, p95 latency, upstream p95, cache hit ratio; status classes; latency percentiles with trace exemplars; a per-route table (rate, 5xx ratio, p95, upstream p95); gateway overhead; upstream failures; 401/403/429 rates; top clients; payload sizes. Filter by instance, collection and route.
Zerq — Runtime & DependenciesVersion, uptime and health of every instance; synthetic check results and durations; CPU, memory, goroutines, GC, file descriptors; MongoDB pool, command latency and errors; Redis pool; management API traffic; log writes, streaming and retention.
Zerq — SLOs and Error BudgetsAvailability and error budget left over the selected range, burn rates (1h, 6h) against the 14.4x and 6x alert thresholds, latency SLI, per collection. Pick the objective (99%–99.99%) at the top.
Zerq — AI GatewayAI requests by outcome, tokens, cost per client, latency per model (with trace exemplars) and fallbacks; model API responses by status; provider-side failures; failed AI requests from the log stream and the slowest AI traces; provider attempts, failure ratio and call p95 per provider; top clients by cost; cache hit ratio, guardrail blocks, budget limits and tokens per request. See AI Gateway Observability.
Zerq — ClientOne API client across both gateways (pick it by name): requests, 4xx/5xx ratios, throttling, requests by route and status; AI requests by model and outcome, failures, tokens, spend in the range and spend per hour by model.
Zerq — Security401/403 and 429 on the gateway by collection and client, unauthenticated requests by route, AI key and management API rejections; from the audit log stream: events by action, denied management actions, audit log exports and denied audited actions. The audit panels need log streaming to Loki.
Zerq — Workflows & MCPWorkflow runs by trigger and result, run and node durations, failing node types and the slowest runs; MCP tool calls, errors and latency per tool, and MCP gateway responses.
Zerq — Logs & TracesBackend log volume and warnings, failed requests, the audit trail and AI requests from the log stream, slowest and failed traces, and the service map (upstreams and MongoDB as nodes).

Panels that list clients show their names (from zerq_client_info, see Client names), and the client pickers list clients by name.

Signals are linked: click a latency exemplar to open its trace, open the logs of a trace from Tempo, and follow a trace_id in a log line back to its trace.

Alerts​

Prometheus evaluates the Zerq alert rules in deploy/observability/prometheus/rules/zerq-alerts.yml and sends firing alerts to Alertmanager. The default Alertmanager receiver only records alerts; edit deploy/observability/alertmanager/alertmanager.yml to notify Slack, Microsoft Teams, PagerDuty, Opsgenie, e-mail or a webhook (examples are in the file). Every alert links to its entry in Alerts and Runbooks. Set ALERTMANAGER_URL on the backend to also list firing alerts on the console's Alerts page.

The rules have unit tests (deploy/observability/prometheus/tests), run in CI and locally with:

docker run --rm -v "$PWD/deploy/observability/prometheus:/p" --entrypoint promtool \
quay.io/prometheus/prometheus:v2.54.1 test rules /p/tests/zerq-rules.test.yml

Synthetic checks​

The blackbox exporter probes URLs from outside the backend, the way users reach it (Prometheus job zerq-synthetic). The default target is the backend's /readyz. Add your critical gateway routes to the job's targets, with a module in deploy/observability/blackbox/blackbox.yml that sends a dedicated monitoring client's credentials. Failing probes raise ZerqSyntheticProbeFailing.

Kubernetes​

For clusters with the Prometheus Operator (for example kube-prometheus-stack):

kubectl apply -k deploy/observability

This creates a metrics Service and a ServiceMonitor for the backend (port 9100, pod label app: backend, namespace zerq), a PrometheusRule with the Zerq alert and recording rules, and a ConfigMap with the dashboards labelled grafana_dashboard: "1" for the Grafana sidecar. Adjust the selectors and the release label to your installation. The dashboards expect datasources with uids prometheus, loki and tempo.

kubernetes/prometheusrule.yaml is generated from the rule files; after changing a rule run deploy/observability/kubernetes/generate-prometheusrule.py (CI checks it is up to date).

Running it in production​

The Compose stack is single-node with local storage and default credentials. For production:

  • Credentials: replace GF_SECURITY_ADMIN_PASSWORD, turn off anonymous access, put Grafana behind your SSO, and set METRICS_TOKEN on the backend (and the matching authorization in the scrape config).
  • Storage and retention: Prometheus keeps 15 days, Tempo 7 days and Loki 30 days on local volumes. Use object storage (S3, GCS, Azure Blob) for Tempo and Loki, and long-term storage (Thanos, Mimir, a managed Prometheus) for metrics you keep for capacity planning.
  • High availability: run two Prometheus replicas (or an agent remote-writing to a highly available backend) and an Alertmanager cluster.
  • Network: keep METRICS_ADDR and the collector's OTLP ports on a private network.
  • Other vendors: add exporters to the collector configuration (deploy/observability/otel-collector/config.yaml) to send traces and logs to Datadog, Splunk, Elastic, New Relic or Dynatrace instead of, or in addition to, Tempo and Loki.