Exporting metrics in Prometheus format
To export metrics in the Prometheus format, use the prometheusMetrics method. Before uploading metrics to Prometheus, set up metric collection in Prometheus.
An example of metric collection setup from Monitoring in Prometheus:
-
Select the folder you want to collect data from.
-
Select a service from the following list:
application-load-balancer
: Application Load Balanceraudit-trails
: Audit Trailscdn
: Cloud CDNcertificate-manager
: Certificate Managercompute
: Compute Cloudcontainer-registry
: Container Registrydata-proc
: Yandex Data Processingdata-streams
: Data Streamsdata-transfer
: Data Transferiam
: Identity and Access Managementinterconnect
: Cloud Interconnectkms
: Key Management Servicelogging
: Cloud Loggingmanaged-clickhouse
: Managed Service for ClickHouse®managed-elasticsearch
: Managed Service for Elasticsearchmanaged-greenplum
: Managed Service for Greenplum®managed-kafka
: Managed Service for Apache Kafka®managed-kubernetes
: Managed Service for Kubernetesmanaged-mongodb
: Managed Service for MongoDBmanaged-mysql
: Managed Service for MySQL®managed-opensearch
: Managed Service for OpenSearchmanaged-postgresql
: Managed Service for PostgreSQLmanaged-redis
: Yandex Managed Service for Valkey™managed-sqlserver
: Managed Service for SQL Servermessage-queue
: Message Queuemonitoring
: Monitoringnetwork-load-balancer
: Network Load Balancerserverless-apigateway
: API Gatewayserverless-containers
: Serverless Containersserverless-functions
: Cloud Functionsspeechkit
: SpeechKitstorage
: Object Storagetranslate
: Translatevision
: Vision OCRydb
: Managed Service for YDB
-
Create a static API key for the service account.
-
Assign the service account the
monitoring.viewer
role for the selected folder. -
In the Prometheus configuration
, add a new job (job
) to the data collection section:... scrape_configs: ... - job_name: 'yc-monitoring-export' metrics_path: '/monitoring/v2/prometheusMetrics' scheme: 'https' params: folderId: - '<folder_ID>' # for example, `aoeng2krmasi`******** service: - '<service>' # for example, `managed-mongodb` bearer_token: '<API_key>' # Or via a file (recommended): # bearer_token_file: '<name_of_file_with_API_key>' static_configs: - targets: ['monitoring.api.cloud.yandex.net'] labels: folderId: '<folder_ID>' service: '<service _ID>'
-
Restart Prometheus.
-
Check data collection in the Prometheus user interface:
http://localhost:9090/targets
(replacelocalhost
with the name of your host running Prometheus). -
If you need to change label names, use relabeling
.
Tip
If you have a lot of metrics, increase the data collection timeout (scrape_timeout
) to 60s.
ClickHouse® is a registered trademark of ClickHouse, Inc