通过shell 创建zabbix索引成功,而无法导入数据问题

#bin/bash
##crontab -e
#0 0 * * * /bin/bash /root/zabbix_xput.sh
IP=xxxxxxxxxxxxx
PASSWPRD=xxxxxxxxxxxxxxx
zabbix_xput () {
date=`date -d "0 days ago" +%Y-%m-%d`
curl -H "Content-Type:application/json" -u $PASSWPRD -XPUT http://$IP/uint_$date  -d '{"settings":{"number_of_replicas":1,"number_of_shards":5},"mappings":{"properties":{"itemid":{"type":"long"},"clock":{"format":"epoch_second","type":"date"},"value":{"type":"long"}}}}'
curl -H "Content-Type:application/json" -u $PASSWPRD -XPUT http://$IP/dbl_$date   -d '{"settings":{"number_of_replicas":1,"number_of_shards":5},"mappings":{"properties":{"itemid":{"type":"long"},"clock":{"format":"epoch_second","type":"date"},"value":{"type":"double"}}}}'
curl -H "Content-Type:application/json" -u $PASSWPRD -XPUT http://$IP/log_$date   -d '{"settings":{"number_of_replicas":1,"number_of_shards":5},"mappings":{"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" -u $PASSWPRD -XPUT http://$IP/text_$date  -d '{"settings":{"number_of_replicas":1,"number_of_shards":5},"mappings":{"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" -u $PASSWPRD -XPUT http://$IP/str_$date   -d '{"settings":{"number_of_replicas":1,"number_of_shards":5},"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_xput

以上是创建的脚本!  发现的两点原因如下:

1是因为zabbix-server配置文件导致的:

HistoryStorageDateIndex=1   没有开启!。

2、是因为zabbix索引没有初始化索引导致:

curl -H "Content-Type:application/json" -XPUT http://IP/_template/uint_template -d '{"template":"uint*","index_patterns":["uint*"],"settings":{"number_of_replicas":1,"number_of_shards":5},"mappings":{"properties":{"itemid":{"type":"long"},"clock":{"format":"epoch_second","type":"date"},"value":{"type":"long"}}}}'
curl -H "Content-Type:application/json" -XPUT http://IP/_template/dbl_template  -d '{"template":"dbl*","index_patterns":["dbl*"],"settings":{"number_of_replicas":1,"number_of_shards":5},"mappings":{"properties":{"itemid":{"type":"long"},"clock":{"format":"epoch_second","type":"date"},"value":{"type":"double"}}}}'
curl -H "Content-Type:application/json" -XPUT http://IP/_template/log_template  -d '{"template":"log*","index_patterns":["log*"],"settings":{"number_of_replicas":1,"number_of_shards":5},"mappings":{"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://IP/_template/text_template -d '{"template":"text*","index_patterns":["text*"],"settings":{"number_of_replicas":1,"number_of_shards":5},"mappings":{"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://IP/_template/str_template  -d '{"template":"str*","index_patterns":["str*"],"settings":{"number_of_replicas":1,"number_of_shards":5},"mappings":{"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://IP/_ingest/pipeline/uint-pipeline -d '{"description":"daily uint index naming","processors":[{"date_index_name":{"field":"clock","date_formats":["UNIX"],"index_name_prefix":"uint_","date_rounding":"d"}}]}'
curl -H "Content-Type:application/json" -XPUT http://IP/_ingest/pipeline/dbl-pipeline  -d '{"description":"daily dbl index naming","processors":[{"date_index_name":{"field":"clock","date_formats":["UNIX"],"index_name_prefix":"dbl_","date_rounding":"d"}}]}'
curl -H "Content-Type:application/json" -XPUT http://IP/_ingest/pipeline/log-pipeline  -d '{"description":"daily log index naming","processors":[{"date_index_name":{"field":"clock","date_formats":["UNIX"],"index_name_prefix":"log_","date_rounding":"d"}}]}'
curl -H "Content-Type:application/json" -XPUT http://IP/_ingest/pipeline/text-pipeline -d '{"description":"daily text index naming","processors":[{"date_index_name":{"field":"clock","date_formats":["UNIX"],"index_name_prefix":"text_","date_rounding":"d"}}]}'
curl -H "Content-Type:application/json" -XPUT http://IP/_ingest/pipeline/str-pipeline  -d '{"description":"daily str index naming","processors":[{"date_index_name":{"field":"clock","date_formats":["UNIX"],"index_name_prefix":"str_","date_rounding":"d"}}]}'
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值