Splunk Search

Field extraction of similiar field across multiple line from Powershell logs

totaro
Explorer

Hi, i was hoping to extract all the fields after "CommandInvocation" that appears in the PS log but i wasnt able to extract properly. Does anyone have any idea?

My rex as follow: "(\n)+CommandInvocation((?.+))"

Sample:
Oct 10 10:10:10 1.1.1.1 Hostname INFO 4103 Hostname\user CommandInvocation(Stop-AgentJob): "Stop-AgentJob"
CommandInvocation(Format-List): "Format-List"
CommandInvocation(Out-String): "Out-String"

Expectation of field:
Stop-AgentJob
Format-List
Out-String

Tags (2)
0 Karma
1 Solution

to4kawa
Ultra Champion
| stats count
| eval _raw="Oct 10 10:10:10 1.1.1.1 Hostname INFO 4103 Hostname\\user CommandInvocation(Stop-AgentJob): \"Stop-AgentJob\"
CommandInvocation(Format-List): \"Format-List\"
CommandInvocation(Out-String): \"Out-String\""
| rex max_match=10 "\bCommandInvocation\((?<yourField>[^\)]+)"

Hi, try max_match option.

View solution in original post

0 Karma

to4kawa
Ultra Champion
| stats count
| eval _raw="Oct 10 10:10:10 1.1.1.1 Hostname INFO 4103 Hostname\\user CommandInvocation(Stop-AgentJob): \"Stop-AgentJob\"
CommandInvocation(Format-List): \"Format-List\"
CommandInvocation(Out-String): \"Out-String\""
| rex max_match=10 "\bCommandInvocation\((?<yourField>[^\)]+)"

Hi, try max_match option.

0 Karma

totaro
Explorer

thanks! max_match work like a charm

0 Karma
Get Updates on the Splunk Community!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...