Writing custom metrics

    To write a metric, use the write 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:

    Sample request

    1. Create a file with the request body (for example, body.json). In the metrics property, specify the list of metrics to write. Pass the required labels in the query parameters and additional labels in the body of the request.


          "metrics": [
                  "name": "temperature",
                  "labels": {
                      "building": "office",
                      "room": "openspace"
                  "value": 18.6
    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/write?folderId=aoe6vrq0g3svvs3uf62u&service=custom' > output.json

      Sample response: