首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

Zabbix历史数据history支持 Elasticsearch

今天没事折腾了一下,整体难度不大。希望对你有用。

首先安装es和kibana

下载:https://www.elastic.co/downloads/elasticsearch

1、安装ES

tar zxvf elasticsearch-6.4.0.tar.gz

cp -rf elasticsearch-6.4.0 /opt/elasticsearch

useradd elastic -d /opt/elasticsearch

chown -R elastic:elastic /opt/elasticsearch

编辑/etc/sysctl.conf

添加下面配置:

vm.max_map_count=655360

命令行执行

sysctl -p

编辑 /etc/security/limits.conf,追加以下内容;

* soft nofile 65536

* hard nofile 131072

编辑 /opt/elasticsearch/config/elasticsearch.yml

cluster.name: es-log

node.name: node-1

path.data: /opt/elasticsearch/data

path.logs: /opt/elasticsearch/logs

network.host: 0.0.0.0

http.port: 9200

bootstrap.memory_lock: false

bootstrap.system_call_filter: false

启动ES,查看9200端口是否启动

2、安装kibana

cp -rf kibana-6.4.0-linux-x86_64 /opt/kibana

后到kibana安装目录的config下,编辑kibana.yml配置文件,添加如下配置:

server.port: 5601

server.host: "你的ip"

elasticsearch.url: "http://你的ip:9200"

kibana.index: ".kibana"

启动kibana,查看5601端口

首先安装zabbix

安装过程略,可以会遇到一些问题,比如:

22988:20181012:151559.821 cannot initialize history storage: cURL library support >= 7.28.0 is required for Elasticsearch history backend

需要升级libcurl

rpm -ivh http://mirror.city-fan.org/ftp/contrib/yum-repo/city-fan.org-release-2-1.rhel6.noarch.rpm

yum upgrade curl libcurl libcurl-devel

大部分lib库的问题,安装对应的devel就可以

配置:

首先配置zabbix在es里的索引

在zabbix-3.4.14/database/elasticsearch/找到elasticsearch.map文件,按照一下命令依次创建uint、dbl、log、str、text索引

uint列子:

curl -X PUT \

http://192.168.50.50:9200/uint \

-H 'content-type:application/json' \

-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"

}

}

}

}

}'

配置zabbix server配置文件,在原来配置最后面添加

HistoryStorageURL=http://你的ip:9200

HistoryStorageTypes=uint,dbl,str,log,text

在zabbix的php前端配置里修改为:

global $DB; -->global $DB, $HISTORY;

添加

$HISTORY['url'] = 'http://你的ip:9200';

$HISTORY['types'] = ['uint', 'dbl', 'str', 'text', 'log'];

在kibana里给uint、dbl、str、text、log创建index pattern。

在kibana和zabbix latest data里查看数据是否正确。

kibana需要做一些设置,为了让数字看起来正常点,修改这个

时间格式修改为:

数据时间和格式是否正常

如果zabbix里的数据正常了,就可以了

有问题随时和我交流,微信号:yunweibang555

  • 发表于:
  • 原文链接https://kuaibao.qq.com/s/20181012B1GD4E00?refer=cp_1026
  • 腾讯「腾讯云开发者社区」是腾讯内容开放平台帐号(企鹅号)传播渠道之一,根据《腾讯内容开放平台服务协议》转载发布内容。
  • 如有侵权,请联系 cloudcommunity@tencent.com 删除。

扫码

添加站长 进交流群

领取专属 10元无门槛券

私享最新 技术干货

扫码加入开发者社群
领券