Splunk Search

Timechart trend over the same interval as the search range

epacke
Path Finder

Hi!

I have a scenario where we have used "| stats count" and gotten the total number for the range that we picked. This has been working fine, but now, we'd like to use timechart to get trends.

However, when using timechart, the number becomes the latest "bucket" instead of the total number.

Example:
Searching with a time range of 60 minutes would give me the value for the last minute.

Been fiddling around with some suggestions but haven't found a reliable solution. This last one:

| timechart [search index=_internal | head 1 | addinfo | eval timerange= info_max_time-info_min_time | eval span=if(round(timerange/3600) == infinity, 1, round(timerange/3600))."h"  | return span] count | appendpipe [stats count | where count=0]

It generates errors like "Error in timechart command. The value for option span (infinityh) is invalid."

Any ideas of what I'm doing wrong?

/Patrik

0 Karma

skoelpin
SplunkTrust
SplunkTrust

Timechart is going to give you a new row for each bucket. Why use timechart if you don't want seperate buckets? Why use head 1 to return the latest bucket? If you were sold on using timechart then you would have to force it to use a single bucket by adding span=60m which would give you identical results of using stats

These 2 queries will give identical results

| bin _time span=60m
| stats count by _time 



| timechart span=60m count
0 Karma

epacke
Path Finder

Timechart is used because I want the trend. Span=60m works but since I have a time picker this would not work for longer search ranges.

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!

May 2026 Splunk Expert Sessions: Security & Observability

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

Network to App: Observability Unlocked [May & June Series]

In today’s digital landscape, your environment is no longer confined to the data center. It spans complex ...

SPL2 Deep Dives, AppDynamics Integrations, SAML Made Simple and Much More on Splunk ...

Splunk Lantern is Splunk’s customer success center that provides practical guidance from Splunk experts on key ...