Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build a Snap package from source #17328

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft

Build a Snap package from source #17328

wants to merge 7 commits into from

Conversation

ralphm
Copy link
Member

@ralphm ralphm commented Apr 5, 2024

No description provided.

This build takes cues from `contrib/debian` and also directly adjusts
the prefix to `/snap/netdata/current` and adjusts the default config to
only the needed changes to point to `/var/snap/netdata/common` for
config and `/current` for everything that goes into `/var`.

Additionally, a lot of runtime dependencies are taken from
snapcraft hints.
@ralphm
Copy link
Member Author

ralphm commented Apr 5, 2024

For testing this out:

Initial install

  1. Find the latest successful build and scroll down to artifacts to download a zip file with the snap package inside.

    image

  2. Extract the snap package from the zipfile.

  3. Install the snap package on the target machine:

    sudo snap install --dangerous ./netdata_0.1_amd64.snap

Note

This uses --dangerous because the Snap is unsigned.

Installing the Snap package automatically runs the Agent as a systemd service snap.netdata.agent. The dashboard should be accessible at http://localhost:19999/.

Granting additional permissions

As Snap packages run in a tightly controlled confinement environment, the agent needs to be granted additional permissions in order to access certain system resources. This is done through so-called connections. The below script enables all currently available connections. There are some comments in the snap/snapcraft.yaml file as to which resources are unlocked:

#!/bin/sh
sudo snap connect netdata:hardware-observe
sudo snap connect netdata:docker-support
sudo snap connect netdata:kubernetes-support
sudo snap connect netdata:log-observe
sudo snap connect netdata:login-session-observe
sudo snap connect netdata:mount-observe
sudo snap connect netdata:network-bind
sudo snap connect netdata:network-observe
sudo snap connect netdata:network-setup-observe
sudo snap connect netdata:system-observe
sudo snap connect netdata:time-control

After changing connections, the Agent may have to be restarted to take full effect:

sudo systemctl restart snap.netdata.agent

Configuration

Upon install, the initial configuration from the package is populated into /var/snap/netdata/common. You can make any additional modifications there, and will not be updated by future versions.

Data files

Data files are stored in /var/snap/netdata/[version]/, with a symlink from /var/snap/netdata/current. When a new version of the snap is installed, a snapshot of this data is created and carried over to the new version. When uninstalling the Snap with sudo snap remove netdata, an automatic snapshot saves the data as well. You can use --purge to skip the creation of this snapshot.

- -DENABLE_PLUGIN_PERF=On
- -DENABLE_PLUGIN_SLABINFO=On
- -DENABLE_PLUGIN_SYSTEMD_JOURNAL=On
- -DENABLE_PLUGIN_XENSTAT=On
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t think it’s possible for a Snap package to access the required interfaces for this plugin to work, no matter what connections are made, so we should probably just disable it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean Xen specifically? Yeah, I haven't gotten to testing that and will indeed disable it if that is indeed the case.

Fortunately, many things do work. I'm currently trying to get eBPF working properly, but here too, some interfaces don't appear to be exposed and may require putting in a ticket with snapd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants