Splunk Search

Coalesce that shows the Field and Value in a Table

JaysonD123
Explorer

Good Afternoon,

I am working on a coalesce query that looks like this: 

| makeresults
| eval Name="John", NAME="Johnny", name="john"
| eval New_Name=coalesce("Name:;"+Name, "NAME:;"+NAME, "name:;"+name)
| rex mode=sed field=New_Name "s/;/\n/g"
| table New_Name

The output I get is exactly what I'm looking for but is there a way I can simplify this? I'm trying to have the table display the field name with the coalesced value without having to type in the string before the value (ie:  "Name:;"+Name). Any help would be greatly appreciated.

Respectfully,

Jayson

Labels (4)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
| makeresults
| eval Name="John", NAME="Johnny", name="john"
| foreach * 
    [eval <<FIELD>>="<<FIELD>>:;".<<FIELD>>]
| eval New_Name=coalesce(Name, NAME, name)
| rex mode=sed field=New_Name "s/;/\n/g"
| table New_Name

View solution in original post

JaysonD123
Explorer

This is perfect. Thank you.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| makeresults
| eval Name="John", NAME="Johnny", name="john"
| foreach * 
    [eval <<FIELD>>="<<FIELD>>:;".<<FIELD>>]
| eval New_Name=coalesce(Name, NAME, name)
| rex mode=sed field=New_Name "s/;/\n/g"
| table New_Name
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...