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!

Aligning Observability Costs with Business Value: Practical Strategies

 Join us for an engaging Tech Talk on Aligning Observability Costs with Business Value: Practical ...

Mastering Data Pipelines: Unlocking Value with Splunk

 In today's AI-driven world, organizations must balance the challenges of managing the explosion of data with ...

Splunk Up Your Game: Why It's Time to Embrace Python 3.9+ and OpenSSL 3.0

Did you know that for Splunk Enterprise 9.4, Python 3.9 is the default interpreter? This shift is not just a ...