一、简介

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的更多相关文章

  1. Zabbix 历史数据存储到 Elasticsearch

    Zabbix 历史数据存储到 Elasticsearch Zabbix 3.4.6 版本开始支持历史数据存储到 Elasticsearch, 早就想测试这个功能,最近有个需求需保存 zabbix 的历 ...

  2. zabbix的历史数据存储到elasticsearch中

    基本配置项 https://www.jianshu.com/p/bffca8128e8f 官方说这个实验性的功能支持es的版本是5.0.x - > 6.1.x,如果使用早期或更高版本的Elast ...

  3. CentOS7.x编译安装zabbix4.0

    编译安装zabbix Zabbix简介 Zabbix 是一个企业级的分布式开源监控方案. Zabbix是一款能够监控各种网络参数以及服务器健康性和完整性的软件.Zabbix使用灵活的通知机制,允许用户 ...

  4. CentOS7 Zabbix4.0环境下的安装和配置实例

    1.安装准备 Zabbix4.0对基础架构有一定的要求,对的英文尤其PHP状语从句:MySQL: 类型 内容 服务端运行环境 Linux和PHP与Web服务器和数据库 服务端操作系统 CentOS7. ...

  5. Centos7+lnmp+zabbix4+分离mysql实验

    一.简介 1.什么是zabbix zabbix是一个企业级的.开源的.分布式的监控套件. zabbix可以对网络和服务进行完整性,健康性的监控.zabbix利用灵活的告警机制,可以实验微信,短信和邮件 ...

  6. 增长中的时间序列存储(Scaling Time Series Data Storage) - Part I

    本文摘译自 Netflix TechBlog : Scaling Time Series Data Storage - Part I 重点:扩容.缓存.冷热分区.分块. 时序数据 - 会员观看历史 N ...

  7. CentOS7 部署zabbix4.2

    zabbix我就不介绍了吧,但是可能又有些小白,我还是介绍一下吧,嘿嘿! 一:什么是zabbix及优缺点(对比cacti和nagios) Zabbix能监视各种网络参数,保证服务器系统的安全运营:并提 ...

  8. 应运而生! 双11当天处理数据5PB—HiStore助力打造全球最大列存储数据库

    阿里巴巴电商业务中历史数据存储与查询相关业务, 大量采用基于列存储技术的HiStore数据库,双11当天HiStore引擎处理数据记录超过6万亿条.原始存储数据量超过5PB.从单日数据处理量上看,该系 ...

  9. MySQL之四 存储引擎

    1.介绍 存储引擎MySQL中的"文件系统" MySQL体系结构 InnoDB存储引擎介绍 My1SAM 和InnoDB区别  mysql MariaDB [(none)]> ...

随机推荐

  1. shell 文本替换 ---出现--- sed:-e 表达式 #1,字符 8:“s”的未知选项

    需要替换的行为: monitor.url=http://192.168.25.100:8443/rest 查询资料得知,报错是因为替换的字符串包含有分隔符/ 所以这行改一下分隔符就可以解决问题了  ( ...

  2. linux网络编程之posix消息队列

    在前面已经学习了System v相关的IPC,今天起学习posix相关的IPC,关于这两者的内容区别,简单回顾一下: 而今天先学习posix的消息队列,下面开始: 接下来则编写程序来创建一个posix ...

  3. 通过 cross apply 实现函数转换成表并与原表进行关联

    create table tb_cross_apply ( id int identity, multivalue ) ) insert into tb_cross_apply VALUES ('A| ...

  4. python_反射——根据字符串获取模块中的属性

    1.获取当前模块中的属性 class Person(object): def __init__(self,name,age): self.name = name self.age = age p = ...

  5. CentOS环境部署(Nginx+Mariadb+Java+Tomcat)

    1.安装nginx 安装 yum install nginx 启动 yum install nginx 开机自启 sudo systemctl enable nginx 2.安装mariadb 安装 ...

  6. 修改DEDE文章标题长度,解决DEDE文章标题显示不全

    在用dede调用列表标题出来的时候,会发现标题文字字数显示不完全,那是因为dede默认标题出来长度是30个字符,为了让标题显示完整,要做以下修改! 进入后台–系统–系统设置–系统基本参数–其他选项–文 ...

  7. 洛谷 P2822 组合数问题 题解

    今天又考试了...... 这是T2. Analysis 考试时想了一个判断质因数个数+打表的神奇方法,但没在每次输入n,m时把ans置0,50分滚粗. 看了题解才发现原来是杨辉三角+二维前缀和,果然还 ...

  8. 采用非常规方法(非gprecoverseg) 恢复greenplum数据库

    greenplum数据库中mirror的作用就是作为primary的备份存在.那么恢复down掉的mirror或primary时,是否可以直接复制文件从primary或mirror到对应的mirror ...

  9. Postgresql pg_dump

    pg_dump 命令详解 参数 描述 -h 指定服务器名称 -p 指定端口 -U 指定要连接的用户名 -w/--no-password 从不提示密码 -W/--password 强制pg_dump在连 ...

  10. CF359D Pair of Numbers gcd+暴力

    利用区间 gcd 个数不超过 log 种来做就可以了~ code: #include <bits/stdc++.h> #define N 300005 #define setIO(s) f ...