From 2a5433b58aa4001d422d4c77c4478defa9c06d61 Mon Sep 17 00:00:00 2001 From: Matthew Macdonald-Wallace Date: Fri, 17 Nov 2023 15:43:23 +0000 Subject: [PATCH] Add systemd service file and related docs (#448) --- contrib/beyla@.service | 17 +++++++++++++++++ contrib/example-service.env | 1 + contrib/example-service.yaml | 17 +++++++++++++++++ docs/sources/setup/standalone.md | 13 +++++++++++++ 4 files changed, 48 insertions(+) create mode 100644 contrib/beyla@.service create mode 100644 contrib/example-service.env create mode 100644 contrib/example-service.yaml diff --git a/contrib/beyla@.service b/contrib/beyla@.service new file mode 100644 index 000000000..0a762b3bf --- /dev/null +++ b/contrib/beyla@.service @@ -0,0 +1,17 @@ +[Unit] +Description=Run the Beyla application for a given application +After=network.target + +[Service] +Type = simple +Restart = always +User = root +Group = root +WorkingDirectory = /etc/beyla +EnvironmentFile = /etc/beyla/%i.env +ExecStart= +ExecStart=/usr/local/bin/beyla \ + --config=/etc/beyla/%i.yaml + +[Install] +WantedBy = multi-user.target diff --git a/contrib/example-service.env b/contrib/example-service.env new file mode 100644 index 000000000..d8c11328f --- /dev/null +++ b/contrib/example-service.env @@ -0,0 +1 @@ +GRAFANA_CLOUD_API_KEY="" diff --git a/contrib/example-service.yaml b/contrib/example-service.yaml new file mode 100644 index 000000000..2098f9579 --- /dev/null +++ b/contrib/example-service.yaml @@ -0,0 +1,17 @@ +open_port: 8000 +service_name: my-django-app +print_traces: true + +ebpf: + wakeup_len: 100 + +grafana: + otlp: + cloud_zone: + cloud_instance_id: + cloud_submit: + - metrics + - traces +routes: + unmatched: heuristic + diff --git a/docs/sources/setup/standalone.md b/docs/sources/setup/standalone.md index 1d8beebf2..a2ce42189 100644 --- a/docs/sources/setup/standalone.md +++ b/docs/sources/setup/standalone.md @@ -26,6 +26,19 @@ Alternatively, download the Beyla executable with the `go install` command: go install github.com/grafana/beyla/cmd/beyla@latest ``` +## Installing as a service + +Once you have Beyla installed on your system, you can use the [systemd service script](https://github.com/grafana/beyla/tree/main/contrib/beyla@.service) to get the daemon up and running. Installing the script is as simple as creating a file at `/etc/systemd/system/beyla@.service` (the `@` is important!) and running `systemctl daemon-reload`. + +The systemd service expects the following requirements to be met: + + * The `beyla` binary is in `/usr/local/bin` and is executable + * A directory exists at `/etc/beyla` to hold the various configuration files + +The service script works in such a way that it will pick up the files named after the service name that follows the `@` sign. As an example, if we wanted to use Beyla to monitor a moodle installation, we would create a configuration file at `/etc/beyla/moodle.yaml` and place our environment variables in `/etc/beyla/moodle.env`, then start the service with the command `systemctl start beyla@moodle.service` - the service will automatically pick up the `moodle` related files and start monitoring. + +If you want to add a second Beyla install on the same system monitoring a Django installation, you would create `/etc/beyla/django.yaml` and `/etc/beyla/django.env`, then start the service as `systemctl start beyla@django` and it will run alongside the existing Moodle Beyla but with the Django configuration. + ## Configure Beyla can be configured via: