Splunk Search

reformatting output in table

secure
Path Finder

Hi everyone

i have a dataset

| makeresults
| eval APP1="appdelta", hostname1= mvappend("syzhost.domain1","abchost.domain1","egfhost.domain1"),hostname2=mvappend("syzhost.domain1","abchost.domain1")
| fields - _time

secure_0-1742492148693.png

i want the final output to be like below 

APP1hostname1hostnames2
appdeltasyzhost.domain1syzhost.domain1
appdeltaabchost.domain1abchost.domain1
appdeltaegfhost.domain1 

 

any suggestions 

Labels (1)
Tags (1)
0 Karma

yuanliu
SplunkTrust
SplunkTrust

You need to describe the logic from the input to the desired output.  There are at least two possible ways to match hostname1 and hostname2:

  1. Match by position.  This is the route @ITWhisperer takes.
  2. Match by hostname.

If the requirement is to match by name, this is one way to do it.

| foreach hostname1 hostname2
    [eval matchhost = if(isnull(matchhost) OR mvcount(<<FIELD>>) > mvcount(matchhost), <<FIELD>>, matchhost)]
| mvexpand matchhost
| foreach hostname1 hostname2
    [eval <<FIELD>> = mvindex(<<FIELD>>, mvfind(<<FIELD>>, matchhost))]
| fields - matchhost
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| eval row=mvrange(0,max(mvcount(hostname1), mvcount(hostname2)))
| mvexpand row
| eval hostname1=mvindex(hostname1,row)
| eval hostname2=mvindex(hostname2,row)
| fields - row
0 Karma
Get Updates on the Splunk Community!

Full-Stack Security in Financial Services: AppDynamics, Cisco Secure Application, and ...

Full-Stack Security in Financial Services: AppDynamics, Cisco Secure Application, and Splunk ES Protecting a ...

It's Customer Success Time at .conf25

Hello Splunkers,   Ready for .conf25? The customer success and experience team is and can’t wait to see you ...

Pro Tips for First-Time .conf Attendees: Advice from SplunkTrust

Heading to your first .Conf? You’re in for an unforgettable ride — learning, networking, swag collecting, ...