Splunk Search

how to match value in events using Rex

james_n
Path Finder

Hi experts,

please help me with regular expression to match the value in each event at search time as shown below

:{\"buaid\":{\"business\":[\"12345\"],\"exclude*

required output: bss_value=12345

thanks in advance.

Tags (2)
0 Karma

to4kawa
Ultra Champion
|rex "(?<bss_value>\d{5})"

This is enough.

0 Karma

jpolvino
Builder

This might get you close, with a run anywhere example:

| makeresults | eval _raw=":{\\\"buaid\\\":{\\\"business\\\":[\\\"12345\\\"],\\\"exclude*"
| rex ":{\\\\\"buaid\\\\\":{\\\\\"business\\\\\":\[\\\\\"(?<bss_value>[^\\\]+)\\\\\"\],"

It sets up a _raw field, and then extracts from it. The last line should do it for you.

james_n
Path Finder

Hi @jpolvino , thanks for the answer. its working fine. but if i have multiple values with , separated than its not working .Please help on this.

Ex: :{\"buaid\":{\"business\":[\"12345\",\"6789\"]

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Try

business\\":\[\\"(?<bss_value>[^\\]+)\\
---
If this reply helps you, Karma would be appreciated.
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...

Data Persistence in the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. What happens if the OpenTelemetry collector ...

Thanks for the Memories! Splunk University, .conf25, and our Community

Thank you to everyone in the Splunk Community who joined us for .conf25, which kicked off with our iconic ...