Splunk Search

tstats results different from eventcount

marian_coman
Explorer

Can anyone provide an explanation on why these two searches produce different results? I am trying to set up an alert for the case when an index does not have logs in the last couple of hours (time condition on tstats removed for the example below):

| tstats latest(_time) as latest where index=* by index

returns 51 of my indexes, while:

| eventcount summarize=false index=* | dedup index | fields index

would return all of my 87 indexes.

Thanks!

0 Karma
1 Solution

somesoni2
Revered Legend

The tstats command runs statistics on the specified parameter based on the time range. Hence you get the actual count. The eventcount command doen't need time range. Specifying a time range has no effect on the results returned by the eventcount command. All of the events on the indexes you specify are counted.

View solution in original post

somesoni2
Revered Legend

The tstats command runs statistics on the specified parameter based on the time range. Hence you get the actual count. The eventcount command doen't need time range. Specifying a time range has no effect on the results returned by the eventcount command. All of the events on the indexes you specify are counted.

marian_coman
Explorer

Thanks. Indeed the tstats returns time range results. However your answer help me realize the difference, that being that the result are different as some indexes have never received logs.

0 Karma
Get Updates on the Splunk Community!

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...