Splunk Search

How to separate a search by groups of hosts?

meleschi
Explorer

Hello!

If I run this query, I'll get a graph of the # of queries over time aggregated for all of my hosts.

host=* | timechart per_minute(Query)

If I run this query, I'll have a similar graph with one line shown per host.

host=* | timechart per_minute(Query) by host

Is there any way to graph by groups of hosts? Say, by the domain of the server.

example:

host=* | timechart per_minute(Query) by group (a, b, c) where group a like "*.a.com" and group b like "*.b.com" and group c like "*.c.com"
0 Karma

woodcock
Esteemed Legend

Like this:

 host=*
| rex field=host mode=sed "s/^[^\.]+/\*/"
| timechart per_minute(Query) BY host
0 Karma

meleschi
Explorer

Thank you for both answers above. I ended up placing some data in a lookup table, and using that to break apart servers by region, type, etc.

0 Karma

somesoni2
Revered Legend

You can create a field with those criteria/specification and they group by those.
e.g.

 host=* | eval group=case(like(host,"%.a.com"),"group a",like(host,"%.b.com"),"group b",...other sets here, 1=1,"defauly") | timechart per_minute(Query) by group

If you're only interested in group a/b/c (you don't want to statistics for other domains, add them as filter in the base search.

 host=*.a.com OR host=*.b.com OR host=*.c.com  | eval group=case(like(host,"%.a.com"),"group a",like(host,"%.b.com"),"group b",...other sets here, 1=1,"defauly") | timechart per_minute(Query) by group

lycollicott
Motivator

Off the top of my head, I would extract a field to be the domain and group by that.

So, something like:

hosts=* 
| rex field=host "\.(?\w+\.\w+)"
| timechart span=1m count by domain_name
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Level Up Your .conf25: Splunk Arcade Comes to Boston

With .conf25 right around the corner in Boston, there’s a lot to look forward to — inspiring keynotes, ...

Manual Instrumentation with Splunk Observability Cloud: How to Instrument Frontend ...

Although it might seem daunting, as we’ve seen in this series, manual instrumentation can be straightforward ...

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

Ready to make your IT operations smarter and more efficient? Discover how to automate Splunk alerts with Red ...