Jump toUpdate content
Configuring the Grafana agent
This page explains how to configure the Grafana agent to push your logs and metrics and visualize them in Grafana.
If you have activated IAM, you may need certain IAM permissions to carry out some actions described on this page. This means:
- you are the Owner of the Scaleway Organization in which the actions will be carried out, or
- you are an IAM user of the Organization, with a policy granting you the necessary permission sets
- You have an account and are logged into the Scaleway console
- You have activated your Cockpit
- You have installed docker and docker compose
Configuring and running the Grafana agent
It is not currently possible to collect logs if you are using OSX.
-
Create a token and select the push permission for metrics and logs.
-
Create a folder where you will keep your configuration files.
-
Create a configuration file inside your folder and name it
config.yaml
. This file will contain the Grafana agent configuration. -
Copy the following yaml template.
Important:- Make sure you replace the
remote_write
URL withhttps://metrics.prd.obs.fr-par.scw.cloud/api/v1/push
and theclients
URL withhttps://logs.prd.obs.fr-par.scw.cloud/loki/api/v1/push
- Make sure you add the token you created in step 2
metrics:
wal_directory: /tmp/agent
global:
scrape_interval: 15s
remote_write:
- url: <your metrics push url>
headers:
"X-Token": <your push token>
logs:
positions_directory: /tmp/positions/
configs:
- name: scw
clients:
- url: <your logs push url>
tenant_id: <your push token>
scrape_configs:
- job_name: varlogs
static_configs:
- targets: [localhost]
labels:
job: varlogs
__path__: /host/root/var/log/*.log
integrations:
node_exporter:
enabled: true
rootfs_path: /host/root
sysfs_path: /host/sys
procfs_path: /host/procYour configuration file should look like the following:
metrics:
wal_directory: /tmp/agent
global:
scrape_interval: 15s
remote_write:
- url: https://metrics.prd.obs.fr-par.scw.cloud/api/v1/push
headers:
"X-Token": 4zz-3cGLS5tzuDRb6LkEdpem7eOqj8EFecfWcJmTvrakS15gu07iEvtC5RfYDzi8
logs:
positions_directory: /tmp/positions/
configs:
- name: scw
clients:
- url: https://logs.prd.obs.fr-par.scw.cloud/loki/api/v1/push
tenant_id: 4zz-3cGLS5tzuDRb6LkEdpem7eOqj8EFecfWcJmTvrakS15gu07iEvtC5RfYDzi8
scrape_configs:
- job_name: varlogs
static_configs:
- targets: [localhost]
labels:
job: varlogs
__path__: /host/root/var/log/*.log
integrations:
node_exporter:
enabled: true
rootfs_path: /host/root
sysfs_path: /host/sys
procfs_path: /host/proc - Make sure you replace the
-
In the same folder, create another file and name it
docker-compose.yaml
. -
Copy the following template and paste it into your file:
version: "3"
services:
agent:
image: grafana/agent:latest
restart: always
volumes:
- "./config.yaml:/etc/agent-config/agent.yaml:ro"
- "/:/host/root:ro"
- "/sys:/host/sys:ro"
- "/proc:/host/proc:ro"
- "/tmp/agent:/etc/agent"
entrypoint:
- /bin/agent
- -config.file=/etc/agent-config/agent.yaml
- -metrics.wal-directory=/tmp/agent/wal
network_mode: "host"
pid: "host" -
Run the following command to open your folder containing your configuration files:
cd <your folder>
-
Run the following command to bring the Grafana Agent container up:
docker-compose up
Important:Run
sudo docker-compose up
if you are using Linux.
Visualizing metrics on Grafana
- Log into Grafana using your Grafana credentials.
- Click the Dashboards icon, then click Browse.
- Click Import on the top right corner of your screen to import your Grafana dashboard.
- Enter
1860
, which is the ID of the Node Exporter Full dashboard, in the ID field and click Load. - Select the Scaleway Metrics Prometheus instance as the data source and click Import. Your dashboard displays with your metrics.
Visualizing logs on Grafana
- Log into Grafana using your Grafana credentials.
- Click the Compass icon.
- Click Explore.
- Select the Scaleway Logs data source on the top left corner of your screen.
- Click Log browser.
- Select your labels and their values using the instructions on your screen.
- Click Show logs. A new screen display with your logs.
- Optionally, click the Live button on the top right corner of your screen to see your logs arriving in real time.