簡體   English   中英

流利的過濾器正則表達式模式給出無效的strptime格式錯誤

[英]fluentd filter regex pattern gives an invalid strptime format error

我正在嘗試使用正則表達式過濾器來解析我的日志。我的正則表達式和示例字符串如下正則表達式:

/^(?<logtime>[^\|]*)\S +(?<cpu-usr>\S+) +(?<cpu-sys>\S+) +(?<cpu-idl>\S+) +(?<cpu-wai>\S+) +(?<cpu-hiq>\S+) +(?<cpu-siq>[^|]+)\S +(?<mem-used>\S+) +(?<mem-buff>\S+) +(?<mem-cach>\S+) +(?<mem-free>\S+)/

示例字符串:

07-07 17:18:12|  0   0 100   0   0   0| 197M 48.9M  182M  546M

所以我將以下過濾器寫入了我的fluent.conf文件

#filter dstat log into fields. 
#----system---- ----total-cpu-usage---- ------memory-usage-----
#  date/time   |usr sys idl wai hiq siq| used  buff  cach  free
<filter input.dstat>
  @type parser
  format /^(?<logtime>[^\|]*)\S +(?<cpu-usr>\S+) +(?<cpu-sys>\S+) +(?<cpu-idl>\S+) +(?<cpu-wai>\S+) +(?<cpu-hiq>\S+) +(?<cpu-siq>[^|]+)\S +(?<mem-used>\S+) +(?<mem-buff>\S+) +(?<mem-cach>\S+) +(?<mem-free>\S+)/
  time_format %d-%m %H:%M:%S
  time_key logtime
  keep_time_key true
  key_name log
</filter>

但是,此過濾器出現以下錯誤。

fluentd_1 | 2017-07-07 05:42:36 +0000 [警告]:無效的時間格式:值= 07-0,error_class = ArgumentError,錯誤=無效的strptime格式-`%d-%m%H:%M:%S “

我已經使用http://fluentular.herokuapp.com/檢查了正則表達式和時間格式,據此看來還可以。 我該如何進行呢? 我目前的假設是錯誤是由於時間格式缺少%Y或年份。 但是,我的日志不包含年份信息。

問題是我在名稱中使用了“-”而不是“ _”。替換它們后,它可以正常工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM