Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
<img src="//i.stack.imgur.com/RUiNP.png" height="16" width="18" alt="" class="sponsor tag img">elasticsearch 如何添加时间戳&;使用fluent进行elasticsearch的键_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch_Logging_Fluentd - Fatal编程技术网 elasticsearch 如何添加时间戳&;使用fluent进行elasticsearch的键,elasticsearch,logging,fluentd,elasticsearch,Logging,Fluentd" /> elasticsearch 如何添加时间戳&;使用fluent进行elasticsearch的键,elasticsearch,logging,fluentd,elasticsearch,Logging,Fluentd" />

elasticsearch 如何添加时间戳&;使用fluent进行elasticsearch的键

elasticsearch 如何添加时间戳&;使用fluent进行elasticsearch的键,elasticsearch,logging,fluentd,elasticsearch,Logging,Fluentd,我已经配置了fluentd和elasticsearch,它们都工作得很好。我跟踪一个文件,然后读取其数据并将其发布到elasticsearch。以下是json数据: {"time": "2018-05-14T11:37:30.339593", "Data count": 78, "Data status": "Sent", "DataId": "332"} 下面是fluentd配置文件: <source> @type tail time_key time path /h

我已经配置了fluentd和elasticsearch,它们都工作得很好。我跟踪一个文件,然后读取其数据并将其发布到elasticsearch。以下是json数据:

{"time": "2018-05-14T11:37:30.339593", "Data count": 78, "Data status": "Sent", "DataId": "332"}
下面是fluentd配置文件:

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

@型尾
时间键时间
path/home/user/file.json
格式json
先标记
@类型弹性搜索
主机192.168.196.118:9200
使用者
密码
索引\名称myindex
类型\名称mytype
id_键100
时间键时间
在上面的配置文件中,我添加了
time\u key
,因为time是我希望从json数据中使用的时间。但是我在
elasticsearch
中收到的数据不包含任何时间数据

此外,我使用的是
id\u键
,但在elasticsearch中,id\u键是一些随机值


请帮忙。谢谢

尝试注入您想要的值:

<inject>
   time_key          @log_time
   time_format       %Y%m%dT%H%M%S%z
</inject>

时间键@日志时间
时间\u格式%Y%m%dT%H%m%S%z

按照以下说明操作:

我已解决此问题。我不需要在配置文件中添加任何额外的内容。我只是在elasticsearch中选择了时间作为时间域。

您是否仔细检查了elasticsearch插件是否支持此功能?