Splunk Search

How to edit my search to find multiple averages from one field based based on the context provided by other fields?

matthewjohnson
Explorer

When working with Windows performance counters, the Value field contains the interesting data for a given context. The context of Value is defined by other fields - the counter field for example.

What I'd like to do is something like this:

index="perfmon" collection="Free Disk Space" | stats avg(Value when counter == "% Free Space") as percent_free avg(Value when counter == "Free Megabytes") as mb_free by host

So I end up with something like this:

Host            | percent_free              | mb_free
--------------------------------------------------------
BigHost1        | 20                        | 3000
BigHost2        | 10                        | 1500
...

How do I accomplish this?

Tags (2)
0 Karma
1 Solution

somesoni2
Revered Legend

Try something like this

index="perfmon" collection="Free Disk Space" counter="% Free Space" OR counter="Free Megabytes" | chart avg(Value) over host by counter | rename "% Free Space" as percent_free "Free Megabytes" as mb_free

View solution in original post

somesoni2
Revered Legend

Try something like this

index="perfmon" collection="Free Disk Space" counter="% Free Space" OR counter="Free Megabytes" | chart avg(Value) over host by counter | rename "% Free Space" as percent_free "Free Megabytes" as mb_free

matthewjohnson
Explorer

Exactly what I wanted - thank you!

0 Karma
Get Updates on the Splunk Community!

Accelerating Observability as Code with the Splunk AI Assistant

We’ve seen in previous posts what Observability as Code (OaC) is and how it’s now essential for managing ...

Integrating Splunk Search API and Quarto to Create Reproducible Investigation ...

 Splunk is More Than Just the Web Console For Digital Forensics and Incident Response (DFIR) practitioners, ...

Congratulations to the 2025-2026 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...