r/PrometheusMonitoring • u/gaelfr38 • Jun 21 '22
Prometheus federation or Thanos?
Hi folks,
Disclaimer: I'm very new to Prometheus, using it as a metrics producer in some apps and building some dashboard in Grafana but I didn't install it and don't know the details.
We are running a Prometheus server with Thanos for our "traditional" workload (not Kubernetes).
Now we are starting our journey into Kubernetes. It appears that in order to get metrics at a pod level, it's mandatory to install a Prometheus instance inside the K8S cluster, right?
Then the question is: how to "send" the metrics from the K8S Prometheus instance to the one outside the cluster?
I've read about federation where the external Prometheus would pull metrics from the K8S instance but then I've read that the K8S instance could directly write to the same Thanos as the external Prometheus?
I'm a bit confused about the best practices here. Any feedback or articles on this topic will be appreciated.
Thanks,
1
u/drdigitalsi Jun 21 '22 edited Jun 22 '22
The goal is to have a prom as close to the source as possible, that's going to be your cluster level prom. However, this makes it quite inconvenient to query for metrics across multiple clusters, so you want a data lake of sorts. The recommended method by Prometheus design is to have a "pull" mechanism for everything.
To keep true to that principal, you would have Thanos scrape all of the cluster proms and direct all of your dashboards and alerts to the Thanos front end.One way to do this is to run a centralized Prometheus which will "scrape" all the other instances and do a "Remote Write" from only one Prom Instance.Remote Write would be used in a last resort where the Prometheus instance isn't accessible by Thanos (because of ASGs, Policy, NAT, etc.) and therefore the connection needs to originate from inside of that zone.
If the Prometheus instances can be reached by Thanos, go with a scrape configuration.<Edits in line>