如何添加时间戳和使用fluent进行elasticsearch的关键 [英] How to add timestamp & key for elasticsearch using fluent

查看:552
本文介绍了如何添加时间戳和使用fluent进行elasticsearch的关键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经配置了fluentd和elasticsearch,并且它们都工作正常.我正在尾随一个文件,然后读取其数据并将其发布到elasticsearch.以下是json数据:

I have configured fluentd and elasticsearch and they both are working fine. I am tailing a file and then reading its data and publishing it to elasticsearch. Below is the json data:

{"time": "2018-05-14T11:37:30.339593", "Data count": 78, "Data status": "Sent", "DataId": "332"}

及以下是流利的配置文件:

and below is the fluentd configuration file:

<source>
  @type tail
  time_key time
  path /home/user/file.json
  format json
  tag first
</source>

<match *first*>
  @type elasticsearch
  hosts 192.168.196.118:9200
  user <username>
  password <password>
  index_name myindex
  type_name mytype
  id_key 100
  time_key time
</match>

在上面的配置文件中,我添加了time_key,因为时间是我想从json数据中使用的时间.但是我在elasticsearch中收到的数据不包含任何时间数据.

In the above configuration file, I have added time_key as time is the time which I want to use from json data. But the data which I receive in the elasticsearch do not contain any time data.

此外,我正在使用id_key,但在elasticsearch中,id_key是一些随机值.

Also, I am using id_key but in the elasticsearch, id_key is some random values.

请帮助.谢谢

推荐答案

我解决了此问题.我不必在配置文件中添加任何其他内容.我只是选择时间作为Elasticsearch中的时间字段.

I resolved this issue. I didnt have to add anything extra in the config file. I simply selected time as time field in elasticsearch.

这篇关于如何添加时间戳和使用fluent进行elasticsearch的关键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆