Splunk Search

How to extract value using KV pairs?

hraj05579
New Member

Hello all,

How I can extra value from my event?

23-Oct-2019 08:07:23 <TestCase1>23</TestCase1>
23-Oct-2019 08:07:23    <TestCasePassed>234</TestCasePassed>

I want to display TestCase1= 23 TestCasePassed=234

Thanks in advance.

0 Karma

woodcock
Esteemed Legend

Like this:

|makeresults | eval raw=" 23-Oct-2019 08:07:23 <TestCase1>23</TestCase1>:::23-Oct-2019 08:07:23 <TestCasePassed>234</TestCasePassed>"
| makemv delim=":::" raw
| mvexpand raw
| rename raw AS _raw

| rename COMMENT AS "Everything above generates sample event data; everything below is your solution."

| rex max_match=20 "<(?<key>[^\/][^>]+)>(?<value>.*?)<\/[^>]+>"
| eval _raw=mvzip(key, value, "=")
| kv
0 Karma

to4kawa
Ultra Champion
| makeresults
| eval raw="23-Oct-2019 08:07:23 <TestCase1>23</TestCase1>
23-Oct-2019 08:07:23    <TestCasePassed>234</TestCasePassed>"
| makemv delim="
" raw
| mvexpand raw
| rex field=raw "(?<time>^[^ ]+ [^ ]+) (?<_raw>.+)"
| eval _time=strptime(time,"%d-%b-%Y %H:%M:%S")
| table _time _raw
`comment("this is sample data")`
| spath

Hi, try spath command

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...