Open jhwbarlow opened 3 years ago
The ServiceMonitors must be dependent on .Values.agent.prometheus.scrape as currently they do more than just add the annotation, they primarily setup the metrics endpoint.
The prometheus operator stopped using the scrape annotation on pods in favor of ServiceMonitors as they are more configurable. So if your prometheus is scraping both annotation based and servicemonitors, then either you've added an additionalScrapeConfig to your deployment or are still running an older version.
Ideally, when servicemonitors are enabled, then the service annotations need to not be added.
Enabling the ServiceMonitors causes each metric to be scraped twice.
This is because to enable the ServiceMonitors, the
.Values.agent.prometheus.scrape
value must be set totrue
, see agent here and server here. However, enabling this value is also the trigger to add theptometheus.io/scrape
annotation to the agent service and server service.Because the Prometheus Operator creates a scrape target for each ServiceMonitor resource, and for each service with a
scrape: true
annotation, the same metric get scraped twice with different labels. For example:Where the series with the
service="kiam-server"
label are created from the ServiceMonitor, and the ones without created due to the scrape annotation.I believe that the creation of the ServiceMonitors should not be dependent on the
.Values.agent.prometheus.scrape
value. This value should only be used to toggle the addition of the scrape annotations to the services.