Splunk Search

How can I combine stats from multiple servers from 1 site as 1 row to build a stats table for multiple sites?

sligerc
New Member

I've got to get a report going that will show us multiple cloud site statistics for XenDesktop in a single report. What makes this a challenge is if I use sum() it adds all stats within the search time, and since the script reports in multiple times an hour, the stats would then be off...big time. So ideally I would like to avg() the stats from both Site servers, then add them together to form the Site table. Here's what I have so far:

This search:

index=CitrixXenDesktop source=XenDesktop:Get-XDDesktopGroup7.ps1 sourcetype=XenDesktop:desktopgroup
| eval DesktopsOff = TotalDesktops-(DesktopsUnregistered+DesktopsAvailable+DesktopsDisconnected+DesktopsInUse)
| stats max(DesktopsAvailable) as Available max(DesktopsInUse) as InUse max(DesktopsDisconnected) as Disconnected max(DesktopsUnregistered) as Unregistered max(DesktopsOff) as Off by host

…gives these results:

![alt text

This is close, but I need to add the stats for each Site server and get something like this:

alt text

0 Karma

richgalloway
SplunkTrust
SplunkTrust

If you have a way to get the site names from the host names then you could change the stats command to by site instead of by host and have your desired results. A simplistic example would be:

index=CitrixXenDesktop source=XenDesktop:Get-XDDesktopGroup7.ps1 sourcetype=XenDesktop:desktopgroup
| eval DesktopsOff = TotalDesktops-(DesktopsUnregistered+DesktopsAvailable+DesktopsDisconnected+DesktopsInUse)
| eval site=substr(host,1,5) |
| stats max(DesktopsAvailable) as Available max(DesktopsInUse) as InUse max(DesktopsDisconnected) as Disconnected    max(DesktopsUnregistered) as Unregistered max(DesktopsOff) as Off by site
---
If this reply helps you, Karma would be appreciated.
0 Karma

sundareshr
Legend

Append this to the end of your search. You may have to tweak the regex to match your data. But the idea is to extract the site name from host field and group sum by site.

... | rex field=Host "(?<Site>Site\d+)" | stats sum(*) as * by Site
0 Karma
Get Updates on the Splunk Community!

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

 Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

🔐 Trust at Every Hop: How mTLS in Splunk Enterprise 10.0 Makes Security Simpler

From Idea to Implementation: Why Splunk Built mTLS into Splunk Enterprise 10.0  mTLS wasn’t just a checkbox ...