Prometheus Operator is the perfect cloud-native monitoring solution for Kubernetes. By deploying the Helm chart you get a preconfigured Prometheus and Grafana setup plus an array of CRDs to add monitoring your own services.
Not everything necessarily lives in a Kubernetes cluster, though. So how would you add external targets to a Prometheus Operator setup? One could define an Endpoint, Service and ServiceMonitor for the external resource to have it picked up by Prometheus’ Kubernetes service discovery, which works, but there is a better solution that is more in line with how Prometheus is used outside
of the Operator deployment.
The helm chart accepts a value to supply additional targets identical to how you would define them in prometheus.yml for a legacy Prometheus setup. Stick the following in your
- job_name: "External servers"
- targets: ["server1.mydomain:9100", "server2.mydomain:9100"]
helm upgrade prometheus-operator stable/prometheus-operator --values prometheus-values.yml
And watch your external servers show up in Prometheus!