Splunk® Enterprise

Search Manual

Download manual as PDF

Splunk Enterprise version 5.0 reached its End of Life on December 1, 2017. Please see the migration information.
This documentation does not apply to the most recent version of Splunk. Click here for the latest version.
Download topic as PDF

Compare hourly sums across multiple days

While the timechart is great for creating charts that show trends over time, it has strict boundaries limiting what it can do. There are times when you're better off with the chart command, which can provide more flexibility.

This is an example of how you might want to use chart to compare values collected over several days. This is something you can't do with timechart


You have two searches that are nearly identical. They both show the hourly sum of the P field over a 24-hour period. The only difference is that one search covers a period ten days in the past, while the other covers a period nine days into the past:

Search 1:

earliest=-10d latest=-9d | timechart span="1h" sum(P)

Search 2:

earliest=-9d latest=-8d | timechart span="1h" sum(P)

What you'd like to do is create a column chart that combines the results of these two searches, so you can see the sum of P for 3pm, ten days ago side-by-side with the sum of P for 3pm, nine days ago.


You can't pull this off with the timechart command. But you can do it with the chart command, and it's pretty simple. Set up a search that covers both days, and then have it create a "sum of P" column for each distinct date_hour and date_day combination found in the search events.

The finished search looks like this:

earliest=-10d latest=-8d | chart sum(P) by date_hour date_day

This produces a single chart with 24 slots, one for each hour of the day. Each slot contains two columns that enable you to compare hourly sums between the two days covered by the time range of the report.

For a primer on reporting searches and how they're constructed, see "Use reporting commands" in the User Manual.

For more information about chart> and timechart functions, see "Functions for stats, chart, and timechart" in the Search Reference Manual.

Build a chart of multiple data series
About real-time searches and reports

This documentation applies to the following versions of Splunk® Enterprise: 5.0, 5.0.1, 5.0.2, 5.0.3, 5.0.4, 5.0.5, 5.0.6, 5.0.7, 5.0.8, 5.0.9, 5.0.10, 5.0.11, 5.0.12, 5.0.13, 5.0.14, 5.0.15, 5.0.16, 5.0.17, 5.0.18

Was this documentation topic helpful?

Enter your email address, and someone from the documentation team will respond to you:

Please provide your comments here. Ask a question or make a suggestion.

You must be logged into splunk.com in order to post comments. Log in now.

Please try to keep this discussion focused on the content covered in this documentation topic. If you have a more general question about Splunk functionality or are experiencing a difficulty with Splunk, consider posting a question to Splunkbase Answers.

0 out of 1000 Characters