Observability
The cluster covers the three pillars of observability, correlated in Grafana, plus a ready-made lab dashboard and SLOs with burn-rate alerts.
The Three Pillars
| Layer | Signal | Tool | Question it answers |
|---|---|---|---|
| Top | Traces | Grafana Tempo + OpenTelemetry | Why is it slow? Where did it fail? |
| Middle | Logs | Loki + Grafana Alloy | What happened and when? |
| Base | Metrics | Prometheus + Grafana | Is something wrong? |
The pyramid reflects signal volume and cost: metrics are cheap and always on; logs are richer but larger; traces are the most detailed.
| Pillar | Tool(s) | Enabled by |
|---|---|---|
| Metrics | Prometheus, Alertmanager, Grafana, node-exporter, kube-state-metrics, blackbox_exporter | monitoring: prometheus-stack (default) |
| Logs | Loki 3.x + Grafana Alloy | logging: loki |
| Traces | Grafana Tempo + OpenTelemetry Collector | tracing: otel-tempo |
| Mesh visibility | Kiali | installed with monitoring |
Cross-signal correlation
| From | To | How |
|---|---|---|
Log line with traceID= | Trace in Tempo | Click the derived field link |
| Trace span | Logs for that service | “Logs for this span” in Tempo |
| Trace span | RED metrics in Prometheus | service.name tag link |
| Service Map (Tempo) | Prometheus rate/error/duration | Click a node in the graph |
Monitoring
| Component | Description |
|---|---|
| Prometheus Operator | Manages Prometheus and Alertmanager |
| Prometheus | Metrics collection and storage |
| Alertmanager | Alert routing and notifications |
| Grafana | Dashboards (k8s-lab preinstalled), SSO through Keycloak |
| node-exporter | Host metrics (CPU, memory, disk) |
| kube-state-metrics | Kubernetes object metrics |
| kubelet / cAdvisor | Per-container CPU, memory, throttling, PSI and OOM metrics |
| blackbox_exporter | TLS certificate expiry of the API server, kubelets, Vault and every lab host |
| DNS targets | CoreDNS in the cluster, ExternalDNS, and CoreDNS on the storage node |
Access
| URL | Login |
|---|---|
https://grafana.lab.internal | “Sign in with Keycloak”, or admin + Vault secret/k8s-provisioner/grafana/admin |
https://prometheus.lab.internal | none |
https://alertmanager.lab.internal | none |
vagrant ssh controlplane -c \
'sudo k8s-provisioner vault get k8s-provisioner/grafana/admin password -c /etc/k8s-provisioner/config.yaml'
Without Vault, the Grafana password is in /etc/k8s-provisioner/grafana-credentials.txt on the controlplane.
Alertmanager notifications
To send alerts to Slack, email or PagerDuty, store a full alertmanager.yaml in Vault:
vault kv patch secret/k8s-provisioner/api-keys alertmanager_config=@alertmanager.yaml
Without Vault, edit the secret directly: kubectl edit secret alertmanager-alertmanager -n monitoring.
Lab dashboard (k8s-lab)
Provisioned with the cluster: Dashboards → k8s-lab → k8s-lab (https://grafana.lab.internal/d/k8s-lab/k8s-lab). One screen, one collapsible row per concern:
▼ Resources CPU/memory usage vs request vs limit, throttling, PSI, OOM, restarts,
per workload revision (filters at the top apply here)
▼ SLOs DNS objectives: SLI, error budget left, burn rate, alerts firing
▼ DNS — cluster CoreDNS in kube-system: queries by zone, response codes, forward latency
▼ DNS — lab ExternalDNS (records requested vs published, last sync, errors)
+ CoreDNS on the storage node (queries, failures, latency, cache)
▼ Certificates every certificate by days left: cert-manager, kubelet client certs,
and TLS probes of the API server, kubelets, Vault and each lab host
▶ DNS changes ExternalDNS "A record added/removed" log lines (Loki; collapsed)
Pick a Namespace and Workload at the top for the Resources row; the other rows cover the whole lab and ignore those filters. Rows only appear when their source exists (no storage node → no lab DNS row; no Loki → no DNS change log). Times follow cluster.timezone.
| Row | Metrics from | Notes |
|---|---|---|
| Resources | kube-state-metrics + kubelet cAdvisor, through the k8s-lab-resources recording rules (k8s_lab:* series) | PSI panels need kernel PSI (on in Debian 13) |
| SLOs | k8s-lab-slos recording rules | See DNS SLOs |
| DNS — cluster | CoreDNS :9153 in kube-system (job kube-dns) | The zone lab.internal. shows pod lookups forwarded to the storage node |
| DNS — lab | ExternalDNS :7979 (job external-dns), CoreDNS on storage :9153 (job lab-dns) | Unpublished hosts > 0 means a Gateway host is not resolvable yet |
| Certificates | cert-manager, kubelet /metrics, blackbox_exporter TLS probes (job blackbox) | Probes read the certificate each endpoint presents, so a renewed-but-not-reloaded certificate shows up. Lab CA expires in is the CA your machine trusts |
DNS SLOs
Every lab URL depends on DNS, so the DNS path has service level objectives over a 7-day window (not the usual 28: the lab is rebuilt often):
| SLO | SLI (good events / time) | Objective |
|---|---|---|
coredns-cluster-availability | Cluster DNS answers without SERVFAIL/REFUSED | 99.9% |
coredns-cluster-latency | Cluster DNS answers within 128 ms | 99% |
coredns-lab-availability | Lab DNS (storage node, lab zone) answers without SERVFAIL/REFUSED | 99.9% |
coredns-lab-latency | Lab DNS answers within 128 ms (lab zone; upstream forwarding excluded) | 99% |
external-dns-freshness | Share of time ExternalDNS synced within the last 2 minutes | 99% |
external-dns-coverage | Share of time no requested host stays unpublished for over 2 minutes | 99% |
The rules live in the k8s-lab-slos PrometheusRule. Alerts use multi-window burn rates (Google SRE Workbook, “Alerting on SLOs”) and reach Alertmanager:
| Alert | Fires when | Severity |
|---|---|---|
SLOErrorBudgetBurnFast | error rate over 1h and 5m above 14.4× the sustainable rate (~9% of the 7-day budget in an hour) | critical |
SLOErrorBudgetBurnSlow | error rate over 6h and 30m above 6× | warning |
DNSScrapeTargetDown | kube-dns, lab-dns or external-dns not scraped for 5m | warning |
Notes for a low-traffic lab:
- CoreDNS burn alerts need at least 60 queries in the alert window, so one failed lookup out of three does not page. No traffic counts as no errors.
- A stopped CoreDNS reports no metrics, so its SLOs cannot see the outage;
DNSScrapeTargetDowncovers that. ExternalDNS SLOs are time-based and count the time it is down as bad, but not the minutes before its first scrape at install time. - Suspending the host (laptop sleep) pauses the VMs, so a short gap or dip after wake-up is expected.
Recommended dashboards
Import from grafana.com: Dashboards → Import → enter the ID → Load → set the data source to Prometheus.
| ID | Dashboard | Description |
|---|---|---|
15760 | Kubernetes / Views / Global | Cluster overview |
15757 | Kubernetes / Views / Namespaces | Per-namespace metrics |
15759 | Kubernetes / Views / Pods | Pod details |
1860 | Node Exporter Full | Detailed host metrics |
20842 | cert-manager | Certificate expiry, renewal, issuer status |
4701 / 11955 | JVM (Micrometer) / JVM Metrics | Java apps (Micrometer or JMX Exporter) |
10826 / 14061 | Go Processes / Go Runtime | Go apps (client_golang) |
Logging (Loki + Grafana Alloy)
| Component | Description |
|---|---|
| Loki 3.x | Log aggregation and storage (TSDB schema v13) |
| Grafana Alloy | DaemonSet collector (replaces the deprecated Promtail): pod logs and Kubernetes events |
Open Grafana → Explore → data source Loki.
# All logs from a namespace
{namespace="default"}
# Errors, case-insensitive, without health checks
{namespace="default"} |~ "(?i)error" != "health"
# Parse JSON logs
{namespace="default"} | json | level="error"
# Errors per pod over 5 minutes
sum by (pod) (count_over_time({namespace="default"} |= "error" [5m]))
| ID | Dashboard | Description |
|---|---|---|
13639 | Loki Dashboard | General log overview |
12611 | Loki & Alloy | Logs with Alloy stats |
15141 | Loki Logs | Simple log viewer |
Storage by environment
| Environment | Storage for Loki/Tempo | Reason |
|---|---|---|
| Lab/Dev (this project) | NFS dynamic | Simple, zero configuration |
| On-premise production | Ceph (Rook) or Longhorn | Distributed block storage, HA |
| Cloud production | S3 / GCS / Azure Blob | Native object storage support |
| Hybrid production | MinIO (S3-compatible) | Self-hosted S3 API |
API Server Audit Logs
The control plane is bootstrapped with API server audit logging: kubeadm init sets --audit-policy-file and --audit-log-path=-. Writing to stdout puts audit events in the kube-apiserver container’s logs, so Alloy ships them to Loki like every other pod log: no file on disk, no privileged shipper.
Audit policy (/etc/kubernetes/audit/policy.yaml, first match wins):
| What | Level |
|---|---|
get/list/watch, health/version/metrics endpoints | None (dropped) |
secrets, serviceaccounts, RBAC roles/bindings (mutations) | RequestResponse (full body) |
pods/exec, pods/attach, pods/portforward | Request |
| every other create/update/delete/patch | Metadata |
# All audit events
{container="kube-apiserver"} | json | kind = "Event"
# Secret/RBAC mutations only
{container="kube-apiserver"} | json | objectRef_resource =~ "secrets|roles|rolebindings|clusterroles|clusterrolebindings"
# Who exec'd into a pod
{container="kube-apiserver"} | json | objectRef_subresource = "exec"
Check it: kubectl create secret generic audit-test --from-literal=k=v, then look for a RequestResponse event for create secrets.
Reads of secrets are not logged (the
get/list/watch = Nonerule matches first) to bound volume. Reorder the policy if secret reads must be audited.
Tracing (OpenTelemetry + Grafana Tempo)
Enabled with components.tracing: "otel-tempo".
| Component | Description | Ports |
|---|---|---|
| Grafana Tempo | Trace storage and query backend | 3200 (HTTP), 4317 (OTLP gRPC), 4318 (OTLP HTTP) |
| OpenTelemetry Collector | DaemonSet that receives and forwards traces | 4317/4318 (hostPort) |
Layer 1 — Istio mesh tracing (always on)
Envoy sidecars forward HTTP/gRPC spans to the collector for every namespace with istio-injection: enabled:
App Pod → Envoy Sidecar → OTel Collector → Grafana Tempo
(auto-injected) (DaemonSet)
You get inbound/outbound spans with latency, status code, method and URL, a service-to-service graph, and 100% sampling (configurable in the Telemetry resource).
Layer 2 — OTel Operator (code-level, opt-in)
Deploy the OTel Operator and annotate the pod (see examples/otel-operator-instrumentation.yaml):
annotations:
instrumentation.opentelemetry.io/inject-java: "true"
instrumentation.opentelemetry.io/inject-nodejs: "true"
instrumentation.opentelemetry.io/inject-python: "true"
instrumentation.opentelemetry.io/inject-go: "true"
Manual SDK
OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector.monitoring.svc:4317 # gRPC, in-cluster
OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector.monitoring.svc:4318 # HTTP, in-cluster
OTEL_EXPORTER_OTLP_ENDPOINT=http://<node-ip>:4317 # from a node (hostPort)
View traces in Grafana → Explore → Tempo: search by TraceID or service name, or open the Service Graph.
Trace → log correlation checklist
| Requirement | Why |
|---|---|
Pod label app: my-app | Alloy adds it as a Loki stream label |
Log lines contain traceID=<hex> | Loki’s derived field (traceID=(\w+)) links the log to the trace |
OTel resource service.name=my-app (same as the app label) | Tempo queries {app="my-app"} in Loki |
Namespace has istio-injection: enabled | Sidecars produce the mesh spans |
OTLP endpoint otel-collector.monitoring.svc:4317 | The collector forwards to Tempo |
// Go: log the active trace ID
traceID := span.SpanContext().TraceID().String()
log.Printf("traceID=%s level=info msg=\"handled request\"", traceID)
# Python
trace_id = trace.get_current_span().get_span_context().trace_id
logging.info(f"traceID={trace_id:032x} level=info msg=handled_request")
// Java (SLF4J + OTel SDK)
String traceId = Span.current().getSpanContext().getTraceId();
logger.info("traceID={} level=info msg=handled_request", traceId);
See examples/otel-demo-app/ for a complete working Go app.
kubectl get pods -n monitoring -l app=tempo
kubectl get pods -n monitoring -l app=otel-collector
Kiali (Service Mesh)
Kiali visualizes the mesh topology in real time, shows traffic health between services and validates Istio configuration. It is installed with the monitoring stack and opens at https://kiali.lab.internal/kiali (anonymous mode, no login).
| View | Description |
|---|---|
| Service Graph | Live topology with RPS, error rate and latency on each edge |
| Traffic Metrics | RED metrics per workload |
| Config Validation | Misconfigured VirtualServices, DestinationRules, Gateways |
| Workload Details | Pod health, logs (Loki), traces (Tempo) |
It links to Prometheus (metrics), Loki (“Show Logs”), Tempo (“Show Traces”) and Grafana (“View in Grafana”).
Istio dashboards for Grafana
Import the official dashboards (pre-configured for Prometheus):
ISTIO_VERSION=release-1.31
BASE_URL=https://raw.githubusercontent.com/istio/istio/${ISTIO_VERSION}/manifests/addons/dashboards
for d in istio-mesh-dashboard istio-service-dashboard istio-workload-dashboard \
istio-performance-dashboard istio-extension-dashboard; do
curl -sSL "${BASE_URL}/${d}.json" -o "/tmp/${d}.json"
done
# Grafana → Dashboards → Import → Upload JSON file
Or from grafana.com: 7639 (Mesh), 7636 (Service), 7630 (Workload), 7645 (Control Plane), 15983 (OpenTelemetry Collector: set $otelcol_datasource to Prometheus).