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 CDN.certificate-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 Elasticsearch
managed-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
: Managed Service for Redismanaged-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. -
Add a new
job
to the data collection section of the Prometheus configuration .... scrape_configs: ... - job_name: 'yc-monitoring-export' metrics_path: '/monitoring/v2/prometheusMetrics' scheme: 'https' params: folderId: - '<folder_ID>' # e.g., aoeng2krmasi******** service: - '<service>' # e.g., managed-mongodb bearer_token: '<API_key>' # Or via a file (recommended): # bearer_token_file: '<name_of_the_file_with_the_API_key>' static_configs: - targets: ['monitoring.api.cloud.yandex.net'] labels: folderId: '<folder_ID>' service: '<service_ID>'
-
Restart Prometheus.
-
Check the data collection in the Prometheus user interface:
http://localhost:9090/targets
(replacelocalhost
with the name of the 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