Compare hourly sums across multiple days
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
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:
earliest=-10d latest=-9d | timechart span="1h" sum(P)
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_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
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