Yandex Cloud
Search
Contact UsGet started
  • Pricing
  • Customer Stories
  • Documentation
  • Blog
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • AI for business
    • Business tools
  • 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
  • Pricing
  • Customer Stories
  • Documentation
  • Blog
© 2025 Direct Cursus Technology L.L.C.
Yandex Query
    • Data formats and compression algorithms
      • Reading data using 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
  • 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. Working with Yandex Monitoring
  3. Writing data

Writing metrics to Monitoring

Written by
Yandex Cloud
Updated at August 12, 2025
  • 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 consists of 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, e.g., a host name or application version, serves as 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

To write metrics to Monitoring, use this 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 with 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. Yandex Query supports DGAUGE and IGAUGE metrics.
  • List of labels.

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

Field type Description Constraints
Time: Date, Datetime, Timestamp, TzDate, TzDatetime, or TzTimestamp Timestamp common for all metrics A query may only contain one timestamp field.
Integer: Bool, Int8, Uint8, Int16, Uint16, Int32, Uint32, Int64, or 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 or 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 or Utf8 Label values The field name in an SQL statement is the label name, and the 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

Example of a query to write 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 the SQL query. This may be a YQL subquery, including a connection to the data source.
my_timestamp Timestamp Data source: my_timestamp column in the data source stream (stream)
exception_count Metrica Data source: exception_count column in the data source stream (stream)
host_name Label Data source: host column in the data source stream (stream)
app_version Label Data source: app_version column in the data source stream (stream)

Result example for a query to Monitoring:

Was the article helpful?

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