【问题标题】:Telegraf parsing “grok” patterns out to prometheusTelegraf 将“grok”模式解析为 prometheus
【发布时间】:2020-12-22 03:26:22
【问题描述】:

我一直在尝试将数据从日志文件中提取到 influx 中。结构如下

2020-12-20 09:03:33.867 [http-nio-8080-exec-1] [] INFO  FCPROCESS_WEB_DIGEST - (process.IndexController.index,/api/index,Y,0ms),

我用过这个模式

[[inputs.logparser]]
   files = ["/etc/telegraf/example/fcprocess1.log"]
   from_beginning = true
   [inputs.logparser.grok]
      measurement = "fcprocess1"
      patterns = [ "%{COMBINED_LOG_FORMAT}", "%{TIMESTAMP_ISO8601:date:tag} \\[%{NOTSPACE:thread:tag}\\] \\[\\] %{NOTSPACE:level:tag}  %{NOTSPACE:filename:tag} \\- \\(%{NOTSPACE:handler:tag}\\.%{NOTSPACE:controller}\\.%{NOTSPACE:path}\\,%{NOTSPACE:msg:tag}\\,%{NOTSPACE:flag:tag}\\,%{NOTSPACE:cost:tag}\\),"]
   [inputs.logparser.tags]
       value = "1"

我可以获得有关制定模式的帮助吗?谢谢你

【问题讨论】:

    标签: prometheus telegraf grok


    【解决方案1】:

    请细化下面与您的日志匹配的 grok 模式:

    %{TIMESTAMP_ISO8601:timestamp} \[%{DATA:thread}\] \[\] %{LOGLEVEL:loglevel} %{DATA:filename} \- \(%{WORD:handler}\.%{WORD:controller}\.%{WORD:tag}\,%{DATA:path}\,%{WORD:flag}\,%{INT:cost}ms\)\,

    您可以使用任何 grok 调试器来检查 grok 模式是否与您的日志匹配。在这里我使用https://grokdebug.herokuapp.com/ 进行了检查。

    输出截图:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-31
      • 2021-10-24
      • 1970-01-01
      • 2017-07-18
      相关资源
      最近更新 更多