
- Elasticsearch exporter Bob starts with the Prometheus exporter for Elasticsearch. He downloads, unpacks, and runs it pointing at his local Elasticsearch instance (listening on port 3200 in this lab):
9114. Among many metrics it exposes are the JVM heap used and the JVM heap max; these two values are used later for alerting.
- Prometheus — scraping the exporter
Next Bob runs Prometheus and tells it to scrape the exporter. Prometheus’s
scrape_configslists the jobs Prometheus polls; Bob adds anelasticsearchjob that points at the exporter:

- Grafana — visualizing metrics
Bob installs Grafana and configures a Prometheus datasource that points to
http://localhost:9090. Grafana runs on port3000and he logs in with the initial credentialsadmin/admin, then changes the password and adds the datasource.

- Alert rules — detecting high heap usage
Because Bob doesn’t watch dashboards 24/7, he defines a Prometheus alert rule to notify him when Elasticsearch heap usage becomes problematic. The rule below computes heap usage as the ratio of
usedtomaxJVM memory (exported by the Elasticsearch exporter) and fires if the ratio exceeds a threshold for 2 minutes. For demonstration the threshold is intentionally low (5%) so the alert fires quickly; in production use a higher, realistic threshold.
The 5% threshold is intentionally low for demonstration so the alert fires quickly. In production set a realistic threshold (for example, 90%) and tune the
for duration to reduce noisy alerts.POST /-/reload (recommended when supported). Bob restarted Prometheus in his lab to pick up the changes:
Using
kill -9 forcibly terminates a process and can prevent graceful shutdown and data flushing. Prefer a graceful reload (POST /-/reload) or a clean shutdown (kill <pid>), and use kill -9 only as a last resort.for period, Prometheus shows the alert as FIRING in its Alerts page. Prometheus then forwards the alert to an external alert manager for routing and delivery.
- Alertmanager — routing alerts to receivers
Bob installs Alertmanager and begins with a simple routing configuration that sends alerts to a webhook receiver running locally on port
5001:
alerting configuration should reference Alertmanager’s http://localhost:9093 endpoint). When Alertmanager receives an alert from Prometheus it delivers it to the configured webhook.

- Webhook receiver — example notification endpoint
For the demo Bob runs a small Python webhook receiver that listens on port
5001and prints the payload it receives:


- Prometheus docs — scraping & configuration: https://prometheus.io/docs/
- Prometheus alerting rules: https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/
- Alertmanager docs — routing and receivers: https://prometheus.io/docs/alerting/latest/alertmanager/
- Grafana: https://grafana.com/
- Elasticsearch exporter: https://github.com/prometheus-community/elasticsearch_exporter
- Notification integrations: Slack (https://slack.com), PagerDuty (https://www.pagerduty.com)