你不知道的Prometheus - elasticsearch_exporter 部署
簡(jiǎn)介

prometheus獲取elasticsearch指標(biāo)需要借助elasticsearch_exporter。
部署
在github下載頁(yè)面:
github.com/prometheus-community/elasticsearch_exporter/releases
解壓到
/opt/prometheus/elasticsearch_exporter目錄就可以直接運(yùn)行(如果式解壓到其他目錄,下面的啟動(dòng)文件也要修改對(duì)應(yīng)的路徑)
- vim /usr/lib/systemd/system/elasticsearch_exporter.service
- [Unit]
- Description=elasticsearch_exporter
- After=network.target
- [Service]
- Type=simple
- WorkingDirectory=/opt/prometheus/elasticsearch_exporter
- ExecStart=/opt/prometheus/elasticsearch_exporter/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://elastic:xxxxx@192.168.1.200:9200
- LimitNOFILE=65536
- PrivateTmp=true
- RestartSec=2
- StartLimitInterval=0
- Restart=always
- [Install]
- WantedBy=multi-user.target
--es.uri 這里如果有驗(yàn)證就寫(xiě)成basic auth的方式,如果沒(méi)有驗(yàn)證直接寫(xiě)http://192.168.1.200:9200
啟動(dòng):
- systemctl enable elasticsearch_exporter.service
- systemctl start elasticsearch_exporter.service
配置prometheus

直接在prometheus.yaml里面加一個(gè)job即可。
- - job_name: 'elasticsearch_exporter'
- static_configs:
- - targets: ['127.0.0.1:9114']
重載一下prometheus配置即可生效。
grafana配置
下載壓縮包里面有一個(gè)dashboard.json的文件就可以grafana的面板JSON。
grafana界面左邊的菜單:Dashboards --> import ,將JSON文件的內(nèi)容復(fù)制到Import via panel json的輸入框,保存即可導(dǎo)入完成。
