How mindw/elasticsearch-prometheus-exporter works
This Elasticsearch plugin exposes cluster and node metrics in Prometheus text formats through GET /_prometheus/metrics. A scrape enters the REST handler, which dispatches an internal metrics action; its transport action gathers Elasticsearch health, node, index, and cluster-state data, and the handler builds and renders a metric catalog. The collector covers the documented cluster, node, index, selected cluster-setting, and HotSpot metric capabilities. Some collector internals and action wiring were not excerpted, so only documented or indexed relationships are shown.
Main entry points: RestPrometheusMetricsAction.java Metrics REST handler · TransportNodePrometheusMetricsAction.java Transport collector action · NodePrometheusMetricsResponse.java Metrics response · PrometheusExporterPlugin.java Plugin registration
Components 14
Plugin and REST
- Plugin registration
src/main/java/org/elasticsearch/plugin/prometheus/PrometheusExporterPlugin.java - Metrics REST handler
src/main/java/org/elasticsearch/rest/prometheus/RestPrometheusMetricsAction.java
Metrics action
- Metrics request
src/main/java/org/elasticsearch/action/NodePrometheusMetricsRequest.java - Metrics action type
src/main/java/org/elasticsearch/action/NodePrometheusMetricsAction.java - Transport collector action
src/main/java/org/elasticsearch/action/TransportNodePrometheusMetricsAction.java - Metrics response
src/main/java/org/elasticsearch/action/NodePrometheusMetricsResponse.java
Collection and settings
- Cluster settings data
src/main/java/org/elasticsearch/action/ClusterStatsData.java - Index response access
src/main/java/org/elasticsearch/action/admin/indices/stats/PackageAccessHelper.java - Exporter settings
src/main/java/org/compuscene/metrics/prometheus/PrometheusSettings.java
Prometheus output
- Metric collector
src/main/java/org/compuscene/metrics/prometheus/PrometheusMetricsCollector.java - Metric catalog
src/main/java/org/compuscene/metrics/prometheus/PrometheusMetricsCatalog.java
Other components
- Prometheus scraper
- Elasticsearch stats APIs
- Prometheus metrics
Connections 16
- Prometheus scraper → Metrics REST handler: scrapes
README.md - Plugin registration → Metrics REST handler: registers handler
src/main/java/org/elasticsearch/plugin/prometheus/PrometheusExporterPlugin.java - Plugin registration → Transport collector action: registers action
src/main/java/org/elasticsearch/plugin/prometheus/PrometheusExporterPlugin.java - Plugin registration → Exporter settings: registers settings
src/main/java/org/elasticsearch/plugin/prometheus/PrometheusExporterPlugin.java - Metrics REST handler → Metrics request: creates
src/main/java/org/elasticsearch/rest/prometheus/RestPrometheusMetricsAction.java - Metrics REST handler → Metrics action type: dispatches
src/main/java/org/elasticsearch/rest/prometheus/RestPrometheusMetricsAction.java - Transport collector action → Elasticsearch stats APIs: requests stats
src/main/java/org/elasticsearch/action/TransportNodePrometheusMetricsAction.java - Transport collector action → Metrics response: builds response
src/main/java/org/elasticsearch/action/TransportNodePrometheusMetricsAction.java - Transport collector action → Exporter settings: reads flags
src/main/java/org/elasticsearch/action/TransportNodePrometheusMetricsAction.java - Metrics response → Cluster settings data: constructs
src/main/java/org/elasticsearch/action/NodePrometheusMetricsResponse.java - Metrics response → Index response access: reads index response
src/main/java/org/elasticsearch/action/NodePrometheusMetricsResponse.java - Metrics REST handler → Metrics response: renders from
src/main/java/org/elasticsearch/rest/prometheus/RestPrometheusMetricsAction.java - Metrics REST handler → Metric collector: creates
src/main/java/org/elasticsearch/rest/prometheus/RestPrometheusMetricsAction.java - Metric collector → Metric catalog: populates metrics
src/main/java/org/compuscene/metrics/prometheus/PrometheusMetricsCollector.java - Metrics REST handler → Metric catalog: formats response
src/main/java/org/elasticsearch/rest/prometheus/RestPrometheusMetricsAction.java - Metric catalog → Prometheus metrics: serializes