Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scraping metrics from every Pod in a DaemonSet

We're using https://github.com/fluent/fluentd-kubernetes-daemonset to deploy Fluentd in our K8s cluster. We have 5 nodes in the cluster, which means there are 5 Fluentd pods.

Each Fluentd pod in the DaemonSet exposes Prometheus metrics on localhost:24231/metrics endpoint via fluentd prometheus plugin. I'm having trouble finding the relevant bits of documentation on how to configure Prometheus to collect those metrics from every Pod's localhost:24321/metrics endpoint.

TL;DR

  • there are N pods in a DaemonSet
  • each pod has prometheus metrics exposed on localhost:24321

I need to configure Prometheus so it's able to scrape those metrics somehow. Any tips on how to solve this or examples of such configurations would be much appreciated!

like image 627
Roman Kolpak Avatar asked Oct 18 '25 12:10

Roman Kolpak


1 Answers

Solution in our case was using pod monitors CRD from the prometheus operator with podMetricEndpoints pointing at the right port:

apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
  name: fluentd
spec:
  podMetricsEndpoints:
    - honorLabels: true
      interval: 15s
      path: /metrics
      targetPort: 24231
      scheme: http
  selector:
    matchLabels:
      app: fluentd
like image 150
Roman Kolpak Avatar answered Oct 20 '25 13:10

Roman Kolpak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!