Yandex Cloud
Search
Discuss with expertTry it for free
  • Customer Stories
  • Documentation
  • Blog
  • All Services
  • 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 July 7, 2026
View in Markdown
  • Setting up a connection
  • Data model
  • Metrics writing example

Monitoring allows you to collect and store metrics, as well as display them as charts on dashboards. Data sent to Monitoring includes metrics and their descriptive labels.

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

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 send metrics to Monitoring:

  1. Navigate to the Connections section of the Yandex Query interface and click Create new.

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

  3. In the Type dropdown, select Monitoring.

  4. In the Service account field, select an existing service account or create a new one. Assign it the monitoring.editor permissions allowing it to write metrics.

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

  5. Click Create to create a connection.

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 step.
  • <fields>: List of fields that include a timestamp, metrics, and their labels.
  • <query>: Yandex Query source data query.

Note

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

To write metrics, use the write Monitoring API method. When writing metrics, provide the following information:

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

Yandex Query automatically infers parameter semantics from the SQL query.

Field type Description Limitations
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 in the SQL statement is the metric name. A single query may contain an unlimited number of metrics.
Floating point: Float or Double Metric values, DGAUGE The field name in 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 may contain an unlimited number of metrics.

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 SQL query data source. It can be a YQL subquery or a data source connection
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:

Was the article helpful?

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