Elasticsearch集群监控:elasticsearch_exporter + Prometheus + Grafana

前言

选择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

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值