Splunk Dev

How do you use the stats command on a timechart output?

asharm65
New Member

Hi,

i wanted to calculate a count for every 1 sec period and then find the max of the count per day.

i have calculated the count using timechart function.Using query below:

1)..base_query|timechart span=1s count(field_1) as c by field_2

The output of the above query gives a count every 1 second.

Now to calculate the max of count per day. i tried using stats:

2)..base_query|timechart span=1s count(field_1) as c by field_2|stats max(c) by Date

But, the 2nd query does not give desired output.

Thanks in Advance!!!

Tags (1)
0 Karma

FrankVl
Ultra Champion

Where do you get that by Date from? That Date field doesn't exist (at least not given the exact query you are showing here).

If you want to get the max per-second-count by day, try it like this:

...base_query
| timechart span=1s count(field_1) as c by field_2
| bin _time span=1d
| stats max(c) by _time
0 Karma

asharm65
New Member

This does not give any output

0 Karma

FrankVl
Ultra Champion

Can you share the actual search you are running which doesn't give output and / or a screenshot of the situation?

0 Karma
Get Updates on the Splunk Community!

Index This | What is broken 80% of the time by February?

December 2025 Edition   Hayyy Splunk Education Enthusiasts and the Eternally Curious!    We’re back with this ...

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...

Splunk MCP & Agentic AI: Machine Data Without Limits

Discover how the Splunk Model Context Protocol (MCP) Server can revolutionize the way your organization uses ...