From 179f5998c013b034d1cfd343cc96a70bc9d2e754 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 24 Dec 2025 00:43:11 +0200 Subject: Update content for html --- about/novels.html | 3 +- about/resources.html | 202 ++--- gemfeed/DRAFT-x-rag-observability-hackathon.html | 923 +++++++++++++++++++++ .../dashboard-pod-system-metrics.png | Bin 0 -> 914327 bytes .../dashboard-xrag-overview.png | Bin 0 -> 342684 bytes .../index-node-graph.png | Bin 0 -> 201872 bytes .../x-rag-observability-hackathon/index-trace.png | Bin 0 -> 236012 bytes .../search-node-graph.png | Bin 0 -> 186601 bytes .../x-rag-observability-hackathon/search-trace.png | Bin 0 -> 239660 bytes index.html | 2 +- notes/search-inside-yourself.gmi.tpl.lock | 0 uptime-stats.html | 140 ++-- 12 files changed, 1097 insertions(+), 173 deletions(-) create mode 100644 gemfeed/DRAFT-x-rag-observability-hackathon.html create mode 100644 gemfeed/x-rag-observability-hackathon/dashboard-pod-system-metrics.png create mode 100644 gemfeed/x-rag-observability-hackathon/dashboard-xrag-overview.png create mode 100644 gemfeed/x-rag-observability-hackathon/index-node-graph.png create mode 100644 gemfeed/x-rag-observability-hackathon/index-trace.png create mode 100644 gemfeed/x-rag-observability-hackathon/search-node-graph.png create mode 100644 gemfeed/x-rag-observability-hackathon/search-trace.png create mode 100644 notes/search-inside-yourself.gmi.tpl.lock diff --git a/about/novels.html b/about/novels.html index 93f9d696..5c4ee243 100644 --- a/about/novels.html +++ b/about/novels.html @@ -66,7 +66,8 @@ _-" . ' + . . ,//////0\ | /00HHHHHHHMMMMM
  • 2001 - Chasm City - Revelation Space Universe, Paperback
  • 2002 - Redemption Ark (english) / Die Arche (german) - Revelation Space Universe, Paperback
  • 2003 - Absolution Gap (english) / Offenbarung (german) - Revelation Space Universe, Paperback
  • -
  • 2005 - Diamond Dogs, Turquoise Days (english ) / Träume von Unendlichkeit (german) - Revelation Space Universe, Paperback
  • +
  • 2005 - Diamond Dogs, Turquoise Days (english) / Träume von Unendlichkeit (german) - Revelation Space Universe, Paperback
  • +
  • 2021 - Inhibitor Phase - Revelation Space Universe, Audiobook (Libro.fm)

  • Arthur C. Clarke



    diff --git a/about/resources.html b/about/resources.html index 4262f3ec..2b6f8c36 100644 --- a/about/resources.html +++ b/about/resources.html @@ -50,67 +50,67 @@ In random order:


    Technical references



    I didn't read them from the beginning to the end, but I am using them to look up things. The books are in random order:


    Self-development and soft-skills books


    @@ -118,44 +118,44 @@ In random order:


    Here are notes of mine for some of the books

    @@ -165,29 +165,29 @@

    Technical guides



    These are not whole books, but guides (smaller or larger) which I found very useful. in random order:


    Podcasts


    @@ -197,21 +197,21 @@ In random order:


    Podcasts I liked



    @@ -219,38 +219,38 @@

    Newsletters I like



    This is a mix of tech and non-tech newsletters I am subscribed to. In random order:


    Magazines I like(d)



    This is a mix of tech I like(d). I may not be a current subscriber, but now and then, I buy an issue. In random order:


    Formal education


    diff --git a/gemfeed/DRAFT-x-rag-observability-hackathon.html b/gemfeed/DRAFT-x-rag-observability-hackathon.html new file mode 100644 index 00000000..cffd81b1 --- /dev/null +++ b/gemfeed/DRAFT-x-rag-observability-hackathon.html @@ -0,0 +1,923 @@ + + + + +Adding Observability to X-RAG + + + + + +

    +Home | Markdown | Gemini +

    +

    Adding Observability to X-RAG


    +
    +This blog post describes my hackathon efforts adding observability to X-RAG, a distributed Retrieval-Augmented Generation (RAG) platform built by my brother Florian. I especially made time available over the weekend to join his 3-day hackathon (attending 2 days) with the goal of instrumenting his existing distributed system with observability. What started as "let's add some metrics" turned into a comprehensive implementation of the three pillars of observability: tracing, metrics, and logs.
    +
    +X-RAG source code on GitHub
    +
    +

    Table of Contents


    +
    +
    +

    What is X-RAG?


    +
    +X-RAG is a distributed RAG (Retrieval-Augmented Generation) platform running on Kubernetes. The idea behind RAG is simple: instead of asking an LLM to answer questions from its training data alone, you first retrieve relevant documents from your own knowledge base, then feed those documents to the LLM as context. The LLM synthesises an answer grounded in your actual content—reducing hallucinations and enabling answers about private or recent information the model was never trained on.
    +
    +X-RAG handles the full pipeline: ingest documents, chunk them into searchable pieces, generate vector embeddings, store them in a vector database, and at query time, retrieve relevant chunks and pass them to an LLM for answer generation. The system supports both local LLMs (Florian runs his on a beefy desktop) and cloud APIs like OpenAI. I configured an OpenAI API key since my laptop's CPU and GPU aren't fast enough for decent local inference.
    +
    +All services are implemented in Python. I'm more used to Ruby, Go, and Bash these days, but for this project it didn't matter—Python's OpenTelemetry integration is straightforward, I wasn't planning to write or rewrite tons of application code, and with GenAI assistance the language barrier was a non-issue. The OpenTelemetry concepts and patterns should translate to other languages too—the SDK APIs are intentionally similar across Python, Go, Java, and others.
    +
    +X-RAG consists of several independently scalable microservices:
    +
    +
    +The Embedding Service deserves extra explanation because in the beginning I didn't really knew what it was. Text isn't directly searchable in a vector database—you need to convert it to numerical vectors (embeddings) that capture semantic meaning. The Embedding Service takes text chunks and calls an embedding model (OpenAI's text-embedding-3-small in my case, or a local model on Florian's setup) to produce these vectors. For the LLM search completion answer, I used gpt-4o-mini.
    +
    +Similar concepts end up with similar vectors, so "What is machine learning?" and "Explain ML" produce vectors close together in the embedding space. At query time, your question gets embedded too, and the vector database finds chunks with nearby vectors—that's semantic search.
    +
    +The data layer includes Weaviate (vector database with hybrid search), Kafka (message queue), MinIO (object storage), and Redis (cache). All of this runs in a Kind Kubernetes cluster for local development, with the same manifests deployable to production.
    +
    +
    +┌─────────────────────────────────────────────────────────────────────────┐
    +│                      X-RAG Kubernetes Cluster                            │
    +├─────────────────────────────────────────────────────────────────────────┤
    +│   ┌─────────────┐  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐    │
    +│   │ Search UI   │  │Search Svc   │  │Embed Service│  │   Indexer   │    │
    +│   └──────┬──────┘  └──────┬──────┘  └──────┬──────┘  └──────┬──────┘    │
    +│          │                │                │                │           │
    +│          └────────────────┴────────────────┴────────────────┘           │
    +│                                    │                                     │
    +│                                    ▼                                     │
    +│          ┌─────────────┐  ┌─────────────┐  ┌─────────────┐              │
    +│          │  Weaviate   │  │   Kafka     │  │   MinIO     │              │
    +│          └─────────────┘  └─────────────┘  └─────────────┘              │
    +└─────────────────────────────────────────────────────────────────────────┘
    +
    +
    +

    Running Kubernetes locally with Kind


    +
    +X-RAG runs on Kubernetes, but you don't need a cloud account to develop it. The project uses Kind (Kubernetes in Docker)—a tool originally created by the Kubernetes SIG for testing Kubernetes itself.
    +
    +Kind - Kubernetes in Docker
    +
    +Kind spins up a full Kubernetes cluster using Docker containers as nodes. The control plane (API server, etcd, scheduler, controller-manager) runs in one container, and worker nodes run in separate containers. Inside these "node containers," pods run just like they would on real servers—using containerd as the container runtime. It's containers all the way down.
    +
    +Technically, each Kind node is a Docker container running a minimal Linux image with kubelet and containerd installed. When you deploy a pod, kubelet inside the node container instructs containerd to pull and run the container image. So you have Docker running node containers, and inside those, containerd running application containers. Network-wise, Kind sets up a Docker bridge network and uses CNI plugins (kindnet by default) for pod networking within the cluster.
    +
    +
    +$ docker ps --format "table {{.Names}}\t{{.Image}}"
    +NAMES                  IMAGE
    +xrag-k8-control-plane  kindest/node:v1.32.0
    +xrag-k8-worker         kindest/node:v1.32.0
    +xrag-k8-worker2        kindest/node:v1.32.0
    +
    +
    +The kindest/node image contains everything needed: kubelet, containerd, CNI plugins, and pre-pulled pause containers. Port mappings in the Kind config expose services to the host—that's how http://localhost:8080 reaches the search-ui running inside a pod, inside a worker container, inside Docker.
    +
    +
    +┌─────────────────────────────────────────────────────────────────────────┐
    +│                           Docker Host                                    │
    +├─────────────────────────────────────────────────────────────────────────┤
    +│  ┌───────────────────┐  ┌───────────────────┐  ┌───────────────────┐    │
    +│  │ xrag-k8-control   │  │ xrag-k8-worker    │  │ xrag-k8-worker2   │    │
    +│  │ -plane (container)│  │ (container)       │  │ (container)       │    │
    +│  │                   │  │                   │  │                   │    │
    +│  │ K8s API server    │  │ Pods:             │  │ Pods:             │    │
    +│  │ etcd, scheduler   │  │ • search-ui       │  │ • weaviate        │    │
    +│  │                   │  │ • search-service  │  │ • kafka           │    │
    +│  │                   │  │ • embedding-svc   │  │ • prometheus      │    │
    +│  │                   │  │ • indexer         │  │ • grafana         │    │
    +│  └───────────────────┘  └───────────────────┘  └───────────────────┘    │
    +└─────────────────────────────────────────────────────────────────────────┘
    +
    +
    +Why Kind? It gives you a real Kubernetes environment—the same manifests deploy to production clouds unchanged. No minikube quirks, no Docker Compose translation layer. Just Kubernetes. I already have a k3s cluster running at home, but Kind made collaboration easier—everyone working on X-RAG gets the exact same setup by cloning the repo and running make cluster-start.
    +
    +Florian developed X-RAG on macOS, but it worked seamlessly on my Linux laptop. The only difference was Docker's resource allocation: on macOS you configure limits in Docker Desktop, on Linux it uses host resources directly. That's because under macOS the Linux Docker containers run on an emulation layer as macOS is not Linux.
    +
    +My hardware: a ThinkPad X1 Carbon Gen 9 with an 11th Gen Intel Core i7-1185G7 (4 cores, 8 threads at 3.00GHz) and 32GB RAM (running Fedora Linux). During the hackathon, memory usage peaked around 15GB—comfortable headroom. CPU was the bottleneck; with ~38 pods running across all namespaces (rag-system, monitoring, kube-system, etc.), plus Discord for the remote video call and Tidal streaming hi-res music, things got tight. When rebuilding Docker images or restarting the cluster, Discord video and audio would stutter—my fellow hackers probably wondered why I kept freezing mid-sentence. A beefier CPU would have meant less waiting and smoother calls, but it was manageable.
    +
    +

    Motivation


    +
    +When I joined the hackathon, Florian's X-RAG was functional but opaque. With five services communicating via gRPC, Kafka, and HTTP, debugging was cumbersome. When a search request take 5 seconds, there was no visibility into where the time was being spent. Was it the embedding generation? The vector search? The LLM synthesis? Nobody would be able to figure it out quickly.
    +
    +Distributed systems are inherently opaque. Each service logs its own view of the world, but correlating events across service boundaries is archaeology. Grepping through logs on many pods, trying to mentally reconstruct what happened—not fun. This was the perfect hackathon project: Explore this Observability Stack in greater depth.
    +
    +

    The observability stack


    +
    +Before diving into implementation, here's what I deployed. The complete stack runs in the monitoring namespace:
    +
    +
    +$ kubectl get pods -n monitoring
    +NAME                                  READY   STATUS
    +alloy-84ddf4cd8c-7phjp                1/1     Running
    +grafana-6fcc89b4d6-pnh8l              1/1     Running
    +kube-state-metrics-5d954c569f-2r45n   1/1     Running
    +loki-8c9bbf744-sc2p5                  1/1     Running
    +node-exporter-kb8zz                   1/1     Running
    +node-exporter-zcrdz                   1/1     Running
    +node-exporter-zmskc                   1/1     Running
    +prometheus-7f755f675-dqcht            1/1     Running
    +tempo-55df7dbcdd-t8fg9                1/1     Running
    +
    +
    +Each component has a specific role:
    +
    +
    +Everything is accessible via port-forwards:
    +
    +
    +

    Grafana Alloy: the unified collector


    +
    +Before diving into the individual signals, I want to highlight Grafana Alloy—the component that ties everything together. Alloy is Grafana's vendor-neutral OpenTelemetry Collector distribution, and it became the backbone of the observability stack.
    +
    +Grafana Alloy documentation
    +
    +Why use a centralised collector instead of having each service push directly to backends?
    +
    +
    +Alloy uses a configuration language called River, which feels similar to Terraform's HCL—declarative blocks with attributes. If you've written Terraform, River will look familiar. The full Alloy configuration runs to over 1400 lines with comments explaining each section. It handles OTLP receiving, batch processing, Prometheus export, Tempo export, Kubernetes metrics scraping, infrastructure metrics, and pod log collection. All three signals—metrics, traces, logs—flow through this single component, making Alloy the central nervous system of the observability stack.
    +
    +In the following sections, I'll cover each observability pillar and show the relevant Alloy configuration for each.
    +
    +

    Centralised logging with Loki


    +
    +Getting all logs in one place was the foundation. I deployed Grafana Loki in the monitoring namespace, with Grafana Alloy running as a DaemonSet on each node to collect logs.
    +
    +
    +┌──────────────────────────────────────────────────────────────────────┐
    +│                           LOGS PIPELINE                               │
    +├──────────────────────────────────────────────────────────────────────┤
    +│  Applications write to stdout → containerd stores in /var/log/pods   │
    +│                                    │                                  │
    +│                              File tail                                │
    +│                                    ▼                                  │
    +│                         Grafana Alloy (DaemonSet)                     │
    +│                    Discovers pods, extracts metadata                  │
    +│                                    │                                  │
    +│                       HTTP POST /loki/api/v1/push                     │
    +│                                    ▼                                  │
    +│                           Grafana Loki                                │
    +│                   Indexes labels, stores chunks                       │
    +└──────────────────────────────────────────────────────────────────────┘
    +
    +
    +

    Alloy configuration for logs


    +
    +Alloy discovers pods via the Kubernetes API, tails their log files from /var/log/pods/, and ships to Loki. Importantly, Alloy runs as a DaemonSet on each worker node—it doesn't run inside the application pods. Since containerd writes all container stdout/stderr to /var/log/pods/ on the node's filesystem, Alloy can tail logs for every pod on that node from a single location without any sidecar injection:
    +
    +
    +loki.source.kubernetes "pod_logs" {
    +  targets    = discovery.relabel.pod_logs.output
    +  forward_to = [loki.process.pod_logs.receiver]
    +}
    +
    +loki.write "default" {
    +  endpoint {
    +    url = "http://loki.monitoring.svc.cluster.local:3100/loki/api/v1/push"
    +  }
    +}
    +
    +
    +

    Querying logs with LogQL


    +
    +Now I could query logs in Loki (e.g. via Grafana UI) with LogQL:
    +
    +
    +{namespace="rag-system", container="search-ui"} |= "ERROR"
    +
    +
    +

    Metrics with Prometheus


    +
    +I added Prometheus metrics to every service. Following the Four Golden Signals (latency, traffic, errors, saturation), I instrumented the codebase with histograms, counters, and gauges:
    +
    + +
    from prometheus_client import Histogram, Counter, Gauge
    +
    +search_duration = Histogram(
    +    "search_service_request_duration_seconds",
    +    "Total duration of Search Service requests",
    +    ["method"],
    +    buckets=[0.1, 0.25, 0.5, 1.0, 2.5, 5.0, 10.0, 20.0, 30.0, 60.0],
    +)
    +
    +errors_total = Counter(
    +    "search_service_errors_total",
    +    "Error count by type",
    +    ["method", "error_type"],
    +)
    +
    +
    +Initially, I used Prometheus scraping—each service exposed a /metrics endpoint, and Prometheus pulled metrics every 15 seconds. This worked, but I wanted a unified pipeline.
    +
    +

    Alloy configuration for application metrics


    +
    +The breakthrough came with Grafana Alloy as an OpenTelemetry collector. Services now push metrics via OTLP (OpenTelemetry Protocol), and Alloy converts them to Prometheus format:
    +
    +
    +┌─────────────┐  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐
    +│ search-ui   │  │search-svc   │  │embed-svc    │  │  indexer    │
    +│ OTel Meter  │  │ OTel Meter  │  │ OTel Meter  │  │ OTel Meter  │
    +│      │      │  │      │      │  │      │      │  │      │      │
    +│ OTLPExporter│  │ OTLPExporter│  │ OTLPExporter│  │ OTLPExporter│
    +└──────┬──────┘  └──────┬──────┘  └──────┬──────┘  └──────┬──────┘
    +       │                │                │                │
    +       └────────────────┴────────────────┴────────────────┘
    +                                 │
    +                                 ▼ OTLP/gRPC (port 4317)
    +                        ┌─────────────────────┐
    +                        │   Grafana Alloy     │
    +                        └──────────┬──────────┘
    +                                   │ prometheus.remote_write
    +                                   ▼
    +                        ┌─────────────────────┐
    +                        │    Prometheus       │
    +                        └─────────────────────┘
    +
    +
    +Alloy receives OTLP on ports 4317 (gRPC) or 4318 (HTTP), batches the data for efficiency, and exports to Prometheus:
    +
    +
    +otelcol.receiver.otlp "default" {
    +  grpc { endpoint = "0.0.0.0:4317" }
    +  http { endpoint = "0.0.0.0:4318" }
    +  output {
    +    metrics = [otelcol.processor.batch.metrics.input]
    +    traces  = [otelcol.processor.batch.traces.input]
    +  }
    +}
    +
    +otelcol.processor.batch "metrics" {
    +  timeout = "5s"
    +  send_batch_size = 1000
    +  output { metrics = [otelcol.exporter.prometheus.default.input] }
    +}
    +
    +otelcol.exporter.prometheus "default" {
    +  forward_to = [prometheus.remote_write.prom.receiver]
    +}
    +
    +
    +Instead of sending each metric individually, Alloy accumulates up to 1000 metrics (or waits 5 seconds) before flushing. This reduces network overhead and protects backends from being overwhelmed.
    +
    +

    Kubernetes metrics: kubelet, cAdvisor, and kube-state-metrics


    +
    +Alloy also pulls metrics from Kubernetes itself—kubelet resource metrics, cAdvisor container metrics, and kube-state-metrics for cluster state.
    +
    +Why three separate sources? It does feel fragmented, but each serves a distinct purpose. kubelet exposes resource metrics about pod CPU and memory usage from its own bookkeeping—lightweight summaries of what's running on each node. cAdvisor (Container Advisor) runs inside kubelet and provides detailed container-level metrics: CPU throttling, memory working sets, filesystem I/O, network bytes. These are the raw runtime stats from containerd. kube-state-metrics is different—it doesn't measure resource usage at all. Instead, it queries the Kubernetes API and exposes the *desired state*: how many replicas a Deployment wants, whether a Pod is pending or running, what resource requests and limits are configured. You need all three because "container used 500MB" (cAdvisor), "pod requested 1GB" (kube-state-metrics), and "node has 4GB available" (kubelet) are complementary views. The fragmentation is a consequence of Kubernetes' architecture—no single component has the complete picture.
    +
    +None of these components speak OpenTelemetry—they all expose Prometheus-format metrics via HTTP endpoints. That's why Alloy uses prometheus.scrape instead of receiving OTLP pushes. Alloy handles both worlds: OTLP from our applications, Prometheus scraping for infrastructure.
    +
    +
    +prometheus.scrape "kubelet_resource" {
    +  targets         = discovery.relabel.kubelet.output
    +  job_name        = "kubelet-resource"
    +  scheme          = "https"
    +  scrape_interval = "30s"
    +  bearer_token_file = "/var/run/secrets/kubernetes.io/serviceaccount/token"
    +  tls_config { insecure_skip_verify = true }
    +  forward_to      = [prometheus.remote_write.prom.receiver]
    +}
    +
    +prometheus.scrape "cadvisor" {
    +  targets         = discovery.relabel.cadvisor.output
    +  job_name        = "cadvisor"
    +  scheme          = "https"
    +  scrape_interval = "60s"
    +  bearer_token_file = "/var/run/secrets/kubernetes.io/serviceaccount/token"
    +  tls_config { insecure_skip_verify = true }
    +  forward_to      = [prometheus.relabel.cadvisor_filter.receiver]
    +}
    +
    +prometheus.scrape "kube_state_metrics" {
    +  targets = [
    +    {"__address__" = "kube-state-metrics.monitoring.svc.cluster.local:8080"},
    +  ]
    +  job_name        = "kube-state-metrics"
    +  scrape_interval = "30s"
    +  forward_to      = [prometheus.relabel.kube_state_filter.receiver]
    +}
    +
    +
    +Note that kubelet and cAdvisor require HTTPS with bearer token authentication (using the service account token mounted by Kubernetes), while kube-state-metrics is a simple HTTP target. cAdvisor is scraped less frequently (60s) because it returns many more metrics with higher cardinality.
    +
    +

    Infrastructure metrics: Kafka, Redis, MinIO


    +
    +Application metrics weren't enough. I also needed visibility into the data layer. Each infrastructure component has a specific role in X-RAG and got its own exporter:
    +
    +Redis is the caching layer. It stores search results and embeddings to avoid redundant API calls to OpenAI. We collect 25 metrics via oliver006/redis_exporter running as a sidecar, including cache hit/miss rates, memory usage, connected clients, and command latencies. The key metric? redis_keyspace_hits_total / (redis_keyspace_hits_total + redis_keyspace_misses_total) tells you if caching is actually helping.
    +
    +Kafka is the message queue connecting the ingestion API to the indexer. Documents are published to a topic, and the indexer consumes them asynchronously. We collect 12 metrics via danielqsj/kafka-exporter, with consumer lag being the most critical—it shows how far behind the indexer is. High lag means documents aren't being indexed fast enough.
    +
    +MinIO is the S3-compatible object storage where raw documents are stored before processing. We collect 16 metrics from its native /minio/v2/metrics/cluster endpoint, covering request rates, error counts, storage usage, and cluster health.
    +
    +You can verify these counts by querying Prometheus directly:
    +
    +
    +$ curl -s 'http://localhost:9090/api/v1/label/__name__/values' \
    +    | jq -r '.data[]' | grep -c '^redis_'
    +25
    +$ curl -s 'http://localhost:9090/api/v1/label/__name__/values' \
    +    | jq -r '.data[]' | grep -c '^kafka_'
    +12
    +$ curl -s 'http://localhost:9090/api/v1/label/__name__/values' \
    +    | jq -r '.data[]' | grep -c '^minio_'
    +16
    +
    +
    +Full Alloy configuration with detailed metric filtering
    +
    +Alloy scrapes all of these and remote-writes to Prometheus:
    +
    +
    +prometheus.scrape "redis_exporter" {
    +  targets = [
    +    {"__address__" = "xrag-redis.rag-system.svc.cluster.local:9121"},
    +  ]
    +  job_name        = "redis"
    +  scrape_interval = "30s"
    +  forward_to      = [prometheus.relabel.redis_filter.receiver]
    +}
    +
    +prometheus.scrape "kafka_exporter" {
    +  targets = [
    +    {"__address__" = "kafka-exporter.rag-system.svc.cluster.local:9308"},
    +  ]
    +  job_name        = "kafka"
    +  scrape_interval = "30s"
    +  forward_to      = [prometheus.relabel.kafka_filter.receiver]
    +}
    +
    +prometheus.scrape "minio" {
    +  targets = [
    +    {"__address__" = "xrag-minio.rag-system.svc.cluster.local:9000"},
    +  ]
    +  job_name     = "minio"
    +  metrics_path = "/minio/v2/metrics/cluster"
    +  scrape_interval = "30s"
    +  forward_to   = [prometheus.relabel.minio_filter.receiver]
    +}
    +
    +
    +Note that MinIO exposes metrics at a custom path (/minio/v2/metrics/cluster) rather than the default /metrics. Each exporter forwards to a relabel component that filters down to essential metrics before sending to Prometheus.
    +
    +With all metrics in Prometheus, I can use PromQL queries in Grafana dashboards. For example, to check Kafka consumer lag and see if the indexer is falling behind:
    +
    +
    +sum by (consumergroup, topic) (kafka_consumergroup_lag)
    +
    +
    +Or check Redis cache effectiveness:
    +
    +
    +redis_keyspace_hits_total / (redis_keyspace_hits_total + redis_keyspace_misses_total)
    +
    +
    +

    Distributed tracing with Tempo


    +
    +

    Understanding traces, spans, and the trace tree


    +
    +Before diving into the implementation, let me explain the core concepts I learned. A trace represents a single request's journey through the entire distributed system. Think of it as a receipt that follows your request from the moment it enters the system until the final response.
    +
    +Each trace is identified by a trace ID—a 128-bit identifier (32 hex characters) that stays constant across all services. When I make a search request, every service handling that request uses the same trace ID: 9df981cac91857b228eca42b501c98c6.
    +
    +Quick video explaining the difference between trace IDs and span IDs in OpenTelemetry
    +
    +Within a trace, individual operations are recorded as spans. A span has:
    +
    +
    +The first span in a trace is the root span—it has no parent. When the root span calls another service, that service creates a child span with the root's span ID as its parent. This parent-child relationship forms a tree structure:
    +
    +
    +                        ┌─────────────────────────┐
    +                        │      Root Span          │
    +                        │  POST /api/search       │
    +                        │  span_id: a1b2c3d4...   │
    +                        │  parent: (none)         │
    +                        └───────────┬─────────────┘
    +                                    │
    +              ┌─────────────────────┴─────────────────────┐
    +              │                                           │
    +              ▼                                           ▼
    +┌─────────────────────────┐             ┌─────────────────────────┐
    +│      Child Span         │             │      Child Span         │
    +│  gRPC Search            │             │  render_template        │
    +│  span_id: e5f6g7h8...   │             │  span_id: i9j0k1l2...   │
    +│  parent: a1b2c3d4...    │             │  parent: a1b2c3d4...    │
    +└───────────┬─────────────┘             └─────────────────────────┘
    +            │
    +            ├──────────────────┬──────────────────┐
    +            ▼                  ▼                  ▼
    +     ┌────────────┐     ┌────────────┐     ┌────────────┐
    +     │ Grandchild │     │ Grandchild │     │ Grandchild │
    +     │ embedding  │     │ vector     │     │ llm.rag    │
    +     │ .generate  │     │ _search    │     │ _completion│
    +     └────────────┘     └────────────┘     └────────────┘
    +
    +
    +This tree structure answers the critical question: "What called what?" When I see a slow span, I can trace up to see what triggered it and down to see what it's waiting on.
    +
    +

    How trace context propagates


    +
    +The magic that links spans across services is trace context propagation. When Service A calls Service B, it must pass along the trace ID and its own span ID (which becomes the parent). OpenTelemetry uses the W3C traceparent header:
    +
    +
    +traceparent: 00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01
    +             │   │                                │                 │
    +             │   │                                │                 └── flags
    +             │   │                                └── parent span ID (16 hex)
    +             │   └── trace ID (32 hex)
    +             └── version
    +
    +
    +For HTTP, this travels as a request header. For gRPC, it's passed as metadata. For Kafka, it's embedded in message headers. The receiving service extracts this context, creates a new span with the propagated trace ID and the caller's span ID as parent, then continues the chain.
    +
    +This is why all my spans link together—OpenTelemetry's auto-instrumentation handles propagation automatically for HTTP, gRPC, and Kafka clients.
    +
    +

    Implementation


    +
    +This is where distributed tracing made the difference. I integrated OpenTelemetry auto-instrumentation for FastAPI, gRPC, and HTTP clients, plus manual spans for RAG-specific operations:
    +
    + +
    from opentelemetry.instrumentation.fastapi import FastAPIInstrumentor
    +from opentelemetry.instrumentation.grpc import GrpcAioInstrumentorClient
    +
    +# Auto-instrument frameworks
    +FastAPIInstrumentor.instrument_app(app)
    +GrpcAioInstrumentorClient().instrument()
    +
    +# Manual spans for custom operations
    +with tracer.start_as_current_span("llm.rag_completion") as span:
    +    span.set_attribute("llm.model", model_name)
    +    result = await generate_answer(query, context)
    +
    +
    +Auto-instrumentation is the quick win: one line of code and you get spans for every HTTP request, gRPC call, or database query. The instrumentor patches the framework at runtime, so existing code works without modification. The downside? You only get what the library authors decided to capture—generic HTTP attributes like http.method and http.status_code, but nothing domain-specific. Auto-instrumented spans also can't know your business logic, so a slow request shows up as "POST /api/search took 5 seconds" without