From c127f940638d5739ead61a891f16814703a0d04d Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Mon, 9 Mar 2026 09:06:48 +0200 Subject: Update content for gemtext --- ...25-12-07-f3s-kubernetes-with-freebsd-part-8.gmi | 401 ++++++--------- ...2-07-f3s-kubernetes-with-freebsd-part-8.gmi.tpl | 389 ++++++-------- gemfeed/atom.xml | 556 ++++++++------------- .../grafana-etcd-dashboard.png | Bin 0 -> 201310 bytes .../grafana-zfs-arc-stats.png | Bin 0 -> 168537 bytes .../grafana-zfs-dashboard.png | Bin 0 -> 210342 bytes .../grafana-zfs-datasets.png | Bin 0 -> 149339 bytes 7 files changed, 514 insertions(+), 832 deletions(-) create mode 100644 gemfeed/f3s-kubernetes-with-freebsd-part-8/grafana-etcd-dashboard.png create mode 100644 gemfeed/f3s-kubernetes-with-freebsd-part-8/grafana-zfs-arc-stats.png create mode 100644 gemfeed/f3s-kubernetes-with-freebsd-part-8/grafana-zfs-dashboard.png create mode 100644 gemfeed/f3s-kubernetes-with-freebsd-part-8/grafana-zfs-datasets.png diff --git a/gemfeed/2025-12-07-f3s-kubernetes-with-freebsd-part-8.gmi b/gemfeed/2025-12-07-f3s-kubernetes-with-freebsd-part-8.gmi index 221f80cd..c0ceefa9 100644 --- a/gemfeed/2025-12-07-f3s-kubernetes-with-freebsd-part-8.gmi +++ b/gemfeed/2025-12-07-f3s-kubernetes-with-freebsd-part-8.gmi @@ -41,14 +41,6 @@ This is the 8th blog post about the f3s series for my self-hosting demands in a * ⇢ ⇢ ⇢ Adding FreeBSD hosts to Prometheus * ⇢ ⇢ ⇢ FreeBSD memory metrics compatibility * ⇢ ⇢ ⇢ Disk I/O metrics limitation -* ⇢ ⇢ Monitoring external OpenBSD hosts -* ⇢ ⇢ ⇢ Installing Node Exporter on OpenBSD -* ⇢ ⇢ ⇢ Adding OpenBSD hosts to Prometheus -* ⇢ ⇢ ⇢ OpenBSD memory metrics compatibility -* ⇢ ⇢ Enabling etcd metrics in k3s -* ⇢ ⇢ ⇢ Configuring Prometheus to scrape etcd -* ⇢ ⇢ ⇢ Verifying etcd metrics -* ⇢ ⇢ ⇢ Complete persistence-values.yaml * ⇢ ⇢ ZFS Monitoring for FreeBSD Servers * ⇢ ⇢ ⇢ Node Exporter ZFS Collector * ⇢ ⇢ ⇢ Verifying ZFS Metrics @@ -58,6 +50,10 @@ This is the 8th blog post about the f3s series for my self-hosting demands in a * ⇢ ⇢ ⇢ Verifying ZFS Metrics in Prometheus * ⇢ ⇢ ⇢ Key Metrics to Monitor * ⇢ ⇢ ⇢ ZFS Pool and Dataset Metrics via Textfile Collector +* ⇢ ⇢ Monitoring external OpenBSD hosts +* ⇢ ⇢ ⇢ Installing Node Exporter on OpenBSD +* ⇢ ⇢ ⇢ Adding OpenBSD hosts to Prometheus +* ⇢ ⇢ ⇢ OpenBSD memory metrics compatibility * ⇢ ⇢ Distributed Tracing with Grafana Tempo * ⇢ ⇢ ⇢ Why Distributed Tracing? * ⇢ ⇢ ⇢ Deploying Grafana Tempo @@ -85,14 +81,15 @@ This is the 8th blog post about the f3s series for my self-hosting demands in a ## Introduction -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 four main components, all deployed into the `monitoring` namespace: +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: * 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 from all pods to Loki +* 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 -Together, these form the "PLG" stack (Prometheus, Loki, Grafana), which is a popular open-source alternative to commercial observability platforms. +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: @@ -131,6 +128,7 @@ For example, the observability stack uses these paths on the NFS share: * `/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. @@ -217,17 +215,29 @@ kubeControllerManager: insecureSkipVerify: true ``` -By default, k3s binds the controller-manager to localhost only, so the "Kubernetes / Controller Manager" dashboard in Grafana will show no data. To expose the metrics endpoint, add the following to `/etc/rancher/k3s/config.yaml` on each k3s server node: +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: ```sh [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 ``` -Repeat for `r1` and `r2`. After restarting all nodes, the controller-manager metrics endpoint will be accessible and Prometheus can scrape it. +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. + +Verify etcd metrics are exposed: + +```sh +[root@r0 ~]# curl -s http://127.0.0.1:2381/metrics | grep etcd_server_has_leader +etcd_server_has_leader 1 +``` + +The full `persistence-values.yaml` and all other Prometheus configuration files are available on Codeberg: + +=> https://codeberg.org/snonux/conf/src/branch/master/f3s/prometheus 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: @@ -251,6 +261,8 @@ Grafana connects to Prometheus using the internal service URL `http://prometheus => ./f3s-kubernetes-with-freebsd-part-8/grafana-dashboard.png Grafana dashboard showing cluster metrics +=> ./f3s-kubernetes-with-freebsd-part-8/grafana-etcd-dashboard.png Grafana etcd dashboard showing cluster health, RPC rate, disk sync duration, and peer round trip times + ## Installing Loki and Alloy 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. @@ -386,8 +398,11 @@ prometheus-prometheus-kube-prometheus-prometheus-0 2/2 Running 0 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 ``` +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. + And the services: ```sh @@ -403,6 +418,7 @@ 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 ``` Let me break down what each pod does: @@ -423,6 +439,8 @@ Let me break down what each pod does: * `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 ### Viewing metrics in Grafana @@ -586,238 +604,7 @@ This file is saved as `freebsd-recording-rules.yaml` and applied as part of the Unlike memory metrics, disk I/O metrics (`node_disk_read_bytes_total`, `node_disk_written_bytes_total`, etc.) are not available on FreeBSD. The Linux diskstats collector that provides these metrics doesn't have a FreeBSD equivalent in the node_exporter. -The disk I/O panels in the Node Exporter dashboards will show "No data" for FreeBSD hosts. FreeBSD does expose ZFS-specific metrics (`node_zfs_arcstats_*`) for ARC cache performance, and per-dataset I/O stats are available via `sysctl kstat.zfs`, but mapping these to the Linux-style metrics the dashboards expect is non-trivial. Custom ZFS-specific dashboards are covered later in this post. - -## Monitoring external OpenBSD hosts - -The same approach works for OpenBSD hosts. I have two OpenBSD edge relay servers (`blowfish`, `fishfinger`) that handle TLS termination and forward traffic through WireGuard to the cluster. These can also be monitored with Node Exporter. - -### Installing Node Exporter on OpenBSD - -On each OpenBSD host, install the node_exporter package: - -```sh -blowfish:~ $ doas pkg_add node_exporter -quirks-7.103 signed on 2025-10-13T22:55:16Z -The following new rcscripts were installed: /etc/rc.d/node_exporter -See rcctl(8) for details. -``` - -Enable the service to start at boot: - -```sh -blowfish:~ $ doas rcctl enable node_exporter -``` - -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: - -```sh -blowfish:~ $ doas rcctl set node_exporter flags '--web.listen-address=192.168.2.110:9100' -``` - -Start the service: - -```sh -blowfish:~ $ doas rcctl start node_exporter -node_exporter(ok) -``` - -Verify it's running: - -```sh -blowfish:~ $ curl -s http://192.168.2.110:9100/metrics | head -3 -# HELP go_gc_duration_seconds A summary of the wall-time pause... -# TYPE go_gc_duration_seconds summary -go_gc_duration_seconds{quantile="0"} 0 -``` - -Repeat for the other OpenBSD host (`fishfinger`) with its respective WireGuard IP (`192.168.2.111`). - -### Adding OpenBSD hosts to Prometheus - -Update `additional-scrape-configs.yaml` to include the OpenBSD targets: - -```yaml -- job_name: 'node-exporter' - static_configs: - - targets: - - '192.168.2.130:9100' # f0 via WireGuard - - '192.168.2.131:9100' # f1 via WireGuard - - '192.168.2.132:9100' # f2 via WireGuard - labels: - os: freebsd - - targets: - - '192.168.2.110:9100' # blowfish via WireGuard - - '192.168.2.111:9100' # fishfinger via WireGuard - labels: - os: openbsd -``` - -The `os: openbsd` label allows filtering these hosts separately from FreeBSD and Linux nodes. - -### OpenBSD memory metrics compatibility - -OpenBSD uses the same memory metric names as FreeBSD (`node_memory_size_bytes`, `node_memory_free_bytes`, etc.), so a similar PrometheusRule is needed to generate Linux-compatible metrics: - -```yaml -apiVersion: monitoring.coreos.com/v1 -kind: PrometheusRule -metadata: - name: openbsd-memory-rules - namespace: monitoring - labels: - release: prometheus -spec: - groups: - - name: openbsd-memory - rules: - - record: node_memory_MemTotal_bytes - expr: node_memory_size_bytes{os="openbsd"} - labels: - os: openbsd - - record: node_memory_MemAvailable_bytes - expr: | - node_memory_free_bytes{os="openbsd"} - + node_memory_inactive_bytes{os="openbsd"} - + node_memory_cache_bytes{os="openbsd"} - labels: - os: openbsd - - record: node_memory_MemFree_bytes - expr: node_memory_free_bytes{os="openbsd"} - labels: - os: openbsd - - record: node_memory_Cached_bytes - expr: node_memory_cache_bytes{os="openbsd"} - labels: - os: openbsd -``` - -This file is saved as `openbsd-recording-rules.yaml` and applied alongside the FreeBSD rules. Note that OpenBSD doesn't expose a buffer memory metric, so that rule is omitted. - -=> https://codeberg.org/snonux/conf/src/branch/master/f3s/prometheus/openbsd-recording-rules.yaml openbsd-recording-rules.yaml on Codeberg - -After running `just upgrade`, the OpenBSD hosts appear in Prometheus targets and the Node Exporter dashboards. - -> Updated Mon 09 Mar: Added section about enabling etcd metrics - -## Enabling etcd metrics in k3s - -The etcd dashboard in Grafana initially showed no data because k3s uses an embedded etcd that doesn't expose metrics by default. - -On each control-plane node (r0, r1, r2), create /etc/rancher/k3s/config.yaml: - -``` -etcd-expose-metrics: true -``` - -Then restart k3s on each node: - -``` -systemctl restart k3s -``` - -After restarting, etcd metrics are available on port 2381: - -``` -curl http://127.0.0.1:2381/metrics | grep etcd -``` - -### Configuring Prometheus to scrape etcd - -In persistence-values.yaml, enable kubeEtcd with the node IP addresses: - -``` -kubeEtcd: - enabled: true - endpoints: - - 192.168.1.120 - - 192.168.1.121 - - 192.168.1.122 - service: - enabled: true - port: 2381 - targetPort: 2381 -``` - -Apply the changes: - -``` -just upgrade -``` - -### Verifying etcd metrics - -After the changes, all etcd targets are being scraped: - -``` -kubectl exec -n monitoring prometheus-prometheus-kube-prometheus-prometheus-0 \ - -c prometheus -- wget -qO- 'http://localhost:9090/api/v1/query?query=etcd_server_has_leader' | \ - jq -r '.data.result[] | "\(.metric.instance): \(.value[1])"' -``` - -Output: - -``` -192.168.1.120:2381: 1 -192.168.1.121:2381: 1 -192.168.1.122:2381: 1 -``` - -The etcd dashboard in Grafana now displays metrics including Raft proposals, leader elections, and peer round trip times. - -=> ./f3s-kubernetes-with-freebsd-part-8/grafana-etcd-dashboard.png Grafana etcd dashboard showing cluster health, RPC rate, disk sync duration, and peer round trip times - -### Complete persistence-values.yaml - -The complete updated persistence-values.yaml: - -``` -kubeEtcd: - enabled: true - endpoints: - - 192.168.1.120 - - 192.168.1.121 - - 192.168.1.122 - service: - enabled: true - port: 2381 - targetPort: 2381 - -prometheus: - prometheusSpec: - additionalScrapeConfigsSecret: - enabled: true - name: additional-scrape-configs - key: additional-scrape-configs.yaml - storageSpec: - volumeClaimTemplate: - spec: - storageClassName: "" - accessModes: ["ReadWriteOnce"] - resources: - requests: - storage: 10Gi - selector: - matchLabels: - type: local - app: prometheus - -grafana: - persistence: - enabled: true - type: pvc - existingClaim: "grafana-data-pvc" - - initChownData: - enabled: false - - podSecurityContext: - fsGroup: 911 - runAsUser: 911 - runAsGroup: 911 -``` - -> Updated Mon 09 Mar: Added section about ZFS monitoring for FreeBSD servers +The disk I/O panels in the Node Exporter dashboards will show "No data" for FreeBSD hosts. FreeBSD does expose ZFS-specific metrics (`node_zfs_arcstats_*`) for ARC cache performance, and per-dataset I/O stats are available via `sysctl kstat.zfs`, but mapping these to the Linux-style metrics the dashboards expect is non-trivial. To address this, I created custom ZFS-specific dashboards, covered in the next section. ## ZFS Monitoring for FreeBSD Servers @@ -1110,13 +897,126 @@ zfs_pool_capacity_percent{pool="zroot"} 10 zfs_pool_free_bytes{pool="zdata"} 3.48809678848e+11 ``` -> Updated Mon 09 Mar: Added section about distributed tracing with Grafana Tempo +All ZFS-related configuration files are available on Codeberg: + +=> https://codeberg.org/snonux/conf/src/branch/master/f3s/prometheus/zfs-recording-rules.yaml zfs-recording-rules.yaml on Codeberg +=> https://codeberg.org/snonux/conf/src/branch/master/f3s/prometheus/zfs-dashboards.yaml zfs-dashboards.yaml on Codeberg + +## Monitoring external OpenBSD hosts + +The same approach works for OpenBSD hosts. I have two OpenBSD edge relay servers (`blowfish`, `fishfinger`) that handle TLS termination and forward traffic through WireGuard to the cluster. These can also be monitored with Node Exporter. + +### Installing Node Exporter on OpenBSD + +On each OpenBSD host, install the node_exporter package: + +```sh +blowfish:~ $ doas pkg_add node_exporter +quirks-7.103 signed on 2025-10-13T22:55:16Z +The following new rcscripts were installed: /etc/rc.d/node_exporter +See rcctl(8) for details. +``` + +Enable the service to start at boot: + +```sh +blowfish:~ $ doas rcctl enable node_exporter +``` + +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: + +```sh +blowfish:~ $ doas rcctl set node_exporter flags '--web.listen-address=192.168.2.110:9100' +``` + +Start the service: + +```sh +blowfish:~ $ doas rcctl start node_exporter +node_exporter(ok) +``` + +Verify it's running: + +```sh +blowfish:~ $ curl -s http://192.168.2.110:9100/metrics | head -3 +# HELP go_gc_duration_seconds A summary of the wall-time pause... +# TYPE go_gc_duration_seconds summary +go_gc_duration_seconds{quantile="0"} 0 +``` + +Repeat for the other OpenBSD host (`fishfinger`) with its respective WireGuard IP (`192.168.2.111`). + +### Adding OpenBSD hosts to Prometheus + +Update `additional-scrape-configs.yaml` to include the OpenBSD targets: + +```yaml +- job_name: 'node-exporter' + static_configs: + - targets: + - '192.168.2.130:9100' # f0 via WireGuard + - '192.168.2.131:9100' # f1 via WireGuard + - '192.168.2.132:9100' # f2 via WireGuard + labels: + os: freebsd + - targets: + - '192.168.2.110:9100' # blowfish via WireGuard + - '192.168.2.111:9100' # fishfinger via WireGuard + labels: + os: openbsd +``` + +The `os: openbsd` label allows filtering these hosts separately from FreeBSD and Linux nodes. + +### OpenBSD memory metrics compatibility + +OpenBSD uses the same memory metric names as FreeBSD (`node_memory_size_bytes`, `node_memory_free_bytes`, etc.), so a similar PrometheusRule is needed to generate Linux-compatible metrics: + +```yaml +apiVersion: monitoring.coreos.com/v1 +kind: PrometheusRule +metadata: + name: openbsd-memory-rules + namespace: monitoring + labels: + release: prometheus +spec: + groups: + - name: openbsd-memory + rules: + - record: node_memory_MemTotal_bytes + expr: node_memory_size_bytes{os="openbsd"} + labels: + os: openbsd + - record: node_memory_MemAvailable_bytes + expr: | + node_memory_free_bytes{os="openbsd"} + + node_memory_inactive_bytes{os="openbsd"} + + node_memory_cache_bytes{os="openbsd"} + labels: + os: openbsd + - record: node_memory_MemFree_bytes + expr: node_memory_free_bytes{os="openbsd"} + labels: + os: openbsd + - record: node_memory_Cached_bytes + expr: node_memory_cache_bytes{os="openbsd"} + labels: + os: openbsd +``` + +This file is saved as `openbsd-recording-rules.yaml` and applied alongside the FreeBSD rules. Note that OpenBSD doesn't expose a buffer memory metric, so that rule is omitted. + +=> https://codeberg.org/snonux/conf/src/branch/master/f3s/prometheus/openbsd-recording-rules.yaml openbsd-recording-rules.yaml on Codeberg + +After running `just upgrade`, the OpenBSD hosts appear in Prometheus targets and the Node Exporter dashboards. ## Distributed Tracing with Grafana Tempo After implementing logs (Loki) and metrics (Prometheus), the final pillar of observability is distributed tracing. Grafana Tempo provides distributed tracing capabilities that help understand request flows across microservices. -How will this look tracing with Tempo like in Grafana? Have a look at the X-RAG blog post of mine: +For a preview of what distributed tracing with Tempo looks like in Grafana, see the X-RAG blog post: => ./2025-12-24-x-rag-observability-hackathon.gmi X-RAG Observability Hackathon @@ -1747,7 +1647,12 @@ With Prometheus, Grafana, Loki, Alloy, and Tempo deployed, I now have complete v This observability stack runs entirely on the home lab infrastructure, with data persisted to the NFS share. It's lightweight enough for a three-node cluster but provides the same capabilities as production-grade setups. -=> https://codeberg.org/snonux/conf/src/branch/master/f3s/prometheus prometheus configuration on Codeberg +All configuration files are available on Codeberg: + +=> https://codeberg.org/snonux/conf/src/branch/master/f3s/prometheus Prometheus, Grafana, and recording rules configuration +=> https://codeberg.org/snonux/conf/src/branch/master/f3s/loki Loki and Alloy configuration +=> https://codeberg.org/snonux/conf/src/branch/master/f3s/tempo Tempo configuration +=> https://codeberg.org/snonux/conf/src/branch/master/f3s/tracing-demo Demo tracing application Other *BSD-related posts: diff --git a/gemfeed/2025-12-07-f3s-kubernetes-with-freebsd-part-8.gmi.tpl b/gemfeed/2025-12-07-f3s-kubernetes-with-freebsd-part-8.gmi.tpl index dbeee59c..3bfbd5cf 100644 --- a/gemfeed/2025-12-07-f3s-kubernetes-with-freebsd-part-8.gmi.tpl +++ b/gemfeed/2025-12-07-f3s-kubernetes-with-freebsd-part-8.gmi.tpl @@ -12,14 +12,15 @@ This is the 8th blog post about the f3s series for my self-hosting demands in a ## Introduction -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 four main components, all deployed into the `monitoring` namespace: +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: * 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 from all pods to Loki +* 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 -Together, these form the "PLG" stack (Prometheus, Loki, Grafana), which is a popular open-source alternative to commercial observability platforms. +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: @@ -58,6 +59,7 @@ For example, the observability stack uses these paths on the NFS share: * `/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. @@ -144,17 +146,29 @@ kubeControllerManager: insecureSkipVerify: true ``` -By default, k3s binds the controller-manager to localhost only, so the "Kubernetes / Controller Manager" dashboard in Grafana will show no data. To expose the metrics endpoint, add the following to `/etc/rancher/k3s/config.yaml` on each k3s server node: +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: ```sh [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 ``` -Repeat for `r1` and `r2`. After restarting all nodes, the controller-manager metrics endpoint will be accessible and Prometheus can scrape it. +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. + +Verify etcd metrics are exposed: + +```sh +[root@r0 ~]# curl -s http://127.0.0.1:2381/metrics | grep etcd_server_has_leader +etcd_server_has_leader 1 +``` + +The full `persistence-values.yaml` and all other Prometheus configuration files are available on Codeberg: + +=> https://codeberg.org/snonux/conf/src/branch/master/f3s/prometheus 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: @@ -178,6 +192,8 @@ Grafana connects to Prometheus using the internal service URL `http://prometheus => ./f3s-kubernetes-with-freebsd-part-8/grafana-dashboard.png Grafana dashboard showing cluster metrics +=> ./f3s-kubernetes-with-freebsd-part-8/grafana-etcd-dashboard.png Grafana etcd dashboard showing cluster health, RPC rate, disk sync duration, and peer round trip times + ## Installing Loki and Alloy 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. @@ -313,8 +329,11 @@ prometheus-prometheus-kube-prometheus-prometheus-0 2/2 Running 0 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 ``` +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. + And the services: ```sh @@ -330,6 +349,7 @@ 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 ``` Let me break down what each pod does: @@ -350,6 +370,8 @@ Let me break down what each pod does: * `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 ### Viewing metrics in Grafana @@ -513,238 +535,7 @@ This file is saved as `freebsd-recording-rules.yaml` and applied as part of the Unlike memory metrics, disk I/O metrics (`node_disk_read_bytes_total`, `node_disk_written_bytes_total`, etc.) are not available on FreeBSD. The Linux diskstats collector that provides these metrics doesn't have a FreeBSD equivalent in the node_exporter. -The disk I/O panels in the Node Exporter dashboards will show "No data" for FreeBSD hosts. FreeBSD does expose ZFS-specific metrics (`node_zfs_arcstats_*`) for ARC cache performance, and per-dataset I/O stats are available via `sysctl kstat.zfs`, but mapping these to the Linux-style metrics the dashboards expect is non-trivial. Custom ZFS-specific dashboards are covered later in this post. - -## Monitoring external OpenBSD hosts - -The same approach works for OpenBSD hosts. I have two OpenBSD edge relay servers (`blowfish`, `fishfinger`) that handle TLS termination and forward traffic through WireGuard to the cluster. These can also be monitored with Node Exporter. - -### Installing Node Exporter on OpenBSD - -On each OpenBSD host, install the node_exporter package: - -```sh -blowfish:~ $ doas pkg_add node_exporter -quirks-7.103 signed on 2025-10-13T22:55:16Z -The following new rcscripts were installed: /etc/rc.d/node_exporter -See rcctl(8) for details. -``` - -Enable the service to start at boot: - -```sh -blowfish:~ $ doas rcctl enable node_exporter -``` - -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: - -```sh -blowfish:~ $ doas rcctl set node_exporter flags '--web.listen-address=192.168.2.110:9100' -``` - -Start the service: - -```sh -blowfish:~ $ doas rcctl start node_exporter -node_exporter(ok) -``` - -Verify it's running: - -```sh -blowfish:~ $ curl -s http://192.168.2.110:9100/metrics | head -3 -# HELP go_gc_duration_seconds A summary of the wall-time pause... -# TYPE go_gc_duration_seconds summary -go_gc_duration_seconds{quantile="0"} 0 -``` - -Repeat for the other OpenBSD host (`fishfinger`) with its respective WireGuard IP (`192.168.2.111`). - -### Adding OpenBSD hosts to Prometheus - -Update `additional-scrape-configs.yaml` to include the OpenBSD targets: - -```yaml -- job_name: 'node-exporter' - static_configs: - - targets: - - '192.168.2.130:9100' # f0 via WireGuard - - '192.168.2.131:9100' # f1 via WireGuard - - '192.168.2.132:9100' # f2 via WireGuard - labels: - os: freebsd - - targets: - - '192.168.2.110:9100' # blowfish via WireGuard - - '192.168.2.111:9100' # fishfinger via WireGuard - labels: - os: openbsd -``` - -The `os: openbsd` label allows filtering these hosts separately from FreeBSD and Linux nodes. - -### OpenBSD memory metrics compatibility - -OpenBSD uses the same memory metric names as FreeBSD (`node_memory_size_bytes`, `node_memory_free_bytes`, etc.), so a similar PrometheusRule is needed to generate Linux-compatible metrics: - -```yaml -apiVersion: monitoring.coreos.com/v1 -kind: PrometheusRule -metadata: - name: openbsd-memory-rules - namespace: monitoring - labels: - release: prometheus -spec: - groups: - - name: openbsd-memory - rules: - - record: node_memory_MemTotal_bytes - expr: node_memory_size_bytes{os="openbsd"} - labels: - os: openbsd - - record: node_memory_MemAvailable_bytes - expr: | - node_memory_free_bytes{os="openbsd"} - + node_memory_inactive_bytes{os="openbsd"} - + node_memory_cache_bytes{os="openbsd"} - labels: - os: openbsd - - record: node_memory_MemFree_bytes - expr: node_memory_free_bytes{os="openbsd"} - labels: - os: openbsd - - record: node_memory_Cached_bytes - expr: node_memory_cache_bytes{os="openbsd"} - labels: - os: openbsd -``` - -This file is saved as `openbsd-recording-rules.yaml` and applied alongside the FreeBSD rules. Note that OpenBSD doesn't expose a buffer memory metric, so that rule is omitted. - -=> https://codeberg.org/snonux/conf/src/branch/master/f3s/prometheus/openbsd-recording-rules.yaml openbsd-recording-rules.yaml on Codeberg - -After running `just upgrade`, the OpenBSD hosts appear in Prometheus targets and the Node Exporter dashboards. - -> Updated Mon 09 Mar: Added section about enabling etcd metrics - -## Enabling etcd metrics in k3s - -The etcd dashboard in Grafana initially showed no data because k3s uses an embedded etcd that doesn't expose metrics by default. - -On each control-plane node (r0, r1, r2), create /etc/rancher/k3s/config.yaml: - -``` -etcd-expose-metrics: true -``` - -Then restart k3s on each node: - -``` -systemctl restart k3s -``` - -After restarting, etcd metrics are available on port 2381: - -``` -curl http://127.0.0.1:2381/metrics | grep etcd -``` - -### Configuring Prometheus to scrape etcd - -In persistence-values.yaml, enable kubeEtcd with the node IP addresses: - -``` -kubeEtcd: - enabled: true - endpoints: - - 192.168.1.120 - - 192.168.1.121 - - 192.168.1.122 - service: - enabled: true - port: 2381 - targetPort: 2381 -``` - -Apply the changes: - -``` -just upgrade -``` - -### Verifying etcd metrics - -After the changes, all etcd targets are being scraped: - -``` -kubectl exec -n monitoring prometheus-prometheus-kube-prometheus-prometheus-0 \ - -c prometheus -- wget -qO- 'http://localhost:9090/api/v1/query?query=etcd_server_has_leader' | \ - jq -r '.data.result[] | "\(.metric.instance): \(.value[1])"' -``` - -Output: - -``` -192.168.1.120:2381: 1 -192.168.1.121:2381: 1 -192.168.1.122:2381: 1 -``` - -The etcd dashboard in Grafana now displays metrics including Raft proposals, leader elections, and peer round trip times. - -=> ./f3s-kubernetes-with-freebsd-part-8/grafana-etcd-dashboard.png Grafana etcd dashboard showing cluster health, RPC rate, disk sync duration, and peer round trip times - -### Complete persistence-values.yaml - -The complete updated persistence-values.yaml: - -``` -kubeEtcd: - enabled: true - endpoints: - - 192.168.1.120 - - 192.168.1.121 - - 192.168.1.122 - service: - enabled: true - port: 2381 - targetPort: 2381 - -prometheus: - prometheusSpec: - additionalScrapeConfigsSecret: - enabled: true - name: additional-scrape-configs - key: additional-scrape-configs.yaml - storageSpec: - volumeClaimTemplate: - spec: - storageClassName: "" - accessModes: ["ReadWriteOnce"] - resources: - requests: - storage: 10Gi - selector: - matchLabels: - type: local - app: prometheus - -grafana: - persistence: - enabled: true - type: pvc - existingClaim: "grafana-data-pvc" - - initChownData: - enabled: false - - podSecurityContext: - fsGroup: 911 - runAsUser: 911 - runAsGroup: 911 -``` - -> Updated Mon 09 Mar: Added section about ZFS monitoring for FreeBSD servers +The disk I/O panels in the Node Exporter dashboards will show "No data" for FreeBSD hosts. FreeBSD does expose ZFS-specific metrics (`node_zfs_arcstats_*`) for ARC cache performance, and per-dataset I/O stats are available via `sysctl kstat.zfs`, but mapping these to the Linux-style metrics the dashboards expect is non-trivial. To address this, I created custom ZFS-specific dashboards, covered in the next section. ## ZFS Monitoring for FreeBSD Servers @@ -1037,13 +828,126 @@ zfs_pool_capacity_percent{pool="zroot"} 10 zfs_pool_free_bytes{pool="zdata"} 3.48809678848e+11 ``` -> Updated Mon 09 Mar: Added section about distributed tracing with Grafana Tempo +All ZFS-related configuration files are available on Codeberg: + +=> https://codeberg.org/snonux/conf/src/branch/master/f3s/prometheus/zfs-recording-rules.yaml zfs-recording-rules.yaml on Codeberg +=> https://codeberg.org/snonux/conf/src/branch/master/f3s/prometheus/zfs-dashboards.yaml zfs-dashboards.yaml on Codeberg + +## Monitoring external OpenBSD hosts + +The same approach works for OpenBSD hosts. I have two OpenBSD edge relay servers (`blowfish`, `fishfinger`) that handle TLS termination and forward traffic through WireGuard to the cluster. These can also be monitored with Node Exporter. + +### Installing Node Exporter on OpenBSD + +On each OpenBSD host, install the node_exporter package: + +```sh +blowfish:~ $ doas pkg_add node_exporter +quirks-7.103 signed on 2025-10-13T22:55:16Z +The following new rcscripts were installed: /etc/rc.d/node_exporter +See rcctl(8) for details. +``` + +Enable the service to start at boot: + +```sh +blowfish:~ $ doas rcctl enable node_exporter +``` + +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: + +```sh +blowfish:~ $ doas rcctl set node_exporter flags '--web.listen-address=192.168.2.110:9100' +``` + +Start the service: + +```sh +blowfish:~ $ doas rcctl start node_exporter +node_exporter(ok) +``` + +Verify it's running: + +```sh +blowfish:~ $ curl -s http://192.168.2.110:9100/metrics | head -3 +# HELP go_gc_duration_seconds A summary of the wall-time pause... +# TYPE go_gc_duration_seconds summary +go_gc_duration_seconds{quantile="0"} 0 +``` + +Repeat for the other OpenBSD host (`fishfinger`) with its respective WireGuard IP (`192.168.2.111`). + +### Adding OpenBSD hosts to Prometheus + +Update `additional-scrape-configs.yaml` to include the OpenBSD targets: + +```yaml +- job_name: 'node-exporter' + static_configs: + - targets: + - '192.168.2.130:9100' # f0 via WireGuard + - '192.168.2.131:9100' # f1 via WireGuard + - '192.168.2.132:9100' # f2 via WireGuard + labels: + os: freebsd + - targets: + - '192.168.2.110:9100' # blowfish via WireGuard + - '192.168.2.111:9100' # fishfinger via WireGuard + labels: + os: openbsd +``` + +The `os: openbsd` label allows filtering these hosts separately from FreeBSD and Linux nodes. + +### OpenBSD memory metrics compatibility + +OpenBSD uses the same memory metric names as FreeBSD (`node_memory_size_bytes`, `node_memory_free_bytes`, etc.), so a similar PrometheusRule is needed to generate Linux-compatible metrics: + +```yaml +apiVersion: monitoring.coreos.com/v1 +kind: PrometheusRule +metadata: + name: openbsd-memory-rules + namespace: monitoring + labels: + release: prometheus +spec: + groups: + - name: openbsd-memory + rules: + - record: node_memory_MemTotal_bytes + expr: node_memory_size_bytes{os="openbsd"} + labels: + os: openbsd + - record: node_memory_MemAvailable_bytes + expr: | + node_memory_free_bytes{os="openbsd"} + + node_memory_inactive_bytes{os="openbsd"} + + node_memory_cache_bytes{os="openbsd"} + labels: + os: openbsd + - record: node_memory_MemFree_bytes + expr: node_memory_free_bytes{os="openbsd"} + labels: + os: openbsd + - record: node_memory_Cached_bytes + expr: node_memory_cache_bytes{os="openbsd"} + labels: + os: openbsd +``` + +This file is saved as `openbsd-recording-rules.yaml` and applied alongside the FreeBSD rules. Note that OpenBSD doesn't expose a buffer memory metric, so that rule is omitted. + +=> https://codeberg.org/snonux/conf/src/branch/master/f3s/prometheus/openbsd-recording-rules.yaml openbsd-recording-rules.yaml on Codeberg + +After running `just upgrade`, the OpenBSD hosts appear in Prometheus targets and the Node Exporter dashboards. ## Distributed Tracing with Grafana Tempo After implementing logs (Loki) and metrics (Prometheus), the final pillar of observability is distributed tracing. Grafana Tempo provides distributed tracing capabilities that help understand request flows across microservices. -How will this look tracing with Tempo like in Grafana? Have a look at the X-RAG blog post of mine: +For a preview of what distributed tracing with Tempo looks like in Grafana, see the X-RAG blog post: => ./2025-12-24-x-rag-observability-hackathon.gmi X-RAG Observability Hackathon @@ -1674,7 +1578,12 @@ With Prometheus, Grafana, Loki, Alloy, and Tempo deployed, I now have complete v This observability stack runs entirely on the home lab infrastructure, with data persisted to the NFS share. It's lightweight enough for a three-node cluster but provides the same capabilities as production-grade setups. -=> https://codeberg.org/snonux/conf/src/branch/master/f3s/prometheus prometheus configuration on Codeberg +All configuration files are available on Codeberg: + +=> https://codeberg.org/snonux/conf/src/branch/master/f3s/prometheus Prometheus, Grafana, and recording rules configuration +=> https://codeberg.org/snonux/conf/src/branch/master/f3s/loki Loki and Alloy configuration +=> https://codeberg.org/snonux/conf/src/branch/master/f3s/tempo Tempo configuration +=> https://codeberg.org/snonux/conf/src/branch/master/f3s/tracing-demo Demo tracing application Other *BSD-related posts: diff --git a/gemfeed/atom.xml b/gemfeed/atom.xml index 17afd024..7ce70162 100644 --- a/gemfeed/atom.xml +++ b/gemfeed/atom.xml @@ -1,6 +1,6 @@ - 2026-03-09T08:44:03+02:00 + 2026-03-09T09:06:40+02:00 foo.zone feed To be in the .zone! @@ -3573,14 +3573,6 @@ $ curl -s -G "http://localhost:3200/api/search" \
  • ⇢ ⇢ Adding FreeBSD hosts to Prometheus
  • ⇢ ⇢ FreeBSD memory metrics compatibility
  • ⇢ ⇢ Disk I/O metrics limitation
  • -
  • Monitoring external OpenBSD hosts
  • -
  • ⇢ ⇢ Installing Node Exporter on OpenBSD
  • -
  • ⇢ ⇢ Adding OpenBSD hosts to Prometheus
  • -
  • ⇢ ⇢ OpenBSD memory metrics compatibility
  • -
  • Enabling etcd metrics in k3s
  • -
  • ⇢ ⇢ Configuring Prometheus to scrape etcd
  • -
  • ⇢ ⇢ Verifying etcd metrics
  • -
  • ⇢ ⇢ Complete persistence-values.yaml
  • ZFS Monitoring for FreeBSD Servers
  • ⇢ ⇢ Node Exporter ZFS Collector
  • ⇢ ⇢ Verifying ZFS Metrics
  • @@ -3588,9 +3580,12 @@ $ curl -s -G "http://localhost:3200/api/search" \
  • ⇢ ⇢ Grafana Dashboards
  • ⇢ ⇢ Deployment
  • ⇢ ⇢ Verifying ZFS Metrics in Prometheus
  • -
  • ⇢ ⇢ Accessing the Dashboards
  • ⇢ ⇢ Key Metrics to Monitor
  • ⇢ ⇢ ZFS Pool and Dataset Metrics via Textfile Collector
  • +
  • Monitoring external OpenBSD hosts
  • +
  • ⇢ ⇢ Installing Node Exporter on OpenBSD
  • +
  • ⇢ ⇢ Adding OpenBSD hosts to Prometheus
  • +
  • ⇢ ⇢ OpenBSD memory metrics compatibility
  • Distributed Tracing with Grafana Tempo
  • ⇢ ⇢ Why Distributed Tracing?
  • ⇢ ⇢ Deploying Grafana Tempo
  • @@ -3602,8 +3597,6 @@ $ curl -s -G "http://localhost:3200/api/search" \
  • ⇢# Upgrade Alloy
  • ⇢ ⇢ Demo Tracing Application
  • ⇢# Application Architecture
  • -
  • ⇢# OpenTelemetry Instrumentation
  • -
  • ⇢# Deployment
  • ⇢ ⇢ Visualizing Traces in Grafana
  • ⇢# Accessing Traces
  • ⇢# Service Graph Visualization
  • @@ -3615,21 +3608,21 @@ $ curl -s -G "http://localhost:3200/api/search" \
  • ⇢ ⇢ Verifying the Complete Pipeline
  • ⇢ ⇢ Practical Example: Viewing a Distributed Trace
  • ⇢ ⇢ Storage and Retention
  • -
  • ⇢ ⇢ Complete Observability Stack
  • ⇢ ⇢ Configuration Files
  • Summary

  • Introduction



    -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 four main components, all deployed into the monitoring namespace:
    +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:


    -Together, these form the "PLG" stack (Prometheus, Loki, Grafana), which is a popular open-source alternative to commercial observability platforms.
    +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:

    @@ -3673,6 +3666,7 @@ http://www.gnu.org/software/src-highlite -->
  • /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.

    @@ -3771,7 +3765,7 @@ kubeControllerManager: insecureSkipVerify: true
    -By default, k3s binds the controller-manager to localhost only, so the "Kubernetes / Controller Manager" dashboard in Grafana will show no data. To expose the metrics endpoint, add the following to /etc/rancher/k3s/config.yaml on each k3s server node:
    +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:

    [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
     

    -Repeat for r1 and r2. After restarting all nodes, the controller-manager metrics endpoint will be accessible and Prometheus can scrape it.
    +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.
    +
    +Verify etcd metrics are exposed:
    +
    + +
    [root@r0 ~]# curl -s http://127.0.0.1:2381/metrics | grep etcd_server_has_leader
    +etcd_server_has_leader 1
    +
    +
    +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:

    @@ -3811,6 +3820,8 @@ http://www.gnu.org/software/src-highlite -->
    Grafana dashboard showing cluster metrics

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

    Installing Loki and Alloy



    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.
    @@ -3962,8 +3973,11 @@ http://www.gnu.org/software/src-highlite --> 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
    +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.
    +
    And the services:

    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
    Let me break down what each pod does:
    @@ -4010,6 +4025,9 @@ http://www.gnu.org/software/src-highlite -->
    +

    Using the observability stack



    Viewing metrics in Grafana


    @@ -4195,253 +4213,7 @@ spec:
    Unlike memory metrics, disk I/O metrics (node_disk_read_bytes_total, node_disk_written_bytes_total, etc.) are not available on FreeBSD. The Linux diskstats collector that provides these metrics doesn't have a FreeBSD equivalent in the node_exporter.

    -The disk I/O panels in the Node Exporter dashboards will show "No data" for FreeBSD hosts. FreeBSD does expose ZFS-specific metrics (node_zfs_arcstats_*) for ARC cache performance, and per-dataset I/O stats are available via sysctl kstat.zfs, but mapping these to the Linux-style metrics the dashboards expect is non-trivial. Custom ZFS-specific dashboards are covered later in this post.
    -
    -

    Monitoring external OpenBSD hosts


    -
    -The same approach works for OpenBSD hosts. I have two OpenBSD edge relay servers (blowfish, fishfinger) that handle TLS termination and forward traffic through WireGuard to the cluster. These can also be monitored with Node Exporter.
    -
    -

    Installing Node Exporter on OpenBSD


    -
    -On each OpenBSD host, install the node_exporter package:
    -
    - -
    blowfish:~ $ doas pkg_add node_exporter
    -quirks-7.103 signed on 2025-10-13T22:55:16Z
    -The following new rcscripts were installed: /etc/rc.d/node_exporter
    -See rcctl(8) for details.
    -
    -
    -Enable the service to start at boot:
    -
    - -
    blowfish:~ $ doas rcctl enable node_exporter
    -
    -
    -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:
    -
    - -
    blowfish:~ $ doas rcctl set node_exporter flags '--web.listen-address=192.168.2.110:9100'
    -
    -
    -Start the service:
    -
    - -
    blowfish:~ $ doas rcctl start node_exporter
    -node_exporter(ok)
    -
    -
    -Verify it's running:
    -
    - -
    blowfish:~ $ curl -s http://192.168.2.110:9100/metrics | head -3
    -# HELP go_gc_duration_seconds A summary of the wall-time pause...
    -# TYPE go_gc_duration_seconds summary
    -go_gc_duration_seconds{quantile="0"} 0
    -
    -
    -Repeat for the other OpenBSD host (fishfinger) with its respective WireGuard IP (192.168.2.111).
    -
    -

    Adding OpenBSD hosts to Prometheus


    -
    -Update additional-scrape-configs.yaml to include the OpenBSD targets:
    -
    -
    -- job_name: 'node-exporter'
    -  static_configs:
    -    - targets:
    -      - '192.168.2.130:9100'  # f0 via WireGuard
    -      - '192.168.2.131:9100'  # f1 via WireGuard
    -      - '192.168.2.132:9100'  # f2 via WireGuard
    -      labels:
    -        os: freebsd
    -    - targets:
    -      - '192.168.2.110:9100'  # blowfish via WireGuard
    -      - '192.168.2.111:9100'  # fishfinger via WireGuard
    -      labels:
    -        os: openbsd
    -
    -
    -The os: openbsd label allows filtering these hosts separately from FreeBSD and Linux nodes.
    -
    -

    OpenBSD memory metrics compatibility


    -
    -OpenBSD uses the same memory metric names as FreeBSD (node_memory_size_bytes, node_memory_free_bytes, etc.), so a similar PrometheusRule is needed to generate Linux-compatible metrics:
    -
    -
    -apiVersion: monitoring.coreos.com/v1
    -kind: PrometheusRule
    -metadata:
    -  name: openbsd-memory-rules
    -  namespace: monitoring
    -  labels:
    -    release: prometheus
    -spec:
    -  groups:
    -    - name: openbsd-memory
    -      rules:
    -        - record: node_memory_MemTotal_bytes
    -          expr: node_memory_size_bytes{os="openbsd"}
    -          labels:
    -            os: openbsd
    -        - record: node_memory_MemAvailable_bytes
    -          expr: |
    -            node_memory_free_bytes{os="openbsd"}
    -              + node_memory_inactive_bytes{os="openbsd"}
    -              + node_memory_cache_bytes{os="openbsd"}
    -          labels:
    -            os: openbsd
    -        - record: node_memory_MemFree_bytes
    -          expr: node_memory_free_bytes{os="openbsd"}
    -          labels:
    -            os: openbsd
    -        - record: node_memory_Cached_bytes
    -          expr: node_memory_cache_bytes{os="openbsd"}
    -          labels:
    -            os: openbsd
    -
    -
    -This file is saved as openbsd-recording-rules.yaml and applied alongside the FreeBSD rules. Note that OpenBSD doesn't expose a buffer memory metric, so that rule is omitted.
    -
    -openbsd-recording-rules.yaml on Codeberg
    -
    -After running just upgrade, the OpenBSD hosts appear in Prometheus targets and the Node Exporter dashboards.
    -
    -Updated Mon 09 Mar: Added section about enabling etcd metrics
    -
    -

    Enabling etcd metrics in k3s


    -
    -The etcd dashboard in Grafana initially showed no data because k3s uses an embedded etcd that doesn't expose metrics by default.
    -
    -On each control-plane node (r0, r1, r2), create /etc/rancher/k3s/config.yaml:
    -
    -
    -etcd-expose-metrics: true
    -
    -
    -Then restart k3s on each node:
    -
    -
    -systemctl restart k3s
    -
    -
    -After restarting, etcd metrics are available on port 2381:
    -
    -
    -curl http://127.0.0.1:2381/metrics | grep etcd
    -
    -
    -

    Configuring Prometheus to scrape etcd


    -
    -In persistence-values.yaml, enable kubeEtcd with the node IP addresses:
    -
    -
    -kubeEtcd:
    -  enabled: true
    -  endpoints:
    -    - 192.168.1.120
    -    - 192.168.1.121
    -    - 192.168.1.122
    -  service:
    -    enabled: true
    -    port: 2381
    -    targetPort: 2381
    -
    -
    -Apply the changes:
    -
    -
    -just upgrade
    -
    -
    -

    Verifying etcd metrics


    -
    -After the changes, all etcd targets are being scraped:
    -
    -
    -kubectl exec -n monitoring prometheus-prometheus-kube-prometheus-prometheus-0 \
    -  -c prometheus -- wget -qO- 'http://localhost:9090/api/v1/query?query=etcd_server_has_leader' | \
    -  jq -r '.data.result[] | "\(.metric.instance): \(.value[1])"'
    -
    -
    -Output:
    -
    -
    -192.168.1.120:2381: 1
    -192.168.1.121:2381: 1
    -192.168.1.122:2381: 1
    -
    -
    -The etcd dashboard in Grafana now displays metrics including Raft proposals, leader elections, and peer round trip times.
    -
    -Grafana etcd dashboard showing cluster health, RPC rate, disk sync duration, and peer round trip times
    -
    -

    Complete persistence-values.yaml


    -
    -The complete updated persistence-values.yaml:
    -
    -
    -kubeEtcd:
    -  enabled: true
    -  endpoints:
    -    - 192.168.1.120
    -    - 192.168.1.121
    -    - 192.168.1.122
    -  service:
    -    enabled: true
    -    port: 2381
    -    targetPort: 2381
    -
    -prometheus:
    -  prometheusSpec:
    -    additionalScrapeConfigsSecret:
    -      enabled: true
    -      name: additional-scrape-configs
    -      key: additional-scrape-configs.yaml
    -    storageSpec:
    -      volumeClaimTemplate:
    -        spec:
    -          storageClassName: ""
    -          accessModes: ["ReadWriteOnce"]
    -          resources:
    -            requests:
    -              storage: 10Gi
    -          selector:
    -            matchLabels:
    -              type: local
    -              app: prometheus
    -
    -grafana:
    -  persistence:
    -    enabled: true
    -    type: pvc
    -    existingClaim: "grafana-data-pvc"
    -
    -  initChownData:
    -    enabled: false
    -
    -  podSecurityContext:
    -    fsGroup: 911
    -    runAsUser: 911
    -    runAsGroup: 911
    -
    -
    -Updated Mon 09 Mar: Added section about ZFS monitoring for FreeBSD servers
    +The disk I/O panels in the Node Exporter dashboards will show "No data" for FreeBSD hosts. FreeBSD does expose ZFS-specific metrics (node_zfs_arcstats_*) for ARC cache performance, and per-dataset I/O stats are available via sysctl kstat.zfs, but mapping these to the Linux-style metrics the dashboards expect is non-trivial. To address this, I created custom ZFS-specific dashboards, covered in the next section.

    ZFS Monitoring for FreeBSD Servers



    @@ -4523,11 +4295,13 @@ spec: **Dashboard 1: FreeBSD ZFS (per-host detailed view)**

    Includes variables to select:
    +

    -**Pool Overview Row:**
    +Pool Overview Row:
    +

    -**Dataset Statistics Row:**
    +Dataset Statistics Row:
    +

    -**ARC Cache Statistics Row:**
    +ARC Cache Statistics Row:
    +

    **Dashboard 2: FreeBSD ZFS Summary (cluster-wide overview)**

    -**Cluster-Wide Pool Statistics Row:**
    +Cluster-Wide Pool Statistics Row:
    +

    -**Per-Host Pool Breakdown Row:**
    +Per-Host Pool Breakdown Row:
    +

    -**Cluster-Wide ARC Statistics Row:**
    +Cluster-Wide ARC Statistics Row:
    +

    -**Dashboard Visualization:**
    +Dashboard Visualization:

    ZFS monitoring dashboard in Grafana showing pool capacity, health, and I/O throughput
    -
    ZFS ARC cache statistics showing hit rate, memory usage, and size trends
    -
    ZFS datasets table and ARC data vs metadata breakdown

    Deployment


    @@ -4631,38 +4408,22 @@ kubectl exec -n monitoring prometheus-prometheus-kube-prometheus-prometheus-0 -c ]
    -

    Accessing the Dashboards


    -
    -The dashboards are automatically imported by the Grafana sidecar and accessible at:
    -
    -https://grafana.f3s.buetow.org
    +

    Key Metrics to Monitor



    -Navigate to Dashboards and search for:

    -

    Key Metrics to Monitor


    -
    -**ARC Hit Rate:** Should typically be above 90% for optimal performance. Lower hit rates indicate the ARC cache is too small or workload has poor locality.
    -
    -**ARC Memory Usage:** Shows how much of the maximum ARC size is being used. If consistently at or near maximum, the ARC is effectively utilizing available memory.
    -
    -**Data vs Metadata:** Typically data should dominate, but workloads with many small files will show higher metadata percentages.
    -
    -**MRU vs MFU:** Most Recently Used vs Most Frequently Used cache. The ratio depends on workload characteristics.
    -
    -**Pool Capacity:** Monitor pool usage to ensure adequate free space. ZFS performance degrades when pools exceed 80% capacity.
    -
    -**Pool Health:** Should always show ONLINE (green). DEGRADED (yellow) indicates a disk issue requiring attention. FAULTED (red) requires immediate action.
    -
    -**Dataset Usage:** Track which datasets are consuming the most space to identify growth trends and plan capacity.
    -

    ZFS Pool and Dataset Metrics via Textfile Collector



    To complement the ARC statistics from node_exporter's built-in ZFS collector, I added pool capacity and dataset metrics using the textfile collector feature.

    -Created a script at /usr/local/bin/zfs_pool_metrics.sh on each FreeBSD server:
    +Created a script at /usr/local/bin/zfs_pool_metrics.sh on each FreeBSD server:

     #!/bin/sh
    @@ -4755,13 +4516,141 @@ zfs_pool_capacity_percent{pool="zroot"} 10
     zfs_pool_free_bytes{pool="zdata"} 3.48809678848e+11
     

    -Updated Mon 09 Mar: Added section about distributed tracing with Grafana Tempo
    +All ZFS-related configuration files are available on Codeberg:
    +
    +zfs-recording-rules.yaml on Codeberg
    +zfs-dashboards.yaml on Codeberg
    +
    +

    Monitoring external OpenBSD hosts


    +
    +The same approach works for OpenBSD hosts. I have two OpenBSD edge relay servers (blowfish, fishfinger) that handle TLS termination and forward traffic through WireGuard to the cluster. These can also be monitored with Node Exporter.
    +
    +

    Installing Node Exporter on OpenBSD


    +
    +On each OpenBSD host, install the node_exporter package:
    +
    + +
    blowfish:~ $ doas pkg_add node_exporter
    +quirks-7.103 signed on 2025-10-13T22:55:16Z
    +The following new rcscripts were installed: /etc/rc.d/node_exporter
    +See rcctl(8) for details.
    +
    +
    +Enable the service to start at boot:
    +
    + +
    blowfish:~ $ doas rcctl enable node_exporter
    +
    +
    +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:
    +
    + +
    blowfish:~ $ doas rcctl set node_exporter flags '--web.listen-address=192.168.2.110:9100'
    +
    +
    +Start the service:
    +
    + +
    blowfish:~ $ doas rcctl start node_exporter
    +node_exporter(ok)
    +
    +
    +Verify it's running:
    +
    + +
    blowfish:~ $ curl -s http://192.168.2.110:9100/metrics | head -3
    +# HELP go_gc_duration_seconds A summary of the wall-time pause...
    +# TYPE go_gc_duration_seconds summary
    +go_gc_duration_seconds{quantile="0"} 0
    +
    +
    +Repeat for the other OpenBSD host (fishfinger) with its respective WireGuard IP (192.168.2.111).
    +
    +

    Adding OpenBSD hosts to Prometheus


    +
    +Update additional-scrape-configs.yaml to include the OpenBSD targets:
    +
    +
    +- job_name: 'node-exporter'
    +  static_configs:
    +    - targets:
    +      - '192.168.2.130:9100'  # f0 via WireGuard
    +      - '192.168.2.131:9100'  # f1 via WireGuard
    +      - '192.168.2.132:9100'  # f2 via WireGuard
    +      labels:
    +        os: freebsd
    +    - targets:
    +      - '192.168.2.110:9100'  # blowfish via WireGuard
    +      - '192.168.2.111:9100'  # fishfinger via WireGuard
    +      labels:
    +        os: openbsd
    +
    +
    +The os: openbsd label allows filtering these hosts separately from FreeBSD and Linux nodes.
    +
    +

    OpenBSD memory metrics compatibility


    +
    +OpenBSD uses the same memory metric names as FreeBSD (node_memory_size_bytes, node_memory_free_bytes, etc.), so a similar PrometheusRule is needed to generate Linux-compatible metrics:
    +
    +
    +apiVersion: monitoring.coreos.com/v1
    +kind: PrometheusRule
    +metadata:
    +  name: openbsd-memory-rules
    +  namespace: monitoring
    +  labels:
    +    release: prometheus
    +spec:
    +  groups:
    +    - name: openbsd-memory
    +      rules:
    +        - record: node_memory_MemTotal_bytes
    +          expr: node_memory_size_bytes{os="openbsd"}
    +          labels:
    +            os: openbsd
    +        - record: node_memory_MemAvailable_bytes
    +          expr: |
    +            node_memory_free_bytes{os="openbsd"}
    +              + node_memory_inactive_bytes{os="openbsd"}
    +              + node_memory_cache_bytes{os="openbsd"}
    +          labels:
    +            os: openbsd
    +        - record: node_memory_MemFree_bytes
    +          expr: node_memory_free_bytes{os="openbsd"}
    +          labels:
    +            os: openbsd
    +        - record: node_memory_Cached_bytes
    +          expr: node_memory_cache_bytes{os="openbsd"}
    +          labels:
    +            os: openbsd
    +
    +
    +This file is saved as openbsd-recording-rules.yaml and applied alongside the FreeBSD rules. Note that OpenBSD doesn't expose a buffer memory metric, so that rule is omitted.
    +
    +openbsd-recording-rules.yaml on Codeberg
    +
    +After running just upgrade, the OpenBSD hosts appear in Prometheus targets and the Node Exporter dashboards.

    Distributed Tracing with Grafana Tempo



    After implementing logs (Loki) and metrics (Prometheus), the final pillar of observability is distributed tracing. Grafana Tempo provides distributed tracing capabilities that help understand request flows across microservices.

    -How will this look tracing with Tempo like in Grafana? Have a look at the X-RAG blog post of mine:
    +For a preview of what distributed tracing with Tempo looks like in Grafana, see the X-RAG blog post:

    X-RAG Observability Hackathon

    @@ -5008,25 +4897,28 @@ User → Frontend (Flask:5000) → Middleware (Flask:5001) → Backend (Flask:50 Alloy (OTLP:4317) → Tempo → Grafana
    -**Frontend Service:**
    +Frontend Service:
    +

    -**Middleware Service:**
    +Middleware Service:
    +

    -**Backend Service:**
    +Backend Service:
    +

    -#### OpenTelemetry Instrumentation
    +OpenTelemetry Instrumentation:

    All services use Python OpenTelemetry libraries:

    @@ -5083,7 +4975,7 @@ http://www.gnu.org/software/src-highlite -->
  • Propagates trace context via W3C Trace Context headers
  • Links parent and child spans across service boundaries

  • -#### Deployment
    +Deployment:

    Created Helm chart in /home/paul/git/conf/f3s/tracing-demo/ with three separate deployments, services, and an ingress.

    @@ -5354,20 +5246,22 @@ Service: backend X-RAG Observability Hackathon (more Grafana Tempo screenshots)

    The trace reveals the distributed request flow:
    +

    **6. Service graph visualization:**

    The service graph is automatically generated from traces and shows service dependencies. For examples of service graph visualization in Grafana, see the screenshots in the X-RAG Observability Hackathon blog post.

    -X-RAG Observability Hackathon (includes service graph screenshots)
    +X-RAG Observability Hackathon (includes service graph screenshots)

    This visualization helps identify:
    +

    -

    Complete Observability Stack


    -
    -The f3s cluster now has complete observability:
    -
    -**Metrics** (Prometheus):
    -
    -**Logs** (Loki):
    -
    -**Traces** (Tempo):
    -
    -**Visualization** (Grafana):
    -

    Configuration Files



    All configuration files are available on Codeberg:
    @@ -5441,7 +5304,12 @@ kubectl exec -n monitoring <tempo-pod> -- df -h /var/tempo
    This observability stack runs entirely on the home lab infrastructure, with data persisted to the NFS share. It's lightweight enough for a three-node cluster but provides the same capabilities as production-grade setups.

    -prometheus configuration on Codeberg
    +All configuration files are available on Codeberg:
    +
    +Prometheus, Grafana, and recording rules configuration
    +Loki and Alloy configuration
    +Tempo configuration
    +Demo tracing application

    Other *BSD-related posts:

    diff --git a/gemfeed/f3s-kubernetes-with-freebsd-part-8/grafana-etcd-dashboard.png b/gemfeed/f3s-kubernetes-with-freebsd-part-8/grafana-etcd-dashboard.png new file mode 100644 index 00000000..e1d3100b Binary files /dev/null and b/gemfeed/f3s-kubernetes-with-freebsd-part-8/grafana-etcd-dashboard.png differ diff --git a/gemfeed/f3s-kubernetes-with-freebsd-part-8/grafana-zfs-arc-stats.png b/gemfeed/f3s-kubernetes-with-freebsd-part-8/grafana-zfs-arc-stats.png new file mode 100644 index 00000000..2609c477 Binary files /dev/null and b/gemfeed/f3s-kubernetes-with-freebsd-part-8/grafana-zfs-arc-stats.png differ diff --git a/gemfeed/f3s-kubernetes-with-freebsd-part-8/grafana-zfs-dashboard.png b/gemfeed/f3s-kubernetes-with-freebsd-part-8/grafana-zfs-dashboard.png new file mode 100644 index 00000000..7a427184 Binary files /dev/null and b/gemfeed/f3s-kubernetes-with-freebsd-part-8/grafana-zfs-dashboard.png differ diff --git a/gemfeed/f3s-kubernetes-with-freebsd-part-8/grafana-zfs-datasets.png b/gemfeed/f3s-kubernetes-with-freebsd-part-8/grafana-zfs-datasets.png new file mode 100644 index 00000000..47890a0c Binary files /dev/null and b/gemfeed/f3s-kubernetes-with-freebsd-part-8/grafana-zfs-datasets.png differ -- cgit v1.2.3