应用版本信息:
zabbix 版本:4.4.3
elasticsearch 版本:6.8.5
kibana 版本: 6.8.5
系统版本:Centos: 7.7
服务分布:
elasticsearch 192.168.1.105 端口:9500,9100
kibana 192.168.1.105 端口:5601
zabbix_server 192.168.1.103 端口:80
zabbix elasticsearch、kibana安装这里不阐述
配置:
zabbix 配置支持elasticsearch
elasticsearch支持的监控项类型:uint,dbl,str,log,text
监控项数据类型|数据库表|对应elasticsearch类型:
修改zabbix_server.conf
# Mandatory: no
# Default:
HistoryStorageURL=http://192.168.1.105:9500
### Option: HistoryStorageTypes
# Comma separated list of value types to be sent to the history storage.
#
# Mandatory: no
# Default:
HistoryStorageTypes=uint,dbl,str,log,text
### Option: HistoryStorageDateIndex
# Enable preprocessing of history values in history storage to store values in different indices based on date.
# 0 - disable
# 1 - enable
#
# Mandatory: no
# Default:
HistoryStorageDateIndex=1
修改 zabbix.conf.php配置文件,增加以下参数:
$HISTORY[‘url‘] = ‘http://192.168.1.105:9500‘;
$HISTORY[‘types‘] = [‘uint‘, ‘text‘, ‘log‘, ‘str‘, ‘dbl‘];
保存并启动zabbix_server
添加Elasticsearch mapping
curl -H "Content-Type:application/json" -XPUT http://192.168.1.105:9500/uint -d ‘ { "settings" : { "index" : { "number_of_replicas" : 1, "number_of_shards" : 5 } }, "mappings" : { "values" : { "properties" : { "itemid" : { "type" : "long" }, "clock" : { "format" : "epoch_second", "type" : "date" }, "value" : { "type" : "long" } } } } } ‘
curl -H "Content-Type:application/json" -XPUT http://192.168.1.105:9500/dbl -d ‘ { "settings" : { "index" : { "number_of_replicas" : 1, "number_of_shards" : 5 } }, "mappings" : { "values" : { "properties" : { "itemid" : { "type" : "long" }, "clock" : { "format" : "epoch_second", "type" : "date" }, "value" : { "type" : "double" } } } } } ‘
curl -H "Content-Type:application/json" -XPUT http://192.168.1.105:9500/log -d ‘ { "settings" : { "index" : { "number_of_replicas" : 1, "number_of_shards" : 5 } }, "mappings" : { "values" : { "properties" : { "itemid" : { "type" : "long" }, "clock" : { "format" : "epoch_second", "type" : "date" }, "value" : { "fields" : { "analyzed" : { "index" : true, "type" : "text", "analyzer" : "standard" } }, "index" : false, "type" : "text" } } } } } ‘
curl -H "Content-Type:application/json" -XPUT http://192.168.1.105:9500/text -d ‘ { "settings" : { "index" : { "number_of_replicas" : 1, "number_of_shards" : 5 } }, "mappings" : { "values" : { "properties" : { "itemid" : { "type" : "long" }, "clock" : { "format" : "epoch_second", "type" : "date" }, "value" : { "fields" : { "analyzed" : { "index" : true, "type" : "text", "analyzer" : "standard" } }, "index" : false, "type" : "text" } } } } } ‘
curl -H "Content-Type:application/json" -XPUT http://192.168.1.105:9500/str -d ‘ { "settings" : { "index" : { "number_of_replicas" : 1, "number_of_shards" : 5 } }, "mappings" : { "values" : { "properties" : { "itemid" : { "type" : "long" }, "clock" : { "format" : "epoch_second", "type" : "date" }, "value" : { "fields" : { "analyzed" : { "index" : true, "type" : "text", "analyzer" : "standard" } }, "index" : false, "type" : "text" } } } } } ‘
打开kibana或elasticsearch 验证索引:
http:/192.168.1.105:9500
原文:https://www.cnblogs.com/ArchitecTang/p/12759323.html