ebpf-autoinstrument

module
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 21, 2023 License: Apache-2.0

README

eBPF autoinstrumenter

Build Status

eBPF-based autoinstrumentation 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).

Documentation.

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

How to setup a quick demo

We recommend you to follow our quickstart tutorial.

Optionally 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 Aent:

    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/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

Directories

Path Synopsis
cmd
otelauto command
configs
offsets command
docs
pkg
connector
Package connector provides tools for sharing the connection of diverse exporters (Prometheus, OTEL...) from different nodes
Package connector provides tools for sharing the connection of diverse exporters (Prometheus, OTEL...) from different nodes
exec
Package goexec provides the utilities to analyse the executable code
Package goexec provides the utilities to analyse the executable code
export/debug
Package debug provides some export nodes that are aimed basically at debugging/testing
Package debug provides some export nodes that are aimed basically at debugging/testing
goexec
Package goexec provides the utilities to analyse the executable code
Package goexec provides the utilities to analyse the executable code
imetrics
Package imetrics supports recording and submission of internal metrics from the autoinstrument
Package imetrics supports recording and submission of internal metrics from the autoinstrument
transform
Package transform provides some intermediate nodes that might filter/process/transform the events
Package transform provides some intermediate nodes that might filter/process/transform the events
test
cmd/grpc/client command
Package main implements a simple gRPC client that demonstrates how to use gRPC-Go libraries to perform unary, client streaming, server streaming and full duplex RPCs.
Package main implements a simple gRPC client that demonstrates how to use gRPC-Go libraries to perform unary, client streaming, server streaming and full duplex RPCs.
cmd/grpc/server command
Package main implements a simple gRPC server that demonstrates how to use gRPC-Go libraries to perform unary, client streaming, server streaming and full duplex RPCs.
Package main implements a simple gRPC server that demonstrates how to use gRPC-Go libraries to perform unary, client streaming, server streaming and full duplex RPCs.
cmd/pingserver command
cmd/pingwrapper command
collector
Package collector implements a test OTEL collector to use in unit tests
Package collector implements a test OTEL collector to use in unit tests
integration/components/docker
Package docker provides some helpers to manage docker-compose clusters from the test suites
Package docker provides some helpers to manage docker-compose clusters from the test suites
integration/components/jaeger
Package jaeger provides some convenience data structures for integration testing.
Package jaeger provides some convenience data structures for integration testing.
integration/components/prom
Package prom provides some convenience functions for prometheus handling in integration tests
Package prom provides some convenience functions for prometheus handling in integration tests
integration/components/testserver/grpc/client
Package main implements a simple gRPC client that demonstrates how to use gRPC-Go libraries to perform unary, client streaming, server streaming and full duplex RPCs.
Package main implements a simple gRPC client that demonstrates how to use gRPC-Go libraries to perform unary, client streaming, server streaming and full duplex RPCs.
integration/components/testserver/grpc/server
Package main implements a simple gRPC server that demonstrates how to use gRPC-Go libraries to perform unary, client streaming, server streaming and full duplex RPCs.
Package main implements a simple gRPC server that demonstrates how to use gRPC-Go libraries to perform unary, client streaming, server streaming and full duplex RPCs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL