Hi Logstash experts.
Im having big issues parsing MSSQL logs from the Windows event log, and i hope someone can assist.
MSSQL logs event id 33205 to Windows event log, in a somewhat structured format, except the "Statement" field containing the SQL query.
Raw Event id looks like this:
server_principal_name:domain.local\username
server_principal_sid:123456789123456798123456
database_principal_name:test1
server_instance_name:coolServerName
database_name:coolDatabaseName
statement:with info as(
select test123.*,
lu.test as hellohello,
lu.hhy as whatIsThisEven,
gtinInf.GTIN,
left(case when HelloAgain.cleansedRow is not null and HelloAgain.cleansedRow not in (select * from #stopwords) then HelloAgain.cleansedRow end, 1000) as Party123,
additional_information:someMoreInfoHere
By default, logstash does not know how to parse and puts everything in message field.
My first solution was to use KV filter to specify ":" as value split, and "\n" as field split.
This works, until it meets a multiline log.
I made a Regex that is able to capture the multiline SQL statement, but i feel like i still need to use KV filter for all the other lines, where KV filter works fine.
Am i able to use KV filter until a sudden point, and then explicitly specify the statement field using my Regex?
I have been though the Filter documentation, and KV or Gsub seems to be the way, but im not sure.
Any sugestions would be appereciated.
Note: Because the "statement" field changes ALOT depending on what queries are run, i cannot statically parse it, i think. If im approaching this wrong, please let me know
Current KV filter:
filter {
if [event][code] == 33205 {
kv {
field_split => "\n"
value_split => ":"
remove_field => [ "{param}", "my_extraneous_field" ]
}
}
}
Best regards