Splunk Search

Join SPL result to a single line?

wbolten
Path Finder

Hi, 

The following SPL returns records to me as shown below. 

 

 

index="uf_basickpi" host!=DS-* (sourcetype="CPU" counter="% Processor Time") OR (sourcetype="Memory" counter="Available MBytes") OR (sourcetype="DiskStuff" counter="% Free Space" instance=C:) 
| stats latest(Value) as Value by host, counter 
| eval "CPU Time" = if(counter="% Processor Time",Value,0) 
| eval "RAM Available" = if(counter="Available MBytes",Value,0) 
| eval "C Free Space" = if(counter="% Free Space",Value,0) 
| table host, "CPU Time", "RAM Available", "C Free Space"

 

 

Screenshot 2020-08-11 at 13.43.17.png

Rows 1,2 and 3 are from the same server. Rows 4,5 and 6 from the second server. 

What I would like to have is a single row per server with the three values. What would be the best way to do this. 

Labels (2)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

The stats command can merge the rows.

index="uf_basickpi" host!=DS-* (sourcetype="CPU" counter="% Processor Time") OR (sourcetype="Memory" counter="Available MBytes") OR (sourcetype="DiskStuff" counter="% Free Space" instance=C:) 
| stats latest(Value) as Value by host, counter 
| eval "CPU Time" = if(counter="% Processor Time",Value,0) 
| eval "RAM Available" = if(counter="Available MBytes",Value,0) 
| eval "C Free Space" = if(counter="% Free Space",Value,0) 
| stats values(*) as * by host
| table host, "CPU Time", "RAM Available", "C Free Space"
---
If this reply helps you, Karma would be appreciated.

View solution in original post

0 Karma

richgalloway
SplunkTrust
SplunkTrust

The stats command can merge the rows.

index="uf_basickpi" host!=DS-* (sourcetype="CPU" counter="% Processor Time") OR (sourcetype="Memory" counter="Available MBytes") OR (sourcetype="DiskStuff" counter="% Free Space" instance=C:) 
| stats latest(Value) as Value by host, counter 
| eval "CPU Time" = if(counter="% Processor Time",Value,0) 
| eval "RAM Available" = if(counter="Available MBytes",Value,0) 
| eval "C Free Space" = if(counter="% Free Space",Value,0) 
| stats values(*) as * by host
| table host, "CPU Time", "RAM Available", "C Free Space"
---
If this reply helps you, Karma would be appreciated.
0 Karma

wbolten
Path Finder

I did not know that 😉

With your suggestion I did get a single row but the 0 values where in there as well. Replaced them with isnull and now I only have values and a single two per server. 

| stats latest(Value) as Value by host, counter 
| eval "CPU Time" = if(counter="% Processor Time",Value,isnull) 
| eval "RAM Available" = if(counter="Available MBytes",Value,isnull) 
| eval "C Free Space" = if(counter="% Free Space",Value,isnull) 
| stats Values(*) as * by host
| table host, "CPU Time", "RAM Available", "C Free Space"

 Thanks

0 Karma
Get Updates on the Splunk Community!

Observability Unlocked: Kubernetes Monitoring with Splunk Observability Cloud

  Ready to master Kubernetes and cloud monitoring like the pros?Join Splunk’s Growth Engineering team for an ...

Wrapping Up Cybersecurity Awareness Month

October might be wrapping up, but for Splunk Education, cybersecurity awareness never goes out of season. ...

🌟 From Audit Chaos to Clarity: Welcoming Audit Trail v2

🗣 You Spoke, We Listened  Audit Trail v2 wasn’t written in isolation—it was shaped by your voices.  In ...