Elastic Agent metric endpoint autodiscovery in Kubernetes

Hello everyone,

we are looking into monitoring Kubernetes Clusters with Elastic Agents using the Kubernetes Integration. We are using Fleet to manage our Elastic Agents. We are able to collect metrics from kubelet api, kube-state-metrics and so on.

Now we want to collect metrics provided by the applications via the /metrics endpoint. The “Prometheus Input” Integration has the ability to scrape metrics from endpoints, if you know the endpoints. But we want to use labels to autodiscover the /metrics-endpoints, similar to how Prometheus does it since we don’t know the endpints and don’t know how many applications have an endpoint.

The goal is to tell the developers which labels to place for their Kubernetes applications so that their application metrics get ingested by the Agent.

The question is: Is there a way to autodiscover /metric-endpoints based on labels using our setup?

Our Cluster and Agents are v. 9.1.5. We are using Elastic Package Registry 9.1.2

Best regards,
Ilya

In case someone else stumbles across this with the same questions, this is what worked for us: Fleet managed elastic agent: Kubernetes Prometheus Metrics Autodiscover

Unfortunatly it’s not well documented and if you don’t have deep knowledge of Kubernetes it is not obvious how to do it.

Basically the Agent has the ability to autodiscover Pods with their respective IPs, annotations and so on. You can use this information in the Prometheus Integration to autodiscover any metrics-endpoints the same way a Prometheus does it.