Splunk® Enterprise

Search Manual

Download manual as PDF

Download topic as PDF

Compare hourly sums across multiple days

The timechart command creates charts that show trends over time. It has strict boundaries limiting what it can do. There are times when you should use the chart command command, which can provide more flexibility.

This example demonstrates how to use chart to compare values collected over several days. You cannot do this with timechart

Scenario

These two searches are almost 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)

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.


Solution

Using the chart command, set up a search that covers both days. Then, create a "sum of P" column for each distinct date_hour and date_wday combination found in the search results.

The finished search looks like this:

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

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 Search Manual.

For more information about chart> and timechart functions, see "Statistical and charting functions" in the Search Reference.

PREVIOUS
Build a chart of multiple data series
  NEXT
Drill down on table row or cell information

This documentation applies to the following versions of Splunk® Enterprise: 6.2.0, 6.2.1, 6.2.2, 6.2.3, 6.2.4, 6.2.5, 6.2.6, 6.2.7, 6.2.8, 6.2.9, 6.2.10, 6.2.11, 6.2.12, 6.2.13, 6.3.0, 6.3.1, 6.3.2, 6.3.3, 6.3.4, 6.3.5, 6.3.6, 6.3.7, 6.3.8, 6.3.9, 6.3.10, 6.3.11, 6.3.12, 6.4.0, 6.4.1, 6.4.2, 6.4.3, 6.4.4, 6.4.5, 6.4.6, 6.4.7, 6.4.8, 6.4.9, 6.5.0, 6.5.1, 6.5.1612 (Splunk Cloud only), 6.5.2, 6.5.3, 6.5.4, 6.5.5, 6.5.6, 6.6.0, 6.6.1, 6.6.2, 6.6.3, 6.6.4, 7.0.0


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