Skip to content

Open-source status page, incident response and uptime monitoring

1.8 KB
Raw Blame
TOKEN "endpoint__dns_metrics_7d__v1_endpoint_read_4418" READ

NODE endpoint
SQL >

%
    SELECT
        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,
        count() as count,
        countIf(requestStatus = 'success') AS success,
        countIf(requestStatus = 'degraded') AS degraded,
        countIf(requestStatus = 'error') AS error,
        max(cronTimestamp) AS lastTimestamp
    FROM dns_response__v0
    WHERE
        monitorId = {{ String(monitorId, '7417', required=True) }}
        AND timestamp >= toUnixTimestamp64Milli(toDateTime64(now() - INTERVAL 7 DAY, 3))
        {% if regions %} AND region IN {{ Array(regions, 'String', 'ams,fra') }} {% end %}
    UNION ALL
    SELECT
        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,
        count() as count,
        countIf(requestStatus = 'success') AS success,
        countIf(requestStatus = 'degraded') AS degraded,
        countIf(requestStatus = 'error') AS error,
        NULL as lastTimestamp  -- no need to query the `lastTimestamp` as not relevant
    FROM dns_response__v0
    WHERE
        monitorId = {{ String(monitorId, '7417', required=True) }}
        AND timestamp >= toUnixTimestamp64Milli(toDateTime64(now() - INTERVAL 14 DAY, 3))
        AND timestamp < toUnixTimestamp64Milli(toDateTime64(now() - INTERVAL 7 DAY, 3))
        {% if regions %} AND region IN {{ Array(regions, 'String', 'ams,fra') }} {% end %}

TYPE endpoint