需要使用 grok 从日志中排除几个词

Need to exclude few words from logs using grok

考虑以下字符串

date 00:00 1.1.1.1 POST test.com hello-world

如何使用 grok 仅打印日期总时间和 URL(test.com)?

给定上面的示例

^%{DATA:date} %{DATA:time} %{IP:ip} %{DATA:method} %{DATA:url} %{GREEDYDATA:path}$

会生成:

{
  "date": [
    [
      "date"
    ]
  ],
  "time": [
    [
      "00:00"
    ]
  ],
  "ip": [
    [
      "1.1.1.1"
    ]
  ],
  "method": [
    [
      "POST"
    ]
  ],
  "url": [
    [
      "test.com"
    ]
  ],
  "path": [
    [
      "hello-world"
    ]
  ]
}

之后你可以改变任何你想要的形式