Splunk Search

Building KV Pairs

Andrew_Banman
Explorer

Hi folks,

I am trying to build KV pairs from some UNIX command output. The log entries look like the output below. In this case I would like to build keys from the headers (%usr, %sys, %wio, %idel) and values for each from the values shown (2, 5, 0, 93). I will then graph multiple entries over time. While the preview here shows this all in a line, the log is a preformatted table.

HP-UX van-sama B.11.31 U ia64 08/21/12
12:49:47 %usr %sys %wio %idle
12:49:48 2 5 0 93

The likely search function seems to be "extract(kv)" but I am unclear on how to go about this and the examples in the docs seem weak.

Can anyone put me on the right track?

Thanks 🙂

Tags (1)
0 Karma

Andrew_Banman
Explorer

Good idea but it still failes. Thanks for the help. Multikv seems the answer but doesn't do what we expect it too. Not sure why! Thanks again for the ideas 🙂

_d_
Splunk Employee
Splunk Employee

Multikv will replace non alphanumeric chars with underscore.
See if this does the trick:

... | multikv fields _usr _sys _wio _idle

d.

0 Karma

Andrew_Banman
Explorer

Thanks for your responce but this doesn't seem to work. No change in the results I get at all. I wonder if it could be the % characters. It certainly doesn't build KV pairs as I would expect it to.

Any other thoughts anyone?

0 Karma

MarioM
Motivator

Multikv seems more appropriate than extract in your case:

... | multikv fields %usr %sys %wio %idle
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, ...