ADH Cloud monitoring

Export metrics

Each cluster object (TrinoCluster, ImpalaCluster, SparkHistoryServer, SparkApplication) has a property that enables metrics exposition in the Prometheus format:

monitoring:
    # Enables Prometheus metrics export from this product's pods.
    exportMetrics: true

Additionally, Kerberos operator supports the monitoring.exportMetrics property as it doesn’t have a cluster object associated with it.

Setting just the exportMetrics parameter exposes the metrics that can be picked up by a monitoring agent.

To view these metrics, you can add an entry to a load balancer service configuration, for example for Trino:

- name: http-metrics
  port: 9209
  targetPort: http-metrics
- name: https-metrics
  port: 9210
  targetPort: https-metrics

Alternatively, you can check the metrics with port forwarding:

$ kubectl port-forward pod/trino-coordinator-0 9209:http-metrics -n trino

The metrics will be available at http://<host>:9209/metrics if SSL is not enabled.

NOTE
When SSL is enabled, the http-metrics entry in the load balancer configuration sample above won’t work along with the http://<host>:9209/metrics URL. For Trino and Impala, port can be kept the same, but for Spark History Server and a Spark application, the port number should be changed.
Example of the exposed metrics for a Trino cluster
# HELP io_airlift_bootstrap_LifeCycleManager_PreDestroyInstancesCount  io.airlift.bootstrap:name=LifeCycleManager,type=null,attribute=PreDestroyInstancesCount
# TYPE io_airlift_bootstrap_LifeCycleManager_PreDestroyInstancesCount untyped
io_airlift_bootstrap_LifeCycleManager_PreDestroyInstancesCount 44.0
# HELP io_airlift_http_client_HttpClient_1xxResponse_FifteenMinute_Count  io.airlift.http.client:name=ForExchange,type=HttpClient,attribute=1xxResponse.FifteenMinute.Count
# TYPE io_airlift_http_client_HttpClient_1xxResponse_FifteenMinute_Count untyped
io_airlift_http_client_HttpClient_1xxResponse_FifteenMinute_Count{name="ForAnnouncer"} 0.0
io_airlift_http_client_HttpClient_1xxResponse_FifteenMinute_Count{name="ForExchange"} 0.0
io_airlift_http_client_HttpClient_1xxResponse_FifteenMinute_Count{name="ForMemoryManager"} 0.0
io_airlift_http_client_HttpClient_1xxResponse_FifteenMinute_Count{name="ForNodeManager"} 0.0
io_airlift_http_client_HttpClient_1xxResponse_FifteenMinute_Count{name="ForQueryHistory"} 0.0
io_airlift_http_client_HttpClient_1xxResponse_FifteenMinute_Count{name="ForScheduler"} 0.0
io_airlift_http_client_HttpClient_1xxResponse_FifteenMinute_Count{name="ForWorkerInfo"} 0.0

In-cluster collector

If you have Prometheus operator (the podmonitors.monitoring.coreos.com or servicemonitors.monitoring.coreos.com CRD) or VictoriaMetrics operator (vmpodscrapes.operator.victoriametrics.com or vmservicescrapes.operator.victoriametrics.com CRD) installed, you need to generate a specific config. If the corresponding CRDs are not installed, the attempt to apply a configuration with adc will result in failure. The metric scraper should be able to discover the resource by its namespace and labels. Make sure to specify the monitoring.scrape.labels parameter according to your scraper settings.

To generate configuration for PodMonitor, ServiceMonitor, VMPodScrape, or VMServiceScrape, you need to specify the provider (--prom/--vm) and discovery mode (--pod/--service) flags for the adc init command, for example:

  • PodMonitor

  • ServiceMonitor

  • VMPodScrape

  • VMServiceScrape

$ ./adc init --spark-application --prom --pod -o spark-application.yaml
# Monitoring configuration.
monitoring:
  # Enables Prometheus metrics export from this product's pods.
  exportMetrics: true

  # Configures one PodMonitor, ServiceMonitor, VMPodScrape or VMServiceScrape resource.
  scrape:
    # Metadata labels added to the selected scrape resource.
    labels:
      release: prometheus
    podMonitor:
      podMetricsEndpoints:
        - interval: 15s
          path: /metrics/prometheus
          relabelings:
          - sourceLabels:
            - __meta_kubernetes_pod_label_spark_app_name
            targetLabel: app
        - interval: 15s
          path: /metrics/executors/prometheus
          relabelings:
          - sourceLabels:
            - __meta_kubernetes_pod_label_spark_app_name
            targetLabel: app
      selector:
        matchLabels:
          app.kubernetes.io/instance: my-cluster
          spark-role: driver
$ ./adc init --spark-application --prom --service -o spark-application.yaml
# Monitoring configuration.
monitoring:
  # Enables Prometheus metrics export from this product's pods.
  exportMetrics: true

  # Configures one PodMonitor, ServiceMonitor, VMPodScrape or VMServiceScrape resource.
  scrape:
    # Metadata labels added to the selected scrape resource.
    labels:
      release: prometheus
    serviceMonitor:
      endpoints:
        - interval: 15s
          path: /metrics/prometheus
          relabelings:
          - sourceLabels:
            - __meta_kubernetes_service_label_app_kubernetes_io_instance
            targetLabel: app
        - interval: 15s
          path: /metrics/executors/prometheus
          relabelings:
          - sourceLabels:
            - __meta_kubernetes_service_label_app_kubernetes_io_instance
            targetLabel: app
      selector:
        matchLabels:
          app.kubernetes.io/instance: my-cluster
          spark-role: driver
$ ./adc init --spark-application --vm --pod -o spark-application.yaml
# Monitoring configuration.
monitoring:
  # Enables Prometheus metrics export from this product's pods.
  exportMetrics: true

  # Configures one PodMonitor, ServiceMonitor, VMPodScrape or VMServiceScrape resource.
  scrape:
    # Metadata labels added to the selected scrape resource.
    labels: {}
    vmPodScrape:
      podMetricsEndpoints:
        - attach_metadata: {}
          interval: 15s
          path: /metrics/prometheus
          relabelConfigs:
          - sourceLabels:
            - __meta_kubernetes_pod_label_spark_app_name
            targetLabel: app
        - attach_metadata: {}
          interval: 15s
          path: /metrics/executors/prometheus
          relabelConfigs:
          - sourceLabels:
            - __meta_kubernetes_pod_label_spark_app_name
            targetLabel: app
      selector:
        matchLabels:
          app.kubernetes.io/instance: my-cluster
          spark-role: driver
$ ./adc init --spark-application --vm --service -o spark-application.yaml
# Monitoring configuration.
monitoring:
  # Enables Prometheus metrics export from this product's pods.
  exportMetrics: true

  # Configures one PodMonitor, ServiceMonitor, VMPodScrape or VMServiceScrape resource.
  scrape:
    # Metadata labels added to the selected scrape resource.
    labels: {}
    vmServiceScrape:
      endpoints:
        - attach_metadata: {}
          interval: 15s
          path: /metrics/prometheus
          relabelConfigs:
          - sourceLabels:
            - __meta_kubernetes_service_label_app_kubernetes_io_instance
            targetLabel: app
        - attach_metadata: {}
          interval: 15s
          path: /metrics/executors/prometheus
          relabelConfigs:
          - sourceLabels:
            - __meta_kubernetes_service_label_app_kubernetes_io_instance
            targetLabel: app
      selector:
        matchLabels:
          app.kubernetes.io/instance: my-cluster
          spark-role: driver

External ADM integration

Each operator (TrinoOperator, ImpalaOperator, SparkOperator, KerberosOperator) can remotely write metrics to an external ADM cluster.

For Trino and Impala, you need to activate the monitoring.exportMetrics property in the cluster document and specify the monitoring.vmagent.remoteWrite.url property in the operator document.

Spark History Server and Spark application share the monitoring.vmagent.remoteWrite.url property from Spark operator, but have separate monitoring.exportMetrics cluster properties.

As for Kerberos operator, YuniKorn, and Celeborn, both aforementioned properties are configured in the same document.

The ADM monitoring configuration in an operator document with SSL support looks as follows:

Operator monitoring configuration
## Operator monitoring configuration. Supports product-specific metrics export and optional vmagent delivery to an external ADM.
  monitoring:
  #  # Renders a namespace-scoped vmagent that sends metrics to an external ADM.
    vmagent:
      remoteWrite:
        url: http://tsn-adm.ru-central1.internal/insert/0/prometheus/api/v1/write (1)
      scrapeInterval: 15s
      image: hub.arenadata.io/adm-enterprise/vmagent:1.136.0-adm-5.0.0-x86_64 (2)
  #
  #    ## HTTPS settings used by vmagent when scraping product metrics.
      tls: (3)
  #    #  ## CA certificate source used to verify the metrics endpoint.
        ca:
  #    #  #  # Use a Secret managed outside ADC.
  #    #  #  externalSecretName: existing-product-metrics-ca
  #    #  #
  #    #  #  ## Or let ADC create the Secret.
          secretName: product-metrics-ca
  #    #  #
  #    #  #  # Key containing the CA certificate in the referenced Secret.
          certificateKey: ca.crt
  #    #  #
  #    #  #  ## Local CA certificate read by ADC to create the configured Secret.
          files:
            certificatePath: /etc/ssl/ca.crt
  #    #
  #    #  ## Server name used to verify the metrics endpoint certificate hostname.
        serverName: metrics.example.com (4)
  #    #
  #    #  # Skip verification of the metrics endpoint certificate. Do not use together with ca.
  #    #  insecureSkipVerify: true
1 ADM write endpoint.
2 URL to a vmagent image.
3 Certificate check settings used while collecting metrics.
4 DNS name from the CA certificate’s SAN.

The workloads (YuniKorn and Celeborn) contain metrics export and remote write configurations:

Workload monitoring configuration
## Monitoring configuration.
  monitoring:
  #  # Enables Prometheus metrics export from this product's pods.
    exportMetrics: true
  #
  #  ## Renders a namespace-scoped vmagent that sends metrics to an external ADM.
    vmagent:
      remoteWrite:
        url: http://tsn-adm.ru-central1.internal:8480/insert/0/prometheus/api/v1/write (1)
      scrapeInterval: 30s
  #  #
  #  #  ## HTTPS settings used by vmagent when scraping product metrics.
      tls: (2)
  #  #  #  ## CA certificate source used to verify the metrics endpoint.
        ca:
  #  #  #  #  # Use a Secret managed outside ADC.
  #  #  #  #  externalSecretName: existing-product-metrics-ca
  #  #  #  #
  #  #  #  #  ## Or let ADC create the Secret.
          secretName: product-metrics-ca
  #  #  #  #
  #  #  #  #  # Key containing the CA certificate in the referenced Secret.
          certificateKey: ca.crt
  #  #  #  #
  #  #  #  #  ## Local CA certificate read by ADC to create the configured Secret.
          files:
            certificatePath: /path/to/ca.crt
  #  #  #
  #  #  #  ## Server name used to verify the metrics endpoint certificate hostname.
        serverName: metrics.example.com (3)
  #  #  #
  #  #  #  # Skip verification of the metrics endpoint certificate. Do not use together with ca.
  #  #  #  insecureSkipVerify: true
1 ADM write endpoint.
2 Certificate check settings used while collecting metrics.
3 DNS name from the CA certificate’s SAN.

The monitoring.vmagent.remoteWrite scheme doesn’t have a TLS section, hence the ADM certificate check should be performed by setting the following extraArgs:

  • -remoteWrite.tlsCAFile

  • -remoteWrite.tlsServerName

  • -remoteWrite.tlsInsecureSkipVerify

The CA certificate file gets mounted into a container from /etc/vmagent-tls/ca.crt.

For convenience, you can import the prepared dashboards into Grafana. For that, you need to export them:

$ ./adc export dashboards -o ./dashboards

A bunch of JSON files will be created in the dashboards directory. You can upload them into the Grafana web UI and view the metrics.

Grafana web UI
Grafana web UI
Grafana web UI
Grafana web UI
Found a mistake? Seleсt text and press Ctrl+Enter to report it