前言
选择grafana作为监控是因为它展示出来很漂亮,而且可下载到前人使用过的配置文件,能够快速的搭建起监控系统;选择elasticsearch_exporter是因为它与ES集群是分开独立的,不需要对原有的ES集群(可能有很多个)做任何修改,不需要重启,只要能访问es集群即可,非常方便。
1.安装elasticsearch_exporter
1.1 下载链接:elasticsearch_exporter
下载版本:elasticsearch_exporter-1.1.0.linux-amd64.tar.gz
1.2 安装启动
安装go:yum -y install golang
上传elasticsearch_exporter-1.1.0.linux-amd64.tar.gz文件到/usr/local/目录,解压:
tar -xvf elasticsearch_exporter-1.1.0.linux-amd64.tar.gz
cd elasticsearch_exporter-1.1.0.linux-amd64/
只要设置不同的-web.listen-address监听端口,可启动多个实例,分别监控不同的ES集群:
# es集群1:10.xxx.xxx.10:9200
nohup ./elasticsearch_exporter --es.all --es.indices --es.cluster_settings --es.indices_settings --es.shards --es.snapshots --es.timeout=10s --web.listen-address=":9114" --web.telemetry-path="/metrics" --es.uri http://10.xxx.xxx.10:9200 &
# es集群2:10.xxx.xxx.11:9200
nohup ./elasticsearch_exporter --es.all --es.indices --es.cluster_settings --es.indices_settings --es.shards --es.snapshots --es.timeout=10s --web.listen-address=":9115" --web.telemetry-path="/metrics" --es.uri http://10.xxx.xxx.11:9200 &
可通过命令:tailf nohup.out 查看日志。
启动成功后,可以访问curl “http://127.0.0.1:9114/metrics”,看抓取的指标信息
elasticsearch_breakers_estimated_size_bytes{breaker="fielddata",cluster="es-test",es_client_node="true",es_data_node="true",es_ingest_node="true",es_master_node="true",host="10.xxx.xxx.xxx",name="test_es04"} 0
elasticsearch_breakers_estimated_size_bytes{breaker="in_flight_requests",cluster="es-test",es_client_node="true",es_data_node="true",es_ingest_node="true",es_master_node="true",host="10.xxx.xxx.xxx",name="test_es05"} 489
2.Prometheus
2.1下载 prometheus,
下载链接:https://prometheus.io/download/,下载prometheus-2.16.0.linux-amd64.tar.gz,并上传到/usr/local/解压
2.2修改prometheus组件的prometheus.yml加入elasticsearch节点:
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: 'prometheus'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['localhost:9090']
# es1 集群监控配置 --------------------新增
- job_name: 'es_9114'
static_configs:
- targets: ['10.xxx.xxx.10:9114']
# es2 集群监控配置 --------------------新增
- job_name: 'es_9115'
static_configs:
- targets: ['10.xxx.xxx.11:9115']
启动:./prometheus
可通过命令查看:curl “http://localhost:9090/status”
3.Grafana
3.1下载仪表盘配置
下载链接:https://grafana.com/grafana/dashboards/2322
这里的配置还是比较全面的,可以直接使用。
3.2 导入仪表盘
3.3 查看仪表盘
这里有具体监控的指标解释:Metrics