Observability

Metrics, logs and traces, the k8s-lab dashboard, DNS SLOs and service mesh visibility

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

LayerSignalToolQuestion it answers
TopTracesGrafana Tempo + OpenTelemetryWhy is it slow? Where did it fail?
MiddleLogsLoki + Grafana AlloyWhat happened and when?
BaseMetricsPrometheus + GrafanaIs 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.

PillarTool(s)Enabled by
MetricsPrometheus, Alertmanager, Grafana, node-exporter, kube-state-metrics, blackbox_exportermonitoring: prometheus-stack (default)
LogsLoki 3.x + Grafana Alloylogging: loki
TracesGrafana Tempo + OpenTelemetry Collectortracing: otel-tempo
Mesh visibilityKialiinstalled with monitoring

Cross-signal correlation

FromToHow
Log line with traceID=Trace in TempoClick the derived field link
Trace spanLogs for that service“Logs for this span” in Tempo
Trace spanRED metrics in Prometheusservice.name tag link
Service Map (Tempo)Prometheus rate/error/durationClick a node in the graph

Monitoring

ComponentDescription
Prometheus OperatorManages Prometheus and Alertmanager
PrometheusMetrics collection and storage
AlertmanagerAlert routing and notifications
GrafanaDashboards (k8s-lab preinstalled), SSO through Keycloak
node-exporterHost metrics (CPU, memory, disk)
kube-state-metricsKubernetes object metrics
kubelet / cAdvisorPer-container CPU, memory, throttling, PSI and OOM metrics
blackbox_exporterTLS certificate expiry of the API server, kubelets, Vault and every lab host
DNS targetsCoreDNS in the cluster, ExternalDNS, and CoreDNS on the storage node

Access

URLLogin
https://grafana.lab.internal“Sign in with Keycloak”, or admin + Vault secret/k8s-provisioner/grafana/admin
https://prometheus.lab.internalnone
https://alertmanager.lab.internalnone
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.

RowMetrics fromNotes
Resourceskube-state-metrics + kubelet cAdvisor, through the k8s-lab-resources recording rules (k8s_lab:* series)PSI panels need kernel PSI (on in Debian 13)
SLOsk8s-lab-slos recording rulesSee DNS SLOs
DNS — clusterCoreDNS :9153 in kube-system (job kube-dns)The zone lab.internal. shows pod lookups forwarded to the storage node
DNS — labExternalDNS :7979 (job external-dns), CoreDNS on storage :9153 (job lab-dns)Unpublished hosts > 0 means a Gateway host is not resolvable yet
Certificatescert-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):

SLOSLI (good events / time)Objective
coredns-cluster-availabilityCluster DNS answers without SERVFAIL/REFUSED99.9%
coredns-cluster-latencyCluster DNS answers within 128 ms99%
coredns-lab-availabilityLab DNS (storage node, lab zone) answers without SERVFAIL/REFUSED99.9%
coredns-lab-latencyLab DNS answers within 128 ms (lab zone; upstream forwarding excluded)99%
external-dns-freshnessShare of time ExternalDNS synced within the last 2 minutes99%
external-dns-coverageShare of time no requested host stays unpublished for over 2 minutes99%

The rules live in the k8s-lab-slos PrometheusRule. Alerts use multi-window burn rates (Google SRE Workbook, “Alerting on SLOs”) and reach Alertmanager:

AlertFires whenSeverity
SLOErrorBudgetBurnFasterror rate over 1h and 5m above 14.4× the sustainable rate (~9% of the 7-day budget in an hour)critical
SLOErrorBudgetBurnSlowerror rate over 6h and 30m above 6×warning
DNSScrapeTargetDownkube-dns, lab-dns or external-dns not scraped for 5mwarning

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; DNSScrapeTargetDown covers 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.

Import from grafana.com: Dashboards → Import → enter the ID → Load → set the data source to Prometheus.

IDDashboardDescription
15760Kubernetes / Views / GlobalCluster overview
15757Kubernetes / Views / NamespacesPer-namespace metrics
15759Kubernetes / Views / PodsPod details
1860Node Exporter FullDetailed host metrics
20842cert-managerCertificate expiry, renewal, issuer status
4701 / 11955JVM (Micrometer) / JVM MetricsJava apps (Micrometer or JMX Exporter)
10826 / 14061Go Processes / Go RuntimeGo apps (client_golang)

Logging (Loki + Grafana Alloy)

ComponentDescription
Loki 3.xLog aggregation and storage (TSDB schema v13)
Grafana AlloyDaemonSet 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]))
IDDashboardDescription
13639Loki DashboardGeneral log overview
12611Loki & AlloyLogs with Alloy stats
15141Loki LogsSimple log viewer

Storage by environment

EnvironmentStorage for Loki/TempoReason
Lab/Dev (this project)NFS dynamicSimple, zero configuration
On-premise productionCeph (Rook) or LonghornDistributed block storage, HA
Cloud productionS3 / GCS / Azure BlobNative object storage support
Hybrid productionMinIO (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):

WhatLevel
get/list/watch, health/version/metrics endpointsNone (dropped)
secrets, serviceaccounts, RBAC roles/bindings (mutations)RequestResponse (full body)
pods/exec, pods/attach, pods/portforwardRequest
every other create/update/delete/patchMetadata
# 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 = None rule matches first) to bound volume. Reorder the policy if secret reads must be audited.


Tracing (OpenTelemetry + Grafana Tempo)

Enabled with components.tracing: "otel-tempo".

ComponentDescriptionPorts
Grafana TempoTrace storage and query backend3200 (HTTP), 4317 (OTLP gRPC), 4318 (OTLP HTTP)
OpenTelemetry CollectorDaemonSet that receives and forwards traces4317/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

RequirementWhy
Pod label app: my-appAlloy 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: enabledSidecars produce the mesh spans
OTLP endpoint otel-collector.monitoring.svc:4317The 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).

ViewDescription
Service GraphLive topology with RPS, error rate and latency on each edge
Traffic MetricsRED metrics per workload
Config ValidationMisconfigured VirtualServices, DestinationRules, Gateways
Workload DetailsPod 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).