Assignments
25 assignments
Beginner assignments run on Docker Compose on your laptop. Intermediate and advanced ones use a local kind cluster with kube-prometheus-stack (the same setup as the hands-on lab, release name kps, namespace observability). The CloudWatch assignments need an AWS account; delete what you create afterwards. Try each one before opening the hints.
๐ข Beginner
A1. Prometheus and node_exporter with Docker Compose ๐ข
Objective: Run Prometheus locally, scrape a host exporter and understand the scrape model.
Tasks
- Write a
docker-compose.ymlwithprom/prometheusandprom/node-exporteron one network. - Write
prometheus.ymlwithscrape_interval: 15sand two jobs:prometheus(itself on:9090) andnode(node-exporter:9100). - Open
http://localhost:9090/targetsand confirm both targets areUP. - Stop node-exporter and watch
up{job="node"}go to 0 within one scrape interval. - Open
http://localhost:9100/metricsand find one counter, one gauge and one metric with labels.
Expected outcome: Both targets are UP, you can explain what the up metric is and where the job and instance labels come from.
Hints
Mount the config with ./prometheus.yml:/etc/prometheus/prometheus.yml:ro. Inside Compose, use service names as hostnames, not localhost. node_cpu_seconds_total is a counter, node_memory_MemAvailable_bytes is a gauge. Reload config without a restart by starting Prometheus with --web.enable-lifecycle and running curl -X POST localhost:9090/-/reload.
Bonus: Add scrape_timeout: 5s and a relabel_configs rule that sets a static env="lab" label on the node job.
A2. Your first ten PromQL queries ๐ข
Objective: Get fluent with selectors, rate, increase and aggregation.
Tasks Using the setup from A1, write and save queries that return:
- CPU utilisation per instance as a percentage (from
node_cpu_seconds_total). - Available memory as a percentage of total.
- Per-second network receive bytes per interface, excluding
lo. - Total bytes received in the last hour.
- Root filesystem free space percentage.
- The number of HTTP requests Prometheus served per second, by handler.
- The top 3 handlers by request rate.
- The 5-minute load average divided by the CPU count.
- Whether any target is down.
- The same query as 1, but one hour ago (using
offset).
Expected outcome: Each query returns a sensible value in the graph view, and you can explain why you used rate versus increase versus a raw gauge.
Hints
CPU: 100 * (1 - avg by (instance) (rate(node_cpu_seconds_total{mode="idle"}[5m]))). CPU count: count by (instance) (node_cpu_seconds_total{mode="idle"}). Prometheus' own HTTP metric is prometheus_http_requests_total. increase(x[1h]) is rate(x[1h]) * 3600.
Bonus: Turn query 1 into a recording rule named instance:node_cpu_utilisation:rate5m and query the recorded series.
A3. Instrument a small app with a client library ๐ข
Objective: Expose custom application metrics with correct types and labels.
Tasks
- Write a tiny HTTP service (Python
prometheus_client, Goclient_golangor Nodeprom-client) with routes/and/checkout. - Add a counter
http_requests_totalwith labelsroute,method,status. - Add a histogram
http_request_duration_secondswith buckets suited to 10 msโ2 s. - Add a gauge
app_inflight_requests. - Make
/checkoutfail with a 500 about 5% of the time and sleep a random 50โ400 ms. - Add the app as a scrape target in Prometheus and generate traffic with a loop of
curl.
Expected outcome: /metrics shows the three metrics; in Prometheus you can graph request rate, error ratio and p95 latency for /checkout.
Hints
Use the route template as the label value, never the raw path with IDs. Python: Histogram("http_request_duration_seconds", "...", ["route"], buckets=(.01,.025,.05,.1,.25,.5,1,2)). Traffic loop: while true; do curl -s localhost:8080/checkout >/dev/null; sleep 0.1; done.
Bonus: Expose a build_info gauge with value 1 and labels version and commit, and use it in a query that shows error ratio by version.
A4. Grafana with provisioned data source and a golden-signals dashboard ๐ข
Objective: Run Grafana with configuration as files and build a first service dashboard.
Tasks
- Add
grafana/grafanato the Compose file from A1โA3. - Provision the Prometheus data source with a file in
provisioning/datasources/. - Build a dashboard for the A3 app with four panels: traffic, errors (%), p50/p95/p99 latency, in-flight requests (saturation).
- Add a
routetemplate variable populated bylabel_values(http_requests_total, route). - Export the dashboard JSON and provision it from
provisioning/dashboards/so it survivesdocker compose down -v.
Expected outcome: After a full restart with volumes deleted, Grafana comes back with the data source and dashboard already present.
Hints
The dashboards provider file needs providers: [{ name: default, type: file, options: { path: /var/lib/grafana/dashboards } }]. Use $__rate_interval instead of a hard-coded [5m]. Set percentage units on the error panel and seconds on latency.
Bonus: Add a stat panel showing the current error ratio with green/amber/red thresholds at 0.1% and 1%.
A5. Write and validate your first alert rule ๐ข
Objective: Create alerting rules with for:, labels and annotations, and validate them.
Tasks
- Create
rules/app.ymlwith an alertAppHighErrorRatefiring when the 5xx ratio for/checkoutis above 5% for 5 minutes. - Add
severity: warning, asummary, adescriptionthat prints the value, and arunbook_url. - Add an
InstanceDownalert onup == 0for 2 minutes. - Validate with
promtool check rules rules/app.ymland load the file viarule_files. - Raise the failure rate in the app to 20% and watch the alert go inactive โ pending โ firing on
/alerts.
Expected outcome: Both rules load without errors, and you can show the pending state and explain why for: exists.
Hints
Run promtool from the image: docker run --rm -v $PWD/rules:/rules --entrypoint promtool prom/prometheus check rules /rules/app.yml. In annotations, {{ $value | humanizePercentage }} formats a ratio nicely.
Bonus: Add keep_firing_for: 5m and explain which kind of flapping it prevents.
A6. Alertmanager routing to Slack (or a webhook) ๐ข
Objective: Deliver alerts to a receiver with grouping.
Tasks
- Add
prom/alertmanagerto Compose and point Prometheus at it with thealertingblock. - Configure a Slack receiver using
api_url_file(or a local webhook receiver if you have no Slack). - Group by
alertnameandjob, withgroup_wait: 30s,group_interval: 5m,repeat_interval: 4h. - Validate with
amtool check-config. - Trigger
InstanceDownby stopping node-exporter, then start it again and confirm a resolved notification. - Create a 15-minute silence from the UI or
amtooland confirm it suppresses the alert.
Expected outcome: One firing and one resolved message arrive, and the silence demonstrably mutes the alert.
Hints
Add send_resolved: true to the Slack config. amtool --alertmanager.url=http://localhost:9093 silence add alertname=InstanceDown --duration=15m --comment="A6 test". A simple local webhook receiver: docker run -p 8000:8080 mendhak/http-https-echo and look at its logs.
Bonus: Write a custom Slack title and text template that includes runbook_url and the number of firing alerts in the group.
A7. Ship container logs to Loki and query them with LogQL ๐ข
Objective: Run a minimal log pipeline and learn the basic LogQL shapes.
Tasks
- Add
grafana/loki(single binary) andgrafana/alloyto Compose. - Configure Alloy to discover Docker containers and send their logs to Loki with labels
containerandcompose_service. - Make the A3 app log one JSON line per request with
level,route,status,duration_ms. - Add Loki as a Grafana data source and in Explore run: all logs for the app, only errors (
|= "error"), JSON-parsed lines withstatus >= 500. - Build a panel with
sum by (status) (count_over_time({compose_service="app"} | json [1m])).
Expected outcome: Logs appear in Explore within seconds; you can filter by content and by parsed fields, and you can explain why status is not a Loki label.
Hints
Alloy components: discovery.docker, discovery.relabel (map __meta_docker_container_name), loki.source.docker, loki.write. Mount /var/run/docker.sock read-only. Promtail reached end of life in 2026, so do not start new setups with it.
Bonus: Write a Loki alerting rule (ruler) that fires when the app logs more than 10 errors per minute.
A8. Synthetic checks with the blackbox exporter ๐ข
Objective: Monitor endpoints from the outside, including TLS expiry.
Tasks
- Add
prom/blackbox-exporterto Compose with the defaulthttp_2xxmodule. - Configure a Prometheus job that probes three URLs (your app,
https://example.com, a URL that returns 404) using the standard relabeling pattern. - Query
probe_success,probe_duration_secondsandprobe_http_status_code. - Write alerts for
probe_success == 0for 3m and certificate expiry under 21 days.
Expected outcome: Two probes succeed, the 404 probe fails, and the TLS expiry query returns days remaining for the HTTPS site.
Hints
The job uses metrics_path: /probe, params: { module: [http_2xx] }, and relabels __address__ โ __param_target, __param_target โ instance, then sets __address__ to blackbox-exporter:9115. Days to expiry: (probe_ssl_earliest_cert_expiry - time()) / 86400.
Bonus: Add a dns_udp module that checks resolution of your domain against 1.1.1.1.
A9. Install kube-prometheus-stack and find your way around ๐ข
Objective: Install the standard Kubernetes monitoring stack and learn what each component does.
Tasks
- Create a
kindcluster and installprometheus-community/kube-prometheus-stackas releasekpsin namespaceobservability. - List the pods and name the role of each (operator, Prometheus, Alertmanager, Grafana, kube-state-metrics, node-exporter).
- Port-forward Prometheus and Grafana, log in to Grafana with the admin secret.
- List the CRDs the chart installed and the
ServiceMonitors it created. - Find which default targets are
DOWNon kind and explain why. - Open the "Kubernetes / Compute Resources / Namespace (Pods)" dashboard.
Expected outcome: You can explain the operator pattern in two sentences and map each ServiceMonitor to a target on /targets.
Hints
kubectl -n observability get secret kps-grafana -o jsonpath='{.data.admin-password}' | base64 -d. kubectl get crd | grep monitoring.coreos.com. On kind, kube-scheduler, controller-manager and etcd bind to 127.0.0.1 on the control-plane node, so their targets are down unless you change the bind addresses.
Bonus: Use helm get values kps -a and find the values that control serviceMonitorSelector.
A10. CloudWatch alarm on EC2 CPU with SNS ๐ข
Objective: Use native AWS monitoring for a basic alert.
Tasks
- Launch a
t3.microinstance (or use an existing test one). - Create an SNS topic and subscribe your email.
- Create a CloudWatch alarm on
CPUUtilization> 70% for 3 consecutive 1-minute periods (enable detailed monitoring) using the AWS CLI. - SSH in and generate load (
stress-ng --cpu 2 --timeout 600), then confirm the alarm goes toALARMand the email arrives. - Stop the load and confirm the
OKnotification.
Expected outcome: You receive both ALARM and OK emails, and you can explain periods, evaluation periods and datapoints to alarm.
Hints
aws cloudwatch put-metric-alarm --alarm-name a10-cpu --namespace AWS/EC2 --metric-name CPUUtilization --dimensions Name=InstanceId,Value=<id> --statistic Average --period 60 --evaluation-periods 3 --threshold 70 --comparison-operator GreaterThanThreshold --alarm-actions <topic-arn> --ok-actions <topic-arn>. Detailed monitoring: aws ec2 monitor-instances --instance-ids <id>.
Bonus: Set --treat-missing-data breaching on a second alarm, stop the instance, and explain what happens and when that setting is right.
๐ก Intermediate
A11. ServiceMonitor and PrometheusRule for your own app ๐ก
Objective: Onboard an application to kube-prometheus-stack the way platform teams expect.
Tasks
- Containerise the A3 app, load it into kind and deploy it to namespace
a11with 2 replicas and a Service with a named porthttp-metrics. - Write a
ServiceMonitorthat selects the Service and scrapes/metricsevery 30s. - Confirm both pods appear on
/targets. If they do not, debug the selector chain. - Write a
PrometheusRulewith one recording rule (request rate per route) and one alert (error ratio > 5% for 5m). - Verify the rule appears on Prometheus'
/rulespage.
Expected outcome: Two UP targets with namespace, pod and service labels, and your rule group loaded and evaluating.
Hints
The chain is: Prometheus serviceMonitorSelector (default release: kps) โ ServiceMonitor labels โ spec.selector โ Service labels โ Service ports[].name โ endpoints[].port. Load the image with kind load docker-image app:dev --name obs. Rules need the same release: kps label unless ruleSelectorNilUsesHelmValues: false.
Bonus: Switch to a PodMonitor instead and explain when you would choose it over a ServiceMonitor.
A12. Recording rules and correct latency percentiles ๐ก
Objective: Prove why you aggregate histogram buckets, not quantiles, and speed up dashboards with recording rules.
Tasks
- Run three replicas of the A3 app and make one replica much slower than the others.
- Compute p99 latency the right way:
histogram_quantileoversum by (le)of bucket rates. - Compute it the wrong way:
avgof per-pod p99 values. Compare the two numbers. - Create recording rules following the
level:metric:operationsconvention for request rate, error ratio and bucket rates aggregated byroute. - Rebuild the latency panel on the recorded series and compare query time in the query inspector.
Expected outcome: A short written explanation of why the averaged quantile is wrong, with both numbers, and a dashboard that queries only recorded series.
Hints
Record route:http_request_duration_seconds_bucket:rate5m as sum by (route, le) (rate(http_request_duration_seconds_bucket[5m])). Then histogram_quantile(0.99, route:http_request_duration_seconds_bucket:rate5m). Never drop le in the recording rule.
Bonus: Enable native histograms in Prometheus and the client library and compare the accuracy and series count.
A13. Alertmanager routing tree, inhibition and route tests ๐ก
Objective: Design routing for multiple teams and severities and prove it with tests.
Tasks
- Write an
alertmanager.yamlwith a default receiver, acriticalroute to a pager receiver, and team routes (team="payments",team="search") to separate Slack channels. - Use
continue: trueso critical alerts also go to the team channel. - Add an inhibition rule: when
NodeDownfires, suppresswarningalerts on the sameinstance. - Add a weekday-only time interval for
severity="ticket"alerts. - Test with
amtool config routes testfor at least six label sets and record the expected receiver for each. - Deploy it through the chart's
alertmanager.configvalues and fire test alerts withamtool alert add.
Expected outcome: Every test label set reaches exactly the receivers you predicted, and inhibition visibly suppresses the child alert.
Hints
amtool config routes test --config.file=alertmanager.yaml severity=critical team=payments. Inhibition: inhibit_rules: [{ source_matchers: [alertname="NodeDown"], target_matchers: [severity="warning"], equal: [instance] }]. Time intervals are referenced from routes with active_time_intervals.
Bonus: Write a small CI script that runs all route tests from a YAML table and fails on any mismatch.
A14. Dashboards as code with variables and the Grafana sidecar ๐ก
Objective: Ship a reusable service dashboard with the application, not by clicking.
Tasks
- Build a RED dashboard with
namespace,serviceandroutevariables (chained so each one filters the next). - Use
$__rate_intervalin every rate and set a stableuid. - Export the JSON, remove
id, and wrap it in a ConfigMap labelledgrafana_dashboard: "1"with agrafana_folderannotation. - Deploy the ConfigMap with the app's manifests and confirm the dashboard appears without touching the UI.
- Add a deployment annotation query that marks new versions from
kube_deployment_status_observed_generationchanges orchanges(build_info[5m]).
Expected outcome: Deleting and recreating the ConfigMap removes and restores the dashboard, and the variables work for any onboarded service.
Hints
Variable query: label_values(http_requests_total{namespace="$namespace"}, service). In kube-prometheus-stack values, set grafana.sidecar.dashboards.searchNamespace: ALL and folderAnnotation: grafana_folder.
Bonus: Generate the same dashboard with the Grafana Foundation SDK or Grafonnet and diff the output with your exported JSON.
A15. Fluent Bit to Loki on Kubernetes with LogQL metrics ๐ก
Objective: Build a cluster log pipeline with sane labels and turn logs into alerts.
Tasks
- Install Loki (single binary) and Fluent Bit (DaemonSet) with Helm.
- Configure Fluent Bit with the
kubernetesfilter and thelokioutput, using onlynamespace,app,containerandlevelas labels. - Make sure JSON app logs are parsed so
levelis available. - Write LogQL for: error rate per app, top 5 noisiest pods by bytes, and p95
duration_msper route usingunwrap. - Create a Loki ruler alert for error rate and route it to Alertmanager.
- Check the number of active streams and explain what would happen if you added
podortrace_idas a label.
Expected outcome: Logs flow with exactly the planned labels, the LogQL metrics work in a panel, and the ruler alert reaches Alertmanager.
Hints
Fluent Bit loki output: labels job=fluent-bit, namespace=$kubernetes['namespace_name'], app=$kubernetes['labels']['app']. Use Merge_Log On in the kubernetes filter to lift JSON fields. Loki ruler needs ruler.alertmanager_url. Streams: loki_ingester_memory_streams.
Bonus: Drop health-check log lines in Fluent Bit with a grep filter and measure the reduction with bytes_over_time.
A16. Distributed tracing with OpenTelemetry and Tempo ๐ก
Objective: Trace a request across two services through an OTel Collector.
Tasks
- Create a second service (
inventory) thatcheckoutcalls over HTTP. - Instrument both with the OpenTelemetry SDK (auto-instrumentation for HTTP plus one manual span named
reserve-stock). - Deploy an OpenTelemetry Collector with
otlpreceiver,memory_limiterandbatchprocessors, and an exporter to Tempo. - Set
service.nameanddeployment.environmentresource attributes. - Find a trace in Grafana that shows both services and the manual span; identify the slowest span.
- Break propagation (stop forwarding headers) and observe two disconnected traces.
Expected outcome: One trace spans both services with correct parent-child links; you can explain the role of the traceparent header.
Hints
SDK env vars: OTEL_SERVICE_NAME, OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4317, OTEL_TRACES_SAMPLER=parentbased_traceidratio, OTEL_TRACES_SAMPLER_ARG=1.0. Collector order: memory_limiter first, batch last.
Bonus: Install the OpenTelemetry Operator and use an Instrumentation resource with the pod annotation to inject auto-instrumentation without code changes.
A17. Correlate metrics, logs and traces ๐ก
Objective: Make one click take you from a latency spike to the trace and its logs.
Tasks
- Add the current
trace_idto every JSON log line in both services from A16. - Configure a Loki derived field in Grafana that turns
trace_idinto a link to Tempo. - Configure the Tempo data source "trace to logs" to query Loki by
service.nameand trace ID. - Record exemplars on the latency histogram, enable
exemplar-storagein Prometheus, and show exemplars on the p99 panel. - Walk the path: p99 spike โ exemplar โ trace โ logs for that trace.
Expected outcome: The full metric โ trace โ log path works with clicks only, and you can screenshot each hop.
Hints
Derived field regex: "trace_id":"(\w+)". Prometheus feature flag: prometheus.prometheusSpec.enableFeatures: [exemplar-storage]. Exemplars require the OpenMetrics exposition format, which client libraries serve when Prometheus asks for it.
Bonus: Generate RED metrics from spans with the Collector's spanmetrics connector and compare them with the app's own metrics.
A18. Unit-test alert rules with promtool ๐ก
Objective: Test alert logic the same way you test code.
Tasks
- Take the A11 error-ratio alert and the A5
InstanceDownalert into a plain rules file. - Write
tests.ymlwithinput_seriesthat cross the threshold after 10 minutes. - Assert the alert is not firing at 4 minutes (pending), and is firing at 15 minutes with the expected labels and annotations.
- Add a test proving the alert does not fire when traffic is zero (no division-by-zero false positives).
- Run
promtool test rules tests.ymland make a test fail on purpose to read the output.
Expected outcome: All tests pass, including the edge case, and a deliberate threshold change makes the suite fail.
Hints
Series notation: '0+60x20' grows by 60 per minute for 20 steps; '0x20' stays flat. Use exp_alerts: [] to assert nothing fires. Annotations must match exactly, including templated values.
Bonus: Run pint lint on the same rules and fix every finding.
A19. Find and fix a cardinality explosion ๐ก
Objective: Experience a cardinality problem and fix it at the right layer.
Tasks
- Add a label
user_idwith random values to a counter in the A3 app and run load for 10 minutes. - Watch
prometheus_tsdb_head_seriesand Prometheus memory grow. - Find the offender with the
/tsdb-statuspage andtopk(10, count by (__name__)({__name__=~".+"})). - Drop the label at scrape time with
metricRelabelings(labeldrop) in theServiceMonitorand confirm series stop growing. - Fix the code properly, and set
sampleLimiton theServiceMonitoras a guard rail. - Calculate how many series one high-cardinality label would add at 10,000 users ร 20 routes ร 5 statuses.
Expected outcome: A before/after graph of head series and a short explanation of why the fix belongs in code, with relabeling as a safety net.
Hints
metricRelabelings: [{ action: labeldrop, regex: user_id }]. Dropping a label can create duplicate series if it was the only differentiator; check for duplicate sample for timestamp warnings. scrape_samples_scraped per target shows which target got bigger.
Bonus: Alert on scrape_samples_scraped growing more than 50% compared with a day ago using offset 1d.
A20. CloudWatch Agent, Logs Insights and metric filters ๐ก
Objective: Collect OS metrics and logs on EC2 and alert from logs.
Tasks
- Attach an IAM role with
CloudWatchAgentServerPolicyto an instance and install the CloudWatch agent. - Configure it to send memory and disk usage metrics and
/var/log/nginx/access.logto a log group with 7-day retention. - Write a Logs Insights query for the count of 5xx responses per 5 minutes.
- Create a metric filter that counts 5xx lines into a custom metric and an alarm on it.
- Add the CloudWatch data source to Grafana and put the custom metric next to a Prometheus panel.
Expected outcome: Memory and disk metrics appear under the CWAgent namespace, the Logs Insights query returns counts, and the alarm fires when you generate 5xx responses.
Hints
Agent config: metrics.metrics_collected.mem.measurement: ["mem_used_percent"], logs.logs_collected.files.collect_list with log_group_name and retention_in_days: 7. Logs Insights: fields @timestamp, @message | filter @message like / 5\d\d / | stats count() by bin(5m). Put the metric filter with aws logs put-metric-filter.
Bonus: Replace the metric filter with Embedded Metric Format (EMF) output from a small script and compare cost and flexibility.
๐ด Advanced
A21. SLOs with multi-window multi-burn-rate alerts ๐ด
Objective: Define an SLO and alert on error budget burn, then prove the alerts behave.
Tasks
- Define two SLOs for
checkout: 99.5% availability (non-5xx) and 99% of requests under 300 ms, over 30 days. - Write recording rules for error ratios over 5m, 30m, 1h, 2h, 6h, 1d and 3d.
- Write the two standard page alerts (14.4ร over 1h and 5m, 6ร over 6h and 30m) and the ticket alerts (3ร over 1d and 2h, 1ร over 3d and 6h).
- Build an error budget dashboard: SLI, budget remaining, burn rate per window.
- Inject failures at 2%, then 10%, and record how long each alert takes to fire and to reset.
- Generate the same rules with Sloth or Pyrra and diff them against yours.
Expected outcome: A written table of detection time and reset time per failure level, matching the theory within a few minutes.
Hints
Burn rate = error ratio / (1 โ SLO). For 99.5%, 14.4ร means an error ratio above 7.2%. Latency SLI from histograms: 1 - (rate of bucket{le="0.3"} / rate of count); make sure 0.3 is an actual bucket boundary. Use promtool test rules to check the windows before running live.
Bonus: Write an error budget policy (one page) describing what the team does at 50%, 25% and 0% budget remaining.
A22. Highly available Prometheus with long-term storage ๐ด
Objective: Run an HA pair with deduplicated, long-term queries.
Tasks
- Set
replicas: 2on Prometheus and confirm both scrape the same targets. - Run MinIO in the cluster as object storage.
- Option A: enable the Thanos sidecar (
thanos.objectStorageConfig), deploy Thanos Query and Store Gateway, and set--query.replica-label=prometheus_replica. Option B: deploy Grafana Mimir andremote_writefrom both replicas with HA deduplication onclusterand__replica__. - Point Grafana at the global query layer and confirm results are not doubled.
- Delete one Prometheus pod during load and show there is no gap in the global view.
- Query data older than the local retention to prove blocks come from object storage.
Expected outcome: No duplicate series and no gap during a replica restart, and queries beyond local retention succeed.
Hints
The operator adds a prometheus_replica external label automatically; that is what deduplication keys on. For Mimir HA tracking, set accept_ha_samples: true and configure ha_cluster_label/ha_replica_label in limits. Shorten local retention to 2h to make step 6 quick.
Bonus: Turn on compaction with downsampling (Thanos) or per-tenant retention (Mimir) and explain the cost impact.
A23. Tail sampling with a load-balanced Collector tier ๐ด
Objective: Keep every error and slow trace while sampling the rest, at scale.
Tasks
- Deploy two Collector tiers: an agent tier with the
loadbalancingexporter routing bytraceID, and a gateway tier (3 replicas, headless Service) with thetail_samplingprocessor. - Configure policies: keep all traces with an error status, keep traces slower than 500 ms, keep 5% of the rest.
- Generate traffic with a mix of fast, slow and failing requests.
- Prove that every error trace is complete in Tempo, while normal traces are sampled near 5%.
- Scale the gateway to 1 replica, repeat, and show the broken traces you get without load balancing by trace ID.
- Monitor the Collectors' own metrics (
otelcol_processor_tail_sampling_*, refused spans, queue size).
Expected outcome: Measured keep rates per category that match the policies, and an explanation of why consistent routing by trace ID is mandatory.
Hints
loadbalancing exporter: routing_key: traceID, resolver: { dns: { hostname: otel-gateway-headless.observability.svc.cluster.local } }. Tail sampling needs decision_wait long enough for the slowest trace (for example 10s) and enough memory for num_traces.
Bonus: Generate span metrics before sampling with the spanmetrics connector so RED metrics stay accurate at 100%.
A24. Multi-cluster observability with a central store ๐ด
Objective: Give one Grafana a global view across clusters while keeping alerting local.
Tasks
- Create three kind clusters:
central,east,west. - In
central, install Mimir (or Thanos Receive) and Grafana; expose the write endpoint to the other clusters. - In
eastandwest, installkube-prometheus-stackwithexternalLabels.clusterset andremote_writeto central; keep local Alertmanager and rules. - Build a global dashboard with a
clustervariable and a panel comparing request rates across clusters. - Write one global alert in the central ruler (for example "a cluster stopped sending data") using
absentper cluster. - Cut the network from
westto central and describe what still works locally and what the central view shows.
Expected outcome: A working global view, local alerts that keep firing during a central outage, and a central alert that detects the missing cluster.
Hints
kind clusters can reach each other via the shared kind Docker network using container IPs and a NodePort. remote_write queue metrics (prometheus_remote_storage_samples_pending) show backlog during the outage. Prometheus retries and catches up from the WAL if the outage is shorter than about 2 hours.
Bonus: Switch east to Prometheus agent mode and list what you lose locally.
A25. Observability-as-code pipeline and a game day ๐ด
Objective: Put the whole monitoring configuration behind CI and prove it works under a simulated incident.
Tasks
- Create a repo with folders for
rules/,alertmanager/,dashboards/,servicemonitors/andotel/. - Add a CI pipeline (GitHub Actions or GitLab CI) that runs
promtool check rules,promtool test rules,amtool check-config, route tests,pint, a JSON lint for dashboards, andotelcol validate --configfor the Collector config. - Deploy the repo to the cluster with Argo CD or Flux.
- Plan a game day with three injected failures: a dependency returning 500s, a slow database (latency), and Prometheus losing a target.
- Run it with a teammate as on-call; measure time to detect, time to find the cause, and whether each alert had a working runbook.
- Write a short postmortem and open pull requests for every alert or dashboard gap found.
Expected outcome: A green pipeline that blocks a broken rule, a GitOps-deployed stack, and a postmortem with concrete fixes merged through the same pipeline.
Hints
Extract rules from PrometheusRule YAML for promtool with yq '.spec' rule.yaml > /tmp/rule.yml. Use the prom/prometheus and prom/alertmanager images in CI to get promtool and amtool. Fault injection: a feature flag in the app, tc qdisc add dev eth0 root netem delay 300ms in a debug container, or Chaos Mesh.
Bonus: Add a weekly job that reports alerts that fired but were never acknowledged, and alerts with no firing in 90 days, as candidates for deletion.