---
title: "Telegraf"
sidebar_label: "Telegraf"
description: "How to configure Telegraf to collect metrics to your infrastructure"
sidebar_position: 3
---

import Formbricks from '@theme/MDXComponents/Formbricks';
import CopyIcon from '@selectel/docux/icons/copy'

# Telegraf

[Telegraf](https://www.influxdata.com/time-series-platform/telegraf) is a monitoring system that allows you to set up metric collection, storage, and processing.

Before you begin, [configure Telegraf](#configure-telegraf).

## Configure Telegraf \{#configure-telegraf}

You can configure the agent to collect metrics to your infrastructure.

1. [Add a service user](#add-service-user).
2. [Configure the agent to collect metrics](#set-up-agent).

### 1. Add a service user \{#add-service-user}

[Add a service user](/access-control/manage/add-user.mdx#add-service-user) with permission in the **Projects** scope and the role:

* `metrics.admin;`
* `member;`
* or [`reader`](/access-control/role-reference.mdx#reader).

Users can be added by the [Account Owner](/access-control/user-types.mdx#account-owner) or users with the [`iam.admin`](/access-control/role-reference.mdx#iam-admin) role.

### 2. Configure the agent to collect metrics \{#set-up-agent}

1. Open the CLI.

2. Create a configuration file `telegraf.conf`:

   ```bash
   nano /etc/telegraf/telegraf.conf
   ```

3. Fill in the configuration file `telegraf.conf`:

   ```bash
   [agent]
     interval = "1m"
     flush_interval = "1m"

   [[inputs.prometheus]]
     urls = ["<base_url>/projects/<project_id>/namespaces/<namespace>/prometheus/metrics"]
     username = "<user_id>"
     password = "<password>"

   [[outputs.file]]
     files = ["stdout"]
     data_format = "prometheus"
   ```

   Specify:

   * `<base_url>` — the URL for accessing the Metrics service API. If you are configuring an agent to collect metrics for a [dedicated server](/dedicated/), use the cloud server pool URL that corresponds to the pool where your dedicated server is located. The list of URLs can be found in the [List of URLs](/api/urls/);
   * `<project_id>` — project ID. Can be copied in the [Control Panel](https://my.selectel.ru/vpc/): in the top menu click **Products** and select any product → open the project menu → in the required project row click ;<CopyIcon />
   * `<namespace>` — name of the selected namespace, for example `compute`;
   * `<user_id>` — ID of the user you [added in step 1](#add-service-user);
   * `<password>` — password of the user you [added in step 1](#add-service-user).

4. Optional: you can configure metric collection from multiple pools or projects. To add a new pool or project, in the `inputs.prometheus` section, list all sources separated by a comma in the `urls` parameter.

5. Optional: add metric delivery to external storage or processing systems, for example to VictoriaMetrics. To do this, supplement the `outputs` section in the `telegraf.conf` configuration file using the [`Prometheus Output Plugin`](https://github.com/influxdata/telegraf/tree/master/plugins/outputs/prometheus_client).

6. Exit the `nano` text editor and save your changes: press **Ctrl+X**, and then **Y+Enter**.

7. Start Telegraf:

   ```bash
   docker run \
     --name telegraf \
     --rm \
     -v ${PWD}/telegraf.conf:/etc/telegraf/telegraf.conf:ro \
     telegraf:latest \
     --config /etc/telegraf/telegraf.conf
   ```

   Collected metrics will be output to stdout. Example output:

   ```bash
   # HELP network_meta_info_value Telegraf collected metric
   2026-03-03T12:46:30.359832865Z # TYPE network_meta_info_value untyped
   2026-03-03T12:46:30.359838580Z network_meta_info_value{server_uuid="...", ...} 1
   2026-03-03T12:46:30.359844441Z # HELP network_receive_bits_rate_value Telegraf collected metric
   2026-03-03T12:46:30.359847896Z # TYPE network_receive_bits_rate_value untyped
   2026-03-03T12:46:30.359851348Z network_receive_bits_rate_value{server_uuid="...", ...} 0
   ```

<Formbricks />
