Yandex.Cloud
  • Services
  • Why Yandex.Cloud
  • Solutions
  • Pricing
  • Documentation
  • Contact us
Get started
Yandex Monitoring
  • Getting started
  • Step-by-step instructions
    • All instructions
    • Working with metrics
      • Getting a list of metrics
      • Downloading metrics
      • Writing custom metrics
      • Export metrics in Prometheus format
    • Working with dashboards
      • Creating dashboards
      • Copying dashboards
      • Adding widgets to a dashboard
      • Deleting widgets from a dashboard
      • Deleting dashboards
    • Working with alerts
      • Creating alerts
      • Creating notification channels
      • Deleting alerts
  • Concepts
    • Overview
    • Data model
    • Visualization
      • Overview
      • Query string
      • Widgets
      • Dashboards
    • Query language
    • Alerting
    • Data decimation
    • Deleting expired metrics (TTL)
    • Quotas and limits
  • Access management
  • Pricing policy
    • Current pricing policy
    • Archive
      • Policy before October 1, 2020
  • API reference
    • Authentication in the API
    • REST
      • Overview
      • MetricsData
        • Overview
        • read
        • write
        • prometheusMetrics
      • MetricsMeta
        • Overview
        • listLabelKeys
        • listLabelValues
        • listMetricNames
        • listMetrics
  • Questions and answers
  1. Step-by-step instructions
  2. Working with metrics
  3. Export metrics in Prometheus format

Exporting metrics in Prometheus format

    To export metrics in Prometheus format, use the method prometheusMetrics. Before uploading metrics to Prometheus, set up metrics collection in Prometheus.

    Example of setting up metrics collection from Monitoring in Prometheus:

    1. Select the folder you want to collect data from.

    2. Select a service from the following list:

      • compute – Compute Cloud.
      • storage – Object Storage.
      • managed-postgresql – Managed Service for PostgreSQL.
      • managed-clickhouse – Managed Service for ClickHouse.
      • managed-mongodb – Managed Service for MongoDB.
      • managed-mysql – Managed Service for MySQL.
      • managed-redis – Managed Service for Redis.
      • managed-kafka – Managed Service for Apache Kafka®.
      • managed-elasticsearch – Managed Service for Elasticsearch.
      • managed-sqlserver – Managed Service for SQL Server
      • managed-kubernetes – Managed Service for Kubernetes.
      • serverless-functions – Cloud Functions.
      • serverless_triggers_client_metrics – Cloud Functions triggers.
      • ydb – Yandex Database.
      • interconnect – Cloud Interconnect.
      • certificate-manager – Certificate Manager.
      • data-transfer – Data Transfer.
      • serverless-apigateway – API Gateway.
    3. Create a static API key for your service account.

    4. Assign to the service account the role viewer for the selected folder.

    5. 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'
          params:
            folderId:
            - '<folderId>' # for example, aoeng2krmasimogorn5m
            service:
            - '<service>' # for example, managed-mongodb
          bearer_token: '<api_key>'
          # Or use a file (recommended):
          # bearer_token_file: '<name of file with api_key>'
          static_configs:
          - targets: ['monitoring.api.cloud.yandex.net']
            labels:
              folderId: '<folderId>'
              service: '<serviceId>'
      
    6. Restart Prometheus.

    7. Check the data collection in the Prometheus user interface: http://localhost:9090/targets (replace localhost with the name of the host that runs Prometheus).

    8. If you need to change the label names, use relabeling.

    Tip

    If you have a lot of metrics, increase the data collection timeout (scrape_timeout) to 60s.

    Language / Region
    Careers
    Privacy policy
    Terms of use
    Brandbook
    © 2021 Yandex.Cloud LLC