How do I pull Elastic-search metrics into Prometheus using the Elasticseacrh_exporter

9/12/2019

I have installed Prometheus into a Kubernetes cluster using the helm stable chart. We run Elastic Search and I want to scrape metrics from this and then create Alerts based on events. I have installed the elasticsearch exporter via helm but no where can I find how I then import these metrics into Prometheus ?

There is some config I am missing such as creating a scrap job or something. Anyone can help much appreciated.

I connected to the elasticsearch exporter and can see it pulling metrics.

-- cjm888
elasticsearch
kubernetes
kubernetes-helm

1 Answer

9/12/2019

If you're using an elasticsearch exporter it should contain some documentation. There are more than just one solution out there and you didn't specify which one you're using. In my opinion it would be best for you to start from a tutorial like this one which explains step by step the whole process. As you can read there:

Metrics collection of Prometheus follows the pull model. That means, Prometheus is responsible for getting metrics from the services that it monitors. This process introduced as scraping. Prometheus server scrapes the defined service endpoints, collect the matrixes and store in local database.

which means you need to configure Prometheus to scrape metrics exposed by the elasticsearch exporter you chose.

Official Prometheus documentation will be also a great source of knowledge and good starting point.

EDIT:

If you run your Elasticsearch instance on Kubernetes cluster, you should rather use the Service Discovery mechanism than static configs. More on <kubernetes_sd_config> you can find here.

There are five different types of Kubernetes service discoveries you can use with Prometheus: node, endpoints, service, pod, and ingress. The one which you most probably need in your case is endpoints. Prometheus uses the Kubernetes API to discover targets. Below you have some examples:

https://blog.sebastian-daschner.com/entries/prometheus-kubernetes-discovery https://raw.githubusercontent.com/prometheus/prometheus/master/documentation/examples/prometheus-kubernetes.yml

-- mario
Source: StackOverflow