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!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...