Splunk Search

How do you use tstats to list the number of unique hosts over time?

a212830
Champion

Hi,

Is there a way to use the tstats command to list the number of unique hosts that report into Splunk over time? I'm looking to track the number of hosts reporting in on a monthly basis, over a year.

0 Karma

season88481
Contributor

a single one-liner should do the trick

 

| tstats dc(host) WHERE index=_internal  by _time
Tags (1)
0 Karma

skoelpin
SplunkTrust
SplunkTrust

Yes ofcourse there is, try this and run it over a 1 year period.. It may be slow depending on how many unique hosts you have and how many indexers you have. If you have to run this frequently, I'd recommend setting this up as a scheduled search to populate a summary index

| tstats prestats=f count WHERE index=* sourcetype=*  by _time, host
| timechart span=1mon dc(host) AS unique_host_count

KailA
Contributor

This might be a bit faster.
Trying to not use distinct count here :

| tstats prestats=f count WHERE index=* sourcetype=*  by _time, host span=1mon
| stats count AS distinct_host_count BY _time
0 Karma
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!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...