Yandex.Cloud
  • Services
  • Why Yandex.Cloud
  • Solutions
  • Pricing
  • Documentation
  • Contact us
Get started
Yandex Monitoring
  • Getting started
  • Step-by-step instructions
    • All instructions
    • Working with metrics
      • Getting a list of metrics
      • Downloading metrics
      • Writing custom metrics
      • Export metrics in Prometheus format
    • Working with dashboards
      • Creating dashboards
      • Copying dashboards
      • Adding widgets to a dashboard
      • Deleting widgets from a dashboard
      • Deleting dashboards
    • Working with alerts
      • Creating alerts
      • Creating notification channels
      • Deleting alerts
  • Concepts
    • Overview
    • Data model
    • Visualization
      • Overview
      • Query string
      • Widgets
      • Dashboards
    • Query language
    • Alerting
    • Data decimation
    • Deleting expired metrics (TTL)
    • Quotas and limits
  • Access management
  • Pricing policy
    • Current pricing policy
    • Archive
      • Policy before October 1, 2020
  • API reference
    • Authentication in the API
    • REST
      • Overview
      • MetricsData
        • Overview
        • read
        • write
        • prometheusMetrics
      • MetricsMeta
        • Overview
        • listLabelKeys
        • listLabelValues
        • listMetricNames
        • listMetrics
  • Questions and answers
  1. Step-by-step instructions
  2. Working with metrics
  3. Downloading metrics

Reading metrics

    To read metric data, use the read method.

    Before getting started

    To try the examples in this section:

    1. Make sure you have installed the cURL utility that is used in the examples.
    2. Get the ID of the folder you are granted the editor role or higher of.
    3. Get an IAM token:
      • Instructions for a Yandex account.
      • Instructions for a service account.

    Sample request

    1. Create a file with the request body (for example, body.json). In the query property, specify the query text. For example, the request below gets metric data on CPU usage from 00:00 UTC on July 24 to 00:00 UTC on July 31 for the virtual machine with ID epdpfhoh1r83vdmdnjuf.

      body.json:

      {
          "query": "cpu_usage{service=\"compute\", resource_id=\"epdpfhoh1r83vdmdnjuf\"}",
          "fromTime": "2021-07-24T00:00:00Z",
          "toTime": "2021-07-31T00:00:00Z",
          "downsampling": {
              "maxPoints": 10
          }
      }
      
    2. Send the request and save the response to a file, for example, output.json:

      $ export IAM_TOKEN=CggaATEVAgA...
      $ curl -X POST \
          -H "Content-Type: application/json" \
          -H "Authorization: Bearer ${IAM_TOKEN}" \
          -d '@body.json' \
          'https://monitoring.api.cloud.yandex.net/monitoring/v2/data/read?folderId=b2ghmo15rmnlod3hrf8p' > output.json
      

      Sample response:

      body.json:

      {
          "metrics": [
              {
                  "type": "DGAUGE",
                  "name": "cpu_usage",
                  "labels": {
                      "resource_type": "vm",
                      "cluster": "b2ghmo15rmnlod3hrf8p",
                      "project": "b1gbkpesobgv2i2266vg",
                      "resource_id": "epdpfhoh1r83vdmdnjuf",
                      "service": "compute"
                  },
                  "timeseries": {
                      "timestamps": [
                          1562069440800,
                          1562405369712,
                          1562741298624,
                          1563077227536,
                          1563413156448,
                          1563749085360,
                          1564085014272,
                          1564420943184
                      ],
                      "doubleValues": [
                          53.6475600118669,
                          65.5547751323391,
                          70.7148916473759,
                          49.4514634827568,
                          54.3817816479781,
                          81.9327383032693,
                          99.3035341016667,
                          99.982002860023
                      ]
                  }
              }
          ]
      }
      
    Language / Region
    Careers
    Privacy policy
    Terms of use
    Brandbook
    © 2021 Yandex.Cloud LLC