Prometheus监控Elasticsearch
Posted wxlkeepmoving
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Prometheus监控Elasticsearch相关的知识,希望对你有一定的参考价值。
1 下载elasticsearch exporter
https://github.com/prometheus-community/elasticsearch_exporter
2 systemd 管理elasticsearch exporter
service文件: /usr/lib/systemd/system/es_exporter.service
[Unit]
Description=es_exporter
Documentation=https://prometheus.io
After=network.target
[Service]
ExecStart=/usr/local/elasticsearch_exporter/elasticsearch_exporter --es.all --es.cluster_settings --es.indices --es.indices_settings --es.shards --es.snapshots --es.timeout=10s --web.listen-address ":9114" --web.telemetry-path "/metrics" --es.uri "http://172.16.53.120:19200"
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
[Install]
WantedBy=multi-user.target
[Unit]
Description=es_exporter
After=network.target
elasticsearch_exporter参数:
--collector.cluster-info Enable the cluster-info collector (default: enabled).
--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.aliases Export informational alias metrics.
--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.slm Export stats for SLM snapshots.
--es.data_stream Export stas for Data Streams.
--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
--aws.region="" Region for AWS elasticsearch
--version Show application version.
3 启动exporter
systemctl start es_exporter.service
systemctl stop es_exporter.service
4 prometheus动态发现
prometheus.yml
- job_name: 'es monitor'
scrape_interval: 1m
file_sd_configs:
- files:
- /usr/local/src/prometheus/conf.d/elasticsearch.json
elasticsearch.json
[
"labels":
"desc": "elasticsearch",
"group": "elasticsearch",
"host_ip": "172.16.53.117"
,
"targets": [
"172.16.53.117:9114"
]
]
5 Grafana dashboard
ID:14191
以上是关于Prometheus监控Elasticsearch的主要内容,如果未能解决你的问题,请参考以下文章
Grafana中如何使用Prometheus数据源监控elasticsearch
prometheus监控es集群 — elasticsearch_exporter
Prometheus监控elasticsearch集群(以elasticsearch-6.4.2版本为例)
Elasticsearch_exporter + Prometheus + Grafana监控之搭建梳理