Install Grafana Agent
There are several ways to install and run Grafana Agent. This procedure shows the preferred way of installing the agent using a script for Debian- and Red Hat-based systems. For other Linux distributions, or if you prefer to install the binary directly rather than as a package, see Installing the binary directly without our script for all other use cases**.
For both methods, begin by accessing Integration and Connections from your Grafana Cloud stack:
- In your Grafana Cloud stack, click Integrations and Connections (lightning bolt icon).
- Select an integration to install and click Install Integration.
- Choose your operating system:
- Select Debian/Red Hat if you want to use the provided script to automate the install. See how to install with the provided script for details.
- Select Other Distribution for other use cases to install the binary directly without the provided script. See the Grafana Agent setup documentation for details. Users who install and run the agent directly on the host may want the agent to automatically restart when its process is killed or the host is rebooted. To do this, create a systemd service to manage the agent.
Install with the provided script for Debian- and Red Hat-based systems
This preferred installation method automates the installation for systems that use DEB or RPM packages, such as with Debian- or Red Hat-based systems. The provided script checks and finds which is appropriate for your system and then uses your package manager for the Grafana Agent install. It also sets up the agent to be managed and run as a systemd service.
This method runs Agent using a newly-created user,
grafana-agent. If you are collecting logs, for example, you may need to give this user access to log-containing directories.
Note: The configuration for Grafana Agent is stored in
/etc/grafana-agent.yaml. This file is overwritten each time the script is run, adding and removing integration changes made in the Grafana Cloud UI. If you have custom configurations that you want to use, you can create and maintain your own custom configuration file by changing the environment variable in
/etc/default/grafana-agentto point to your custom configuration file instead of the default location.
- Copy and run the provided script.
- Start the service using the provided systemd command.
- Click Check Connection to confirm metrics are being received.
Note: This method also makes it easy to retrieve and review Grafana Agent logs using systemd.
To retrieve service logs for the agent, enter:
sudo journalctl -b -u grafana-agent.service
Uninstall the Grafana agent
How you uninstall depends on which Linux distribution you’re running and how you installed the agent.
The script method installs a system package called grafana-agent. This means that:
- For Debian-based systems, you can remove the agent using
sudo apt remove grafana-agent
- For Red Hat-based systems, you can remove the agent using
sudo dnf remove grafana-agent
If you installed using the “Other distribution” step, the agent is not persisted anywhere. The binary is only downloaded to the directory you ran the install steps in. Stop any running process and then delete the binary to uninstall.