Elasticsearch Elasticsearch Monitoring with Grafana and Prometheus

By Opster Expert Team - Gustavo

Updated: Mar 24, 2024

| 4 min read

This guide covers how to set up monitoring with Prometheus and Grafana. The instructions in this guide pertain to manual processes in Elasticsearch.

Quick links

Prometheus: Definition

What is Prometheus?

Prometheus is an open-source monitoring tool that integrates with many data sources, offering monitoring, alerting, and visualization capabilities via Grafana integration.

Prometheus diagram explaining how does it works

This guide uses Prometheus Elasticsearch Exporter and Grafana for the visualizations.

For this process users will need: 

  1. A machine that’s compatible with Elasticsearch exporter
  2. A running Elasticsearch instance

Once a compatible exporter is downloaded, start Elasticsearch, and proceed to install the remaining assets.

Installing Prometheus

There are many methods to install Prometheus, this guide will stick to the binary approach.

After downloading the binary, extract it and navigate to the folder. Open “prometheus.yml” and add the following:

  scrape_interval: 15s

- job_name: elasticsearch
  - targets: ['localhost:9114']

After installing the Exporter, outlined in the next step, users can start Prometheus using the following command:

./prometheus –config.file=./prometheus.yml

Installing Prometheus Exporter

The Exporter will pull metrics from Elasticsearch and generate a HTTP endpoint that Prometheus can crawl from.
Download the exporter here, extract the exporter, decompress, and run the following from the extracted folder:

./elasticsearch_exporter --es.uri="http://localhost:9200"

An output like this should be visible:

Example of an output you should receive when installing Prometheus Exporter

Test the endpoint by running:

curl http://localhost:9114/metrics

An output like the one below indicates Exporter is ready for Prometheus to crawl.

Example of an output that indicates Exporter is ready for Prometheus to crawl.

Installing Grafana

Follow system instructions

For macOS: 

curl -O https://dl.grafana.com/enterprise/release/grafana-enterprise-9.2.0-beta1.darwin-amd64.tar.gz


tar -xvf grafana-enterprise-9.2.0-beta1.darwin-amd64.tar.gz

cd to the folder 

cd grafana-9.2.0-beta1

and run:

./bin/grafana-server web

Now go to localhost:3000 and login using admin:admin credentials, users should see the following:

Welcome to Graphana screen

Adding Prometheus as a data source

Go to http://localhost:3000/datasources/new  to add a new prometheus Data Source

Adding Prometheus as a data source screen example

Set ​​http://localhost:9090/ as the URL, and click Save & Test.

Importing the Dashboard 

View the Dashboard description here: Elasticsearch Exporter | Grafana Labs

Go to: http://localhost:3000/dashboard/import and enter 14191 as the Dashboard ID, and click Load.

Example of the screen while importing a dashboard to Grafana

Now go to http://localhost:3000/dashboards and select: Elasticsearch Exporter Quickstart and Dashboard.

How to select Elasticsearch Exporter Quickstart and Dashboard on Grafana Step 1.
How to select Elasticsearch Exporter Quickstart and Dashboard on Grafana Step 2

Done! Now users can monitor their Elasticsearch instance using Prometheus and Grafana. 

Adding recording rules

Some visualizations require configuring Recording Rules. Recording rules allow users to precompute frequently needed or computationally expensive expressions,  saving their result as a new set of time series. This allows the dashboard to query against the precomputed values, which is more performant. 

To add recording rules, download this file, save it in the Prometheus folder, and add the following the prometheus.yml:

 - "elasticsearch_exporter_alerting_rules.yml"

Where elasticsearch_exporter_alerting_rules.yml is the path to the file downloaded in the previous step.

Now restart Prometheus.
Confirm these were added by visiting http://localhost:9090/rules.

Adding recording rules screen example.


Setting up a monitoring stack with Prometheus and Grafana is a simple task using Elasticsearch Exporter for Prometheus. This builds the data metrics format for all users.