Splunk Search

How can I combine stats count by host into a single string to be used in an alert actions token?

burwell
SplunkTrust
SplunkTrust

I have a search that looks like

index=foo value=bar | stats count by host

Imagine you might get results like

host     count
host1   123
host2    456
host3    789

We want to alert when the count is greater than some threshold and I can do that.

What I also want to do is to create a new field that we can use an alert actions token.

So imagine in the above example we had a new field called badhosts whose value was the concatenation of the hosts with their count. For example "host1:123 host2:456 host3:789"

Each host is represented by its count.

The reason to do this is so I can then use $result.badhosts$ as a token and we can see all the hosts and their values.

How to do this? Thanks.

0 Karma
1 Solution

efavreau
Motivator

@burwell Sounds like you're looking for sistats

index=foo value=bar | sistats values(host) as hosts
###

If this reply helps you, an upvote would be appreciated.

View solution in original post

0 Karma

efavreau
Motivator

@burwell Sounds like you're looking for sistats

index=foo value=bar | sistats values(host) as hosts
###

If this reply helps you, an upvote would be appreciated.
0 Karma

burwell
SplunkTrust
SplunkTrust

Perfect! Thanks!

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!

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...

Design, Compete, Win: Submit Your Best Splunk Dashboards for a .conf26 Pass

Hello Splunkers,  We’re excited to kick off a Splunk Dashboard contest! We know that dashboards are a primary ...

May 2026 Splunk Expert Sessions: Security & Observability

Level Up Your Operations: May 2026 Splunk Expert Sessions Whether you are refining your security posture or ...