
Step-by-step: how the metric travels
- Elasticsearch exporter — expose metrics
http://localhost:9200), and runs it in the background. The exporter exposes Prometheus-format metrics (including JVM memory used/max) on port 9114.
Example commands:
http://localhost:9114/metrics you’ll see many metrics. Two important metrics the exporter provides are the JVM memory used and the JVM memory max — these are used later in an alert rule.
- Prometheus — scrape the exporter
prometheus.yml and starts Prometheus.
Relevant excerpt from prometheus.yml:
http://localhost:9090, then go to Status → Targets. You should see both the Prometheus target and the Elasticsearch exporter target marked UP if everything is running.

- Grafana — visualize Prometheus metrics
http://localhost:3000). After logging in (admin / admin on first run) he adds Prometheus as a data source pointing to http://localhost:9090. In Grafana’s Explore you can build PromQL queries from available metrics.
Example query to see active primary shards for the cluster named docker-cluster:
- Alerting — write a rule in Prometheus
rules.yml:

This example uses 5% so the alert will fire immediately for demonstration. In real deployments choose realistic thresholds (for example, 90% heap usage).
prometheus.yml:
rule_files at startup. You can either restart Prometheus or request a runtime reload by POSTing to http://localhost:9090/-/reload. Example of a simple restart approach:
Pending while the for window is counting down; if the condition persists it will change to Firing.
- Alertmanager — group and route alerts
web.hook receiver which posts to a small HTTP server on port 5001.
Relevant excerpt from alertmanager.yml:
alerting section to prometheus.yml (then restart or reload Prometheus):

- Receiver — do something with the alert


- Elasticsearch exporter: https://github.com/prometheus-community/elasticsearch_exporter
- Prometheus download and docs: https://prometheus.io/download/ and https://prometheus.io/docs/
- Grafana: https://grafana.com/get
- Alertmanager docs: https://prometheus.io/docs/alerting/latest/alertmanager/
- PromQL basics — learn common queries for alerting and dashboards.
- Alertmanager routing and receivers — configure Slack, PagerDuty, email, and webhooks.
- Best practices for thresholds and alert fatigue — choose meaningful severity and aggregation windows.