ElasticSearch monitoring options using Prometheus

Why Monitoring for ElasticSearch ?
In my current Dev cluster , Elasticsearch server is used by Kibana for log monitoring , Any outage in Elasticsearch can impact the log monitoring in the cluster. Therefore elasticsearch performance and availability plays an important role and we would like to monitor the same.

What are the different tools available ?
In the first place, Elasticsearch itself provides different REST APIs and tool (Marvel) for monitoring different stats like Nodes and Cluster Health, Unavailable Shards, Memory usage etc .Apart from Elastic search tools/API,
there are also different tools from different open source projects like cerebro, elasticsearch-head and Prometheus for monitoring elasticsearch server.

Monitoring Tools/API:

OpenSource:

1) Cerebro:
https://github.com/lmenezes/cerebro
2) Elasticsearch-head:
https://github.com/mobz/elasticsearch-head

Elasticsearch Native monitoring( Marvel )
https://www.elastic.co/guide/en/marvel/current/introduction.html

Elasticsearch Monitoring Rest GET API’s:

GET /_cluster/stats?human&pretty ,GET _cluster/health,GET _nodes/stats ,GET _nodes/hot_threads
GET /_cluster/health/test1,test2 , GET /_nodes/nodeId1,nodeId2/statsGET /_nodes/stats/indices , GET /_nodes/stats/os,process, GET _nodes/usage

ElasticSearch and Prometheus:

Elasticsearch server can be monitored using Prometheus exporter, which is present in Prometheus repo.

List of different Prometheus Exporters:
https://prometheus.io/docs/instrumenting/exporters/

Elasticsearch Exporter:
The exporter “elasticsearch_exporte” is developed in Go and used for collecting various metrics about ElasticSearch.
Helm charts and Docker images are also provided as a part of the Git repo.

https://github.com/justwatchcom/elasticsearch_exporter

Basic Configuration: ( Exporter and Prometheus )

Exporter:

Elastic search URL need to be configured with the exporter for getting the required data points. Exporter provides list of different configuration parameters. Among different parameters , “es.uri” is the parameter
used for configuring elastic search.Once Exporter is configured , it can be started to scrape the elastic search and Next step is to configure
the exporter with Prometheus.

Prometheus:

Exporter URL need to be configured with Prometheus for scraping the data from ES.The parameter “target” present in the following location should be configured with the required exporter.

Sample Configuration with Prometheus:

scrape_configs:

The job name is added as a label `job=` to any timeseries scraped from this config.
job_name: ‘prometheus’
metrics_path defaults to ‘/metrics’
scheme defaults to ‘http’.
static_configs:

targets: [‘:’]
~

***

As per the deployment model ( Running Docker image directly, Installing using Helm Charts ) the way we configure the above parameters might be different but parameters remains the same.

Metrics :

Search for the following metrics in Prometheus and press execute to see the results.

elasticsearch_os_cpu_percent
elasticsearch_jvm_memory_max_bytes
elasticsearch_cluster_health_active_primary_shards
elasticsearch_node_stats_total_scrapes

Prometheus deployed @ http://:9090/graph

Apart from the above, there are many more metrics provided by this exporter, refer to https://github.com/justwatchcom/elasticsearch_exporter for more metrics.

Leave a comment