nats-io / k8s

NATS on Kubernetes with Helm Charts
Apache License 2.0
444 stars 300 forks source link

Expose promExporter to service or Prometheus could not scrape #877

Open duylddev opened 5 months ago

duylddev commented 5 months ago

What motivated this proposal?

promExporter port 777 should expose to nats service so Prometheus can scrape

What is the proposed change?

  service:
    ports:
      monitor:
        enabled: true

should add promExporter: enabled: true here

Who benefits from this change?

Who doesn't want to install prometheus-nats-exporter from https://prometheus-community.github.io/helm-charts and can use embedded pod by set enable = true

What alternatives have you evaluated?

I must write a new service to expose prompExporter 777 and update Prometheuse scrape config

caleblloyd commented 5 months ago

It's already enabled via the headless service, example: nats-headless:7777 Also you want to scrape each pod, not just 1 pod via a ClusterIP Service.

duylddev commented 5 months ago

Thank you for the really fast reply I run wget in Prometheus and it works

What makes me confused is port 7777 isn't listed in the headless service port table. But looks like it doesn't matter, we still can connect to all ports anyway image

caleblloyd commented 5 months ago

Ah, maybe we should go ahead and add it to the Headless Service port list if its enabled then. If you're not doing any network policy it should still work though.

duylddev commented 5 months ago

I have 1 more question about promExporter. Is it compatible with Grafana Nats template? https://grafana.com/grafana/dashboards/2279-nats-servers/

The thing is when I install a new chart from https://artifacthub.io/packages/helm/prometheus-community/prometheus-nats-exporter Grafana works fine.

But if I use embedded promExporter, Grafana always shows no data

duylddev commented 5 months ago

more information: Prometheus scape works fine: image

martincolladodev commented 2 months ago

I have 1 more question about promExporter. Is it compatible with Grafana Nats template? https://grafana.com/grafana/dashboards/2279-nats-servers/

The thing is when I install a new chart from https://artifacthub.io/packages/helm/prometheus-community/prometheus-nats-exporter Grafana works fine.

But if I use embedded promExporter, Grafana always shows no data

Did you you realice how to use the embedded promExporter on Grafana, show no data to me as well., even using the chart for helm https://github.com/nats-io/prometheus-nats-exporter/blob/main/walkthrough/grafana-jetstream-dash-helm.json