Zabbix Server 安装
Zabbix Agent 安装
Zabbix agent这里使用docker安装,如果不想安装zabbix_agent也可以的,因为es的数据是通过HTTP
的方式获取,可以不安装Zabbix agent
docker run --name zabbix-agent -t -v zabbix_agent:/etc/zabbix -e ZBX_HOSTNAME="apisix-es" -e ZBX_SERVER_HOST="192.168.0.10" -e ZBX_SERVER_PORT=10051 -p 10050:10050 --restart=unless-stopped --privileged -d zabbix/zabbix-agent:alpine-6.2-latest
#参数解释
ZBX_HOSTNAME Zabbix主机名,最好和外面的保持一致
ZBX_SERVER_HOST Zabbix Server 地址
ZBX_SERVER_PORT Zabbix Server端口号
ES安装
docker run --name es01 -p 9200:9200 -p 9300:9300
-e "discovery.type=single-node" -e ES_JAVA_OPTS="-Xms84m -Xmx512m" -d elasticsearch:7.12.0
#如果需要持久化可以添加以下参数
-v /home/es_docker/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
-v /home/es_docker/data:/usr/share/elasticsearch/data
-v /home/es_docker/plugins:/usr/share/elasticsearch/plugins
检查服务状态
[root@abcdocker ~]# docker ps|grep es01
d0cb70808be4 elasticsearch:7.12.0 "/bin/tini -- /usr/l…" 2 minutes ago Up 2 minutes 0.0.0.0:9200->9200/tcp, :::9200->9200/tcp, 0.0.0.0:9300->9300/tcp, :::9300->9300/tcp es01
修改Elasticsearch Cluster by HTTP模板
我们在Template App Elasticsearch Cluster by HTTP
这个模板的监控项中发现以下五个监控项需要修改,3个是采集源监控项,2个是简单检查监控项,它们默认访问的是127.0.0.1
,我们得改成可自定义配置IP
实际上就是将
{HOST.CONN}
替换为{$ELASTICSEARCH.IP}
监控项 | 类型 | 修改前URL | 修改后URL |
---|---|---|---|
ES: Get cluster health | HTTP代理 | {$ELASTICSEARCH.SCHEME}://{HOST.CONN}:{$ELASTICSEARCH.PORT}/_cluster/health?timeout=5s | {$ELASTICSEARCH.SCHEME}://{$ELASTICSEARCH.IP}:{$ELASTICSEARCH.PORT}/_cluster/health?timeout=5s |
ES: Get cluster stats | HTTP代理 | {$ELASTICSEARCH.SCHEME}://{HOST.CONN}:{$ELASTICSEARCH.PORT}/_cluster/stats | {$ELASTICSEARCH.SCHEME}://{$ELASTICSEARCH.IP}:{$ELASTICSEARCH.PORT}/_cluster/stats |
ES: Get nodes stats | HTTP代理 | {$ELASTICSEARCH.SCHEME}://{HOST.CONN}:{$ELASTICSEARCH.PORT}/_nodes/stats | {$ELASTICSEARCH.SCHEME}://{$ELASTICSEARCH.IP}:{$ELASTICSEARCH.PORT}/_nodes/stats |
ES: Service response time | 简单检查 | net.tcp.service.perf["{$ELASTICSEARCH.SCHEME}","{HOST.CONN}","{$ELASTICSEARCH.PORT}"] | net.tcp.service.perf["{$ELASTICSEARCH.SCHEME}","{$ELASTICSEARCH.IP}","{$ELASTICSEARCH.PORT}"] |
ES: Service status | 简单检查 | net.tcp.service["{$ELASTICSEARCH.SCHEME}","{HOST.CONN}","{$ELASTICSEARCH.PORT}"] | net.tcp.service["{$ELASTICSEARCH.SCHEME}","{$ELASTICSEARCH.IP}","{$ELASTICSEARCH.PORT}"] |
Zabbix中替换url即可,记得点击保存
Zabbix Agent配置
选择ES监控模板
添加主机宏
{$ELASTICSEARCH.IP}
#这里的IP为ES IP
这里就可以看到已经获取到最新数据了