Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

splitting kubernetes service ip with regex #2971

Closed
bahho opened this Issue Jul 19, 2017 · 3 comments

Comments

Projects
None yet
2 participants
@bahho
Copy link

bahho commented Jul 19, 2017

What did you do?
I have pods with jmx-exporter. I would like to scrape only the exposed ports.
I do use the annotation "prometheus.io/port" but to be that only the exposed port is scraped in case some pods/services dont have the annotation. To do so I am trying to replace the ports in the addresses that I get from the service endpoints.

I have multiple ports exposed in the pods so that with the below config I get endpoints in prometheus like
http://10.131.0.2:1111 http://10.131.0.2:2222 http://10.131.0.2:3333 http://10.131.0.2:4444

I would like to split up the pod IP and append the port number I would like to scrape.

I don't seem to be able to make use of the regexes...

What I need is something like

      - source_labels: [__meta_kubernetes_service_annotation_prometheus_io_port]
        action: replace
        target_label: __address__
        regex: functioning regex 
        replacement:  ${1}:2222

where ${1} is the service IP and 2222 is the port I want.

Can anybody help me with that?

Environment
OpenShift

  • Prometheus version:

    1.6.2

  • Prometheus configuration file:

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

      relabel_configs:
      - source_labels: [__meta_kubernetes_service_annotation_prometheus_io_scrape]
        action: keep
        regex: true
      - source_labels: [__meta_kubernetes_service_annotation_prometheus_io_port]
        action: replace
        target_label: __address__
        regex: (.+)
        replacement:  
 

@bahho bahho changed the title kubernetes pod ip splitting kubernetes pod ip with regex Jul 19, 2017

@bahho bahho changed the title splitting kubernetes pod ip with regex splitting kubernetes service ip with regex Jul 19, 2017

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Jul 24, 2017

It makes more sense to ask questions like this on the prometheus-users mailing list rather than in a GitHub issue. On the mailing list, more people are available to potentially respond to your question, and the whole community can benefit from the answers provided.

@bahho

This comment has been minimized.

Copy link
Author

bahho commented Jul 24, 2017

Thanks for the info. I'll do that.

@lock

This comment has been minimized.

Copy link

lock bot commented Mar 23, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Mar 23, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.