Splunk Search

How to write field name in its value

mah
Builder

Hi,

How can I write the name of a field in the value like I have :

test_1test_2test_3
warnerrorcritical

 

I want :

test
test_1 - warn
test_2 - error
test_3 - critical

 

I must do this for unknown fields (by now I have 3 tests but it can be more so it must be variable). 

I thought to foreach command but I don't know how to do it.

Can you help me if this usecase is possible ?

Labels (1)
Tags (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

There are couple of ways, for example

| makeresults
| eval _raw="test_1	test_2	test_3
warn	error	critical"
| multikv forceheader=1
| table test_*
| foreach test_*
    [eval test=if(isnull(test),"<<FIELD>>"." - ".<<FIELD>>,mvappend(test,"<<FIELD>>"." - ".<<FIELD>>))]
| table test

or

| makeresults
| eval _raw="test_1	test_2	test_3
warn	error	critical"
| multikv forceheader=1
| table test_*
| transpose 0
| eval test=column." - ".'row 1'
| table test
0 Karma
Get Updates on the Splunk Community!

SplunkTrust Application Period is Officially OPEN!

It's that time, folks! The application/nomination period for the 2025 SplunkTrust is officially open! If you ...

Splunk Answers Content Calendar, June Edition II

Get ready to dive into Splunk Dashboard panels this week! We'll be tackling common questions around ...

Splunk Observability Cloud's AI Assistant in Action Series: Auditing Compliance and ...

This is the third post in the Splunk Observability Cloud’s AI Assistant in Action series that digs into how to ...