Log Insight 3.0 Agents: Parser Examples

Now that you know all about the Log Insight 3.0 agent parsers, it is time for a quiz! Read on to learn more.

li-agentThe quiz is straightforward — I will provide a log example and you tell me which parser to use. Bonus points if you can provide the entire agent configuration. Ready?

Test 1

The above events contain a bunch of different formats. At first glance, at least starting with the CLF base parser likely makes sense. Let’s break down the pieces of the events:

  • Timestamp: Unfortunately, the timestamp is in a non-standard format. While it can be extracted using a custom format, the default %t will not work. The timestamp could also just be ignored with “%i %i %i”
  • Severity: Easy with CLF base parser, but do note the double spaces or tab after
  • Class: Easy with CLF base parser
  • Thread: Easy with CLF base parser, but do note the threadid after the @ sign
  • Message: Some events could be parsed with KVP

Upon looking at the entire log message, it appears that none of the KVP pieces are valuable. As such, I would recommend the following configuration:

Note the above example parsing section ignores the timestamp. In addition, the thread is properly extracted so that duplicate threads — with or without duplicate thread IDs — are properly grouped.

Test 2

The above entry is in JSON. There is no JSON agent parser at this time and as explained earlier existing parsers should not be used for formats they were not intended for. As such, the above message should not be parsed. Do not attempt to use the CLF parser for JSON events. Note that the above event can still be collected and sent to Log Insight — it just should not be parsed client-side.

Test 3

You may not be familiar with the above format, but it is called Labeled Tab Separated Values or LTSV. It is similar to KVP, but the separator is colon and between each pair is a tab. This is another example format that agent parsers did not support today so the event should not be parsed, but it can be collected and send to Log Insight.

Test 4

Given the above event you might think:

  • This event should not be parsed because it is not in a standard format — actually, it is!
  • This event can be parsed with CLF — it could, but this is not recommended
  • This events looks a lot like CSV — right!

The above event is basically CSV, but with pipe instead of commas. The CSV parser supports this and should be leveraged. You do need to be careful for the trailing pipe though:

Now, the above message could be parsed with CLF:

However, what if the next event in looked like:

Now the thread contains a space and the CLF parser can no longer be used. Whether this second event existed or not, the above format is known value separated and as such is not meant for the CLF parser.

Test 5

OK, last one — the kicker here is that the request method and the request URL needs to be extracted from events that contain such information.

The CLF parser is capable of handling all of the parsing, however not all events contain the additional information that needs to be parsed. As such, multiple parsers are needed:

You may look at the above parsing and realize that the KVP parser could be of use. This is true, but given the format of the event is consistent/known and the CLF parser is already being used, the KVP parser is not required. I know I said that the proper parser should be leveraged, but in the above example the format of the message is known so using either CLF or KVP would be the “proper” parser.

Summary

Parsing events can be fun and can be challenging. The biggest problem is that while there are some event format standards like the syslog RFC or structured events like LTSV, no one follows the same standard and for complex applications it is common to see several different formats on the same system or even within the same file. The good news is for every application you can determine the agent configuration once and then re-use it. In my next two posts, I will explain some re-use functionality that has been added to Log Insight 3.0.

How did you do on the quiz?

© 2015 – 2016, Steve Flanders. All rights reserved.

Leave a Reply