How to push Kuberntes metrics in Prometheus instead of pull?

9/19/2020

I have configured Prometheus in our infra for monitoring. In our infra, we have an EKS clusters running. I have to collect EKS metrics in Prometheus.

By default, Prometheus work on a pull-based mechanism. Here I have a question on how to collect metrics from outside the Kubernetes cluster. In this case, traffic flow will be Prometheus --> Ingress controller --> Metric pod.

I search for this kind of scenario, but many peoples suggested Prometheus should be in the Kubernetes cluster then only it will work. Please suggest anyone have a good solution for this kind of scenario.
Is there any way to push Kubernetes metrics in Prometheus?

-- Vishal Patil
amazon-eks
devops
kubernetes
prometheus

1 Answer

9/19/2020

You can use Prometheus federation (https://prometheus.io/docs/prometheus/latest/federation/).

In your case, you can add a Prometheus instance into the EKS cluster that will scrape all cluster metrics, expose this Prometheus instance through ingress controller, and then add a target pointing on the ingress into the external Prometheus instance.

-- Alexandre Cartapanis
Source: StackOverflow