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
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
  • Blog
  • Pricing
  • Documentation
Yandex project
© 2025 Yandex.Cloud LLC
Yandex Query
    • Data formats and compression algorithms
    • Working with Managed Service for ClickHouse® databases
    • Working with Managed Service for Greenplum® databases
    • Working with Managed Service for MySQL® databases
    • Working with Managed Service for PostgreSQL databases
    • Working with Managed Service for YDB databases
    • Writing metrics to Yandex Monitoring
  • Access management
  • Pricing policy
  • Integration
  • Audit Trails events
  • FAQ

In this article:

  • Setting up a connection
  • Data model
  • Example of writing metrics
  1. Data sources and targets
  2. Writing metrics to Yandex Monitoring

Writing metrics to Monitoring

Written by
Yandex Cloud
Updated at July 15, 2024
  • Setting up a connection
  • Data model
  • Example of writing metrics

Monitoring allows you to collect and store metrics and display them as charts on dashboards. Data sent to Monitoring represents measured values (metrics) and labels that describe them.

For example, to track the number of application failures, you can use the failure count per time interval as a metric. Data describing a failure, such as host name and application version, are labels. The Monitoring interface allows you to aggregate metrics by label.

Example of writing metrics from Yandex Query to Monitoring:

INSERT INTO `monitoring`.custom
SELECT
        `my_timestamp`,
        host_name,
        app_version,
        exception_count,
        "exception_monitor" as service_type
FROM $query;

Under streaming processing, Yandex Query can send query results to Monitoring as metrics and their labels.

Setting up a connectionSetting up a connection

To send metrics to Monitoring:

  1. Go to Connections in the Yandex Query interface and click Create new.

  2. In the window that opens, specify a name for a connection to Monitoring in the Name field.

  3. In the drop-down list under Type, select Monitoring.

  4. In the Service account field, select the service account to use for metric writes. You can also create a new service account with the monitoring.editor permissions.

    To use a service account, the iam.serviceAccounts.user role is required.

  5. Click Create to create a connection.

Data modelData model

Metrics are written to Monitoring using the following SQL statement:

INSERT INTO
        <connection>.custom
SELECT
        <fields>
FROM
        <query>;

Where:

  • <connection>: Name of the Monitoring connection created in the previous step.
  • <fields>: List of fields that contain a timestamp, metrics, and their labels.
  • <query>: Yandex Query data source query.

Note

When writing metrics, use INSERT INTO <connection>.custom, where custom is the name reserved in Monitoring for writing custom metrics.

Metrics are written using the write Monitoring API method. Pass the following when writing metrics:

  • Timestamp.
  • List of metrics with their type specified. Yandex Query supports the DGAUGE and IGAUGE metric types.
  • List of labels.

Yandex Query automatically prints the semantics of parameters from the SQL query.

Field type Description Limitations
Time: Date, Datetime, Timestamp, TzDate, TzDatetime, and TzTimestamp Timestamp common for all metrics A query may only contain one field with the timestamp.
Integer: Bool, Int8, Uint8, Int16, Uint16, Int32, Uint32, Int64, and Uint64 Metric values, IGAUGE The SQL query field name is the metric name. A single query may contain an unlimited number of metrics.
With a floating point: Float and Double Metric values, DGAUGE The SQL query field name is the metric name. A single query may contain an unlimited number of metrics.
Text: String and Utf8 Label values The SQL query field name is the label name, while a text value is the label value. A single query may contain an unlimited number of metrics.

No other data types are allowed in the fields.

Example of writing metricsExample of writing metrics

Sample query for writing metrics from Yandex Query to Monitoring:

INSERT INTO
        `monitoring`.custom
SELECT
        `my_timestamp`,
        host AS host_name,
        app_version,
        exception_count,
        "exception_monitor" as service_type
FROM $query;

Where:

Field Type Description
monitoring Monitoring connection name
$query SQL query data source, can be a YQL subquery, including a connection to the data source
my_timestamp Timestamp Data source (my_timestamp column in the source stream)
exception_count Metric Data source (exception_count column in the source stream)
host_name Label Data source (host column in the source stream)
app_version Label Data source (app_version column in the source data stream)

Sample query execution result in Monitoring.

Was the article helpful?

Previous
Working with Managed Service for YDB databases
Next
All tutorials
Yandex project
© 2025 Yandex.Cloud LLC