This repository has been archived by the owner on Dec 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(schema/query): add prometheus lag and sample rate
- Loading branch information
Showing
2 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
SELECT | ||
metrics.labels->>'pod' AS "metric", | ||
MAX("time") AS "time", | ||
EXTRACT(EPOCH FROM NOW()) - MAX(value) AS "value" | ||
FROM metrics | ||
WHERE | ||
time > NOW() - INTERVAL '15 minute' AND | ||
name = 'prometheus_remote_storage_highest_timestamp_in_seconds' AND | ||
value != 'NaN' | ||
GROUP BY metric | ||
ORDER BY time DESC | ||
LIMIT 4; | ||
|
||
|
||
SELECT | ||
MAX(pod) AS "metric", | ||
"time", | ||
MAX("local") - MAX("remote") AS "value" | ||
FROM ( | ||
SELECT | ||
metrics.labels->>'pod' AS "pod", | ||
$__timeGroup("time", $__interval), | ||
CASE WHEN name = 'prometheus_remote_storage_highest_timestamp_in_seconds' THEN value ELSE NULL END AS "local", | ||
CASE WHEN name = 'prometheus_remote_storage_queue_highest_sent_timestamp_seconds' THEN value ELSE NULL END AS "remote" | ||
FROM metrics | ||
WHERE | ||
$__timeFilter("time") | ||
AND name IN ('prometheus_remote_storage_highest_timestamp_in_seconds', 'prometheus_remote_storage_queue_highest_sent_timestamp_seconds') | ||
AND value != 'NaN' | ||
) AS t | ||
GROUP BY time, pod | ||
ORDER BY time, pod; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
SELECT | ||
bucket AS "time", | ||
metric, | ||
(( | ||
CASE | ||
WHEN lag(value) OVER w IS NULL THEN 0 | ||
WHEN value > lag(value) OVER w THEN (value - lag(value) OVER w) | ||
ELSE value | ||
END | ||
) / EXTRACT(EPOCH FROM INTERVAL '$__interval')) AS "value" | ||
FROM ( | ||
SELECT | ||
labels->>'pod' AS "metric", | ||
time_bucket('$__interval', "time") AS "bucket", | ||
MAX(value) AS "value" | ||
FROM metrics | ||
WHERE | ||
$__timeFilter("time") and | ||
name = 'prometheus_remote_storage_succeeded_samples_total' | ||
GROUP BY metric, bucket | ||
ORDER BY metric, bucket | ||
) AS m | ||
WHERE value > 0 | ||
WINDOW w AS (PARTITION BY metric ORDER BY bucket) | ||
ORDER BY time; | ||
|
||
SELECT | ||
bucket AS "time", | ||
metric, | ||
(( | ||
CASE | ||
WHEN lag(value) OVER w IS NULL THEN 0 | ||
WHEN value > lag(value) OVER w THEN (value - lag(value) OVER w) | ||
ELSE value | ||
END | ||
) / EXTRACT(EPOCH FROM INTERVAL '$__interval')) AS "value" | ||
FROM ( | ||
SELECT | ||
labels->>'pod' AS "metric", | ||
time_bucket('$__interval', "time") AS "bucket", | ||
MAX(value) AS "value" | ||
FROM metrics | ||
WHERE | ||
$__timeFilter("time") and | ||
name = 'adapter_samples_sent_total' | ||
GROUP BY metric, bucket | ||
ORDER BY metric, bucket | ||
) AS m | ||
WHERE value > 0 | ||
WINDOW w AS (PARTITION BY metric ORDER BY bucket) | ||
ORDER BY time; |