How to add servicemonitor for pgbouncer-exporter metrics

452 Views Asked by At

I have added pgbouncer-exporter container to my deployment. It is emitting the metrics on port 9100. I want to add a scraper for these metrics so that it becomes visible in Prometheus. How can I do it by using Kubernetes ServiceMonitor?

1

There are 1 best solutions below

1
DazWilkin On BEST ANSWER

I'm unfamiliar with pgbouncer-exporter but the principles are consistent irrespective of technology.

You'll need to:

  1. Ensure the pgbouncer_exporter's port (default 9127?) is published so that the /metrics are accessible beyond the Pod.
  2. Test GET'ting the endpoint (e.g. kubectl port-forward to the Deployment) to ensure that /metrics is accessible.
  3. Determine whether to use a ServiceMonitor or PodMonitor. If you have a Service exposing pgbouncer_exporter, then use ServiceMonitor. Otherwise, use PodMonitor
  4. Configure *Monitor's selector and port
  5. Apply the config to your cluster in the Namespace of your Deployment.