Update query with a custom time window

When monitoring your system, you may see unexpected spikes that you want to explore more carefully. You don't have to write a new query; you can scrub a chart to view more detail for a period of time shown on a chart. This creates a time window.

Scrub a chart

We ran this query to see look how long users spent waiting for an application to launch.

SELECT average(`queueDuration`) FROM Transaction TIMESERIES
FACET `appId` LIMIT 5 SINCE 30 minutes ago EXTRAPOLATE

The chart for this query shows a spike in the time users had a longer wait between 11:03 and 11:04.

Example of chart for original query
Example of a chart showing a spike in time waiting for the application to load

You can scrub a chart in the chart builder or on a dashboard to view selected data in more detail. To scrub a part of the chart, use your mouse to select the area you want to examine.

Chart with the area to view in more detail selected
Example showing the selection of the area to examine more closely.

As soon as you release the mouse after selecting a time window, the chart re-displays showing just the time range you selected. The time window indicator also appears on the chart.

Updated chart after being scrubbed and showing new time window
Updated chart with the new time window

In the chart builder, that action creates a new time window for the query; on a dashboard, the time window applies to all the charts on that dashboard. You can update the original query with the new time window, or you can choose to not update the query.

Use time windows in the chart builder

When you scrub a chart in the chart builder, a temporary filter defines the time window used for this chart view. A blue box indicates the specific time window being used. You can either update your original query with the view used in the filter or remove the filter.

Example of a time window for a chart and the option used to update the query with the time window.
If you want to ... Do this ...
Update your query with a new time window. Click Update query with this time next to the blue box.
Remove the temporary filter from your chart. Click the close close-x.png mark in the blue box.
Restore your query to its original state. Use the My recent queries dropdown to locate the original version of your query and then run that query.

Use time windows on a dashboard

When you scrub a chart, the time filter you create is used for all charts on the dashboard. This gives you the same temporal view of all of your data and provides a deeper, more detailed view of your systems. To specify your time filter more precisely, click the down arrow.

Example of the dashboard time filter box

Even though you view your time window on all of the charts on your dashboard, you can only update one query at a time.

To update your query with the temporary time filter:

  1. Click the ellipses ellipses.png icon on the chart for the query you want to update.
  2. Select Edit from the chart action menu to open the chart builder.
  3. Click Update query with this time.

Repeat this procedure for each query you want to update.

Example: Before and after time window queries

When you choose to update your query with a time window, New Relic revises your query with statements that define the time window. In this section, let's look at a query before and after the update.

Before query update

Let's look at this sample NRQL query:

SELECT count(*) FROM Transaction WHERE httpResponseCode = '404' TIMESERIES
FACET `appName` LIMIT 10 SINCE 1800 seconds ago EXTRAPOLATE

In this query, we are looking for transactions, faceted by app name, that have a page not found condition, all within the last 30 minutes (30 minutes x 60 seconds per minute is 1800 seconds). The time value for the query is stated in this SINCE clause: SINCE 1800 seconds ago.

After query update

After this query ran, which created a chart, we scrubbed the chart to view just two minutes of data. We then updated the query with the time window we created.

Let's look at the query that's been updated with the time window:

SELECT count(*) FROM Transaction WHERE httpResponseCode = '404' TIMESERIES
FACET `appName` LIMIT 10 SINCE '2019-06-18 14:16:00-0000' EXTRAPOLATE
UNTIL '2019-06-18 14:18:00-0000'

The SINCE clause no longer uses the 1800 seconds; instead, the SINCE clause has a Coordinated Universal Time (UTC) timestamp, which correlates to the beginning of the time window we specified. An UNTIL clause has been added, showing another timestamp exactly two minutes after the one shown in the SINCE clause.

Because we've saved this query, the next time the query runs, it will return the data for June 18, 2019, from 14:16 UTC until 14:18 UTC.

For more help

Recommendations for learning more: