【问题标题】:Fluentd NewRelic output "time must be a Fluent::EventTime (or Integer): Float"Fluentd NewRelic 输出“时间必须是 Fluent::EventTime (or Integer): Float”
【发布时间】:2020-09-22 08:09:29
【问题描述】:

我遇到了一个我不明白的问题,td-agent 的配置摘录:

<source>
  @type gelf
  tag gelf-nr
  <parse>
    @type json
  </parse>
  port 12201
</source>

<match gelf-nr**>
  @type copy
  <store>
    @type stdout
  </store>
  <store>
    @type newrelic
     api_key XXXXXXXXXXXXXXXXXXXXXXXXXX
  </store>
</match>

输出插件newrelic总是在抱怨gelf failed to emit error="time must be a Fluent::EventTime (or Integer): Float" error_class="ArgumentError

我尝试将 json 的字段时间戳编辑为纳秒,但这不是导致问题的原因。 消息摘录:

2020-09-22 10:00:18.135967969 +0200 gelf-nr: {"version":"1.0","host":"plop-01.stag-21","message":"TEST log plop","level":3,"facility":"plop.log","misc":{"reason":"test erreur","status_code":400,"quote_ids":[1234,5678]},"timestamp":"1600761476000000000","subject"...

我怀疑问题是最初的 2020-09-22 10:00:18.135967969 +0200。 你怎么看 ?你能帮忙吗?

【问题讨论】:

    标签: newrelic fluentd td-agent


    【解决方案1】:

    摆脱纳秒,显然是 NR 输出插件中的错误(过时的实现):

    <source>
    ...
    </source>
    
    <filter **>
      @type record_modifier
      <record>
        timestamp "${timestamp.to_datetime.iso8601(6)}"
      </record>
    </filter>
    
    <match **>
    ...
    </match>
    

    【讨论】:

    • 谢谢!我的活动格式似乎是:2020-09-22 13:39:29.046163082 +0200 请问你会用什么。因为我试过了,但都是一样的。 time_format %Y-%m-%dT %H:%M:%S %zkeep_time_key truetime_key time
    • 你试过没有time_format吗?由于它将时间戳解析为纪元,我假设它可以默认处理它
    • 您在结果标准输出中看到时间键了吗?
    • %Y-%m-%d %H:%M:%S.%N %z。我认为那是其他的。
    • 不是更好,但谢谢。在标准输出中是的,我看到 2020-09-22 15:25:38.739240884 +0200 &lt;tag&gt;: &lt;json message&gt; 其中标签和 json 消息当然在这里被混淆了
    【解决方案2】:

    感谢 Max,我让它工作了:

    我用过:

    <filter **>
    @type record_modifier
      <record>
      timestamp "${timestamp.to_datetime.iso8601(6)}"
      </record>
    </filter>
    

    并删除了时间解析(time_Format,keep_time_key)。但不是 time_key,因为 jsons 中的字段不是时间而是时间戳。 问题似乎在 NR 中而不是在解析器中

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-22
    • 1970-01-01
    • 2021-02-07
    • 2020-04-24
    • 2020-09-18
    • 1970-01-01
    相关资源
    最近更新 更多