Timeshift

Here is a set of functions performing a time shift of your data. These functions display the values from the corresponding time period on the graph. On their own, they may not be of high value, but together with the current values they may provide useful insight into the performance of your application.

Timeshift

FunctionDescriptionExample
timeshift()Graph values from an arbitrary <TIME_IN_SECOND> before the current timestamp for the metric.timeshift(<METRIC_NAME>{*}, -<TIME_IN_SECOND>)

For example, if you wanted to use this to compare current system load with load from 2 weeks ago (60*60*24*14 = 1209600), your query would be:

timeshift(avg:system.load.1{*}, -1209600)

Calendar shift

FunctionDescriptionExample
calendar_shift()Graph values from the previous day, week, or month from the current timestamp for the metric.calendar_shift(<METRIC_NAME>{*}, "<TIME_SHIFT_STRING>", "<TIME_ZONE_CODE>")

To access the calendar_shift() function click the Add function button, select Timeshift > Month before. The calendar shift allows you to compare the same metric across equivalent time frames. Below is an example of cloud cost metric aws.cost.net.amortized with the calendar_shift() value from two weeks ago compared to the current value.

Example of a calendar_shift() function used to compare the `aws.cost.net.amortized ` metric value from two weeks ago and the present

Valid TIME_SHIFT_STRING values are negative integers followed by “d” for days, “w” for weeks, or “mo” for months. Some examples are -1d, -7d, -1mo, -30d, and -4w.

Valid TIME_ZONE_CODE values are the IANA time zone codes for a specific city, or UTC. For example, UTC, America/New_York, Europe/Paris, or Asia/Tokyo.

Hour before

FunctionDescriptionExample
hour_before()Graph values from an hour before the current timestamp for the metric.hour_before(<METRIC_NAME>{*})

Here is an example of system.load.1 with the hour_before() value shown as a dotted line. In this particular example, you can see the machine was started at 6:30am and the hour_before() values show up at the 7:30 mark. Of course, this example was created specifically so that you can see the hour_before() values match up with the actual values.

simple hour before example

Day before

The day before feature is being deprecated. Use calendar shift with a value of "-1d" instead.
FunctionDescriptionExample
day_before()Graph values from a day before the current timestamp for the metric.day_before(<METRIC_NAME>{*})

Here is an example of nginx.net.connections with the day_before() value shown as a lighter, thinner line. In this example, you can see a week’s worth of data, which makes the day_before() data easier to identify.

simple day before example

Week before

The week before feature is being deprecated. Use calendar shift with a value of "-7d" instead.
FunctionDescriptionExample
week_before()Graph values from a week (7 days) before the current timestamp for the metric.week_before(<METRIC_NAME>{*})

Here is an example of cassandra.db.read_count with the week_before() value shown as a dotted line. In this example, you can see about three weeks’ worth of data, which makes the week_before() data easier to identify.

simple week before example

Month before

The month before feature is being deprecated. Use calendar shift with a value of "-1mo", "-30d" or "-4w" instead, depending on your use case.
FunctionDescriptionExample
month_before()Graph values from a month (28 days / 4 weeks) before the current timestamp for the metric.month_before(<METRIC_NAME>{*})

Here is an example of aws.ec2.cpuutilization with the month_before() value shown as a thin, solid line.

simple month before example

Other functions


Further Reading

Additional helpful documentation, links, and articles: