Splunk Search

How to drop extra fields while maintaining groupby?

yuanliu
SplunkTrust
SplunkTrust

To groupby?  Or not to groupby?  That is the question. (Not really.  The question arises because trellis splitby seems to depend on an invisible groupby register.)

Take the following example:

 

 

| makeresults count=10
| eval value = "value" . random() % 3
| stats count by value
| eventstats sum(count) as total
| eval ratio = count / total

 

 

If I want to visualize ratio as single value in trellis, I can add `| fields - total count` in the end.

groupby.png

But if there are many intermediate variables, it gets tedious to list them for dropping.  I thought `table value ratio` would be simpler, as statistics table is exactly the same, but SPL's invisible hand prevents splitby from seeing the original groupby field, so I get weird output like

groupbynot.png

I can avoid tedious `fields -` listing by doing another stats with groupby, e.g., `stats values(ratio) as ratio by value`.

groupbydouble.png

 But I feel silly to do a useless calculation.  Is there a simpler way to preserve groupby register without the tedious listing?

Labels (2)
0 Karma

yuanliu
SplunkTrust
SplunkTrust

I just realize that I can carefully name intermediate variables so I can drop them with wildcard.  But is there any SPL answer to the original question?

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

Celebrating Fast Lane: 2025 Authorized Learning Partner of the Year

At .conf25, Splunk proudly recognized Fast Lane as the 2025 Authorized Learning Partner of the Year. This ...

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...