Fluentd 过滤器正则表达式模式给出无效的 strptime 格式错误



我正在尝试使用正则表达式过滤器来解析我的日志 我的正则表达式和示例字符串如下 正则表达式:

/^(?<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 = 参数错误,错误 = 无效的 strptime 格式 - '%d-%m %H:%M:%S'

我已经使用 http://fluentular.herokuapp.com/检查了正则表达式和时间格式,根据这一点似乎还可以。我该如何进行此操作?我目前的假设是错误是由于时间格式中缺少 %Y 或年份造成的。但是,我的日志不包含年份信息。

问题是我在名称中使用了"-"而不是"_" 更换它们后,它工作正常。

最新更新