GithubHelp home page GithubHelp logo

tztztz2 / beyla Goto Github PK

View Code? Open in Web Editor NEW

This project forked from grafana/beyla

0.0 0.0 0.0 30.04 MB

eBPF-based autoinstrumentation of HTTP and HTTPS services

License: Apache License 2.0

Shell 0.07% JavaScript 0.02% Ruby 0.54% Python 0.02% C 87.30% Java 0.10% Go 11.22% C# 0.01% Rust 0.20% Makefile 0.22% HTML 0.01% Dockerfile 0.25% Jsonnet 0.05%

beyla's Introduction

Grafana Beyla logo

Grafana Beyla

eBPF-based auto-instrumentation of HTTP/HTTPS/GRPC Go services, as well as HTTP/HTTPS services written in other languages (intercepting Kernel-level socket operations as well as OpenSSL invocations).

Build Status

Getting Started

To try out Beyla, you need to run a network service for Beyla to instrument. Beyla supports a wide range of programming languages (Go, Java, .NET, NodeJS, Python, Ruby, Rust, etc.), so if you already have an example service you can use it. If you don't have an example, you can download and run example-http-service.go from the examples/ directory:

curl -OL https://raw.githubusercontent.com/grafana/beyla/main/examples/example-http-service/example-http-service.go
go run ./example-http-service.go

Next, generate some traffic. The following command will trigger a GET request to http://localhost:8080 every two seconds.

watch curl -s http://localhost:8080

Now that we have an example running, we are ready to download and run Beyla.

First, download and unpack the latest release from the Github releases page. The release should contain the ./beyla executable.

Beyla supports multiple ways to find the service to be instrumented (by network port, executable name, process ID), and multiple exposition formats (Prometheus, OpenTelemetry metrics, Single Span traces).

For getting started, we'll tell Beyla to instrument the service running on port 8080 (our example service) and expose metrics in Prometheus format on port 9400.

export BEYLA_PROMETHEUS_PORT=9400
export OPEN_PORT=8080
sudo -E ./beyla

Now, you should see metrics on http://localhost:9400/metrics.

See Documentation and the quickstart tutorial for more info.

Requirements

  • Linux with Kernel 4.18 or higher
  • eBPF enabled in the host
  • For instrumenting Go programs, they must have been compiled with Go 1.17 or higher
  • Administrative access to execute the instrumenter
    • Or execute it from a user enabling the SYS_ADMIN capability.
  • If you want to instrument HTTP calls at kernel-level (for other languages than Go), your Kernel needs to enable BTF (compiled with CONFIG_DEBUG_INFO_BTF)
Library Working
Kernel-level HTTP calls
OpenSSL library
Standard net/http
Gorilla Mux
Gin
gRPC-Go

Kubernetes

You can just trigger the Kubernetes descriptors in the deployments/ folder.

  1. Provide your Grafana credentials. Use the following K8s Secret template to introduce the endpoints, usernames and API keys for Mimir and Tempo:

    $ cp deployments/01-grafana-credentials.template.yml 01-grafana-credentials.yml
    $ # EDIT the fields
    $ vim 01-grafana-credentials.yml
    $ kubectl apply -f 01-grafana-credentials.yml 
    
  2. Deploy the Grafana Agent:

    kubectl apply -f deployments/02-grafana-agent.yml
    
  3. Deploy a demo app with the auto-instrumenter as a sidecar. You can use the blog example in the deployments/03-instrumented-app.yml file.

    $ kubectl apply -f ./deployments/03-instrumented-app.yml
    $ kubectl port-forward service/goblog 8443:8443
    

You should be able to query traces and metrics in your Grafana board.

Development recipes

How to regenerate the eBPF Kernel binaries

The eBPF program is embedded into the pkg/internal/ebpf/bpf_* generated files. This step is generally not needed unless you change the C code in the bpf folder.

If you have Docker installed, you just need to run:

make docker-generate

If you can't install docker, you should locally install the following required packages:

dnf install -y kernel-devel make llvm clang glibc-devel.i686
make generate

Tested in Fedora 35, 38 and Red Hat Enterprise Linux 8.

Credits

Part of the code is taken from: https://github.com/open-telemetry/opentelemetry-go-instrumentation

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.