Run Beyla on a Linux host
You can run Grafana Beyla as a process on a Linux host, such as a virtual machine or a bare-metal server. Beyla runs with elevated privileges and instruments services that run on the same host, without changes to the services. The steps are the same for services written in any language that Beyla supports.
Before you begin
Before you run Beyla, make sure you have the following:
- A Linux host on
amd64orarm64, with a kernel that meets the Beyla requirements and limitations - Root access with
sudo, or the Linux capabilities listed in Beyla security, permissions, and capabilities - A service on the host that listens on a TCP port, for example an HTTP, HTTPS, or gRPC service
Start an example service
To try Beyla before you instrument your own service, start one of the example services from the examples/quickstart directory of the Beyla repository.
Each example is an HTTP service that listens on port 8080.
If you instrument your own service, skip this section.
For example, to download and start the Go example:
curl -OL https://raw.githubusercontent.com/grafana/beyla/main/examples/quickstart/golang/quickstart.go
go run quickstart.goDownload and install Beyla
Beyla releases include a Linux binary for amd64 and arm64.
Download the archive for your host from the Beyla releases page:
curl -LO https://github.com/grafana/beyla/releases/download/<VERSION>/beyla-linux-<ARCH>-<VERSION>.tar.gzReplace the following:
<VERSION>: The Beyla release tag, for examplev3.40.0<ARCH>: The host architecture,amd64orarm64
Extract the
beylabinary and install it in/usr/local/bin:tar -xzf beyla-linux-<ARCH>-<VERSION>.tar.gz beyla sudo install beyla /usr/local/bin/
Run Beyla
Beyla needs a way to select the process to instrument, and at least one exporter.
The following commands instrument the process that opens port 8080 and print traces to standard output, so you don’t need a backend:
export BEYLA_OPEN_PORT=8080
export BEYLA_TRACE_PRINTER=text
sudo -E beylaThe commands set these environment variables:
The -E option of sudo passes the exported variables to Beyla.
You can also set options in a YAML configuration file.
Pass the file with the -config argument or the BEYLA_CONFIG_PATH environment variable.
If you set an option in both the file and an environment variable, the environment variable takes precedence.
Check that Beyla instruments the service
Send a request to the service:
curl http://localhost:8080/fooBeyla prints one line for each request it captures. Each line includes the start time and duration of the request, the protocol, the response status code, the HTTP method and path, the route, the source and destination addresses, the request and response sizes, the service name, and the trace context.
Send data to a backend
The trace printer is for testing.
To send data to a backend, unset BEYLA_TRACE_PRINTER and set exporter options instead.
To send metrics and traces to an OpenTelemetry endpoint, such as Grafana Cloud, set the OTLP environment variables:
unset BEYLA_TRACE_PRINTER
export BEYLA_OPEN_PORT=<SERVICE_PORT>
export OTEL_EXPORTER_OTLP_PROTOCOL="http/protobuf"
export OTEL_EXPORTER_OTLP_ENDPOINT="<OTLP_ENDPOINT>"
export OTEL_EXPORTER_OTLP_HEADERS="<OTLP_HEADERS>"
sudo -E beylaReplace the following:
<SERVICE_PORT>: The port your service opens<OTLP_ENDPOINT>: The URL of your OTLP endpoint. For Grafana Cloud, copy the endpoint from the OpenTelemetry tile of your stack.<OTLP_HEADERS>: The headers your endpoint needs, such as authentication, as comma-separatedkey=valuepairs. For Grafana Cloud, copy theOTEL_EXPORTER_OTLP_HEADERSvalue that the OpenTelemetry tile generates.
For Grafana Cloud, follow the procedure in Send data to the Grafana Cloud OTLP endpoint.
To expose metrics for Prometheus to scrape, set the Prometheus port:
unset BEYLA_TRACE_PRINTER
export BEYLA_OPEN_PORT=<SERVICE_PORT>
export BEYLA_PROMETHEUS_PORT=8999
sudo -E beylaReplace <SERVICE_PORT> with the port your service opens.
Beyla serves the metrics at http://localhost:8999/metrics.
For all export options, refer to Configure Beyla Prometheus and OpenTelemetry data export.
Run Beyla as a systemd service
To keep Beyla running and start it when the host boots, run Beyla as a systemd service.
The Beyla repository includes a systemd unit file.
The unit runs /usr/local/bin/beyla as root, reads environment variables from /etc/beyla/beyla.env, and loads the configuration file /etc/beyla/beyla.yaml.
Create the configuration directory:
sudo mkdir -p /etc/beylaCreate
/etc/beyla/beyla.yamlto select the service to instrument:discovery: instrument: - open_ports: <SERVICE_PORT>Replace
<SERVICE_PORT>with the port your service opens.Create
/etc/beyla/beyla.envwith the exporter settings:OTEL_EXPORTER_OTLP_PROTOCOL="http/protobuf" OTEL_EXPORTER_OTLP_ENDPOINT="<OTLP_ENDPOINT>" OTEL_EXPORTER_OTLP_HEADERS="<OTLP_HEADERS>"Replace
<OTLP_ENDPOINT>and<OTLP_HEADERS>with the values from Send data to a backend. The unit fails to start if this file doesn’t exist, so create it even if you set the exporters inbeyla.yaml.Download the unit file to
/etc/systemd/system/beyla.service:sudo curl -L -o /etc/systemd/system/beyla.service https://raw.githubusercontent.com/grafana/beyla/main/contrib/beyla.serviceReload systemd, then start Beyla and turn it on at boot:
sudo systemctl daemon-reload sudo systemctl enable --now beylaCheck that Beyla is running:
systemctl status beylaTo read the Beyla logs, run
journalctl -u beyla.