Splunk Search

How to extract missing event date from header

trs01
New Member

Hello, I'm trying to index a log in the IIS W3C Extended Log Format. The date information in each event is missing, but the date is at the top of the file in the header info. The time (HH:MM:SS) is correctly populated in each event. Is there a way I can extract the date from the header and prepend it to each line or a way I can populate the date_mday, date_month, date_year, etc. fields for each event using the info in the header? Sample data below.

Current sourcetype definition

[ iis:log ]
CHARSET=UTF-8
FIELD_DELIMITER=whitespace
FIELD_HEADER_REGEX=^#Fields:\s*(.*)
INDEXED_EXTRACTIONS=W3C
LINE_BREAKER=([\r\n]+)
MISSING_VALUE_REGEX=-
NO_BINARY_CHECK=true
SHOULD_LINEMERGE=false
TIME_FORMAT=%H:%M:%S
TIMESTAMP_FIELDS=Date,time

Sample log file

#Version:   1.0
#Fields:    Date time cs(X-Forwarded-For) cs(Cookie)
#Software:  WebLogic
#Start-Date:    2019-09-03  00:00:00
-   00:00:00    col_3_data  col_4_data
-   00:00:00    col_3_data  col_4_data
-   00:00:06    col_3_data  col_4_data
-   00:00:06    col_3_data  col_4_data
-   00:00:08    col_3_data  col_4_data
-   00:00:08    col_3_data  col_4_data
-   00:00:08    col_3_data  col_4_data
-   00:00:08    col_3_data  col_4_data
-   00:00:09    col_3_data  col_4_data
-   00:00:09    col_3_data  col_4_data
-   00:00:09    col_3_data  col_4_data
-   00:00:09    col_3_data  col_4_data
-   00:00:09    col_3_data  col_4_data
0 Karma
Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...