https://github.com/prometheus-community/elasticsearch_exporter
用于 ElasticSearch 的各种指标的 Prometheus 导出器,由 Go 语言编写。
导出器在每次抓取时从 ElasticSearch 集群中获取信息,因此抓取间隔太短会给 ES 主节点带来负载,尤其是当您使用 --es.all 和 --es.indices 运行时。 我们建议您测量 ES 集群获取 /_nodes/stats 和 /_all/_stats 所需的时间,以确定您的抓取间隔是否太短。 作为最后的手段,您可以使用具有自己的抓取间隔的专用作业抓取此导出器。
docker pull quay.io/prometheuscommunity/elasticsearch-exporter:latest
docker run --rm -p 9114:9114 quay.io/prometheuscommunity/elasticsearch-exporter:latest
Example docker-compose.yml:
elasticsearch_exporter:
image: quay.io/prometheuscommunity/elasticsearch-exporter:latest
command:
- '--es.uri=http://elasticsearch:9200'
restart: always
ports:
- "127.0.0.1:9114:9114"
解压进入目标文件夹后执行./elasticsearch_exporter --help可查看所有配置项;
usage: elasticsearch_exporter []
Flags:
-h, --help Show context-sensitive help (also try --help-long
and --help-man).
--web.listen-address=":9114"
Address to listen on for web interface and
telemetry.
--web.telemetry-path="/metrics"
Path under which to expose metrics.
--es.uri="http://localhost:9200"
HTTP API address of an Elasticsearch node.
--es.timeout=5s Timeout for trying to get stats from Elasticsearch.
--es.all Export stats for all nodes in the cluster. If used,
this flag will override the flag es.node.
--es.node="_local" Node's name of which metrics should be exposed.
--es.indices Export stats for indices in the cluster.
--es.indices_settings Export stats for settings of all indices of the
cluster.
--es.indices_mappings Export stats for mappings of all indices of the
cluster.
--es.cluster_settings Export stats for cluster settings.
--es.shards Export stats for shards in the cluster (implies
--es.indices).
--es.snapshots Export stats for the cluster snapshots.
--es.clusterinfo.interval=5m
Cluster info update interval for the cluster label
--es.ca="" Path to PEM file that contains trusted Certificate
Authorities for the Elasticsearch connection.
--es.client-private-key=""
Path to PEM file that contains the private key for
client auth when connecting to Elasticsearch.
--es.client-cert="" Path to PEM file that contains the corresponding
cert for the private key to connect to
Elasticsearch.
--es.ssl-skip-verify Skip SSL verification when connecting to
Elasticsearch.
--log.level="info" Sets the loglevel. Valid levels are debug, info,
warn, error
--log.format="logfmt" Sets the log format. Valid formats are json and
logfmt
--log.output="stdout" Sets the log output. Valid outputs are stdout and
stderr
--version Show application version.
根据自己的需求拼接参数;