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!

Earn a $35 Gift Card for Answering our Splunk Admins & App Developer Survey

Survey for Splunk Admins and App Developers is open now! | Earn a $35 gift card!      Hello there,  Splunk ...

Continuing Innovation & New Integrations Unlock Full Stack Observability For Your ...

You’ve probably heard the latest about AppDynamics joining the Splunk Observability portfolio, deepening our ...

Monitoring Amazon Elastic Kubernetes Service (EKS)

As we’ve seen, integrating Kubernetes environments with Splunk Observability Cloud is a quick and easy way to ...