Splunk Dev

Re-use host field in Timechart for count aggregation

joshuagray
Engager

I am attempting to create a dynamic timecharted trellis dashboard panel that only shows an aggregation by host based on which host fields are present in the main search.

As an example, the below shows two trellis panels, split by sourcetype using a statically assigned host names.

index=* sourcetype=* host=host1 OR host=host2 
| timechart span=1s count(eval(host == "host1")) as "host1" count(eval(host == "host2")) as "host2" count by sourcetype

What I would like is the number of Trellis panels (aggregated by host) to shrink or grow based on the number of hosts listed in the primary search.

Programmatically this would be something like a for loop over the host aggregation to create multiple panels, depending on the number of host values present.

i.e.

index=* sourcetype=* host=host1 OR host=host2 
| timechart span=1s count(eval(host == )) as "" count by sourcetype

With the expanded search evaluating to something like the below, assuming 3 hosts.

index=* sourcetype=* host=host1 OR host=host2 OR host=3
| timechart span=1s count(eval(host == "host1")) as "host1" count(eval(host == "host2")) as "host2" count(eval(host == "host3")) as "host3" count by sourcetype

Any help would be appreciated!
Thanks.

Tags (1)
0 Karma

DalJeanis
Legend

See the answer by @niketnilay on this one, which includes the full code for a similar solution.

https://answers.splunk.com/answers/623803/trellis-display-of-two-values.html

However, I believe you may need to swap the order of your fields. That is, the "by" field may need to be by host if you want the trellis to break the results by host. Try it the way you have it and see if it works. If not, then swap it and see if that works.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Monitoring AI Agents with Splunk Observability Cloud

Let’s say I’m running a travel planning AI app in production. A user asks for three concise hotel options in ...

[Puzzles] Solve, Learn, Repeat: Tiling

This puzzle (first published here) is based on finding groups of tessellated tiles (inspired by floor tiles I ...

SOK it to Me: Top 3 Benefits of Using Splunk Operator on Kubernetes that’ll Make ...

    Thursday, July 9, 2026  |  11:00AM–12:00PM PDT Duration: 1 hour (includes Q&A) Managing can feel like a ...