Skip to content

Commit

Permalink
Add systemd service file and related docs (#448)
Browse files Browse the repository at this point in the history
  • Loading branch information
proffalken authored Nov 17, 2023
1 parent e2c0c51 commit 2a5433b
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
17 changes: 17 additions & 0 deletions contrib/beyla@.service
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions contrib/example-service.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GRAFANA_CLOUD_API_KEY="<MY-CLOUD-API-KEY>"
17 changes: 17 additions & 0 deletions contrib/example-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
open_port: 8000
service_name: my-django-app
print_traces: true

ebpf:
wakeup_len: 100

grafana:
otlp:
cloud_zone: <my-cloud-zone>
cloud_instance_id: <my-instance-id>
cloud_submit:
- metrics
- traces
routes:
unmatched: heuristic

13 changes: 13 additions & 0 deletions docs/sources/setup/standalone.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 2a5433b

Please sign in to comment.