Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
    • Yandex Cloud Partner program
  • Blog
  • Pricing
  • Documentation
© 2025 Direct Cursus Technology L.L.C.
Yandex Monitoring
  • Getting started
    • All guides
      • Metrics overview
      • Delivering Linux system metrics
      • Delivering custom application metrics
      • Delivering metrics from HAProxy and other third-party applications
      • Delivering metrics from hosts outside Yandex Cloud
      • Writing custom metrics via the API
      • Getting a list of metrics
      • Downloading metrics
      • Exporting metrics in Prometheus format
  • Access management
  • Terraform reference
  • Release notes
  1. Step-by-step guides
  2. Working with metrics
  3. Writing custom metrics via the API

Writing custom metrics via the API

Written by
Yandex Cloud
Updated at April 28, 2025

To start writing custom metrics via the API, use the write method.

Getting startedGetting started

To follow the examples in this section:

  1. Make sure you have installed cURL that is used in the examples.

  2. Get the ID of the folder for which you have the monitoring.editor role or higher.

  3. Get an IAM token:

    • Guide for users with a Yandex account.
    • Guide for a service account.
    • Guide for a federated account.

Request exampleRequest example

  1. Create a file with the request body, e.g., body.json. In the metrics property, specify the list of metrics to write. Provide the required labels in the query parameters and additional labels in the request body.

    body.json:

    {
        "metrics": [
            {
                "name": "temperature",
                "labels": {
                    "building": "office",
                    "room": "openspace"
                },
                "value": 18.6
            }
        ]
    }
    
  2. Send the request and save the response to a file, e.g., output.json:

    export IAM_TOKEN=CggaATEVAgA...
    curl \
      --request POST \
      --header "Content-Type: application/json" \
      --header "Authorization: Bearer ${IAM_TOKEN}" \
      --data '@body.json' \
      'https://monitoring.api.cloud.yandex.net/monitoring/v2/data/write?folderId=aoe6vrq0g3sv********&service=custom' > output.json
    

    Response example:

    output.json:

    {
        "metrics_written":"1"
    }
    

Was the article helpful?

Previous
Delivering metrics from hosts outside Yandex Cloud
Next
Getting a list of metrics
© 2025 Direct Cursus Technology L.L.C.