Splunk Search

Using rex to find matching values.

veera9
New Member

I have the following
ACTION :[7] 'CONNECT'
DATABASE[1] 'SYSTEM'

That's in the _raw data.
How do I extract CONNECT and SYSTEM under headers ACTION and DATABASE?

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi veera9,
Try this

ACTION\s:\[\d\]\s\'(?<ACTION>[^\']*)\'\s+DATABASE\[\d+\]\s\'(?<DATABASE>[^\']*)\'

You can test it at https://regex101.com/r/2BwU4O/1

Bye.
Giuseppe

DalJeanis
Legend

That would be

 | rex "ACTION\s:\[\d\]\s\'(?<ACTION>[^\']*)\'\s+DATABASE\[\d+\]\s\'(?<DATABASE>[^\']*)\'"

The above works fine. Based on your example breaking across lines, I might go with

 | rex "ACTION\s:\[\d\]\s\'(?<ACTION>[^\']*)\'"
 | rex "DATABASE\[\d+\]\s\'(?<DATABASE>[^\']*)\'"

...or...

 | rex "ACTION\s:\[\d\]\s\'(?<ACTION>[^\']*)\'|DATABASE\[\d+\]\s\'(?<DATABASE>[^\']*)\'" max_match=0

Any of the above should work.

0 Karma

veera9
New Member

Thank you everyone.

0 Karma

gcusello
SplunkTrust
SplunkTrust

If you're satisfied, please accept or upvote this answer.
Bye.
Giuseppe

0 Karma
Get Updates on the Splunk Community!

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...