Search code examples
kubernetesprometheuspgbouncerservicemonitor

How to add servicemonitor for pgbouncer-exporter metrics


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?


Solution

  • 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.