下载包
cd /usr/local/src
wget -c https://github.com/prometheus-community/elasticsearch_exporter/releases/download/v1.2.0/elasticsearch_exporter-1.2.0.linux-amd64.tar.gz
tar xf elasticsearch_exporter-1.2.0.linux-amd64.tar.gz
cd elasticsearch_exporter
mv elasticsearch_exporter /usr/local/bin/
创建启动文件
cat > /etc/systemd/system/elasticsearch.service
查看监听地址
netstat -tulnp | grep 9114
tcp6 0 0 :::9114 :::* LISTEN 31048/elasticsearch
prometheus config配置
- job_name: 'elasticsearch-exporter'
consul_sd_configs:
- server: 10.0.7.91:8500
services:
- elasticsearch-exporter
consule添加新的服务脚本
[root@prometheus ~]# cat server_add.sh
#!/bin/bash
curl -X PUT -d '{
"id": "'${1}-${2}'",
"name": "'${2}'",
"address": "'${1}'",
"port": '${3}',
"tags": ["'${2}'"],
"checks": [{"http": "'http://${1}:${3}/metrics'","interval":"5s"}]
}' http://10.0.7.91:8500/v1/agent/service/register
添加新服务
xxx.test.com为9114客户端的host
sh server_add.sh xxx.test.com elasticsearch-exporter 9114
最后一步
grafana导入模板