grafana elasticsearch date类型问题
来源:互联网 发布:linux 重置网络配置 编辑:程序博客网 时间:2024/06/05 05:59
- 大致的数据格式
{ "createTime": 1484967199, "ip": "localhost", "appId": "10000", "threadName": "Thread-acceptor-1", "level": "info", "type": "error", "tag": "tag1", "module": "module1", "detail": "some description"}
从kafka读取数据后由storm计算后直接将es客户端写入es。
使用grafana配置数据源,其中使用自定义的字段createTime。
配置grafana的dashboard的panel,结果报错,
Invalid number format [epoch_millis#]
。- 是时间类型的错误,查下es字段的mapping,
http://132.122.252.22:9200/flume-index/_mapping
{ "flume-index": { "mappings": { "distributed-log": { "properties": { "appId": { "type": "string" }, "createTime": { "type": "long" }, "detail": { "type": "string" }, "ip": { "type": "string" }, "level": { "type": "string" }, "module": { "type": "string" }, "tag": { "type": "string" }, "threadName": { "type": "string" }, "type": { "type": "string" } } } } }}
没有指定es的mapping,所以根据java类型,当storm推数据到es时则会当做long型,具体格式如下,这导致grafana根据createTime查询错误,需要更改createTime的mapping。
- 先删除原来的索引,
curl -XDELETE 'localhost:9200/flume-index/?pretty'
- 再重新建立新索引,且指定createTime字段为date类型,且格式为默认即可。
curl -XPUT 'localhost:9200/flume-index/?pretty' -d '{ "mappings": { "distributed-log": { "properties": { "appId": { "type": "string" }, "createTime": { "type": "date" }, "detail": { "type": "string" }, "ip": { "type": "string" }, "level": { "type": "string" }, "module": { "type": "string" }, "tag": { "type": "string" }, "threadName": { "type": "string" }, "type": { "type": "string" } } } }}'
再用json的字符串格式传入后,es即可以通过这个mapping进行转换。grafana也可以根据时间查出数据来。
如果允许也可以直接使用es的_timestamp字段,但它并非准确的数据生成时间。es默认没有开启timestamp的记录,可以用下面开启,即有了_timestamp字段。
curl -XPOST localhost:9200/flume-index -d '{ "mappings": { "_default_": { "_timestamp": { "enabled": true } } }}'
0 0
- grafana elasticsearch date类型问题
- Elasticsearch Date类型使用技巧
- Elasticsearch Date类型使用技巧
- grafana使用Elasticsearch
- Elasticsearch Date Histogram 时区问题
- Elasticsearch Date类型,时间存储相关说明
- date类型数据格式问题
- Struts2 Date类型转换问题
- mybatis date类型引发问题
- 用Grafana为Elasticsearch做日志分析
- 用Grafana为Elasticsearch做日志分析
- grafana
- grafana
- influxdb+grafana使用问题记录
- spring3 mvc sql date 类型转换问题
- iBatis Date类型时间丢失问题
- 解决struts 注入 Date类型转换问题
- Struts2中转换Date类型的问题
- hdu 6012 维护区间前缀和
- 用力的想你
- 欢迎使用CSDN-markdown编辑器
- Caffe 在window10+VS2015安装
- 内部类
- grafana elasticsearch date类型问题
- STM32F103的IAP中Bootloader中断以及App程序不能进入中断的问题解决方法。
- 最大连续和的四种解法
- Number Complement
- 对于SPFA的优化
- 初识Java的接口和抽象类
- 198. House Robber
- 1034: [ZJOI2008]泡泡堂BNB
- OSRefTable 用法