I am trying to extract the timestamp from a message, but the %{TIMESTAMP_ISO8601} pattern returns a lot of data I do not need. I only need the timestamp field, how do I remove the unnecessary data.
Also, is it possible to skip this field altogether?
Yes, there is a option Named captures only in extractor, or pipeline function grok(), parameter only_named_captures, so it will extract only named, in your case only timestamp.
GROK as a result generate regular expression, so it’s only simplified form of regex. So you need to include grok patterns for part of text.
If you want to skip some text you can use %{GREEDYDATA:UNWANTED}. For example to extract fw field use:
%{TIMESTAMP_ISO8601:timestamp}%{GREEDYDATA:UNWANTED}fw=%{IP:fw_ip}
I’m trying that, as well as some other patterns like INT, NUMBER, WORD, and a few others and Graylog throws an error no matter what I try. Ideally I’d like to strip other fields out as well.
You have space between %{TIMESTAMP_ISO8601:timestamp} %{GREEDYDATA:UNWANTED}
If you check original message, there is " after timestamp, and not only space, so you need to include " in your grok, so:
Either use grok without space (which will also include " and space and another strings): %{TIMESTAMP_ISO8601:timestamp}%{GREEDYDATA:UNWANTED}
Or use grok with " after timestamp: %{TIMESTAMP_ISO8601:timestamp}" %{GREEDYDATA:UNWANTED}