splunkspltimechartsplk-1001tutorial

Splunk timechart Command Tutorial: Visualise Data Over Time

Learn how to use the Splunk timechart command to plot data over time. Covers syntax, span options, and common SPLK-1001 exam use cases with SPL examples.

·Jacob Anderson, Splunk Certified Architect

If you want to see how something changes over time in Splunk, timechart is the command you need. It's one of the most commonly used transforming commands in SPL, and it comes up regularly in the SPLK-1001 exam. Once you understand how it works, it becomes one of your most useful tools.

What timechart Does

timechart is similar to stats, but it always uses time as the X axis. Instead of grouping results by an arbitrary field, it groups them into time buckets and counts (or aggregates) within each bucket.

The output is designed for visualisation. Drop the results into a line chart on a dashboard and you immediately see trends, spikes, and drops.

The basic syntax looks like this:

index=web_logs | timechart count

This gives you a count of events per time period. Splunk automatically picks the time bucket size based on your selected time range.

Controlling Time Buckets with span

You'll often want to control how Splunk buckets the time. Use the span argument for this:

index=web_logs | timechart span=1h count

This groups events into 1-hour buckets. You can use any time unit: 1m (minutes), 1h (hours), 1d (days), 1w (weeks).

Smaller spans give more granular data but can be noisy. Larger spans smooth things out but you lose detail. Pick based on what you're trying to show.

Using timechart with a BY Clause

Just like stats, you can split your results by a field using BY:

index=web_logs | timechart count BY status_code

This creates one line per status code, so you can see how 200s, 404s, and 500s trend over time independently. It's a great way to spot when error rates start climbing.

Be careful with high-cardinality fields here. If you split by a field with hundreds of unique values, your chart becomes unreadable. Splunk will also limit the number of series shown (default is 10).

Aggregation Functions in timechart

You're not limited to counting. Any of the standard aggregation functions work:

index=performance | timechart avg(response_time) BY endpoint
index=transactions | timechart sum(bytes_transferred) span=1h

The first query shows average response time per endpoint over time. The second shows total bytes transferred per hour. Both are useful for performance monitoring and capacity planning.

Want to go deeper?

No Nonsense Introduction to Splunk

Skip the endless docs rabbit hole. This hands-on course takes you from zero to confident with Splunk searches, dashboards, and alerts. Taught by a Splunk Certified Architect with over 10 years of real-world experience.

View the course →

timechart vs stats: When to Use Each

This is a common point of confusion, and it comes up in the exam. Here's the simple version:

  • Use timechart when time is the main axis and you want to see trends
  • Use stats when you want a summary table grouped by a non-time field

If someone asks "how many requests did each endpoint get this week?", that's stats BY endpoint. If they ask "how did request volume change over the week?", that's timechart count.

The two commands use the same aggregation functions (count, sum, avg, max, min, dc), so the syntax is consistent once you know one.

Limiting Series with limit

When splitting by a field with many values, you can use the limit argument to keep only the top N series:

index=web_logs | timechart limit=5 count BY clientip

This keeps the five IP addresses with the highest event count and groups everything else into an "OTHER" category. This makes your chart readable without losing the big picture.

Set limit=0 to show all values (no grouping into OTHER), but do this carefully with high-cardinality fields.

Using timechart in Dashboards

timechart output is built for line and area charts. When you add a search using timechart to a dashboard panel, Splunk will automatically suggest these visualisation types.

A line chart showing timechart count BY status_code over the last 24 hours is one of the most useful panels you can put on a web traffic dashboard. It immediately shows when traffic changes and whether the change is driven by errors or legitimate traffic.

A Practical Example: Hourly Error Rate

Here's a real search you might run to monitor application health:

index=app_logs level=ERROR earliest=-7d
| timechart span=1h count AS error_count

And here's a more detailed version showing errors by component:

index=app_logs level=ERROR earliest=-7d
| timechart span=1h count BY component limit=5

Run this and drop it into a line chart to see which parts of your application generate the most errors, and when those errors spike.

What to Learn Next

Once you're comfortable with timechart, the natural next step is combining it with trendline to add moving averages, or using predict to forecast future values. These are more advanced commands, but they build directly on what you know from timechart.

For the SPLK-1001 exam, make sure you understand the difference between timechart and stats, and know how to use span, BY, and limit. Those are the points the exam questions tend to focus on.

The Introduction to Splunk course covers timechart as part of the Basic Search module, including hands-on exercises building dashboards with time-based charts.

Ready to level up?

No Nonsense Introduction to Splunk

Learn Splunk the practical way. No death-by-slides, no waffle. Just focused video demos with real data and a structured path from installation to dashboards and alerts. From just £9.99 with lifetime access.

Start the course for £9.99 →

Relevant lessons in the course