Skip to content

Open-source status page, incident response and uptime monitoring

1.2 KB
Raw Blame
TOKEN "endpoint__dns_metrics_regions_14d__v0_endpoint_read_2343" READ

NODE endpoint
SQL >

%
SELECT
    region,
    toStartOfInterval(
        toDateTime(cronTimestamp / 1000), INTERVAL {{ Int64(interval, 30) }} MINUTE
    ) as h,
    toUnixTimestamp64Milli(toDateTime64(h, 3)) as timestamp,
    round(quantile(0.50)(latency)) as p50Latency,
    round(quantile(0.75)(latency)) as p75Latency,
    round(quantile(0.90)(latency)) as p90Latency,
    round(quantile(0.95)(latency)) as p95Latency,
    round(quantile(0.99)(latency)) as p99Latency
FROM dns_response__v0
WHERE
    monitorId = {{ String(monitorId, '7417', required=True) }}
    -- dns_response__v0 has no TTL; cap the window like the TTL-bound http/tcp uptime MVs
    AND toDateTime(timestamp / 1000) >= now() - INTERVAL 14 DAY
    {% if defined(fromDate) %}
        AND toDateTime(timestamp / 1000) >= parseDateTimeBestEffortOrNull({{ String(fromDate) }})
    {% end %}
    {% if defined(toDate) %}
        AND toDateTime(timestamp / 1000) <= parseDateTimeBestEffortOrNull({{ String(toDate) }})
    {% end %}
    {% if defined(regions) %} AND region IN {{ Array(regions, 'String', 'ams,fra') }} {% end %}
GROUP BY h, region
ORDER BY h DESC

TYPE endpoint