Splunk Search

How do you transform table values like this?

splunkelz
Engager

Is there a way or command to make the table results something like on the expected output.

current data:

hostname ip database_status internet_status proxy_status
server101 192.168.10.2 online online offline
server102 192.168.10.3 offline online offline


expected output:

hostname ip status
server101 192.168.10.2 database_status = "online"
internet_status = "online"
proxy_status = "offline"
server102 192.168.10.3 database_status = "offline"
internet_status = "online"
proxy_status = "offline"
Labels (1)
0 Karma
1 Solution

kamlesh_vaghela
SplunkTrust
SplunkTrust

@splunkelz 

Can you please try this?

YOUR_SEARCH
| eval status=""
| foreach *_status 
    [| eval status= mvappend(status,"<<FIELD>>"+"="+<<FIELD>>)] 
| table hostname ip status

 

My Sample Search :

| makeresults 
| eval _raw="hostname	ip	database_status	internet_status	proxy_status
server101	192.168.10.2	online	online	offline
server102	192.168.10.3	offline	online	offline" 
| multikv forceheader=1 
| table hostname ip database_status internet_status proxy_status 
| eval status=""
| foreach *_status 
    [| eval status= mvappend(status,"<<FIELD>>"+"="+<<FIELD>>)] 
| table hostname ip status

 

Screenshot 2022-04-26 at 1.14.57 PM.png

 

Thanks
KV


If any of my reply helps you to solve the problem Or gain knowledge, an upvote would be appreciated.

 

View solution in original post

0 Karma

splunkelz
Engager
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @splunkelz,

please try something like this:

index=your_index
| eval 
     database_status="database_status=".database_status,
     internet_status="internet_status".internet_status,
     proxy_status="proxy_status".proxy_status
| stats values(ip) AS ip values(database_status) AS database_status values(internet_status) AS internet_status values(proxy_status) AS proxy_status BY hostname

Ciao.

Giuseppe

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@splunkelz 

Can you please try this?

YOUR_SEARCH
| eval status=""
| foreach *_status 
    [| eval status= mvappend(status,"<<FIELD>>"+"="+<<FIELD>>)] 
| table hostname ip status

 

My Sample Search :

| makeresults 
| eval _raw="hostname	ip	database_status	internet_status	proxy_status
server101	192.168.10.2	online	online	offline
server102	192.168.10.3	offline	online	offline" 
| multikv forceheader=1 
| table hostname ip database_status internet_status proxy_status 
| eval status=""
| foreach *_status 
    [| eval status= mvappend(status,"<<FIELD>>"+"="+<<FIELD>>)] 
| table hostname ip status

 

Screenshot 2022-04-26 at 1.14.57 PM.png

 

Thanks
KV


If any of my reply helps you to solve the problem Or gain knowledge, an upvote would be appreciated.

 

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Thanks for the Memories! Splunk University, .conf25, and our Community

Thank you to everyone in the Splunk Community who joined us for .conf25, which kicked off with our iconic ...

Data Persistence in the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. What happens if the OpenTelemetry collector ...

Introducing Splunk 10.0: Smarter, Faster, and More Powerful Than Ever

Now On Demand Whether you're managing complex deployments or looking to future-proof your data ...