|
I intend modify my app/script so that it will write out a completely custom log file format for Splunk to monitor and index in real-time. What is the best, most optimal format to use for my custom log event such that Splunk automatically extracts ALL of my fields and the timestamp and I do not have to setup or configure any field extractions myself. |
|
The optimal log format is - timestamp key=value key=value key=value key=value key=value key=value key=value key=value You can have other delimiters in there too like , or : but that's pretty much a personal preference. If the keys and values are easily recognizable, Splunk will index and search as fast as you can write it out. The time stamp should be in ISO8601 form - i.e. variants of YYYY-MM-DD HH:MM:SS.mmm TZ DST. Example: 2011-10-24 14:04:02 +0200 DST If you do not want (or need) the time zone of Daylight Savings Time designators - these may be omitted.
(24 Oct '11, 02:08)
RubenOlsen
|
|
Hello Mick. Could you share a log format example? What is the timestamp format? |
|
Something like this: Generic Example: [Timestamp] Hostname HostIP=IPaddress Service=ServiceName ClientIP=IPaddress SrcPor=port# DestPort=port# UID=value Stuff=blah Morestuff=blahblah Specific Example: May 26 18:14:15 myhostname HostIP=10.5.10.2 Service=CustomLogger ClientIP=75.149.38.65 SrcPort=80 DestPort=8080 UID=10534 ImportantValue=Be9r87 AnotherImportantValue=310984 |
|
What if you want log sql commands like this: Example: May 26 18:14:15 myhostname DBIP=10.5.10.2 Service=OracleXE ClientIP=75.149.38.65 SrcPort=80 DestPort=8080 UID=10534 Sql_Text=Select * from Table1 where uname="dummy" As you can see timestamp key=value key=value key=value ... in this example is not good and , or : is not good delimiters because all of this delimiters can be in sql commands which cause broken extract fields. |
|
There are several ways to deal with the Sql_Text=Select * from Table1 where uname="dummy" One way which will work if the Sql_Text=something is at the end of a log event is to use filed extractions (i.e. EXTRACT) in the props.conf file:
You could even do this directly in the search app without using the props.conf stuff. The following should give you a list with the count of the 10 most used Sql_Text expression grouped by the ClientIP field:
|
|
I use:
My props.conf looks like this:
My transforms.conf looks like this:
My events look like this:
The regex I made is pretty cool. It'll let you do:
For example:
|
