Hi, I'm new to prometheus-operator and I do not see difference between ServiceMonitor and PodMonitor.
Documentation describes them as:
ServiceMonitor, which declaratively specifies how groups of services should be monitored. The Operator automatically generates Prometheus scrape configuration based on the definition.
PodMonitor, which declaratively specifies how groups of pods should be monitored. The Operator automatically generates Prometheus scrape configuration based on the definition.
But this does not explain when to use particular one.
I played with them a little bit. Both of them use selector rules to find pods.
So you can either define PodMonitor that search for pods with eg. label app: myAPP, or if your app is behind service that is labeled eg. app:myAPP, you create ServiceMonitor that will scrape metrics from all pods in service with this label. Both of them will produce the same result in prometheus target tab in prometheus UI.
So I would really appreciate if someone will explain to me when one should use PodMonitor and when ServiceMonitor?
Hi, I'm new to prometheus-operator and I do not see difference between ServiceMonitor and PodMonitor.
Documentation describes them as:
But this does not explain when to use particular one.
I played with them a little bit. Both of them use selector rules to find pods.
So you can either define PodMonitor that search for pods with eg. label app: myAPP, or if your app is behind service that is labeled eg. app:myAPP, you create ServiceMonitor that will scrape metrics from all pods in service with this label. Both of them will produce the same result in prometheus target tab in prometheus UI.
So I would really appreciate if someone will explain to me when one should use PodMonitor and when ServiceMonitor?