Yandex Cloud
Search
Discuss with expertTry it for free
  • Customer Stories
  • Documentation
  • Blog
  • All Services
    • Cloud Interconnect
    • Cloud Backup
    • Cloud Registry
    • Yandex AI Studio
    • Compute Cloud
    • Object Storage
    • Managed Service for Kubernetes®
    • Yandex BareMetal
    • Smart Web Security
    • Security Deck
    • Managed Service for PostgreSQL
    • Managed Service for ClickHouse®
    • Monium
    • Cloud CDN
    • Network Load Balancer
    • Virtual Private Cloud
    • Cloud DNS
    • Application Load Balancer
    • Yandex Cloud Video
    • Stackland
    • Yandex Cloud Router
    • Yandex Managed Service for Trino
    • Managed Service for MySQL®
    • Managed Service for Valkey™
    • Managed Service for Apache Spark™
    • Yandex StoreDoc
    • Managed Service for OpenSearch
    • Managed Service for Apache Kafka®
    • Data Transfer
    • Yandex MPP Analytics Engine for PostgreSQL
    • Yandex Managed Service for Apache Airflow®
    • Data Processing
    • Yandex MetaData Hub
    • Managed Service for YDB
    • Managed Service for Sharded PostgreSQL
    • Managed Service for YTsaurus
    • Yandex WebSQL
    • DataLens
    • Yandex Search API
    • SpeechSense
    • SpeechKit
    • DataSphere
    • Vision OCR
    • Translate
    • Yandex Identity Hub
    • Key Management Service
    • Certificate Manager
    • Yandex Lockbox
    • Audit Trails
    • SmartCaptcha
    • Cloud Desktop
    • Yandex SIEM
    • SourceCraft Code Assistant
    • Container Registry
    • Managed Service for GitLab
    • Managed Service for Prometheus®
    • Cloud Functions
    • API Gateway
    • Yandex Cloud Postbox
    • Message Queue
    • Serverless Integrations
    • IoT Core
    • Data Streams
    • Serverless Containers
    • Cloud Notification Service
    • Yandex Query
    • Identity and Access Management
    • Yandex Cloud Console
    • Resource Manager
    • Yandex Cloud Billing
    • Yandex Cloud Quota Manager
    • Cloud Apps
  • System Status
  • Marketplace
    • Featured
    • Infrastructure & Network
    • Data Platform
    • AI for business
    • Security
    • DevOps tools
    • Serverless
    • Monitoring & Resources
  • 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
    • Price calculator
    • Pricing plans
  • Customer Stories
  • Documentation
  • Blog
© 2026 Direct Cursus Technology L.L.C.
Yandex Query
    • Data formats and compression algorithms
      • Reading data via connections
      • Writing data
    • Working with Managed Service for ClickHouse® databases
    • Working with Yandex MPP Analytics for PostgreSQL databases
    • Working with Managed Service for MySQL® databases
    • Working with Managed Service for PostgreSQL databases
    • Working with Managed Service for YDB databases
    • Reading Iceberg tables
  • Access management
  • Pricing policy
  • Integrations
  • Audit Trails events
  • FAQ

In this article:

  • Setting up a connection
  • Data model
  • Metrics writing example
  1. Data sources and sinks
  2. Working with Yandex Monitoring
  3. Writing data

Writing metrics to Monitoring

Written by
Yandex Cloud
Updated at August 17, 2026
View in Markdown
  • Setting up a connection
  • Data model
  • Metrics writing example

Monitoring is a service that collects, stores, and presents metrics on dashboards. The data that goes to Monitoring contains the measured quantity values ​​(metrics) and the labels describing them.

For example, to count app failures, you can use failure count during time interval as the metric. Host name and application version at the time of failure are labels. In the Monitoring interface, you can aggregate metrics by labels.

Query example for writing metrics from Yandex Query into Monitoring:

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

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

Setting up a connectionSetting up a connection

To set up sending metrics to Monitoring:

  1. Navigate to Yandex Query.

  2. In the left-hand panel, select Connections.

  3. Click Create new.

  4. In the window that opens, specify the Monitoring connection name in the Name field.

  5. In the Type field, select Monitoring.

  6. In the Service account field, select the service account you will use to write metrics, or create a new one and assign the monitoring.editor role to it.

    To use the service account on your behalf, you need the iam.serviceAccounts.user role.

  7. Click Create.

Data modelData model

To write metrics to Monitoring, use the following SQL statement:

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

Where:

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

Note

To write custom metrics, use the INSERT INTO <connection>.custom structure. Where custom is a reserved name in Monitoring.

To write metrics, use the write Monitoring API method. Provide the following data:

  • Timestamp.
  • List of metrics and their types: Yandex Query supports the DGAUGE and IGAUGE types.
  • List of labels.

Yandex Query automatically infers parameter semantics from the SQL query.

Field type

Description

Restrictions

Time: Date, Datetime, Timestamp, TzDate, TzDatetime, or TzTimestamp

Common timestamp for all metrics

A query can have only one timestamp field.

Integer: Bool, Int8, Uint8, Int16, Uint16, Int32, Uint32, Int64, or Uint64

Metric values, IGAUGE

The field name from the SQL statement is the metric name. A single query may contain an unlimited number of metrics.

Floating point: Float or Double

DGAUGE type metric values

The field name from the SQL statement is the metric name. A single query may contain an unlimited number of metrics.

Text: String or Utf8

Label values

The field name in the SQL statement serves as the label name, and its text value as the label value. A single query can contain an unlimited number of labels.

No other data types are permitted in these fields.

Metrics writing exampleMetrics writing example

Query example 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

Data source in SQL query. This can be a YQL subquery, including a connection to a data source.

my_timestamp

Timestamp

Data source: my_timestamp column in the source data stream

exception_count

Metric

Data source: exception_count column in the source data stream

host_name

Label

Data source: host column in the source data stream

app_version

Label

Data source: app_version column in the source data stream

Example of query results in Monitoring:

Result of writing metrics to Monitoring

Was the article helpful?

Previous
Reading data via connections
Next
Working with Managed Service for ClickHouse® databases
© 2026 Direct Cursus Technology L.L.C.