How to Set Prometheus to Report Flink Job Metrics of a Specific Deployment Target

Question

How to set Prometheus to report Flink job metrics of specific Deployment Targets (Kubernetes Namespaces)?

Answer

All the Kubernetes Namespaces which the Flink Jobs are deployed must be set inside the Prometheus Operator values file:

prometheusOperator:
  namespaces:
    additional:
    - vvp-jobs-new1
    - vvp-jobs-new2

In addition to the above configuration, a Kubernetes Service definition to expose Flink Pod metrics and a Prometheus Operator ServiceMonitor to declare scraping configuration of that Service must be added for all Deployment Targets individually:

kubectl --namespace "vvp-jobs-new1" apply -f prometheus-operator-resources/service-monitor.yaml
kubectl --namespace "vvp-jobs-new2" apply -f prometheus-operator-resources/service-monitor.yaml

Related Information