# grafana/beyla architecture

> Architecture diagram of the GitHub repository grafana/beyla, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/grafana/beyla
- Repository: https://github.com/grafana/beyla

## Overview

a. Input Flow:
- Application Processes → Process Discovery
- Network Traffic → eBPF Probes
- Kubernetes API → Service Discovery

b. Processing Flow:
- eBPF Events → Protocol Analyzers
- Protocol Data → Data Transformers
- Transformed Data → Exporters

c. Output Flow:
- Metrics → Prometheus Endpoint
- Traces → OpenTelemetry Collector
- Kubernetes Metadata → Enrichment Pipeline

##### Key Architectural Elements

a. eBPF Subsystems:
- kprobes/uprobes Handlers
- Network Traffic Capture
- SSL/TLS Interception

b. Language-Specific Instrumentation:
- Go Runtime Integration
- Java/JVM Support
- Node.js/Python/Ruby Support

c. Security & Configuration:
- Privilege Management
- Configuration Management
- Resource Controls

##### External Integrations

a. Monitoring Systems:
- Grafana
- Prometheus
- Tempo (Traces)
- Mimir (Metrics)

b. Container Platforms:
- Kubernetes
- Docker
- Container Runtimes

##### Implementation Details

a. Core Libraries (show as modules):
- BPF Module (/bpf directory)
- Protocol Handlers (/pkg/internal/ebpf)
- Exporters (/pkg/export)

b. Support Systems:
- Configuration Management
- Logging & Debugging
- Health Monitoring

##### Deployment Contexts (show as separate zones)

a. Host Deployment:
- Direct Process Instrumentation
- System-wide Monitoring

b. Kubernetes Deployment:
- DaemonSet Mode
- Sidecar Mode
- Cache Service

##### The Kubernetes integration capabilities

Remember to:

- Keep the core eBPF functionality central
- Clear data flow paths
- Security boundaries
- Configuration points
- Version dependencies
- Scalability aspects

This design reflects Beyla's architecture as an advanced observability tool that leverages eBPF for automatic instrumentation while maintaining flexibility in deployment and export options.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Core ["Core Components"]
        direction TB
        ebpf["eBPF Instrumentation Engine"]:::core
        procdisc["Process Discovery & Attachment"]:::core
        netint["Network Traffic Interceptor"]:::core
        proto["Protocol Analyzers"]:::core
    end

    subgraph Pipeline ["Data Pipeline"]
        direction TB
        collect["Event Collectors"]:::pipeline
        transform["Data Transformers"]:::pipeline
        export["Exporters"]:::pipeline
    end

    subgraph Integration ["Integration Layer"]
        direction TB
        k8s["Kubernetes Integration"]:::integration
        container["Container Runtime"]:::integration
        svcdisc["Service Discovery"]:::integration
    end

    subgraph Protocols ["Protocol Support"]
        direction TB
        http["HTTP/HTTPS"]:::protocol
        http2["HTTP2/gRPC"]:::protocol
        redis["Redis"]:::protocol
        kafka["Kafka"]:::protocol
        sql["SQL"]:::protocol
    end

    subgraph External ["External Systems"]
        direction TB
        prom["Prometheus"]:::external
        otel["OpenTelemetry"]:::external
        grafana["Grafana"]:::external
        tempo["Tempo"]:::external
    end

    %% Core Relationships
    procdisc --> ebpf
    netint --> ebpf
    ebpf --> proto
    proto --> collect

    %% Pipeline Flow
    collect --> transform
    transform --> export
    export --> prom
    export --> otel

    %% Integration Connections
    k8s --> svcdisc
    container --> procdisc
    svcdisc --> transform

    %% Protocol Connections
    proto --> http
    proto --> http2
    proto --> redis
    proto --> kafka
    proto --> sql

    %% External Connections
    prom --> grafana
    otel --> tempo

    %% Click Events
    click ebpf "https://github.com/grafana/beyla/tree/main/bpf"
    click procdisc "https://github.com/grafana/beyla/tree/main/pkg/internal/discover"
    click netint "https://github.com/grafana/beyla/tree/main/pkg/internal/netolly"
    click proto "https://github.com/grafana/beyla/blob/main/bpf/http_types.h"
    click collect "https://github.com/grafana/beyla/blob/main/pkg/internal/ebpf/common/ringbuf.go"
    click transform "https://github.com/grafana/beyla/tree/main/pkg/transform"
    click export "https://github.com/grafana/beyla/tree/main/pkg/export"
    click k8s "https://github.com/grafana/beyla/tree/main/pkg/internal/kube"
    click container "https://github.com/grafana/beyla/tree/main/pkg/internal/helpers/container"
    click svcdisc "https://github.com/grafana/beyla/tree/main/pkg/services"

    %% Styling
    classDef core fill:#f9f,stroke:#333,stroke-width:2px
    classDef pipeline fill:#bbf,stroke:#333,stroke-width:2px
    classDef integration fill:#bfb,stroke:#333,stroke-width:2px
    classDef protocol fill:#ffb,stroke:#333,stroke-width:2px
    classDef external fill:#ddd,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        direction TB
        l1["Core Components"]:::core
        l2["Pipeline Components"]:::pipeline
        l3["Integration Components"]:::integration
        l4["Protocols"]:::protocol
        l5["External Systems"]:::external
    end
```
