# Golden Metrics Baseline for Services
#
# This document defines a standardized baseline for Golden Metrics (Latency, Traffic, Errors, Saturation - LTES)
# per service, including SLOs (Service Level Objectives) and burn-rate alerts.
#
# Assumptions:
# - Services are monitored using tools like Prometheus, Grafana, Datadog, or PagerDuty.
# - Time windows: Short-term (e.g., 5min), Long-term (e.g., 1hr or 1d/MTD for burn rates).
# - Error Budget: Calculated monthly (e.g., 30 days * 24h * 60m * 60s = 2,592,000s).
# - SLOs are conservative starters; tune based on historical data (e.g., p50/p95/p99 from last 90 days).
# - Burn Rates: Alert if >1 (budget burning faster than allowed). Thresholds: Critical (>8x), Warning (>2x).
# - Services: Example for a typical e-commerce microservices architecture. Extend as needed.
#
# Deployment:
# - Use Prometheus Recording Rules for SLI (Service Level Indicators).
# - Alerting via AlertManager/PagerDuty with runbook links.
# - Dashboards: Grafana with SLO burn-down charts.
global:
slo_window: "30d" # Monthly error budget window
error_budget_allowed: "0.1%" # e.g., for 99.9% SLO
burn_rate_short: "5m"
burn_rate_long: "1h"
burn_rate_alert:
warning_threshold: 2.0 # >2x burn rate
critical_threshold: 8.0 # >8x burn rate
services:
# 1. API Gateway / Load Balancer (Entry point for all traffic)
api-gateway:
description: "Handles incoming HTTP requests, routing, rate-limiting."
golden_metrics:
latency:
slo: "p99 <= 200ms over 5m" # SLI: histogram_quantile(0.99, rate(http_request_duration_seconds_bucket[5m]))
alert: "p99 > 500ms"
traffic:
slo: "N/A (observed, not objective)" # Monitor RPS/TPM
alert: "rps < 80% of avg(1h) or >120%"
errors:
slo: "99.9% good requests over 30d" # SLI: rate(http_requests_total{status=~"2.."}[5m]) / rate(http_requests_total[5m]) >= 0.999
error_budget: "259s/mo" # 0.1% of 2.59M seconds
saturation:
slo: "CPU < 80%, Memory < 80% over 5m"
alert: "CPU > 90% or Mem > 90%"
burn_rates:
short_term: "if rate(sli_failures[5m]) / ({{error_budget_allowed}}/3600) > {{burn_rate_alert.warning_threshold}} then warning"
long_term: "if rate(sli_failures[1h]) / ({{error_budget_allowed}}/3600/12) > {{burn_rate_alert.critical_threshold}} then critical"
runbook: "https://internal.runbooks/api-gateway-slo-breach"
# 2. User Service (CRUD for user profiles)
user-service:
description: "Manages user authentication, profiles, sessions."
golden_metrics:
latency:
slo: "p99 <= 150ms over 5m"
alert: "p99 > 300ms"
traffic:
slo: "N/A"
alert: "rps < 70% or >130% of avg(1h)"
errors:
slo: "99.95% good requests over 30d" # Higher reliability for auth
error_budget: "130s/mo" # 0.05%
saturation:
slo: "CPU < 75%, Connections < 80%"
alert: "CPU > 85% or Conn > 90%"
burn_rates:
short_term: "if rate(sli_failures[5m]) / ({{error_budget_allowed}}/2/3600) > {{burn_rate_alert.warning_threshold}} then warning"
long_term: "if rate(sli_failures[1h]) / ({{error_budget_allowed}}/2/3600/12) > {{burn_rate_alert.critical_threshold}} then critical"
runbook: "https://internal.runbooks/user-service-slo-breach"
# 3. Order Service (E-commerce order processing)
order-service:
description: "Handles order creation, inventory checks, fulfillment."
golden_metrics:
latency:
slo: "p99 <= 300ms over 5m" # Higher due to DB joins
alert: "p99 > 600ms"
traffic:
slo: "N/A"
alert: "rps < 60% or >140% of avg(1h)" # Spiky during sales
errors:
slo: "99.9% good requests over 30d"
error_budget: "259s/mo"
saturation:
slo: "CPU < 80%, DB Query Queue < 70%"
alert: "CPU > 90% or Queue > 80%"
burn_rates:
short_term: "if rate(sli_failures[5m]) / ({{error_budget_allowed}}/3600) > {{burn_rate_alert.warning_threshold}} then warning"
long_term: "if rate(sli_failures[1h]) / ({{error_budget_allowed}}/3600/12) > {{burn_rate_alert.critical_threshold}} then critical"
runbook: "https://internal.runbooks/order-service-slo-breach"
# 4. Payment Service (Third-party integrations)
payment-service:
description: "Processes payments via Stripe/PayPal."
golden_metrics:
latency:
slo: "p99 <= 500ms over 5m" # External deps
alert: "p99 > 1s"
traffic:
slo: "N/A"
alert: "tps < 50% or >150% of avg(1h)"
errors:
slo: "99.99% good requests over 30d" # Critical path
error_budget: "26s/mo" # 0.01%
saturation:
slo: "CPU < 70%, External API Calls < 80%"
alert: "CPU > 80% or ExtCalls > 90%"
burn_rates:
short_term: "if rate(sli_failures[5m]) / ({{error_budget_allowed}}/10/3600) > {{burn_rate_alert.warning_threshold}} then warning"
long_term: "if rate(sli_failures[1h]) / ({{error_budget_allowed}}/10/3600/12) > {{burn_rate_alert.critical_threshold}} then critical"
runbook: "https://internal.runbooks/payment-service-slo-breach"
# 5. Database (Shared PostgreSQL/MySQL cluster)
database:
description: "Primary relational DB for all services."
golden_metrics:
latency:
slo: "p99 query duration <= 50ms over 5m"
alert: "p99 > 100ms"
traffic:
slo: "N/A (QPS)"
alert: "qps < 70% or >130% of avg(1h)"
errors:
slo: "99.99% successful queries over 30d"
error_budget: "26s/mo"
saturation:
slo: "CPU < 70%, IOPS < 80%, Connections < 80%"
alert: "Any > 90%"
burn_rates:
short_term: "if rate(db_query_errors[5m]) / ({{error_budget_allowed}}/10/3600) > {{burn_rate_alert.warning_threshold}} then warning"
long_term: "if rate(db_query_errors[1h]) / ({{error_budget_allowed}}/10/3600/12) > {{burn_rate_alert.critical_threshold}} then critical"
runbook: "https://internal.runbooks/db-slo-breach"
Implementation Notes
- SLI Queries (Prometheus Examples):
# Error Rate SLI (good requests %)
slo_errors = sum(rate(http_requests_total{job="user-service", status=~"2.."}[5m])) / sum(rate(http_requests_total{job="user-service"}[5m])) * 100
# Burn Rate (short-term)
burn_short = rate(sli_failures[5m]) / (0.001 / 3600) # For 99.9% SLO, failures per hour allowed
alert: burn_short > 2
- Grafana Dashboard Template: Use SLO panels with burn-down charts (remaining budget %).
- Alert Routing: Page SRE on-call for critical burn rates; notify devs for warnings.
- Tuning: Baseline from historical p95 data. Review quarterly. Add SLIs for business metrics (e.g., order success rate).
- Next Steps:
- Instrument services with metrics (e.g., via OpenTelemetry).
- Deploy recording rules/alerts.
- Set up error budget policies (e.g., stop deploys if budget <20%).
This baseline ensures reliable services with proactive alerting. Adjust SLOs based on your SLAs/customer expectations! If you provide specific services/metrics data, I can refine it.