Cache Metrics
Cache hits can be determined via the log_attributes['response.headers.cf_cache_status'] key in the logs. Any value that corresponds to either HIT, STALE, REVALIDATED, or UPDATING is categorized as a cache hit.
The following example query will show the top cache misses from the edge_logs:
select log_attributes['request.path'] as path, log_attributes['request.search'] as search, count() as countfrom logswhere source = 'edge_logs' and startsWith(log_attributes['request.path'], '/storage/v1/object') and log_attributes['request.method'] = 'GET' and log_attributes['response.headers.cf_cache_status'] in ('MISS', 'NONE/UNKNOWN', 'EXPIRED', 'BYPASS', 'DYNAMIC')group by path, searchorder by count desclimit 50;Try out this query in the SQL Editor.
Your cache hit ratio over time can then be determined using the following query:
select toStartOfHour(timestamp) as timestamp, countIf(log_attributes['response.headers.cf_cache_status'] in ('HIT', 'STALE', 'REVALIDATED', 'UPDATING')) / count() as ratiofrom logswhere source = 'edge_logs' and startsWith(log_attributes['request.path'], '/storage/v1/object') and log_attributes['request.method'] = 'GET'group by timestamporder by timestamp desclimit 100;Try out this query in the SQL Editor.