缓存指标
缓存命中情况可以通过日志浏览器中的metadata.response.headers.cf_cache_status
字段来判定。任何值为HIT
、STALE
、REVALIDATED
或UPDATING
的情况都属于缓存命中。
以下示例查询将显示edge_logs
中排名前50的缓存未命中情况:
1234567891011121314151617select r.path as path, r.search as search, count(id) as countfrom edge_logs as f cross join unnest(f.metadata) as m cross join unnest(m.request) as r cross join unnest(m.response) as res cross join unnest(res.headers) as hwhere starts_with(r.path, '/storage/v1/object') and r.method = 'GET' and h.cf_cache_status in ('MISS', 'NONE/UNKNOWN', 'EXPIRED', 'BYPASS', 'DYNAMIC')group by path, searchorder by count desclimit 50;
您可以在日志浏览器中尝试此查询。
要计算时间维度上的缓存命中率,可以使用以下查询:
123456789101112select timestamp_trunc(timestamp, hour) as timestamp, countif(h.cf_cache_status in ('HIT', 'STALE', 'REVALIDATED', 'UPDATING')) / count(f.id) as ratiofrom edge_logs as f cross join unnest(f.metadata) as m cross join unnest(m.request) as r cross join unnest(m.response) as res cross join unnest(res.headers) as hwhere starts_with(r.path, '/storage/v1/object') and r.method = 'GET'group by timestamporder by timestamp desc;
您可以在日志浏览器中尝试此查询。