一、下载elasticsearch_exporter二进制文件压缩包
1、在节点上执行命令下载
wget "https://github.com/justwatchcom/elasticsearch_exporter/releases/download/v1.1.0/elasticsearch_exporter-1.1.0.linux-amd64.tar.gz"
2、解压压缩包
[root@master elasticsearch_exporter]# ls
elasticsearch_exporter-1.1.0.linux-amd64.tar.gz
[root@master elasticsearch_exporter]# tar -xvf elasticsearch_exporter-1.1.0.linux-amd64.tar.gz
[root@master elasticsearch_exporter]# ls
drwxr-xr-x 2 80 Aug 2 2022 elasticsearch_exporter-1.1.0.linux-amd64
-rw-r--r-- 1 10649117 Feb 3 15:04 elasticsearch_exporter-1.1.0.linux-amd64.tar.gz
二、将elasticsearch_exporter-1.1.0.linux-amd64目录下的 elasticsearch_exporter二进制文件复制到 /usr/local/bin路径下
[root@master elasticsearch_exporter]# cd elasticsearch_exporter-1.1.0.linux-amd64
[root@master elasticsearch_exporter]# ls
elasticsearch_exporter LICENSE NOTICE
[root@master elasticsearch_exporter]# cp elasticsearch_exporter /usr/local/bin/
[root@master elasticsearch_exporter]# ls -l /usr/local/bin/elasticsearch_exporter
-rwxr-xr-x 1 root root 20745692 Feb 3 15:09 /usr/local/bin/elasticsearch_exporter
三、创建systemd service文件
根据实际情況修改其中的Environment配置值
如果上一步骤沒有修改创建用户命令中的认证参数
则下文可不做变更
直接复制下文全部文字命令並在节点上执行即可
cat <<EOF > /etc/systemd/elasticsearch_exporter.service
[Unit]
Description=elasticsearch_exporter
After=local-fs.target network-online.target network.target
Wants=local-fs.target network-online.target network.target
[Service]
ExecStart=/usr/local/elasticsearch_exporter/elasticsearch_exporter \
--es.all --es.indices \
--es.cluster_settings \
--es.indices_settings \
--es.shards --es.snapshots \
--web.listen-address ":9114" \
--es.timeout 10s \
--web.telemetry-path "/metrics" \
--es.uri http://elastic:2wsxCDE#@10.82.42.196:9200
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
四、重载系统systemd配置
执行命令:systemctl daemon-reload
五、启动服务并且设置服务自启
[root@master blackbox_exporter]# systemctl enable --now elasticsearch_exporter
Created symlink from /etc/systemd/system/multi-user.target.wants/elasticsearch_exporter.service to /etc/systemd/system/elasticsearch_exporter.service.
六、查看服务运行状态
执行命令
能夠得到类似下文的回显结果
主要看Active属性值
以及日志中提示:systemctl status elasticsearch_exporter
systemctl status elasticsearch_exporter
● elasticsearch_exporter.service - elasticsearch_exporter
Loaded: loaded (/etc/systemd/system/elasticsearch_exporter.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2023-02-03 15:55:03 CST; 10s ago
Main PID: 79681 (elasticsearch_exporter)
CGroup: /system.slice/elasticsearch_exporter.service
└─79681 /usr/local/bin/elasticsearch_exporter--config.file=/app/software/elasticsearch_exporter-1.1.0.linux-amd64/blackbox.yml --web.listen-address=:9114
七、测试接口
在节点上使用命令访问接口
能夠得到类似下文結果:curl -s {{节点IP}}:
9114/metrics
[root@master ~]# curl -s 10.82.42.196:9114/metrics
......
......
或直接使用浏览器访问能夠看到相关 elasticsearch实例指标信息则为正常{{节点IP}}:
9114/metrics
文章来源:https://www.toymoban.com/news/detail-643515.html
八、配置Prometheus的任务
cd /usr/local/prometheus
vim /usr/local/prometheus/prometheus.yml,如下:
- job_name: 'elasticsearch'
scrape_interval: 60s
scrape_timeout: 30s
static_configs:
- targets:
- 10.82.42.196:9114
重新启动Prometheus:文章来源地址https://www.toymoban.com/news/detail-643515.html
# systemctl restart prometheus
到了这里,关于elasticsearch_exporter安装教程的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!