elasticsearch_exporter安装部署(接入prometheus并在grafana展现)
环境:
OS:Centos 7
es:6.8.5
1.下载安装接种
下载地址如下:
https://github.com/prometheus-community/elasticsearch_exporter/releases/tag/v1.9.0
我这里下载的是1.9.0版本
2.安装
我这里安装在es服务器上,其实也可以安装到能够访问es的机器也可以的
[root@hxl-biz-b42060e-test soft]#cd /soft
[root@hxl-biz-b42060e-test soft]# tar -xvf elasticsearch_exporter-1.9.0.linux-amd64.tar.gz
[root@hxl-biz-b42060e-test soft]# mv elasticsearch_exporter-1.9.0.linux-amd64 /usr/local/services/elasticsearch_exporter
3.尝试启动(后台启动)
cd /usr/local/services/elasticsearch_exporter
nohup /usr/local/services/elasticsearch_exporter/elasticsearch_exporter --es.all --es.indices --collector.clustersettings --es.indices_settings --es.shards --collector.snapshots --es.timeout=10s --web.listen-address=0.0.0.0:9114 --web.telemetry-path=/metrics --es.uri http://kibana:hxl123@192.168.1.69:19200 &
密码不能有特殊符号,kibana账号的密码只能在kibana界面上修改
4.验证
尝试查看指标
curl "http://192.168.1.69:9114/metrics"
或是浏览器打开
5.停掉之前手工启动的elasticsearch_exporter
6.制定成系统服务
[root@hxl-biz-b42060e-test log]# more /etc/systemd/system/elasticsearch_exporter.service
[Unit]
Description=elasticsearch_exporter
After=local-fs.target network-online.target network.target
[Service]
Type=simple
RemainAfterExit=no
WorkingDirectory=/usr/local/services/elasticsearch_exporter/
User=root
Group=root
ExecStart=/usr/local/services/elasticsearch_exporter/elasticsearch_exporter --es.all --es.indices --collector.clustersettings --es.indices_settings --es.shards --collector.snapshots --es.timeout=10s --web.listen-address=0.0.0.0:9114 --web.telemetry-path=/metrics --es.uri http://kibana:qcULTg5j68riyu2re9@192.168.1.69:19200
[Install]
WantedBy=multi-user.target
7.启动
systemctl daemon-reload
systemctl enable elasticsearch_exporter
systemctl start elasticsearch_exporter
systemctl status elasticsearch_exporter
8.加入prometheus
登录到prometheus服务器
192.168.1.136
[root@localhost conf]# cd /opt/prometheus/conf
vi /opt/prometheus/conf/prometheus.yml
- job_name: 'common_elasticsearch'
scrape_interval: 60s
scrape_timeout: 30s
metrics_path: "/metrics"
static_configs:
- targets: ['192.168.1.69:9114']
检查配置文件是否正确
[root@localhost prometheus]# /opt/prometheus/bin/promtool check config /opt/prometheus/conf/prometheus.yml
重启动prometheus
systemctl restart prometheus.service
systemctl status prometheus.service
页面查看
http://192.168.1.136:9090
9.grafana展现
http://192.168.1.136:3000
初始密码是:admin/admin123
导入官方模版编号
2322
其他可用模板
13071: Dashboard for Elasticsearch Cluster Stats
13073: Dashboard for Elasticsearch Node Stats
13072: Dashboard for Elasticsearch Index Stats
13074: Dashboard for Elasticsearch History Stats
浙公网安备 33010602011771号