---
title: Send metrics to Cockpit using Grafana Alloy
description: Learn to configure Grafana Alloy to push metrics and visualize them in your Grafana dashboard with this step-by-step tutorial.
tags: cockpit observability grafana-alloy agent push-metrics
dates:
  validation: 2026-01-21
  posted: 2024-06-28
---
import Requirements from '@macros/iam/requirements.mdx'

import AlloyDatasource from './assets/scaleway-alloy-datasource.webp'
import AlloyDashboard from './assets/scaleway-alloy-dashboard.webp'



The Grafana Alloy agent is a component used in observability and monitoring setups, to collect and send metrics, logs, and traces from your applications, services, and infrastructure to observability platforms, such as Cockpit.

This page explains how to configure the Grafana Alloy agent to push your metrics and visualize them in Grafana. You can use it to **push your data from Scaleway resources or external/custom resources**.

For the sake of this documentation, we are using Grafana Alloy on macOS. Refer to the [official Grafana documentation](https://grafana.com/docs/alloy/latest/get-started/) to find the commands to use depending on your operating system of choice.

<Requirements />

  - [Owner](/iam/concepts/#owner) status or [IAM permissions](/iam/concepts/#permission) allowing you to perform actions in the intended Organization
  - A Scaleway account logged into the [console](https://console.scaleway.com)
  - [Installed Grafana Alloy](https://grafana.com/docs/alloy/latest/get-started/install/)
  - [Created a custom data source of the metrics type](/cockpit/how-to/create-external-data-sources/)
  - A [token](/cockpit/how-to/create-token/) with push permissions for metrics in the **same region as your metrics**

<Message type="important">
 - Having the default configuration on your agents might lead to more of your resources' metrics being sent, a high consumption and a high bill at the end of the month.

 - Sending metrics and logs for Scaleway resources or personal data using an external path is a billable feature. In addition, any data that you push yourself is billed, even if you send data from Scaleway products. Refer to the [product pricing](https://www.scaleway.com/en/pricing/managed-services/#cockpit) for more information.
</Message>

## Configuring Grafana Alloy

1. Create a folder named `config` on your local machine.
2. Create a file named `cockpit.alloy` inside the `config` folder.
3. Paste the following template inside `cockpit.alloy`:
        ```
        prometheus.exporter.unix "node" {
            set_collectors = [
                "uname",
                "cpu",
                "cpufreq",
                "loadavg",
                "meminfo",
                "filesystem",
                "netdev",
            ]
        }

        prometheus.scrape "node" {
            scrape_interval = "60s"
            scrape_timeout  = "4s"

            targets    = prometheus.exporter.unix.node.targets
            forward_to = [prometheus.remote_write.cockpit.receiver]
        }

        prometheus.remote_write "cockpit" {
            endpoint {
                url = "https://xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.metrics.cockpit.fr-par.scw.cloud/api/v1/push"
                headers = {
                    "X-TOKEN" = "COCKPIT_TOKEN_SECRET_KEY",
                }
            }
        }
        ```
4. Replace `https://xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.metrics.cockpit.fr-par.scw.cloud/api/v1/push` with your metrics' URL. You can retrieve it in the [Data sources tab](https://console.scaleway.com/cockpit/dataSource) of the Scaleway console.
5. Replace `COCKPIT_TOKEN_SECRET_KEY` with your Cockpit token's secret key, then save your changes.
        <Message type="important">
          Make sure that your token and your metrics data source were both created in the same region.
        </Message>
6. Open a terminal and [start Alloy](https://grafana.com/docs/alloy/latest/get-started/run/):
        ```
        brew services start alloy
        ```
7. In the same terminal, run the following command.
        ```
        alloy run config/cockpit.alloy
        ```
        The two last lines of your output should look similar to the following.
        ```
        ts=2026-01-23T14:23:05.542081Z level=info msg="now listening for http traffic" service=http addr=127.0.0.1:12345
        ts=2026-01-23T14:23:13.432896Z level=info msg="Done replaying WAL" component_path=/ component_id=prometheus.remote_write.cockpit subcomponent=rw remote_name=aa0551 url=https://xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.metrics.cockpit.fr-par.scw.cloud/api/v1/push duration=12.900498616s
        ```

## Visualizing your metrics

1. Click **Cockpit** in the **Monitoring** section of the [console](https://console.scaleway.com/) side menu. The **Cockpit** overview page displays.
2. Click **Open dashboards** to open your preconfigured dashboards in Grafana. You are redirected to the Grafana website.
3. Log in to your Grafana account. The Grafana overview page displays.
4. Click the Grafana icon in the top left side of your screen to open the menu.
5. Click **Dashboards**, then click **New** in the top right corner of your screen. A drop-down displays.
6. Click **Import** to import a dashboard.
7. In the **Import via grafana.com** field, enter `1860`, then click **Load**.

    <Message type="note">
      `1860` is the ID of the [Node Exporter Full dashboard](https://grafana.com/grafana/dashboards/1860-node-exporter-full/) provided by Grafana.
    </Message>

8. Enter a name for your dashboard or leave the default one.
9. In the **Folder** field, select a folder in which to store your dashboard.
10. In the **Prometheus** field, select your metrics data source in the drop-down.
11. Click **Import**. Your dashboard should load and display.
12. In the drop-down next to **Datasource**, select your metrics data source. By default, your dashboard retrieves your data source's data from the last 24 hours.
    <Lightbox image={AlloyDatasource} alt="" />
13. If your data source was created less than 24 hours ago, click the clock icon and adjust the time range to match its creation time.

    Your dashboard should look similar to the one in the image below.

    <Lightbox image={AlloyDashboard} alt="" />
