Splunk Search

Regex to extract a word after word and comma

dtccsundar
Path Finder

i have 2 requirements 

1) From different events in need to extract the word after Interface  and Comma. After Interface there will be a space .Field name can be Interface

2) Need to extract a new field with name Activity with values either Up or Down .I have marked in bold in the events .

Ex- 

1) Mar 5 05:45:43 ie-dub-corp-sw1 Eastern: %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet2/0/19, changed state to down

2) Mar 5 05:46:50 omenmnlswfl02 EST: %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet2/3, changed state to up

Please help me with 2 regex .

 

 

Labels (3)
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @dtccsundar,

if you want only one regex, you can use

| rex "Interface\s+(?<interface>[^,]+), changed state to (?<state>\w+)"

if you prefer two regexes, you can use:

| rex "Interface\s+(?<interface>[^,]+)"
| rex ""changed state to (?<state>\w+)"

you can test the regx at https://regex101.com/r/WpmBG3/1

Ciao.

Giuseppe

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...