Splunk Search

help on transpose command

jip31
Motivator

hello

 

In the search below, I need to display anything if the Hostname is not found

Actually, I have the fields displayed even if the hostname doesnt exists (see attachment here https://www.cjoint.com/c/KCmgUBEZndg)

How to display anything if the hostname doesnt exists please??

 

`wire` 
| fields AP_NAME USERNAME LAST_SEEN 
| lookup ap.csv NAME as AP_NAME OUTPUT Building Country Site  
| rename USERNAME as host 
| eval time = strftime(_time, "%d-%m-%y %H:%M") 
| stats latest(time) as "Last check date", last(AP_NAME) as "Access Point", last(Site) as "Geolocation site", last(Building) as "Geolocation building" by host 
| rename host as Hostname
| search Hostname=X3020131
| transpose 0 column_name="Geolocation items" header_field=header 
| rename "row 1" as "Geolocation results"

 

 

Labels (1)
Tags (1)
0 Karma
1 Solution

scelikok
SplunkTrust
SplunkTrust

Hi @jip31,

You can set include_empty parameter of transpose command to false;

`wire` 
| fields AP_NAME USERNAME LAST_SEEN 
| lookup ap.csv NAME as AP_NAME OUTPUT Building Country Site  
| rename USERNAME as host 
| eval time = strftime(_time, "%d-%m-%y %H:%M") 
| stats latest(time) as "Last check date", last(AP_NAME) as "Access Point", last(Site) as "Geolocation site", last(Building) as "Geolocation building" by host 
| rename host as Hostname
| search Hostname=X3020131
| transpose 0 column_name="Geolocation items" header_field=header include_empty=false
| rename "row 1" as "Geolocation results"
If this reply helps you an upvote and "Accept as Solution" is appreciated.

View solution in original post

0 Karma

scelikok
SplunkTrust
SplunkTrust

Hi @jip31,

You can set include_empty parameter of transpose command to false;

`wire` 
| fields AP_NAME USERNAME LAST_SEEN 
| lookup ap.csv NAME as AP_NAME OUTPUT Building Country Site  
| rename USERNAME as host 
| eval time = strftime(_time, "%d-%m-%y %H:%M") 
| stats latest(time) as "Last check date", last(AP_NAME) as "Access Point", last(Site) as "Geolocation site", last(Building) as "Geolocation building" by host 
| rename host as Hostname
| search Hostname=X3020131
| transpose 0 column_name="Geolocation items" header_field=header include_empty=false
| rename "row 1" as "Geolocation results"
If this reply helps you an upvote and "Accept as Solution" is appreciated.
0 Karma

jip31
Motivator

thanks it works

Tags (1)
0 Karma
Get Updates on the Splunk Community!

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...