Splunk Search

How to get the assigned value of a macro with ":" (colon) as a seperator

harshal_chakran
Builder

Hi,

I need to find the value of PLANDATA_TYPE from the given string in my logs

i.e. PLANDATA_TYPE: ASBFGH, PLANWORK: NotMentioned.

I should get output as ASBFGH when I search for value of PLANDATA_TYPE.
And similarly I should get value as NotMentioned for PLANWORK. The issue is they are not separated by "=" sign but by ":". Any ideas how to proceed?

Tags (2)
0 Karma
1 Solution

jtrucks
Splunk Employee
Splunk Employee

Use an extract. Try:

… | rex field=_raw "PLANDATA_TYPE:\s(?<PLANDATA_TYPE>\w+),\sPLANWORK:(?<PLANWORK>\w+)"
--
Jesse Trucks
Minister of Magic

View solution in original post

sowings
Splunk Employee
Splunk Employee

If you can edit the props / transforms directly, this would work just fine with the following transform on your data:


[my_rule]
DELIMS = ":", ","

The first signifies what separates a key from a value, and the second indicates what separates key=value pairs from each other.

0 Karma

jtrucks
Splunk Employee
Splunk Employee

Use an extract. Try:

… | rex field=_raw "PLANDATA_TYPE:\s(?<PLANDATA_TYPE>\w+),\sPLANWORK:(?<PLANWORK>\w+)"
--
Jesse Trucks
Minister of Magic

harshal_chakran
Builder

Thanks jtrucks and dolxor. It worked..!!!

0 Karma

jtrucks
Splunk Employee
Splunk Employee

fixed. Nice call 🙂

--
Jesse Trucks
Minister of Magic
0 Karma

dolxor
Path Finder

Hey jtrucks. Shouldn't there be a whitespace \s between the : and (?<.. or does Splunk trim this automatically when assigning the value to the fieldname?

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!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

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, ...