Set time range on Insights dashboards and charts

You can set time ranges with New Relic Insights by using a time picker or by using NRQL queries for event widgets. Insights always displays the query results based on your browser's time zone.

Chart refresh intervals vary based on the specified time frame. Also, the date ranges available to query depend on your subscription level and data retention period for the New Relic product you are querying.

Set time range using time picker

Use the time picker to quickly set relative time ranges or to set time ranges with specific start and end timestamps. New Relic automatically offsets your browser's time zone when viewing the results.

When using the time picker to set a custom date range, you can select a maximum range of seven days on the calendar. The time picker's appearance and functionality vary, depending on the chart or page you are viewing.

Set time range using NRQL

For event widgets, NRQL allows more control over the time range than the time picker. Use NRQL clauses SINCE and UNTIL to set the time range with relative timestamps or UTC timestamps. To specify the time zone offset for the queried data, use the method appropriate to the type of range you are using.

Relative time range (phrase or numerical unit)

Use relative timestamps to run quick queries, or to create dashboards that are always relevant to the current day/time and won't require constant updating.

Some points to note when using relative time range:

  • "Day" is a 24 hour period.
  • "Month" is a 30 day period, regardless of the length of the calendar month covered by the query.
  • "Year" is a 365 day period, regardless of whether the year covered by the query is a leap year.
  • Relative time does not take into account daylight savings time. A day continues to be 24 hours regardless of whether the clock changed due to daylight savings time.

Use the WITH TIMEZONE argument in your query to return results based on your location's time zone offset. Specifying the time zone ensures the returned data starts and ends on the hour/day/week/month/etc. instead of starting and ending in the middle of them.

Query data for current business week

You can use SINCE Monday at '08:00' UNTIL Friday at '17:00' to represent a business week, and review the complete data on Saturday:

SELECT count(*) FROM PageView SINCE Monday at '08:00' UNTIL Friday at '17:00' WITH TIMEZONE America/Los Angeles
Query to see highest traffic days of week

This query returns data from the PageView Browser event that returns the count of page views from the app named docs.prod. The page view counts are split by days of the week for the past 3 months. The data returned stops at 00:00 on Monday of the current week, so the query returns the data in calendar weeks and not seven-day ranges that flow across calendar weeks.

SELECT count(*) as 'PageViews' FROM PageView WHERE appName = 'docs.prod' SINCE 3 months ago UNTIL monday WITH TIMEZONE 'America/Los_Angeles' facet weekdayOf(timestamp)
[SINCE | UNTIL] integer units AGO

This query provides a chart comparing the 50th, 95th, and 99th percentile of average response time. The start or end of the time range would be 7 days prior at the current time.

In this example, if the current date and timestamp is Tuesday, November 9 11:20am, this query's time range would start on Tuesday, November 2 11:20am.

SELECT percentile(duration, 50, 95, 99) FROM PageView SINCE 1 week AGO 

Other supported units include:

  • X minutes ago
  • X hours ago
  • X days ago
  • X weeks ago
  • X months ago
[SINCE | UNTIL] yesterday

When used in the SINCE clause, this time range begins on the previous day at midnight/00:00 UTC.

When used in the UNTIL clause, this range would end on the previous day at 23:59:59 UTC.

[SINCE | UNTIL] Wednesday

You can specify any day of the week as the start or end of a time range. When used in the UNTIL clause, the returned data does not include data from the specified day, because the time range ends at the beginning of the specified day.

When used in the SINCE clause, this example time range begins on Wednesday at 00:00:00 UTC.

When used in the UNTIL clause, this example time range would end on Tuesday at 11:59:59 UTC.

[SINCE | UNTIL] [this hour | last hour]

When used in the SINCE clause:

  • this hour = time range starts at beginning of current hour.
  • last hour = time range starts at beginning of previous hour.

When used in the UNTIL clause:

  • this hour = time range ends at beginning of current hour.
  • last hour = time range ends at beginning of previous hour.
[SINCE | UNTIL] [this week | last week]

When used in the SINCE clause:

  • this week = time range starts at beginning of current week (Monday at 00:00:00 UTC).
  • last week = time range starts at beginning of previous week (previous Monday at 00:00:00 UTC).

When used in the UNTIL clause:

  • this week = time range ends right before beginning of current week (previous Sunday at 23:59:59 UTC).
  • last week = time range ends right before beginning of previous week (two Sundays ago at 23:59:59 UTC).
[SINCE | UNTIL] [this month | last month]

When used in the SINCE clause:

  • this month = time range starts at beginning of current month (1st of current month at 00:00:00 UTC).
  • last month = time range starts at beginning of previous month (1st of previous month at 00:00:00 UTC).

When used in the UNTIL clause:

  • this month = time range ends right before beginning of current month (last day of previous month at 23:59:59 UTC).
  • last month = time range ends right before beginning of previous month (last day of two months ago at 23:59:59 UTC).
[SINCE | UNTIL] [this quarter | last quarter]

In this example, assume the current date and timestamp is August 10 at 11:25:00.

When used in the SINCE clause:

  • this quarter = time range starts at beginning of current quarter (in this example: July 1 at 00:00:00 UTC).
  • last quarter = time range starts at beginning of previous quarter (in this example: April 1 at 00:00:00 UTC).

When used in the UNTIL clause:

  • this quarter = time range ends right before beginning of current quarter (in this example: June 30 at 23:59:59 UTC).
  • last quarter = time range ends right before beginning of previous quarter (in this example: March 31 at 23:59:59 UTC).
UTC timestamp

UTC timestamp syntax is:

yyyy-mm-dd HH:MM:ss

To refer to a specific date or time, use UTC time as an SQL-style timestamp in a single quoted string. You can also adjust the UTC timestamp to a specific time zone:

Query using UTC timestamp with time zone offset

To adjust UTC time to a specific time zone [external link] , include the hours adjustment in the query. For example, include a minus sign (-) for time zones west of UTC or a plus sign (+) for time zones east of UTC with the number of hours.

This example shows Eastern Standard Time (EST) in North America, which is five hours west of UTC (-0500):

SELECT count(*) FROM PageView SINCE '2014-08-04 00:00:00-0500'

If you use NRQL in an Insights query API call, the + and - characters must be URL-encoded.

Query using UTC timestamp with time zone label

To include the time zone label in the queried range, add a time zone acronym [external link] to the timestamp. For example, to clarify that the query shows Eastern Standard Time, insert EST at the end of the timestamp.

This example also shows Eastern Standard Time (EST) in North America, which is five hours west of UTC (-0500):

SELECT count(*) FROM PageView SINCE '2014-08-04 00:00:00 EST'

Some abbreviations apply to more than one geographic location. For example, EST could mean Eastern Standard Time (EST) in North America or Eastern Standard Time in Australia. For clarity, you may want to use the numeric value to offset UTC time (-0500 for EST in North America or +1000 for EST in Australia).

Use an APM time range

If there is a specific time range in New Relic APM that you want to analyze in Insights, you can use the time code found in the URL to populate your NRQL query:

  1. On an APM page showing a time range, select Permalink.
  2. Inspect the copied URL, and get the UTC 10-digit times (located near the end of the URL) that represents the start and end of the time range.
  3. In a NRQL query, use the SINCE and UNTIL functions with the 10-digit UTC times to retrieve data for that specific time range.

In the following example, the URL is generated by selecting Permalink in the New Relic UI:

https://rpm.newrelic.com/accounts/123456/applications/12345678?tw%5Bend%5D=1502388642&tw%5Bstart%5D=1502386842

In the NRQL query, use 1502386842 as the SINCE value and 1502388642 as the UNTIL value.

For more help

Recommendations for learning more: