How does it make sense that alerts can run on a cache?

I came across something very bizarre. For some reason, alerts in Looker respect caching policies.

This does not make any sense to me. If an alert runs on a cache that is showing outdated information, it will alert to something that might no longer be true.

I don't want to change the caching policy for my Model because it is useful to cache dashboards for a certain time or until the user forces a refresh. Alerts, however, should never run on a cache.

How do you deal with this issue?

0 6 828
6 REPLIES 6

did you ever find a solution to this? we are coming across the same problem

No, unfortunately not. A workaround is to set the caching policy of the model to be lower than the schedule set on the alert. It requires you to monitor alerts being set up and adjust the cache of the model accordingly, so it’s anything less than ideal.

Hi folks - at present that is indeed the situation, the alerts are based on the caching policy you have defined for the underlying explore. What you could do, if this is not working for you, is create an extended version of the same explore with the sole difference of defining a shorter caching policy, and using this extended explore for building dashboard tiles with alerts. This may or may not be practical depending on your use case, but I'm just flagging that the option exists in case it is helpful.

Former Community Member
Not applicable

If you have a 1 hr cache and run schedule every 12 mins on latest 12 mins of data, would this trigger a regen of cached data as we are including new data each 12 mins? Or will it just happily assume that there is no new data?

ie its 12:01 AM run alert and generate cache

12:13 AM now 12 more minutes of time but 1hr hasn't passed, is the 12:01 to 12:13 included?

What if another schedule runs at 12:13 AM but it runs every 30 mins, would this cause a regen of the cache?

Is there difference in schedule vs alert caching behavior?

According to the documentation, "If there are valid results in cache, Looker will deliver cached results. If there are no results or if the cached results have expired, Looker will rerun the query and cache those results." So if the cache has not been invalidated, the schedule will use cached results.

If you are running a schedule on a 12 minute cadence as in the example, it would make sense to invalidate the cache either by setting a shorter max_cache_age, or via a query that will bust the cache if new data has been added to the database.

Former Community Member
Not applicable

Interesting, so even though there is 12 new minutes vs previous result, it will still use cache. Good to know!