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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...