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!

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