Grafana Beyla Documentation

repository·main·Indexed 24 days ago

https://github.com/grafana/beyla

Grafana Beyla is an eBPF-based, zero-code auto-instrumentation tool providing OpenTelemetry and Prometheus observability (traces and metrics) without requiring code changes. It features a Kubernetes mutating admission webhook for automated instrumentation, support for various trace context propagators, and configurable sampling. The tool integrates with Grafana Alloy and provides monitoring mixins for dashboards and alerts.

Tokens
79.9K
Snippets
135
Records
276
Agent score
84%

What's inside Grafana Beyla

  1. What is Grafana Beyla?

    main

    Grafana Beyla is an eBPF-based application auto-instrumentation tool designed to provide application observability without modifying application code or configuration. It automatically inspects application executables and the OS networking layer to capture trace spans for web transactions and Rate, Errors, and Duration (RED) metrics for Linux HTTP/S and gRPC services.

    Key Features

    • Auto-instrumentation: Supports various languages including Go, C/C++, Rust, Python, Ruby, Java (including GraalVM Native), NodeJS, and .NET.
    • Low Overhead: Uses efficient eBPF-based data capture that runs outside the application process memory.
    • Vendor Agnostic: Exports data in OpenTelemetry format and as native Prometheus metrics.
    • Kubernetes Integration: Listens to the Kubernetes API to decorate metrics and traces with Pods and Services metadata.
    • Distributed Tracing: Supports distributed traces (available with Beyla 2).
    • Grafana Alloy Integration: Works with Grafana Alloy for telemetry pipelines.
  2. Configure Beyla service discovery

    main

    Beyla uses service discovery to identify which processes to instrument. For simple use cases, you can use environment variables like BEYLA_AUTO_TARGET_EXE or BEYLA_OPEN_PORT to target a single service or group of services.

    For more complex scenarios, such as running Beyla as a Kubernetes DaemonSet to instrument all services on a node, you can use the discovery YAML configuration section to define granular selection criteria. This allows you to specify exactly which services Beyla should target, which it should exclude, and how to override their reported names or namespaces.

  3. Choose a Beyla setup method

    main

    Beyla can be deployed in several ways depending on your environment and target application. Choose the method that matches your infrastructure:

    • Docker: Instrument a process running inside a container.
    • Kubernetes DaemonSet (Grafana Cloud): Use Helm to deploy as a DaemonSet specifically for Grafana Cloud.
    • Kubernetes DaemonSet (Kubernetes Monitoring Helm chart): Use the standard Kubernetes Monitoring Helm chart.
    • Kubernetes DaemonSet (Generic Helm): Use a standard Helm chart for Kubernetes DaemonSet deployment.
    • Kubernetes DaemonSet (Grafana Alloy Helm chart): Deploy as a DaemonSet using the Grafana Alloy Helm chart.
    • Kubernetes DaemonSet or Sidecar: Manual deployment as either a DaemonSet or a sidecar container.
    • Standalone Process: Run Beyla as a standalone process on bare metal, virtual machines, or for local development.
  4. Understand Beyla performance overhead

    main

    Beyla is designed to run alongside applications with minimal performance impact. The overhead varies depending on the features enabled.

    Key factors affecting overhead include:

    • Instrumentation Scope: Instrumenting all applications in a cluster increases CPU usage as Beyla processes more traffic.
    • Enabled Features: Enabling application_span, application_service_graph, or network monitoring increases both memory and CPU usage due to the generation of additional metrics and graph data.
    • Debug Mode: Setting log_level: debug and bpf_debug: true increases resource consumption because of increased logging and debug information generation.
    • Exporter Type: Using the OpenTelemetry metrics exporter vs. generating traces affects memory patterns (e.g., tracing may cause memory bursts during batching).
  5. Use Beyla monitoring mixins for Dashboards and Alerts

    main
    The Beyla monitoring mixins provide pre-configured Grafana Dashboards and Alerts specifically designed for Beyla. Use these mixins to visualize Beyla's telemetry and set up automated alerting for your monitoring stack.
  6. Handle missing system capabilities with enforce_sys_caps

    main

    The enforce_sys_caps property (or BEYLA_ENFORCE_SYS_CAPS environment variable) controls Beyla's behavior when required system capabilities are missing at startup.

    • false (default): Beyla logs the missing capabilities but continues startup.
    • true: Beyla aborts startup and logs the missing capabilities.
  7. How parent-based samplers work in Beyla

    main

    Parent-based samplers are composite samplers that adjust their behavior based on the existence of a parent span:

    1. If the span has no parent: The root sampler (the specific sampler configured) is used to make the sampling decision.
    2. If the span has a parent: The sampling decision follows the configuration of the parent.

    Available parent-based samplers include:

    • parentbased_always_on (Default)
    • parentbased_always_off
    • parentbased_traceidratio (Requires an arg value)
  8. Understand eBPF program overhead and latency

    main

    Beyla's eBPF programs run in kernel space and execute in the context of the application, which minimizes overhead by:

    • Avoiding user-space context-switching.
    • Utilizing Just-In-Time (JIT) compilation for optimization.

    To monitor the overhead of the eBPF programs themselves, you can use Beyla's ebpf feature to collect program latency. In benchmark tests (OpenTelemetry demo running for 24 hours), the combined latency of all probes was approximately 500ns per request, which is considered negligible.

  9. Use the direct image mount instrumentation mode (Kubernetes 1.31+)

    main
    For Kubernetes versions 1.31 and greater, Beyla can use the direct image mount mode. In this mode, Beyla is provided with the path to an injector image, which it then mounts as a read-only volume to each instrumented pod. The injector image is structured so that using copy-to-volume.sh or a direct mount results in the same folder structure, allowing these modes to be used interchangeably.
  10. Define URL path patterns for `http.route`

    main

    Use the patterns list to match URL paths and assign them a common http.route value. This helps group high-cardinality paths (like those containing IDs) into a single route.

    Matcher Formats

    • Tags: Use :name or {name} to identify segments that should be grouped. For example, /user/{id} will match /user/123 and /user/456, setting http.route to /user/{id}.
    • Wildcards: Use the * character to match path prefixes. For example, /user/* matches /user, /user/123, and /user/123/basket/1.

    Example:

    routes:
      patterns:
        - /user/{id}
        - /user/{id}/basket/{product}
  11. Beyla Webhook Limitations

    main

    When using the Beyla webhook, be aware of the following constraints:

    • Existing LD_PRELOAD: Pods that already have an LD_PRELOAD environment variable are skipped (unless the existing value is from a previous Beyla injection).
    • Host Access: Requires hostPath volume access to provide instrumentation libraries to containers.
    • TLS Timing: TLS certificates must be available before the server starts.
    • Export Protocol: Only supports the OTLP export protocol (via HTTP or gRPC).
  12. Configure Wake up length

    main

    The wakeup_len (or BEYLA_BPF_WAKEUP_LEN) setting determines how many messages Beyla accumulates in the eBPF ringbuffer before triggering a wake-up request to user space.

    • High-load services: Set this value higher to reduce CPU overhead by decreasing the frequency of wake-up requests.
    • Low-load services: Use lower values to ensure metrics are submitted and become visible more quickly, as high values can introduce delays.