From 4c01fc9e0966bb8a462ff5054229a4f1fb3330ce Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Mon, 30 Mar 2026 22:56:03 +0300 Subject: Update content for html --- gemfeed/atom.xml | 2909 ++++++++++++++++++++++++------------------------------ 1 file changed, 1266 insertions(+), 1643 deletions(-) (limited to 'gemfeed/atom.xml') diff --git a/gemfeed/atom.xml b/gemfeed/atom.xml index 5dfae014..f84979a5 100644 --- a/gemfeed/atom.xml +++ b/gemfeed/atom.xml @@ -1,6 +1,6 @@ - 2026-03-30T22:46:37+03:00 + 2026-03-30T22:55:17+03:00 foo.zone feed To be in the .zone! @@ -32,6 +32,7 @@ 2025-07-14 f3s: Kubernetes with FreeBSD - Part 6: Storage
2025-10-02 f3s: Kubernetes with FreeBSD - Part 7: k3s and first pod deployments
2025-12-07 f3s: Kubernetes with FreeBSD - Part 8: Observability
+2025-12-14 f3s: Kubernetes with FreeBSD - Part 8b: Distributed Tracing with Tempo
2026-04-02 f3s: Kubernetes with FreeBSD - Part 9: GitOps with ArgoCD (You are currently reading this)

f3s logo
@@ -646,6 +647,7 @@ webdav https://kubernetes.default.svc services default Other *BSD-related posts:

2026-04-02 f3s: Kubernetes with FreeBSD - Part 9: GitOps with ArgoCD (You are currently reading this)
+2025-12-14 f3s: Kubernetes with FreeBSD - Part 8b: Distributed Tracing with Tempo
2025-12-07 f3s: Kubernetes with FreeBSD - Part 8: Observability
2025-10-02 f3s: Kubernetes with FreeBSD - Part 7: k3s and first pod deployments
2025-07-14 f3s: Kubernetes with FreeBSD - Part 6: Storage
@@ -5174,1026 +5176,1066 @@ $ curl -s -G "http://localhost:3200/api/search" \ - f3s: Kubernetes with FreeBSD - Part 8: Observability - - https://foo.zone/gemfeed/2025-12-07-f3s-kubernetes-with-freebsd-part-8.html - 2025-12-06T23:58:24+02:00, last updated Mon 09 Mar 09:33:08 EET 2026 + f3s: Kubernetes with FreeBSD - Part 8b: Distributed Tracing with Tempo + + https://foo.zone/gemfeed/2025-12-14-f3s-kubernetes-with-freebsd-part-8b.html + 2025-12-14T20:00:00+02:00 Paul Buetow aka snonux paul@dev.buetow.org - This is the 8th blog post about the f3s series for my self-hosting demands in a home lab. f3s? The 'f' stands for FreeBSD, and the '3s' stands for k3s, the Kubernetes distribution I use on FreeBSD-based physical machines. + This is a follow-up to Part 8 of the f3s series, where I covered Prometheus, Grafana, Loki, and Alloy. Now it's time for the last pillar of observability: distributed tracing with Grafana Tempo.
-

f3s: Kubernetes with FreeBSD - Part 8: Observability


+

f3s: Kubernetes with FreeBSD - Part 8b: Distributed Tracing with Tempo



-Published at 2025-12-06T23:58:24+02:00, last updated Mon 09 Mar 09:33:08 EET 2026
+Published at 2025-12-14T20:00:00+02:00

-This is the 8th blog post about the f3s series for my self-hosting demands in a home lab. f3s? The "f" stands for FreeBSD, and the "3s" stands for k3s, the Kubernetes distribution I use on FreeBSD-based physical machines.
+This is a follow-up to Part 8 of the f3s series, where I covered Prometheus, Grafana, Loki, and Alloy. Now it's time for the last pillar of observability: distributed tracing with Grafana Tempo.

-2024-11-17 f3s: Kubernetes with FreeBSD - Part 1: Setting the stage
-2024-12-03 f3s: Kubernetes with FreeBSD - Part 2: Hardware and base installation
-2025-02-01 f3s: Kubernetes with FreeBSD - Part 3: Protecting from power cuts
-2025-04-05 f3s: Kubernetes with FreeBSD - Part 4: Rocky Linux Bhyve VMs
-2025-05-11 f3s: Kubernetes with FreeBSD - Part 5: WireGuard mesh network
-2025-07-14 f3s: Kubernetes with FreeBSD - Part 6: Storage
-2025-10-02 f3s: Kubernetes with FreeBSD - Part 7: k3s and first pod deployments
-2025-12-07 f3s: Kubernetes with FreeBSD - Part 8: Observability (You are currently reading this)
-2026-04-02 f3s: Kubernetes with FreeBSD - Part 9: GitOps with ArgoCD
+Part 8: Observability (Prometheus, Grafana, Loki, Alloy)

-f3s logo
+For a preview of what distributed tracing with Tempo looks like in Grafana, check out the X-RAG blog post:
+
+X-RAG Observability Hackathon

Table of Contents




-

Introduction


+

Why Distributed Tracing?



-In this blog post, I set up a complete observability stack for the k3s cluster. Observability is crucial for understanding what's happening inside the cluster—whether its tracking resource usage, debugging issues, or analysing application behaviour. The stack consists of five main components, all deployed into the monitoring namespace:
+In a microservices setup, a single user request can hop through multiple services. Tracing gives you:

    -
  • Prometheus: time-series database for metrics collection and alerting
  • -
  • Grafana: visualisation and dashboarding frontend
  • -
  • Loki: log aggregation system (like Prometheus, but for logs)
  • -
  • Alloy: telemetry collector that ships logs and traces from all pods to Loki and Tempo
  • -
  • Tempo: distributed tracing backend for request flow analysis across microservices
  • +
  • Request tracking across service boundaries
  • +
  • Performance bottleneck identification
  • +
  • Service dependency visualization
  • +
  • Correlation with logs and metrics

-Together, these form the "PLG" stack (Prometheus, Loki, Grafana) extended with Tempo for distributed tracing, which is a popular open-source alternative to commercial observability platforms.
-
-All manifests for the f3s stack live in my configuration repository:
-
-codeberg.org/snonux/conf/f3s
-
-

Important Note: GitOps Migration


+Without it, you're basically guessing where time gets spent.

-**Note:** After publishing this blog post, the f3s cluster was migrated from imperative Helm deployments to declarative GitOps using ArgoCD. The Kubernetes manifests, Helm charts, and Justfiles in the repository have been reorganized for ArgoCD-based continuous deployment.
+

Deploying Grafana Tempo



-**To view the exact configuration as it existed when this blog post was written** (before the ArgoCD migration), check out the pre-ArgoCD revision:
+Tempo runs in monolithic mode — all components in one process, same pattern as Loki's SingleBinary deployment. Keeps things simple for a home lab.

- -
$ git clone https://codeberg.org/snonux/conf.git
-$ cd conf
-$ git checkout 15a86f3  # Last commit before ArgoCD migration
-$ cd f3s/prometheus/
-
+The setup:

-**Current master branch** contains the ArgoCD-managed versions with:
    -
  • Application manifests organized under argocd-apps/{monitoring,services,infra,test}/
  • -
  • Resources organized under prometheus/manifests/, loki/, etc.
  • -
  • Justfiles updated to trigger ArgoCD syncs instead of direct Helm commands
  • +
  • Filesystem backend using hostPath (10Gi at /data/nfs/k3svolumes/tempo/data)
  • +
  • 7-day retention (168h)
  • +
  • OTLP receivers on gRPC (4317) and HTTP (4318)
  • +
  • Bind to 0.0.0.0 to avoid Tempo 2.7+ localhost-only binding issue

-The deployment concepts and architecture remain the same—only the deployment method changed from imperative (helm install/upgrade) to declarative (GitOps with ArgoCD).
-
-

Persistent storage recap


-
-All observability components need persistent storage so that metrics and logs survive pod restarts. As covered in Part 6 of this series, the cluster uses NFS-backed persistent volumes:
+

Tempo Helm Values



-f3s: Kubernetes with FreeBSD - Part 6: Storage
+
+tempo:
+  retention: 168h
+  storage:
+    trace:
+      backend: local
+      local:
+        path: /var/tempo/traces
+      wal:
+        path: /var/tempo/wal
+  receivers:
+    otlp:
+      protocols:
+        grpc:
+          endpoint: 0.0.0.0:4317
+        http:
+          endpoint: 0.0.0.0:4318
+
+persistence:
+  enabled: true
+  size: 10Gi
+  storageClassName: ""
+
+resources:
+  limits:
+    cpu: 1000m
+    memory: 2Gi
+  requests:
+    cpu: 500m
+    memory: 1Gi
+

-The FreeBSD hosts (f0, f1) serve as master-standby NFS servers, exporting ZFS datasets that are replicated across hosts using zrepl. The Rocky Linux k3s nodes (r0, r1, r2) mount these exports at /data/nfs/k3svolumes. This directory contains subdirectories for each application that needs persistent storage—including Prometheus, Grafana, and Loki.
+

Persistent Volumes



-For example, the observability stack uses these paths on the NFS share:
+
+apiVersion: v1
+kind: PersistentVolume
+metadata:
+  name: tempo-data-pv
+spec:
+  capacity:
+    storage: 10Gi
+  accessModes:
+    - ReadWriteOnce
+  persistentVolumeReclaimPolicy: Retain
+  hostPath:
+    path: /data/nfs/k3svolumes/tempo/data
+---
+apiVersion: v1
+kind: PersistentVolumeClaim
+metadata:
+  name: tempo-data-pvc
+  namespace: monitoring
+spec:
+  storageClassName: ""
+  accessModes:
+    - ReadWriteOnce
+  resources:
+    requests:
+      storage: 10Gi
+

-
    -
  • /data/nfs/k3svolumes/prometheus/data — Prometheus time-series database
  • -
  • /data/nfs/k3svolumes/grafana/data — Grafana configuration, dashboards, and plugins
  • -
  • /data/nfs/k3svolumes/loki/data — Loki log chunks and index
  • -
  • /data/nfs/k3svolumes/tempo/data — Tempo trace data and WAL
  • -

-Each path gets a corresponding PersistentVolume and PersistentVolumeClaim in Kubernetes, allowing pods to mount them as regular volumes. Because the underlying storage is ZFS with replication, we get snapshots and redundancy for free.
+

Grafana Datasource Provisioning



-

The monitoring namespace


+All Grafana datasources (Prometheus, Alertmanager, Loki, Tempo) are provisioned via a single ConfigMap mounted directly to the Grafana pod. No sidecar discovery needed.

-First, I created the monitoring namespace where all observability components will live:
+In grafana-datasources-all.yaml:

- -
$ kubectl create namespace monitoring
-namespace/monitoring created
+
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: grafana-datasources-all
+  namespace: monitoring
+data:
+  datasources.yaml: |
+    apiVersion: 1
+    datasources:
+      - name: Prometheus
+        type: prometheus
+        uid: prometheus
+        url: http://prometheus-kube-prometheus-prometheus.monitoring:9090/
+        access: proxy
+        isDefault: true
+      - name: Alertmanager
+        type: alertmanager
+        uid: alertmanager
+        url: http://prometheus-kube-prometheus-alertmanager.monitoring:9093/
+      - name: Loki
+        type: loki
+        uid: loki
+        url: http://loki.monitoring.svc.cluster.local:3100
+      - name: Tempo
+        type: tempo
+        uid: tempo
+        url: http://tempo.monitoring.svc.cluster.local:3200
+        jsonData:
+          tracesToLogsV2:
+            datasourceUid: loki
+            spanStartTimeShift: -1h
+            spanEndTimeShift: 1h
+          tracesToMetrics:
+            datasourceUid: prometheus
+          serviceMap:
+            datasourceUid: prometheus
+          nodeGraph:
+            enabled: true
 

-

Installing Prometheus and Grafana


-
-Prometheus and Grafana are deployed together using the kube-prometheus-stack Helm chart from the Prometheus community. This chart bundles Prometheus, Grafana, Alertmanager, and various exporters (Node Exporter, Kube State Metrics) into a single deployment. Ill explain what each component does in detail later when we look at the running pods.
+The Tempo datasource config links traces to Loki logs and Prometheus metrics — so you can jump between signals directly in Grafana.

-

Prerequisites


+The kube-prometheus-stack Helm values disable sidecar-based discovery and mount this ConfigMap directly to /etc/grafana/provisioning/datasources/.

-Add the Prometheus Helm chart repository:
+

Installation



- -
$ helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
-$ helm repo update
+
+cd /home/paul/git/conf/f3s/tempo
+just install
 

-Create the directories on the NFS server for persistent storage:
+Verify it's running:

- -
[root@r0 ~]# mkdir -p /data/nfs/k3svolumes/prometheus/data
-[root@r0 ~]# mkdir -p /data/nfs/k3svolumes/grafana/data
+
+kubectl get pods -n monitoring -l app.kubernetes.io/name=tempo
+kubectl exec -n monitoring <tempo-pod> -- wget -qO- http://localhost:3200/ready
 

-

Deploying with the Justfile


-
-The configuration repository contains a Justfile that automates the deployment. just is a handy command runner—think of it as a simpler, more modern alternative to make. I use it throughout the f3s repository to wrap repetitive Helm and kubectl commands:
+

Configuring Alloy for Trace Collection



-just - A handy way to save and run project-specific commands
-codeberg.org/snonux/conf/f3s/prometheus
+I updated the Alloy values to add OTLP receivers for traces alongside the existing log collection.

-To install everything:
+Added to the Alloy config:

- -
$ cd conf/f3s/prometheus
-$ just install
-kubectl apply -f persistent-volumes.yaml
-persistentvolume/prometheus-data-pv created
-persistentvolume/grafana-data-pv created
-persistentvolumeclaim/grafana-data-pvc created
-helm install prometheus prometheus-community/kube-prometheus-stack \
-    --namespace monitoring -f persistence-values.yaml
-NAME: prometheus
-LAST DEPLOYED: ...
-NAMESPACE: monitoring
-STATUS: deployed
+
+// OTLP receiver for traces via gRPC and HTTP
+otelcol.receiver.otlp "default" {
+  grpc {
+    endpoint = "0.0.0.0:4317"
+  }
+  http {
+    endpoint = "0.0.0.0:4318"
+  }
+  output {
+    traces = [otelcol.processor.batch.default.input]
+  }
+}
+
+// Batch processor — accumulates spans before forwarding to Tempo
+otelcol.processor.batch "default" {
+  timeout = "5s"
+  send_batch_size = 100
+  send_batch_max_size = 200
+  output {
+    traces = [otelcol.exporter.otlp.tempo.input]
+  }
+}
+
+// OTLP exporter to Tempo
+otelcol.exporter.otlp "tempo" {
+  client {
+    endpoint = "tempo.monitoring.svc.cluster.local:4317"
+    tls {
+      insecure = true
+    }
+    compression = "gzip"
+  }
+}
 

-The persistence-values.yaml configures Prometheus and Grafana to use the NFS-backed persistent volumes I mentioned earlier, ensuring data survives pod restarts. It also enables scraping of etcd and kube-controller-manager metrics:
+Upgrade Alloy:

-kubeEtcd:
-  enabled: true
-  endpoints:
-    - 192.168.2.120
-    - 192.168.2.121
-    - 192.168.2.122
-  service:
-    enabled: true
-    port: 2381
-    targetPort: 2381
-
-kubeControllerManager:
-  enabled: true
-  endpoints:
-    - 192.168.2.120
-    - 192.168.2.121
-    - 192.168.2.122
-  service:
-    enabled: true
-    port: 10257
-    targetPort: 10257
-  serviceMonitor:
-    enabled: true
-    https: true
-    insecureSkipVerify: true
+cd /home/paul/git/conf/f3s/loki
+just upgrade
 

-By default, k3s binds the controller-manager to localhost only and doesn't expose etcd metrics, so the "Kubernetes / Controller Manager" and "etcd" dashboards in Grafana will show no data. To fix both, add the following to /etc/rancher/k3s/config.yaml on each k3s server node:
+

Demo Tracing Application



- -
[root@r0 ~]# cat >> /etc/rancher/k3s/config.yaml << 'EOF'
-kube-controller-manager-arg:
-  - bind-address=0.0.0.0
-etcd-expose-metrics: true
-EOF
-[root@r0 ~]# systemctl restart k3s
+To actually see traces, I built a three-tier Python app. Nothing fancy — just enough to generate real distributed traces.
+
+

Architecture


+
+
+User -> Frontend (Flask:5000) -> Middleware (Flask:5001) -> Backend (Flask:5002)
+           |                          |                        |
+                    Alloy (OTLP:4317) -> Tempo -> Grafana
 

-Repeat for r1 and r2. After restarting all nodes, the controller-manager metrics endpoint will be accessible and etcd metrics are available on port 2381. Prometheus can now scrape both.
+
    +
  • Frontend: receives requests at /api/process, forwards to middleware
  • +
  • Middleware: transforms data at /api/transform, calls backend
  • +
  • Backend: returns data at /api/data, simulates a 100ms database query
  • +

+

OpenTelemetry Instrumentation



-Verify etcd metrics are exposed:
+All three services use Python OpenTelemetry libraries:
+
+Dependencies:
+
+
+flask==3.0.0
+requests==2.31.0
+opentelemetry-distro==0.49b0
+opentelemetry-exporter-otlp==1.28.0
+opentelemetry-instrumentation-flask==0.49b0
+opentelemetry-instrumentation-requests==0.49b0
+
+
+Auto-instrumentation pattern (same across all services, just change the service name):

-
[root@r0 ~]# curl -s http://127.0.0.1:2381/metrics | grep etcd_server_has_leader
-etcd_server_has_leader 1
+
from opentelemetry import trace
+from opentelemetry.sdk.trace import TracerProvider
+from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
+from opentelemetry.instrumentation.flask import FlaskInstrumentor
+from opentelemetry.instrumentation.requests import RequestsInstrumentor
+from opentelemetry.sdk.resources import Resource
+
+resource = Resource(attributes={
+    "service.name": "frontend",
+    "service.namespace": "tracing-demo",
+    "service.version": "1.0.0"
+})
+
+provider = TracerProvider(resource=resource)
+
+otlp_exporter = OTLPSpanExporter(
+    endpoint="http://alloy.monitoring.svc.cluster.local:4317",
+    insecure=True
+)
+
+processor = BatchSpanProcessor(otlp_exporter)
+provider.add_span_processor(processor)
+trace.set_tracer_provider(provider)
+
+FlaskInstrumentor().instrument_app(app)
+RequestsInstrumentor().instrument()
 

-The full persistence-values.yaml and all other Prometheus configuration files are available on Codeberg:
-
-codeberg.org/snonux/conf/f3s/prometheus
-
-The persistent volume definitions bind to specific paths on the NFS share using hostPath volumes—the same pattern used for other services in Part 7:
+The auto-instrumentation creates spans for HTTP requests, propagates trace context via W3C headers, and links parent/child spans across services automatically.

-f3s: Kubernetes with FreeBSD - Part 7: k3s and first pod deployments
+

Deployment



-

Exposing Grafana via ingress


+The demo app has a Helm chart in the conf repo. Build, import the container images, and install:

-The chart also deploys an ingress for Grafana, making it accessible at grafana.f3s.foo.zone. The ingress configuration follows the same pattern as other services in the cluster—Traefik handles the routing internally, while the OpenBSD edge relays terminate TLS and forward traffic through WireGuard.
+
+cd /home/paul/git/conf/f3s/tracing-demo
+just build
+just import
+just install
+

-Once deployed, Grafana is accessible and comes pre-configured with Prometheus as a data source. You can verify the Prometheus service is running:
+Verify:

- -
$ kubectl get svc -n monitoring prometheus-kube-prometheus-prometheus
-NAME                                    TYPE        CLUSTER-IP      PORT(S)
-prometheus-kube-prometheus-prometheus   ClusterIP   10.43.152.163   9090/TCP,8080/TCP
+
+kubectl get pods -n services | grep tracing-demo
+kubectl get ingress -n services tracing-demo-ingress
 

-Grafana connects to Prometheus using the internal service URL http://prometheus-kube-prometheus-prometheus.monitoring.svc.cluster.local:9090. The default Grafana credentials are admin/prom-operator, which should be changed immediately after first login.
+Access at:

-Grafana dashboard showing Prometheus metrics
+http://tracing-demo.f3s.foo.zone

-Grafana dashboard showing cluster metrics
+

Visualizing Traces in Grafana



-Grafana etcd dashboard showing cluster health, RPC rate, disk sync duration, and peer round trip times
+

Searching for Traces



-

Installing Loki and Alloy


+In Grafana, go to Explore, select the Tempo datasource, and you can search by trace ID, service name, or tags.

-While Prometheus handles metrics, Loki handles logs. It's designed to be cost-effective and easy to operate—it doesn't index the contents of logs, only the metadata (labels), making it very efficient for storage.
+Some useful TraceQL queries:

-Alloy is Grafana's telemetry collector (the successor to Promtail). It runs as a DaemonSet on each node, tails container logs, and ships them to Loki.
+Find all traces from the demo app:
+
+{ resource.service.namespace = "tracing-demo" }
+

-

Prerequisites


+Find slow requests (>200ms):
+
+{ duration > 200ms }
+

-Create the data directory on the NFS server:
+Find traces from a specific service:
+
+{ resource.service.name = "frontend" }
+

- -
[root@r0 ~]# mkdir -p /data/nfs/k3svolumes/loki/data
+Find errors:
+
+{ status = error }
 

-

Deploying Loki and Alloy


+Frontend traces with server errors:
+
+{ resource.service.namespace = "tracing-demo" } && { span.http.status_code >= 500 }
+

-The Loki configuration also lives in the repository:
+

Service Graph



-codeberg.org/snonux/conf/f3s/loki
+The service graph view shows visual connections between services — Frontend to Middleware to Backend — with request rates and latencies. It's generated automatically from trace data using Prometheus metrics.

-To install:
+

Practical Example: End-to-End Trace


+
+Here's what it looks like to generate and examine a trace.
+
+Generate a trace:
+
+
+curl -H "Host: tracing-demo.f3s.foo.zone" http://r0/api/process
+
+
+Response (HTTP 200):

-
$ cd conf/f3s/loki
-$ just install
-helm repo add grafana https://grafana.github.io/helm-charts || true
-helm repo update
-kubectl apply -f persistent-volumes.yaml
-persistentvolume/loki-data-pv created
-persistentvolumeclaim/loki-data-pvc created
-helm install loki grafana/loki --namespace monitoring -f values.yaml
-NAME: loki
-LAST DEPLOYED: ...
-NAMESPACE: monitoring
-STATUS: deployed
-...
-helm install alloy grafana/alloy --namespace monitoring -f alloy-values.yaml
-NAME: alloy
-LAST DEPLOYED: ...
-NAMESPACE: monitoring
-STATUS: deployed
+
{
+  "middleware_response": {
+    "backend_data": {
+      "data": {
+        "id": 12345,
+        "query_time_ms": 100.0,
+        "timestamp": "2025-12-28T18:35:01.064538",
+        "value": "Sample data from backend service"
+      },
+      "service": "backend"
+    },
+    "middleware_processed": true,
+    "original_data": {
+      "source": "GET request"
+    },
+    "transformation_time_ms": 50
+  },
+  "request_data": {
+    "source": "GET request"
+  },
+  "service": "frontend",
+  "status": "success"
+}
 

-Loki runs in single-binary mode with a single replica (loki-0), which is appropriate for a home lab cluster. This means there's only one Loki pod running at any time. If the node hosting Loki fails, Kubernetes will automatically reschedule the pod to another worker node—but there will be a brief downtime (typically under a minute) while this happens. For my home lab use case, this is perfectly acceptable.
-
-For full high-availability, you'd deploy Loki in microservices mode with separate read, write, and backend components, backed by object storage like S3 or MinIO instead of local filesystem storage. That's a more complex setup that I might explore in a future blog post—but for now, the single-binary mode with NFS-backed persistence strikes the right balance between simplicity and durability.
+After a few seconds (batch export delay), search for traces via Tempo API:

-

Configuring Alloy


+
+kubectl exec -n monitoring tempo-0 -- wget -qO- \
+  'http://localhost:3200/api/search?tags=service.namespace%3Dtracing-demo&limit=5' 2>/dev/null | \
+  python3 -m json.tool
+

-Alloy is configured via alloy-values.yaml to discover all pods in the cluster and forward their logs to Loki:
+Returns something like:

-
discovery.kubernetes "pods" {
-  role = "pod"
+
{
+  "traceID": "4be1151c0bdcd5625ac7e02b98d95bd5",
+  "rootServiceName": "frontend",
+  "rootTraceName": "GET /api/process",
+  "durationMs": 221
 }
+
+
+The full trace has 8 spans across 3 services:
+
+
+Trace ID: 4be1151c0bdcd5625ac7e02b98d95bd5
 
-discovery.relabel "pods" {
-  targets = discovery.kubernetes.pods.targets
+Service: frontend
+  GET /api/process                 221.10ms  (HTTP server span)
+  frontend-process                 216.23ms  (business logic)
+  POST                             209.97ms  (HTTP client -> middleware)
 
-  rule {
-    source_labels = ["__meta_kubernetes_namespace"]
-    target_label  = "namespace"
-  }
+Service: middleware
+  POST /api/transform              186.02ms  (HTTP server span)
+  middleware-transform             180.96ms  (business logic)
+  GET                              127.52ms  (HTTP client -> backend)
 
-  rule {
-    source_labels = ["__meta_kubernetes_pod_name"]
-    target_label  = "pod"
-  }
-
-  rule {
-    source_labels = ["__meta_kubernetes_pod_container_name"]
-    target_label  = "container"
-  }
-
-  rule {
-    source_labels = ["__meta_kubernetes_pod_label_app"]
-    target_label  = "app"
-  }
-}
-
-loki.source.kubernetes "pods" {
-  targets    = discovery.relabel.pods.output
-  forward_to = [loki.write.default.receiver]
-}
-
-loki.write "default" {
-  endpoint {
-    url = "http://loki.monitoring.svc.cluster.local:3100/loki/api/v1/push"
-  }
-}
+Service: backend
+  GET /api/data                    103.93ms  (HTTP server span)
+  backend-get-data                 102.11ms  (business logic, 100ms sleep)
 

-This configuration automatically labels each log line with the namespace, pod name, container name, and app label, making it easy to filter logs in Grafana.
-
-

Adding Loki as a Grafana data source


-
-Loki doesn't have its own web UI—you query it through Grafana. First, verify the Loki service is running:
+In Grafana, paste the trace ID in the Tempo search box or use TraceQL:

- -
$ kubectl get svc -n monitoring loki
-NAME   TYPE        CLUSTER-IP    PORT(S)
-loki   ClusterIP   10.43.64.60   3100/TCP,9095/TCP
+
+{ resource.service.namespace = "tracing-demo" }
 

-To add Loki as a data source in Grafana:
-
-
    -
  • Navigate to Configuration → Data Sources
  • -
  • Click "Add data source"
  • -
  • Select "Loki"
  • -
  • Set the URL to: http://loki.monitoring.svc.cluster.local:3100
  • -
  • Click "Save & Test"
  • -

-Once configured, you can explore logs in Grafana's "Explore" view. I'll show some example queries in the "Using the observability stack" section below.
-
-Exploring logs in Grafana with Loki
-
-

The complete monitoring stack


-
-After deploying everything, here's what's running in the monitoring namespace:
+The waterfall view shows the complete request flow with timing:

- -
$ kubectl get pods -n monitoring
-NAME                                                     READY   STATUS    RESTARTS   AGE
-alertmanager-prometheus-kube-prometheus-alertmanager-0   2/2     Running   0          42d
-alloy-g5fgj                                              2/2     Running   0          29m
-alloy-nfw8w                                              2/2     Running   0          29m
-alloy-tg9vj                                              2/2     Running   0          29m
-loki-0                                                   2/2     Running   0          25m
-prometheus-grafana-868f9dc7cf-lg2vl                      3/3     Running   0          42d
-prometheus-kube-prometheus-operator-8d7bbc48c-p4sf4      1/1     Running   0          42d
-prometheus-kube-state-metrics-7c5fb9d798-hh2fx           1/1     Running   0          42d
-prometheus-prometheus-kube-prometheus-prometheus-0       2/2     Running   0          42d
-prometheus-prometheus-node-exporter-2nsg9                1/1     Running   0          42d
-prometheus-prometheus-node-exporter-mqr25                1/1     Running   0          42d
-prometheus-prometheus-node-exporter-wp4ds                1/1     Running   0          42d
-tempo-0                                                  1/1     Running   0          1d
-
+Distributed trace in Grafana Tempo: Frontend -> Middleware -> Backend

-Note: Tempo (tempo-0) is deployed later in this post in the "Distributed Tracing with Grafana Tempo" section. It is included in the pod listing here for completeness.
+More Tempo trace screenshots in the X-RAG blog post:

-And the services:
+X-RAG Observability Hackathon

- -
$ kubectl get svc -n monitoring
-NAME                                      TYPE        CLUSTER-IP      PORT(S)
-alertmanager-operated                     ClusterIP   None            9093/TCP,9094/TCP
-alloy                                     ClusterIP   10.43.74.14     12345/TCP
-loki                                      ClusterIP   10.43.64.60     3100/TCP,9095/TCP
-loki-headless                             ClusterIP   None            3100/TCP
-prometheus-grafana                        ClusterIP   10.43.46.82     80/TCP
-prometheus-kube-prometheus-alertmanager   ClusterIP   10.43.208.43    9093/TCP,8080/TCP
-prometheus-kube-prometheus-operator       ClusterIP   10.43.246.121   443/TCP
-prometheus-kube-prometheus-prometheus     ClusterIP   10.43.152.163   9090/TCP,8080/TCP
-prometheus-kube-state-metrics             ClusterIP   10.43.64.26     8080/TCP
-prometheus-prometheus-node-exporter       ClusterIP   10.43.127.242   9100/TCP
-tempo                                     ClusterIP   10.43.91.44     3200/TCP,4317/TCP,4318/TCP
-
+

Correlation Between Signals



-Let me break down what each pod does:
+This is where the observability stack really comes together. Tempo integrates with Loki and Prometheus so you can jump between traces, logs, and metrics.

-
    -
  • alertmanager-prometheus-kube-prometheus-alertmanager-0: the Alertmanager instance that receives alerts from Prometheus, deduplicates them, groups related alerts together, and routes notifications to the appropriate receivers (email, Slack, PagerDuty, etc.). It runs as a StatefulSet with persistent storage for silences and notification state.
  • -

-
    -
  • alloy-g5fgj, alloy-nfw8w, alloy-tg9vj: three Alloy pods running as a DaemonSet, one on each k3s node. Each pod tails the container logs from its local node via the Kubernetes API and forwards them to Loki. This ensures log collection continues even if a node becomes isolated from the others.
  • -

-
    -
  • loki-0: the single Loki instance running in single-binary mode. It receives log streams from Alloy, stores them in chunks on the NFS-backed persistent volume, and serves queries from Grafana. The -0 suffix indicates it's a StatefulSet pod.
  • -

-
    -
  • prometheus-grafana-...: the Grafana web interface for visualising metrics and logs. It comes pre-configured with Prometheus as a data source and includes dozens of dashboards for Kubernetes monitoring. Dashboards, users, and settings are persisted to the NFS share.
  • -

-
    -
  • prometheus-kube-prometheus-operator-...: the Prometheus Operator that watches for custom resources (ServiceMonitor, PodMonitor, PrometheusRule) and automatically configures Prometheus to scrape new targets. This allows applications to declare their own monitoring requirements.
  • -

-
    -
  • prometheus-kube-state-metrics-...: generates metrics about the state of Kubernetes objects themselves: how many pods are running, pending, or failed; deployment replica counts; node conditions; PVC status; and more. Essential for cluster-level dashboards.
  • -

-
    -
  • prometheus-prometheus-kube-prometheus-prometheus-0: the Prometheus server that scrapes metrics from all configured targets (pods, services, nodes), stores them in a time-series database, evaluates alerting rules, and serves queries to Grafana.
  • -

-
    -
  • prometheus-prometheus-node-exporter-...: three Node Exporter pods running as a DaemonSet, one on each node. They expose hardware and OS-level metrics: CPU usage, memory, disk I/O, filesystem usage, network statistics, and more. These feed the "Node Exporter" dashboards in Grafana.
  • -

-
    -
  • tempo-0: the Grafana Tempo instance for distributed tracing. It receives trace data from Alloy via OTLP (OpenTelemetry Protocol), stores traces on the NFS-backed persistent volume, and serves queries to Grafana. Tempo is covered in detail in the "Distributed Tracing with Grafana Tempo" section later in this post.
  • -

-

Using the observability stack


+Traces to logs: click on any span and select "Logs for this span." Loki filters by time range, service name, namespace, and pod. Super useful for figuring out what a service was doing during a specific request.

-

Viewing metrics in Grafana


+Traces to metrics: from a trace view, the "Metrics" tab shows Prometheus data like request rate, error rate, and duration percentiles for the services involved.

-The kube-prometheus-stack comes with many pre-built dashboards. Some useful ones include:
+Logs to traces: in Loki, logs containing trace IDs are automatically linked. Click the trace ID and you jump straight to the full trace in Tempo.

-
    -
  • Kubernetes / Compute Resources / Cluster: overview of CPU and memory usage across the cluster
  • -
  • Kubernetes / Compute Resources / Namespace (Pods): resource usage by namespace
  • -
  • Node Exporter / Nodes: detailed host metrics like disk I/O, network, and CPU
  • -

-

Querying logs with LogQL


+

Storage and Retention



-In Grafana's Explore view, select Loki as the data source and try queries like:
+With 10Gi storage and 7-day retention, the system handles moderate trace volumes. Check usage:

-# All logs from the services namespace
-{namespace="services"}
-
-# Logs from pods matching a pattern
-{pod=~"miniflux.*"}
-
-# Filter by log content
-{namespace="services"} |= "error"
-
-# Parse JSON logs and filter
-{namespace="services"} | json | level="error"
+kubectl exec -n monitoring <tempo-pod> -- df -h /var/tempo
 

-

Creating alerts


-
-Prometheus supports alerting rules that can notify you when something goes wrong. The kube-prometheus-stack includes many default alerts for common issues like high CPU usage, pod crashes, and node problems. These can be customised via PrometheusRule CRDs.
-
-

Monitoring external FreeBSD hosts


-
-The observability stack can also monitor servers outside the Kubernetes cluster. The FreeBSD hosts (f0, f1, f2) that serve NFS storage can be added to Prometheus using the Node Exporter.
-
-

Installing Node Exporter on FreeBSD


-
-On each FreeBSD host, install the node_exporter package:
+If storage fills up, you can reduce retention to 72h, add sampling in Alloy, or increase the PV size.

- -
paul@f0:~ % doas pkg install -y node_exporter
-
+

Configuration Files



-Enable the service to start at boot:
+All config files are on Codeberg:

- -
paul@f0:~ % doas sysrc node_exporter_enable=YES
-node_exporter_enable:  -> YES
-
+Tempo configuration
+Alloy configuration (updated for traces)
+Demo tracing application

-Configure node_exporter to listen on the WireGuard interface. This ensures metrics are only accessible through the secure tunnel, not the public network. Replace the IP with the host's WireGuard address:
+Other *BSD-related posts:

- -
paul@f0:~ % doas sysrc node_exporter_args='--web.listen-address=192.168.2.130:9100'
-node_exporter_args:  -> --web.listen-address=192.168.2.130:9100
-
+2026-04-02 f3s: Kubernetes with FreeBSD - Part 9: GitOps with ArgoCD
+2025-12-14 f3s: Kubernetes with FreeBSD - Part 8b: Distributed Tracing with Tempo (You are currently reading this)
+2025-12-07 f3s: Kubernetes with FreeBSD - Part 8: Observability
+2025-10-02 f3s: Kubernetes with FreeBSD - Part 7: k3s and first pod deployments
+2025-07-14 f3s: Kubernetes with FreeBSD - Part 6: Storage
+2025-05-11 f3s: Kubernetes with FreeBSD - Part 5: WireGuard mesh network
+2025-04-05 f3s: Kubernetes with FreeBSD - Part 4: Rocky Linux Bhyve VMs
+2025-02-01 f3s: Kubernetes with FreeBSD - Part 3: Protecting from power cuts
+2024-12-03 f3s: Kubernetes with FreeBSD - Part 2: Hardware and base installation
+2024-11-17 f3s: Kubernetes with FreeBSD - Part 1: Setting the stage
+2024-04-01 KISS high-availability with OpenBSD
+2024-01-13 One reason why I love OpenBSD
+2022-10-30 Installing DTail on OpenBSD
+2022-07-30 Let's Encrypt with OpenBSD and Rex
+2016-04-09 Jails and ZFS with Puppet on FreeBSD

-Start the service:
+E-Mail your comments to paul@nospam.buetow.org

- -
paul@f0:~ % doas service node_exporter start
-Starting node_exporter.
-
+Back to the main site
+
+
+
+ + f3s: Kubernetes with FreeBSD - Part 8: Observability + + https://foo.zone/gemfeed/2025-12-07-f3s-kubernetes-with-freebsd-part-8.html + 2025-12-06T23:58:24+02:00, last updated Mon 09 Mar 09:33:08 EET 2026 +