Skip to content

Monitoring Configuration

SLOzy exposes Prometheus-compatible metrics and ships with pre-configured alert rules and Grafana provisioning.

Prometheus Targets

The main prometheus/prometheus.yml defines the following scrape jobs:

JobTargetScrape IntervalPurpose
slozy-webslozy-web-service:8030sApplication metrics (/metrics)
kubernetes-podsAuto-discovery via pod annotations15sAll annotated pods
kubernetes-api-serverKubernetes API15sCluster health
postgres-exporterpostgres-exporter:918715sDatabase metrics
redis-exporterredis-exporter:912115sRedis metrics

For non-Kubernetes deployments, use the simplified deploy/prometheus.yml which targets localhost:8080:

yaml
scrape_configs:
  - job_name: 'slozy'
    static_configs:
      - targets: ['localhost:8080']
    metrics_path: /metrics
    scrape_interval: 15s

Metrics Endpoint

The application exposes a /metrics endpoint (enabled via METRICS_ENABLED=true, default port 9090). Key metric categories:

  • http_requests_total — request count by method, path, status code
  • http_request_duration_seconds — histogram of response times
  • slo_status — current burn-rate status per SLO
  • cache_hits / cache_misses — cache efficiency
  • websocket_connections_total — real-time connection count
  • process_resident_memory_bytes — memory usage

Alert Rules

Alerting rules are defined in prometheus/alerts/alerts.yml (Kubernetes) and deploy/slozy-alerts.yml (standalone). Pre-configured alerts:

Alert NameSeverityCondition
ApplicationDowncriticalup{job="slozy-web"} == 0 for 2m
HighErrorRatewarning5xx rate > 5% over 5m
HighLatencywarningP95 latency > 1s over 5m
VeryHighLatencycriticalP99 latency > 5s over 2m
HighMemoryUsagewarningContainer memory > 80% for 5m
DatabaseDowncriticalPostgres pod unreachable for 2m
HighDatabaseConnectionswarningActive connections > 80
CriticalSLOViolationcriticalAny SLO in critical status for 5m
MultipleSLOViolationswarning3+ SLOs in warning/critical for 10m

Alertmanager is configured to deliver notifications via Slack, email, or PagerDuty. Set alertmanager:9093 as the target in your Prometheus config.

Grafana Dashboards

The docker-compose.yml includes a Grafana container (port 3001) with provisioning from grafana/provisioning/ and dashboard definitions from grafana/dashboards/.

Conceptual dashboards to create:

  1. SLO Overview — burn-rate status for all SLOs, error budget remaining, time to exhaustion
  2. Application Performance — request rate, latency (P50/P95/P99), error rate by endpoint
  3. Database — connection pool usage, query duration, cache hit ratio
  4. Infrastructure — CPU/memory per pod, disk usage, network I/O

Default Grafana credentials: admin / admin. Change these in production.

Running the Stack

bash
# Full stack with monitoring
docker-compose up -d

# Or bring up monitoring standalone
docker-compose up -d prometheus grafana

# Access Grafana
open http://localhost:3001

Retention

ComponentSettingDefault
Prometheus TSDBretention.time30d
Prometheus TSDBretention.size10GB
GrafanaSnapshots / DBConfigurable via GF_* env vars

Adjust retention in prometheus/prometheus.yml under the storage.tsdb section.