Parse IIS access log
#20235
-
Given an IIS access log (below an excerpt, anonymized), what is the suggested way to parse this and have a message with all fields? Should I use
|
Beta Was this translation helpful? Give feedback.
Answered by
vividDuck
May 14, 2025
Replies: 2 comments
-
Hi, I'm use this setting type: remap
inputs:
- iis_logs
source: | # \/ This flag makes regex multiline.
. |= parse_regex!(.message, r'(?m)^(?P<timestamp>\d+-\d+-\d+ \d+:\d+:\d+) (?P<sIp>\d+.\d+.\d+.\d+) (?P<method>\w+) (?P<csUri>\S+) (?P<csUriQuery>\S+) (?P<sPort>\d+) (?P<csUserName>\S+) (?P<cIp>\d+.\d+.\d+.\d+) (?P<csUA>\S+) (?P<csR>\S+) (?P<csStatus>\d+) (?P<csSubstatus>\d+) (?P<csWin32Status>\d+) (?P<timeTaken>\d+)') |
Beta Was this translation helpful? Give feedback.
0 replies
-
This is the remap I've used and works for an iis log format of:
Basically they are space separated, so you could use the parse_csv, remap_iis_logs:
inputs:
- g_iis_logs
type: remap
source: |
. |= parse_regex!(.message, r'(?P<datetime>[^ ]+ [^ ]+) (?P<source_ip>[^ ]+) (?P<method>[^ ]+) (?P<uri_stem>[^ ]+) (?P<uri_query>[^ ]+) (?P<source_port>[^ ]+) (?P<username>[^ ]+) (?P<client_ip>[^ ]+) (?P<version>[^ ]+) (?P<user_agent>[^ ]+) (?P<referer>[^ ]+) (?P<status>[^ ]+) (?P<sub_status>[^ ]+) (?P<win32_status>[^ ]+) (?P<source_bytes>[^ ]+) (?P<client_bytes>[^ ]+) (?P<time_taken>[^ ]+) (?P<x_forwarded_for>[^ \r]+)')
.datetime = parse_timestamp(.datetime, format: "%F %T") ?? now() |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
pront
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is the remap I've used and works for an iis log format of:
Basically they are space separated, so you could use the parse_csv,
parse_csv!(.message, delimiter: " ")
. But that would not provide a header.