Splunk Search

how to extract the below words from a log

umsundar2015
Path Finder

Hi,

I have following sample log string ,

May 13 14:20:32 pcpsd1sb.smart.net 318324: May 13 14:20:31.282 EDT: %CDP-4-DUPLEX_MISMATCH: duplex mismatch discovered on GigabitEthernet7/6 (not half duplex), with RDCBKL1LSW1 FastEthernet0/24 (half duplex).

In this i need to get
1. pcpsd1sb.smart.net
2. GigabitEthernet7/6 alone in different fields.
But in future there might be change in logs based on different settings.

Requirement :
I need to extract the words in these places and create two new fields .

Regards,
sundar

Tags (2)
0 Karma
1 Solution

dineshraj9
Builder

You need to find a starting pattern match and extract these fields. Here timestamp is match for field1 and text "discovered on" for field2 -

<base search> | rex "(\d{2}\:){2}\d{2}(?<field1>[^\s]+)"
| rex "discovered\s+on\s+(?<field2>[^\s]+)"

View solution in original post

0 Karma

dineshraj9
Builder

You need to find a starting pattern match and extract these fields. Here timestamp is match for field1 and text "discovered on" for field2 -

<base search> | rex "(\d{2}\:){2}\d{2}(?<field1>[^\s]+)"
| rex "discovered\s+on\s+(?<field2>[^\s]+)"
0 Karma

umsundar2015
Path Finder

Thank you dineshraj9

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!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...