一、简介

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. SQL Server 2005的几个新功能

    SQL Server 2005相对于SQL Server 2000改进很大,有些还是非常实用的. 举几个例子来简单说明 这些例子我引用了Northwind库. 1. TOP 表达式  SQL Serv ...

  2. Selenium常用API的使用java语言之6-WebDriver常用方法

    前面我们已经学习了定位元素, 定位只是第一步, 定位之后需要对这个元素进行操作, 或单击(按钮) 或 输入(输入框) , 下面就来认识这些最常用的方法. 1.WebDriver 常用方法 下面先来认识 ...

  3. Connecting Graph

    Given n nodes in a graph labeled from 1 to n. There is no edges in the graph at beginning. You need ...

  4. echo 显示命令

    echo 显示命令 echo 是在PHP里面最常用的一个输出.显示功能的命令.直线电机滑台 我们可以让他显示任何可见的字符. <?php echo 123; ?> <?php $ip ...

  5. 查看工程里有多少行java代码

    /** * @Classname CustBankcardServiceImpl * @Description 计算项目代码量(行数) * @Date 2019/11/04 14:24 * @Crea ...

  6. spark读文件写mysql(java版)

    package org.langtong.sparkdemo; import com.fasterxml.jackson.databind.ObjectMapper; import org.apach ...

  7. 14 | count(*)这么慢,我该怎么办?

    在开发系统的时候,你可能经常需要计算一个表的行数,比如一个交易系统的所有变更记录总数.这时候你可能会想,一条select count(*) from t 语句不就解决了吗? 但是,你会发现随着系统中记 ...

  8. Cogs 1714. [POJ1741][男人八题]树上的点对(点分治)

    [POJ1741][男人八题]树上的点对 ★★★ 输入文件:poj1741_tree.in 输出文件:poj1741_tree.out 简单对比 时间限制:1 s 内存限制:256 MB [题目描述] ...

  9. Codechef July Challenge 2019 Division 1题解

    题面 \(CIRMERGE\) 破环成链搞个裸的区间\(dp\)就行了 //quming #include<bits/stdc++.h> #define R register #defin ...

  10. 在默认使用apache中央仓库时, 报错 protocol_version

    https://cloud.tencent.com/developer/ask/136221/answer/241408 2018年6月,为了提高安全性和符合现代标准,不安全的TLS 1.0和1.1协 ...