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)]> ...
随机推荐
- Laravel 队列不执行的原因,job缓存
laravel关于异步消息队列queue不生效(job缓存)解决办法 php artisan queue:restart 每次修改代码都需要执行上面的命令,执行后成功解决! 然后再次执行 php ar ...
- angular ionic 解决微信页面缓存问题
# 在路由对应的页面路径后面加时间戳 .state('viewName', { url: '/viewName', cache: false, templateUrl: function(){ ret ...
- postgresql学习笔记--基础篇 -psql工具
--创建用户 CREATE ROLE pguser WITH ENCRYPTED PASSWORD 'pguser'; --创建表空间目录 mkdir -p /database/pg10/pg_tbs ...
- Visual Studio Code IDE开发插件配置
[PHP通用集成环境] PHP Extension Pack #PHP拓展包,PHP开发最重要的拓展 PHP Intelephense #PHP自动补全工具 PHP IntelliSense #PHP ...
- Nginx反爬虫: 禁止某些User Agent抓取网站
问题 之前客户能够正常访问的一个网站这几天访问很慢,甚至有时候还拒绝访问.通过Nginx访问日志排查,发现有大量的请求指向同一个页面,而且访问的客户端IP地址在不断变化且没有太多规律,很难通过限制IP ...
- django-haystack 安装No local packages or working download links found for setuptools_scm
在虚拟环境中安装drf-haystack时,pip报错 Liang-2:~ langying$ pip install django-haystack Collecting django-haysta ...
- codeforces#572Div2 D1---Add On A Tree【思维】
题目:http://codeforces.com/contest/1189/problem/D1 题意:给定一棵树,可以选择任意两个叶子节点对他们的路径增加一定的权值. 问对于给定的这棵树,是否可以得 ...
- js中使用Switch
语法 switch(n) { case 1: 执行代码块 1 break; case 2: 执行代码块 2 break; default: n 与 case 1 和 case 2 不同时执行的代码 } ...
- 使用jQuery快速高效制作网页交互特效--JavaScript操作BOM对象
JavaScript操作BOM 一.window对象: 二.window对象的属性和方法 1.windows对象的常用属性: 语法:window.属性名="属性值" 2.windo ...
- javascript权威指南第20章 JSON
//20.1 语法 //JAVASCRIPT 是对JSON数据支持的. //JSON 可以申明三种类型的值 简单值("hello world") 对象({"name&qu ...