Yandex Cloud
Search
Contact UsGet started
  • Pricing
  • Customer Stories
  • Documentation
  • Blog
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML Services
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Center for Technologies and Society
    • Yandex Cloud Partner program
  • Pricing
  • Customer Stories
  • Documentation
  • Blog
© 2025 Direct Cursus Technology L.L.C.
Yandex Monitoring
  • Getting started
    • Overview
      • Overview
      • Metric collection agent
      • Remote Write
      • Diagnostics and troubleshooting
    • Recording rules
    • Alerting rules
    • Reading and writing Kubernetes cluster metrics
  • Access management
  • Pricing policy
  • Terraform reference
  • Release notes

In this article:

  • List of supported operating systems
  • Before you begin installation
  • Installation and setup
  • Configuration
  • Overview of VM metrics
  1. Yandex Managed Service for Prometheus®
  2. Writing metrics
  3. Metric collection agent

Prometheus metric collection agent

Written by
Yandex Cloud
Updated at June 17, 2025
  • List of supported operating systems
  • Before you begin installation
  • Installation and setup
  • Configuration
  • Overview of VM metrics

To transfer metrics from the VM to Yandex Managed Service for Prometheus®, you need a metric collection agent. You can install any agent supporting metrics transfer or use the Unified Agent which can transfer Prometheus metrics.

This section describes how to install an agent when creating a VM. For other installation options, see Installing and updating Yandex Unified Agent.

Note

As of version 25.03.80, Unified Agent can collect and transmit Prometheus metrics.

List of supported operating systemsList of supported operating systems

  • Ubuntu 14.04 or higher
  • Debian 9 or higher

Before you begin installationBefore you begin installation

  1. Create a service account in the folder you want to write metrics to and assign it the monitoring.editor role.

  2. Set up agent authorization in the Yandex Monitoring API. To do this, link your service account to the VM. This way, the agent will automatically get the service account IAM token from the metadata service.

Installation and setupInstallation and setup

You can install a metric collection agent when creating a VM with the help of the management console, CLI, API, or Terraform.

Management console
CLI, API
Terraform
  1. In the management console, start creating your VM.

  2. Expand Additional ⟶ Monitoring.

  3. Enable Agent for delivering metrics and select Yandex Managed Service for Prometheus®.

  4. Create a workspace or select an existing one.

  5. Optionally, specify the delivery parameters for your custom metrics, in JSON format.

    It no parameters are specified, the agent will only deliver Linux system metrics. You can add or change the delivery of your custom metrics later, in user metadata.

    Metrics description format:

    {
      "jobs": [
        {
          "job_name": <name>,
          "scrape_interval": "15s",
          "scrape_timeout": "5s",
          "metrics_path": "/metrics",
          "targets": [
            {
              "host": <host_FQDN>, //this is an optional field
              "port": 42
            }
          ]
        }
      ]
    }
    

    Where:

    • job_name: Random name for the set of metrics to collect.
    • scrape_interval: How often the agent will collect metrics.
    • scrape_timeout: Time the agent will have to collect metrics.
    • metrics_path: Path to the service metrics location.
    • targets: Parameters of the host to collect metrics from:
      • host: Full domain name, such as my.example.com. This is an optional setting.
      • port: Metric collection port.

To install the agent, provide the following string in the user metadata (user-data):

```text
#cloud-config\nruncmd:\n  - wget -O - https://monitoring.api.cloud.yandex.net/monitoring/v2/unifiedAgent/config/install.sh | bash
```

To install the agent:

  1. Specify the following in the VM creation configuration:

    resource "yandex_compute_instance" "my-vm" {
      ...
      service_account_id = "ajehka*************"
      metadata    = {
        monitoring_workspaceid = "mon618clr**************"
        user-data = "${file("<path_to_configuration_file>")}"
      }
      ...
    }
    
    

    Where:

    • monitoring_workspaceid: ID of the workspace to which you want to write metrics.
    • service_account_id: ID of the service account with the monitoring.editor role.
  2. In the configuration file (user-data), specify the following line:

    #cloud-config\nruncmd:\n  - wget -O - https://monitoring.api.cloud.yandex.net/monitoring/v2/unifiedAgent/config/install.sh | bash
    

To install the agent and send metrics, make sure the VM has access to the internet.

ConfigurationConfiguration

The agent has two configuration files: config.yml and prometheus.yml.

The config.yml file is located at /etc/yc/unified_agent/config.yml. When the agent is installed in Prometheus metric collection mode, the file does not contain the metric collection parameters.

Sample config.yml file
status:
  port: "16241"

import:
  - /etc/yc/unified_agent/conf.d/*.yml
  - /etc/yc/unified_agent/generated_conf.d/*.yml

The prometheus.yml file is located at /etc/yc/unified_agent/generated_conf.d/prometheus.yml. By default, it is configured to collect metrics in Prometheus format. If you specified your own metric collection settings when installing the agent, they will be added to this file.

Sample prometheus.yml file
storages:
  - name: __prometheus_metrics_storage
    plugin: fs
    config:
      directory: /var/lib/yc/unified_agent/__prometheus_metrics_storage
      max_partition_size: 100mb
      max_segment_size: 10mb
channels:
  - name: __remote_write
    channel:
      pipe:
        - storage_ref:
            name: __prometheus_metrics_storage
      output:
        plugin: metrics
        config:
          url: "https://monitoring.api.cloud.yandex.net/prometheus/workspaces/workspace_id/api/v1/write"
          set_host_label: null
          iam:
            cloud_meta: { }
routes:
  - input:
      id: linux_metrics_input
      plugin: linux_metrics
      config:
        poll_period: 60s
        namespace: sys
        prometheus_config:
          job_name: linux_metrics
    channel:
      channel_ref:
        name: __remote_write

Once the VM is deployed, the agent will start automatically and will be sending metrics to Yandex Managed Service for Prometheus®.

You will be charged for metric delivery.

Overview of VM metricsOverview of VM metrics

To view metrics your agent transfers to Yandex Managed Service for Prometheus®:

Management console
  1. In the management console, select the folder where the VM is located.

  2. In the list of services, select Monitoring.

  3. Navigate to Prometheus.

  4. Select the workspace to which your VM metrics are written.

  5. Open the Metrics tab and enter a Query in PromQL to view:

    • Linux system metrics: {job="linux_metrics", instance="<VM_name>", __name__="<metric_name>"}.

      Example: {job="linux_metrics", instance="my_vm", __name__="sys_cpu_CpuCores"}.

      For the list of metrics transferred by the Prometheus agent, see Yandex Unified Agent metrics.

    • Custom metrics if the agent has been configured to transfer them: {job="metrics_totality_name", instance="<VM_name>:<port>", __name__="<metric_name>"}.

      Where:

      • job: Name of the set of metrics specified when configuring the agent.
      • instance: VM name and port used by your application.
      • name: Name of the metric your application transfers.

      Example: {job="web_server", instance="my_server:9100", __name__="http_requests_total"}.

  6. Click Execute.

Was the article helpful?

Previous
Overview
Next
Remote Write
© 2025 Direct Cursus Technology L.L.C.