Zabbix 历史数据存储到 Elasticsearch

Zabbix 历史数据存储到 Elasticsearch

Zabbix 3.4.6 版本开始支持历史数据存储到 Elasticsearch, 早就想测试这个功能,最近有个需求需保存 zabbix 的历史数据上达十亿条,因此决定测试这功能的实用性,事实证明确实效果挺好。从今以后 zabbix 也支持大量的历史数据。

安装 elasticsearch

这里就不说明安装教程了,详情请参考以前的教程

添加 Elasticsearch mapping

Elasticsearch 支持 Zabbix 的监控项类型:uint,dbl,str,log,text,对应如下

Zabbix 监控项数据类型对应 Zabbix 表对应 Elasticsearch 类型
Numeric(unsigned)(无符号整型)history_uintuint
Numeric(float)(浮点型)historydbl
Character(字符)history_strstr
Log(日志)history_loglog
Texthistory_texttext
# curl -H "Content-Type:application/json" -XPUT http://192.168.1.231:9200/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.231:9200/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.231:9200/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.231:9200/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.231:9200/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" } } } } } ' 

配置 zabbix 服务器

Zabbix 安装过程忽略

配置 zabbix_server.conf 文件

在 /etc/zabbix/zabbix_server.conf 文件下添加 elasticsearch 配置,指定历时数据使用 elasticsearch。 vim /etc/zabbix/zabbix_server.conf

HistoryStorageURL=http://192.168.1.231:9200
HistoryStorageTypes=uint,dbl,str,log,text 

配置 zabbix.conf.php 文件 在 /etc/zabbix/web/zabbix.conf.php 文件下添加 elasticsearch 配置 vim /etc/zabbix/zabbix_server.conf

// Elasticsearch url (can be string if same url is used for all types).
$HISTORY['url'] = 'http://192.168.1.231:9200'; // Value types stored in Elasticsearch. $HISTORY['types'] = ['uint', 'text', 'log', 'str', 'dbl']; 

多台 elasticsearch 集群可按以下格式配置

$HISTORY['url'] = [ 'uint' => 'http://192.168.1.230:9200 ', 'text' => 'http://192.168.1.234:9200', 'log' => 'http://192.168.1.235:9200']; $HISTORY['types'] = ['uint', 'text','log']; 

验证数据

启动 zabbix 后,使用 kibana 查看 es 集群是否有相关索引,方法这里就忽略。

转载于:https://www.cnblogs.com/leffss/p/11188326.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值