一、简介

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. LRU(最近最少使用)(python实现)

    """ python3 only LRU cache """ from collections import OrderedDict fro ...

  2. C# 中自定义配置

    微软在ConfigurationManager类里面为我们提供了AppSetting和ConnectionStrings 两个常用配置, 但是有时候我们需要自定的配置,例如 <image lef ...

  3. MySQL进阶12-- 数据类型介绍: 数值型/字符型/日期型-- 正负溢出保护/枚举型/set型/时间戳

    /*进阶12 SQL 数据类型介绍 数值型: 整数: Tinyint(1b) < mediumint(3b)<smallint(2b) <int(4b) <bigint(8b) ...

  4. 1122 django属性操作orm字段数据操作

    目录 1. 静态文件的配置 手动静态文件的访问资源 静态文件的动态绑定 2.request方法 2.1 请求方式 2.2 获取前端的请求方式 request.method 2.3 request方法 ...

  5. Linux下安装nginx实现伪分布

    1.安装 Nginx 的编译环境 gcc yum install gcc-c++ 2.nginx 的 http 模块使用 pcre 解析正则表达式,所以安装 perl 兼容的正则表达式库 yum in ...

  6. 前端知识体系:JavaScript基础-作用域和闭包-this的原理以及几种使用场景

    一.问题由来: var obj = { foo: function () { console.log(this.bar) }, bar: 1 }; var foo = obj.foo; var bar ...

  7. Copy Books II

    Description Given n books and each book has the same number of pages. There are k persons to copy th ...

  8. [Javascript] Construct a Regex to Match Twitter Mentions with Regexr

    regexr is a powerful tool for debugging existing regexes and creating new ones. In this lesson, we'l ...

  9. idea项目打包和在linux的部署

    1.将项目打包 2.先clean,后package 3.将打好的包上传到linux 使用cd指令到要上传的文件的目录 4.输入rz -y 5.解压tar.gz格式: tar -zxvf filenam ...

  10. [Luogu] 奶酪

    https://www.luogu.org/problemnew/show/3958 #include <iostream> #include <cstdio> #includ ...