Skip to content
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.

Is there a way to open ports for Prometheus to scrape? #114

Closed
afilipchik opened this issue Nov 16, 2019 · 10 comments
Closed

Is there a way to open ports for Prometheus to scrape? #114

afilipchik opened this issue Nov 16, 2019 · 10 comments
Labels
question Further information is requested

Comments

@afilipchik
Copy link

No description provided.

@functicons
Copy link
Collaborator

Thanks for the proposal! I need to do some research first. If you have more detailed ideas, we can discuss here.

@functicons
Copy link
Collaborator

functicons commented Nov 17, 2019

@afilipchik Does this work for you? I think you might need to build a custom image and specify related Flink properties in the CR.

I don't see any change needed in the operator.

@chethanuk
Copy link
Contributor

chethanuk commented Nov 18, 2019

custom image

@afilipchik Check https://github.com/ChethanUK/Flink_Docker/blob/master/Dockerfile to build a custom image

and then In job-manager-service, I add the following lines:

  annotations:
    prometheus.io/scrape: "true"
    prometheus.io/port: "9999"

@functicons
Copy link
Collaborator

@chethanuk Thanks for your image, but why are the annotations needed for JM service?

@afilipchik
Copy link
Author

I thought the operator will need to open appropriate port (in the generated yaml), so the scraper can reach the container. Currently only flink related ports are exposed.

For now I did build a custom image and used prometheus push gateway, but having direct scrape sound more appropriate.

@functicons
Copy link
Collaborator

@afilipchik right, I think we can expose a prometheus port (9999 by default) on JM and TMs.

@functicons
Copy link
Collaborator

I realized the hard part is that, Prometheus needs to distinguish each TM, e.g.

 scrape_configs:
 - job_name: 'flink'
   static_configs:
   - targets: ['job-cluster:9999', 'taskmanager1:9999', 'taskmanager2:9999']

that makes it hard for Kubernetes, because we cannot simply create a TM service which is backed by all TMs.

The doc says:

In more dynamic scenarios we recommend using Prometheus’ service discovery support for different platforms such as Kubernetes, AWS EC2 and more.

I need to do more research on this.

@afilipchik
Copy link
Author

afilipchik commented Nov 18, 2019

I believe Prometheus can discover scrape targets (no need to hardcode them in the config). Target just needs to be accessible.

- job_name: 'kubernetes-service-endpoints'
   kubernetes_sd_configs:
    - role: endpoints

@elanv
Copy link
Contributor

elanv commented Nov 22, 2019

Prometheus also supports pod discovery. Using this method, prometheus queries the k8s api with pod meta information - labels and annotations - to get pod IPs and scrapes directly with those IPs.

Note: https://prometheus.io/docs/prometheus/latest/configuration/configuration/#pod

To support this approach we need to map the exporter port to the pod and allow the pod's label and annotation to be set. In this case metric collection is possible without any services.

@functicons functicons added the question Further information is requested label Mar 27, 2020
@elanv
Copy link
Contributor

elanv commented May 14, 2020

It seems this is resolved via #241, #243.

elanv pushed a commit to metatron-app/flink-on-k8s-operator that referenced this issue Oct 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants