The Problem: Observability Debt in Microservices
Picture your first month on a backend team. Your platform runs 14 microservices—some in Python, a few in Go, and a legacy Node.js service nobody wants to touch. One Tuesday afternoon, checkout latency spikes to 10 seconds. You open your monitoring dashboard and find nothing useful: CPU sits at 18%, memory is flat, and logs are scattered across containers.
Fixing a slowdown like that takes two things: metrics (request rates, errors, and latency) and distributed traces (the exact path a request takes across services). Normally, you have to import an OpenTelemetry SDK into every repo, write instrumentation code, open pull requests, rebuild images, and redeploy. If a service is a third-party binary or an unmaintained legacy app, you hit a wall.
Extracting reliable telemetry from running services without touching application code is a huge time-saver. That is where Grafana Beyla and eBPF come in.
Core Concepts: How Grafana Beyla and eBPF Work Together
Two building blocks power this setup: eBPF in the Linux kernel and Grafana Beyla in user space.
What Is eBPF?
eBPF (Extended Berkeley Packet Filter) runs small, sandboxed programs directly inside the Linux kernel. Instead of changing your app’s source code, eBPF hooks into kernel events like incoming HTTP traffic, socket reads, and TCP handshakes. The kernel verifier checks every program before it loads, so it cannot crash your host. Best of all, it typically adds less than 1–2% CPU overhead.
What Is Grafana Beyla?
Grafana Beyla is an open-source auto-instrumentation agent built on eBPF. You run it alongside your microservices as a separate process or sidecar container. Beyla watches network and system calls, then translates them into standard OpenTelemetry signals:
- RED Metrics: Request rate, error count, and duration histograms for HTTP and gRPC endpoints.
- Distributed Traces: End-to-end spans that follow requests as they hop between services.
Since Beyla operates at the OS level, it works across Go, Python, Java, Node.js, Rust, and even compiled C++ binaries. You do not add a single line of SDK code.
Hands-On Practice: Auto-Instrumenting a Microservice with Grafana Beyla
Let’s build a quick local lab. You will spin up a plain Python web server with zero telemetry libraries, attach Beyla to it, and inspect live metrics and traces.
Prerequisites
- A Linux host (or WSL2 on Windows) running kernel 5.8 or newer
- Docker and Docker Compose
curlfor sending test requests
Step 1: Create a Sample Microservice Without Telemetry
Start by creating a lab directory and a minimal Python HTTP server. Notice there are no OpenTelemetry or Prometheus imports anywhere in the script.
mkdir beyla-demo && cd beyla-demo
Save this code as app.py:
from http.server import BaseHTTPRequestHandler, HTTPServer
import time
class SimpleHandler(BaseHTTPRequestHandler):
def do_GET(self):
if self.path == "/slow":
time.sleep(0.4)
self.send_response(200)
self.end_headers()
self.wfile.write(b"Slow response completed\n")
elif self.path == "/error":
self.send_response(500)
self.end_headers()
self.wfile.write(b"Internal server error\n")
else:
self.send_response(200)
self.end_headers()
self.wfile.write(b"Hello from microservice\n")
if __name__ == "__main__":
server = HTTPServer(("0.0.0.0", 8080), SimpleHandler)
print("Server listening on port 8080...")
server.serve_forever()
Step 2: Configure Docker Compose with Grafana Beyla
Now add a docker-compose.yml file to run both your Python app and Beyla side by side. Pay attention to two settings on the beyla container:
pid: "service:sample-app"shares the Python container’s process namespace so eBPF can inspect its sockets.privileged: truegrants the permissions needed to load eBPF probes. In production Kubernetes clusters, swap this for narrower Linux capabilities likeCAP_BPFandCAP_SYS_ADMIN.
services:
sample-app:
image: python:3.12-slim
volumes:
- ./app.py:/app.py:ro
command: python3 /app.py
ports:
- "8080:8080"
beyla:
image: grafana/beyla:latest
pid: "service:sample-app"
privileged: true
environment:
BEYLA_OPEN_PORT: "8080"
BEYLA_SERVICE_NAME: "checkout-demo"
BEYLA_PROMETHEUS_PORT: "9090"
BEYLA_PRINT_TRACES: "true"
ports:
- "9090:9090"
depends_on:
- sample-app
Boot both containers in the background:
docker compose up -d
Step 3: Generate Traffic and Inspect Metrics and Traces
Hit the normal, slow, and error endpoints with three quick requests:
curl http://localhost:8080/
curl http://localhost:8080/slow
curl http://localhost:8080/error
Next, query the Prometheus metrics endpoint that Beyla exposes on port 9090:
curl -s http://localhost:9090/metrics | grep http_server_request_duration_seconds
You will get histogram buckets (such as le="0.5") and request counts broken down by method, route, and status code (200 vs. 500). Remember, app.py has zero Prometheus client code. To inspect the captured traces, check the container logs:
docker compose logs beyla
Each trace line prints the service name (checkout-demo), HTTP route, status code, and exact duration—including the 400ms delay on /slow.
Step 4: Export Telemetry to an OpenTelemetry Collector
Stdout works well for local debugging, but production setups need a central backend like Grafana Tempo or Jaeger. Switching to OTLP export takes one environment variable in your beyla service:
environment:
BEYLA_OPEN_PORT: "8080"
BEYLA_SERVICE_NAME: "checkout-demo"
OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector:4317"
With that single line, Beyla streams all metrics and traces over gRPC (port 4317) straight to your OpenTelemetry Collector.
Conclusion
You just pulled HTTP metrics and distributed traces from a running service without editing a single line of application code. Pairing Linux kernel eBPF probes with Grafana Beyla closes visibility gaps across polyglot services in five minutes instead of two-week sprints.
Keep one boundary in mind as you roll this out. eBPF excels at request-level visibility—latency, status codes, and service-to-service hops. Custom business context, like a user ID or shopping cart total, still belongs in manual OpenTelemetry spans. Deploy Beyla on a staging service first for instant baseline dashboards, then add manual instrumentation only where business logic demands it.

