Zabbix4.x 历史数据存储到Elasticsearch7.x
一、简介
Zabbix 3.4.6 版本开始支持历史数据存储到 Elasticsearch, 早就想测试这个功能,最近有个需求需保存 zabbix 的历史数据上达十亿条,因此决定测试这功能的实用性,事实证明确实效果挺好。从今以后 zabbix 也支持大量的历史数据。
二、安装 ELK(这里不再讲解,不懂的可以参考:https://www.cnblogs.com/liugp/p/11789933.html)
三、添加 Elasticsearch mapping
Elasticsearch 支持 Zabbix 的监控项类型:uint,dbl,str,log,text,对应如下:
| Zabbix 监控项数据类型 | 对应 Zabbix 表 | 对应 Elasticsearch 类型 |
| Numeric(unsigned)(无符号整型) | history_uint | uint |
| Numeric(float)(浮点型) | history | dbl |
| Character(字符) | history_str | str |
| Log(日志) | history_log | log |
| Text | history_text | text |
ES7.x创建五中类型数据索引
PUT /uint
{
"settings":{
"number_of_replicas":,
"number_of_shards":
},
"mappings":{
"properties":{
"itemid":{
"type":"long"
},
"clock":{
"format":"epoch_second",
"type":"date"
},
"value":{
"type":"long"
}
}
}
} PUT /dbl
{
"settings":{
"number_of_replicas":,
"number_of_shards":
},
"mappings":{
"properties":{
"itemid":{
"type":"long"
},
"clock":{
"format":"epoch_second",
"type":"date"
},
"value":{
"type":"double"
}
}
}
} PUT /log
{
"settings":{
"number_of_replicas":,
"number_of_shards":
},
"mappings":{
"properties":{
"itemid":{
"type":"long"
},
"clock":{
"format":"epoch_second",
"type":"date"
},
"value":{
"fields":{
"analyzed":{
"index":true,
"type":"text",
"analyzer":"standard"
}
},
"index":false,
"type":"text"
}
}
}
} PUT /text
{
"settings":{
"number_of_replicas":,
"number_of_shards":
},
"mappings":{
"properties":{
"itemid":{
"type":"long"
},
"clock":{
"format":"epoch_second",
"type":"date"
},
"value":{
"fields":{
"analyzed":{
"index":true,
"type":"text",
"analyzer":"standard"
}
},
"index":false,
"type":"text"
}
}
}
} PUT /str
{
"settings":{
"number_of_replicas":,
"number_of_shards":
},
"mappings":{
"properties":{
"itemid":{
"type":"long"
},
"clock":{
"format":"epoch_second",
"type":"date"
},
"value":{
"fields":{
"analyzed":{
"index":true,
"type":"text",
"analyzer":"standard"
}
},
"index":false,
"type":"text"
}
}
}
}
注意:通过上面创建的索引,zabbix-server无法添加数据,因为ES7移除了type类型导致的,但是可以让zabbix自动创建
ES6.x创建五中类型数据索引
PUT /uint
{
"settings":{
"index":{
"number_of_replicas":,
"number_of_shards":
}
},
"mappings":{
"values":{
"properties":{
"itemid":{
"type":"long"
},
"clock":{
"format":"epoch_second",
"type":"date"
},
"value":{
"type":"long"
}
}
}
}
} PUT /dbl
{
"settings":{
"index":{
"number_of_replicas":,
"number_of_shards":
}
},
"mappings":{
"values":{
"properties":{
"itemid":{
"type":"long"
},
"clock":{
"format":"epoch_second",
"type":"date"
},
"value":{
"type":"double"
}
}
}
}
} PUT /log
{
"settings":{
"index":{
"number_of_replicas":,
"number_of_shards":
}
},
"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"
}
}
}
}
} PUT /text
{
"settings":{
"index":{
"number_of_replicas":,
"number_of_shards":
}
},
"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"
}
}
}
}
} PUT /str
{
"settings":{
"index":{
"number_of_replicas":,
"number_of_shards":
}
},
"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"
}
}
}
}
}
es6.x curl创建方式
curl -H "Content-Type:application/json" -XPUT http://192.168.182.132: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.182.132: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.182.132: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.182.132: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.182.132: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的大坑,如果是es7,es7上有数据,但是图形会显示无数据,这个后期有待解决。如果有哪位大神已经解决了,可以在评论区回复我,Thank you!!!!。


四、配置zabbix服务器
Zabbix 安装过程忽略
配置 zabbix_server.conf 文件
在 /etc/zabbix/zabbix_server.conf 文件下添加 elasticsearch 配置,指定历时数据使用 elasticsearch。
# vim /etc/zabbix/zabbix_server.conf
HistoryStorageURL=http://192.168.182.132:9200
HistoryStorageTypes=uint,dbl,str,log,text
配置zabbix.conf.php文件
在/home/wwwroot/default/zabbix/conf/zabbix.conf.php文件下添加elasticsearch配置
# vim /home/wwwroot/default/zabbix/conf/zabbix.conf.php
// Elasticsearch url (can be string if same url is used for all types).
$HISTORY['url'] = 'http://192.168.182.132:9200';
// Value types stored in Elasticsearch.
$HISTORY['types'] = ['uint', 'text', 'log', 'str', 'dbl'];
多台 elasticsearch 集群可按以下格式配置
$HISTORY['url'] = [ 'uint' => 'http://192.168.182.132:9200 ', 'text' => 'http://192.168.182.133:9200', 'log' => 'http://192.168.182.134:9200'];
$HISTORY['types'] = ['uint', 'text','log'];
五、验证数据
启动 zabbix 后,使用 kibana 查看 es 集群是否有相关索引,方法这里就忽略。
Zabbix4.x 历史数据存储到Elasticsearch7.x的更多相关文章
- Zabbix 历史数据存储到 Elasticsearch
Zabbix 历史数据存储到 Elasticsearch Zabbix 3.4.6 版本开始支持历史数据存储到 Elasticsearch, 早就想测试这个功能,最近有个需求需保存 zabbix 的历 ...
- zabbix的历史数据存储到elasticsearch中
基本配置项 https://www.jianshu.com/p/bffca8128e8f 官方说这个实验性的功能支持es的版本是5.0.x - > 6.1.x,如果使用早期或更高版本的Elast ...
- CentOS7.x编译安装zabbix4.0
编译安装zabbix Zabbix简介 Zabbix 是一个企业级的分布式开源监控方案. Zabbix是一款能够监控各种网络参数以及服务器健康性和完整性的软件.Zabbix使用灵活的通知机制,允许用户 ...
- CentOS7 Zabbix4.0环境下的安装和配置实例
1.安装准备 Zabbix4.0对基础架构有一定的要求,对的英文尤其PHP状语从句:MySQL: 类型 内容 服务端运行环境 Linux和PHP与Web服务器和数据库 服务端操作系统 CentOS7. ...
- Centos7+lnmp+zabbix4+分离mysql实验
一.简介 1.什么是zabbix zabbix是一个企业级的.开源的.分布式的监控套件. zabbix可以对网络和服务进行完整性,健康性的监控.zabbix利用灵活的告警机制,可以实验微信,短信和邮件 ...
- 增长中的时间序列存储(Scaling Time Series Data Storage) - Part I
本文摘译自 Netflix TechBlog : Scaling Time Series Data Storage - Part I 重点:扩容.缓存.冷热分区.分块. 时序数据 - 会员观看历史 N ...
- CentOS7 部署zabbix4.2
zabbix我就不介绍了吧,但是可能又有些小白,我还是介绍一下吧,嘿嘿! 一:什么是zabbix及优缺点(对比cacti和nagios) Zabbix能监视各种网络参数,保证服务器系统的安全运营:并提 ...
- 应运而生! 双11当天处理数据5PB—HiStore助力打造全球最大列存储数据库
阿里巴巴电商业务中历史数据存储与查询相关业务, 大量采用基于列存储技术的HiStore数据库,双11当天HiStore引擎处理数据记录超过6万亿条.原始存储数据量超过5PB.从单日数据处理量上看,该系 ...
- MySQL之四 存储引擎
1.介绍 存储引擎MySQL中的"文件系统" MySQL体系结构 InnoDB存储引擎介绍 My1SAM 和InnoDB区别 mysql MariaDB [(none)]> ...
随机推荐
- 线性查找与二分查找(python)
# -*- coding: utf-8 -*- number_list = [0, 1, 2, 3, 4, 5, 6, 7] def linear_search(value, iterable): f ...
- python3 读取avro文件
官网示例文档:http://avro.apache.org/docs/current/gettingstartedpython.html#download_install 需要注意的是,官网给出的是p ...
- IntelliJ IDEA lombok插件的安装和使用
IntelliJ IDEA是一款非常优秀的集成开发工具,功能强大,而且插件众多.lombok是开源的代码生成库,是一款非常实用的小工具,我们在编辑实体类时可以通过lombok注解减少getter.se ...
- NodeJS 开发博客(四) 日志及安全攻击
node 操作文件: const fs = require('fs'); const path = require('path'); const filename = path.resolve(__d ...
- Java 中抽象类与接口的区别
TypeScript 中的接口,有点类似抽象类的概念.Java 中抽象类属于包含属性与抽象行为,而接口通常只是抽象行为.抽象类可以实现模板模式. 参考 https://www.cnblogs.com/ ...
- Javascript基础——函数
一 函数的介绍 1.概念:由一堆代码按照一定的规则,组成实现了某个功能,通过函数自身或事件调用 函数的特点: 忽略细节:只关注其实现的功能,不关注内部构造: 重复使用:函数可以实现代码的重复利用: 选 ...
- sql server 将某一列的值拼成一个字符串 赋值到一个字段内
DECLARE @refCodeitems VARCHAR(800), SELECT @refCodeitems=ISNULL(@refCodeitems,'')+refCodeitem +'/' ...
- Linux 文件系统缓存dirty_ratio与dirty_background_ratio两个参数区别
文件系统缓存dirty_ratio与dirty_background_ratio两个参数区别 (2014-03-16 17:54:32) 转载▼ 标签: linux 文件系统缓存 cache dirt ...
- 点分 TREE
/* 1468: Tree Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 774 Solved: 412[Submit][Status][Discus ...
- 国外最受欢迎的BT-磁力网站
1.海盗湾 The Pirate Bay 2.KickAssTorrents 3.Torrentz 4.zooqle 5.SumoTorrent 6.TorrentDownloads 7.Rarbg ...