首页 文章

弹性堆栈:我需要将Time Filter字段名称设置为另一个字段

提问于
浏览
0

我需要通过logstash从rabbitMq读取消息(内容是日志),然后将其发送到elasticsearch,以便在kibana中进行可视化监控 . 所以我在logstash中写了一个从rabbitmq读取的输入,如下所示:

input { 
  rabbitmq {
    queue => "testLogstash"
    host => "localhost"
  }
}

我在logstash中的elasticsearch中为store创建了输出配置,如下所示:

output {
 elasticsearch{
   hosts => "http://localhost:9200"
            index => "d13-%{+YYYY.MM.dd}"
 }
}

它们都放在myConf.conf中

在每条消息的内容中,有一个包含如下字段的Json:

{
  "mDate":"MMMM dd YYYY, HH:mm:ss.SSS"
  "name":"test name"
}

但是有两个问题 . 首先,在创建新索引(时间过滤器字段名称)的字段中没有日期字段 . 其次,我使用与默认@timestamp相同的时间戳,此字段不会显示在图形的构建类型中 . 我认为这是因为该字段的数据类型 . 该字段的类型为date,但会考虑该字符串 .

我尝试通过mutst在logstash配置中将字段的值转换为日期,如下所示:

filter {
  mutate {
    convert => { "mdate" => "date" }
  }
}

Now, two questions arise: 1- Is this the problem? If yes What is the right solution to fix it? 2- My main need is to use the time when messages are entered in the queue, not when Logstash takes them. What is the best solution?

1 回答

  • 0

    如果没有为 @timestamp 指定值,则应在elasticsearch索引文档时获取当前系统时间 . 有了它,你应该能够看到kibana中的项目 .

    如果我理解正确,你宁可使用 mDate 字段来表示 @timestamp . 为此,请在logstash中使用date{} filter .

相关问题