How to Configure Prometheus Metric Reporter for Flink Jobs Running in Ververica Platform?

Question

How to set Prometheus as metric reporter for Flink jobs?

Answer

Note: This section applies to Flink 1.12 onwards.

As of Flink version 1.16, metrics reporter configuration for Prometheus has been changed to the following:

Tip: Port configuration is optional.

From 1.16 onwards

spec:
  template:
    spec:
      flinkConfiguration:
        metrics.reporter.prom.factory.class: org.apache.flink.metrics.prometheus.PrometheusReporterFactory
        metrics.reporter.prom.port: 9249

Prior to 1.16

spec:
  template:
    spec:
      flinkConfiguration:
        metrics.reporter.prom.class: org.apache.flink.metrics.prometheus.PrometheusReporter
        metrics.reporter.prometheus.port: 9249

In order to make sure Prometheus can scrape from Flink jobs, set the following configuration for Flink jobs as well, both for Job Manager and Task Manager pod templates:

spec:
  template:
    spec:
      kubernetes:
        taskManagerPodTemplate:
          metadata:
            annotations:
              prometheus.io/port: '9249'
              prometheus.io/scrape: 'true'
        jobManagerPodTemplate:
          metadata:
            annotations:
              prometheus.io/port: '9249'
              prometheus.io/scrape: 'true'

Note: The above given port 9249 is the default port Prometheus exporter is listening on.

Related Information