Set up Grafana AgentInstall Grafana Agent on Linux

Install Grafana Agent on Linux

Install Grafana Agent and get it up and running on Linux.

Install on Debian or Ubuntu

  1. If your distribution supports the signed-by option, open a terminal and enter:
$ mkdir -p /etc/apt/keyrings/
$ wget -q -O - | gpg --dearmor | sudo tee /etc/apt/keyrings/grafana.gpg
$ echo "deb [signed-by=/etc/apt/keyrings/grafana.gpg] stable main" | sudo tee /etc/apt/sources.list.d/grafana.list

Otherwise, with the deprecated apt-key command:

$ echo "deb stable main" | sudo tee /etc/apt/sources.list.d/grafana.list
$ wget -q -O - | apt-key add -
  1. After you add the repository, update package list:
sudo apt-get update
  1. Install Grafana Agent:
sudo apt-get install grafana-agent

Install on RPM-based Linux (CentOS, Fedora, OpenSuse, Red Hat)

  1. Manually create a new .repo file inside /etc/yum.repos.d using a text editor:
$ sudo nano /etc/yum.repos.d/grafana.repo
  1. Verify that the repository is properly configured using yum-config-manager:
yum-config-manager grafana
  1. Install Grafana Agent:
sudo yum install grafana-agent

Operation guide

The Grafana Agent will be configured a systemd service after using the installation methods explained in the previous sections.

Start the Agent

To run the service you just need to type:

sudo systemctl start grafana-agent

You can check the status of the running agent typing:

sudo systemctl status grafana-agent

Alternately, you can configure the Grafana Agent to restart at boot:

sudo systemctl enable grafana-agent.service

Editing the Agent’s config file

By default, the config file is located in /etc/grafana-agent.yaml. After editing the file with the desired config, you need to restart the agent running:

sudo systemctl restart grafana-agent

Check the logs of running Agent

You can check the logs of running agent typing:

sudo journalctl -u grafana-agent

Sep 02 14:33:28 grafana systemd[1]: Started Monitoring system and forwarder.
Sep 02 14:33:28 grafana grafana-agent[1633180]: ts=2022-09-02T12:33:28Z level=info caller=traces/traces.go:143 msg="Traces Logger I>
Sep 02 14:37:45 grafana systemd[1]: Stopping Monitoring system and forwarder...