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/views): add hourly load aggregate, example union query
- Loading branch information
Showing
3 changed files
with
64 additions
and
12 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
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 |
---|---|---|
@@ -1,10 +1,44 @@ | ||
SELECT | ||
a.bucket AS time, | ||
a.avg_load, | ||
a.max_load, | ||
REGEXP_REPLACE(l.labels->>'instance', '(.+):[0-9]+', '\1') AS instance | ||
FROM | ||
agg_instance_load AS a | ||
JOIN | ||
metric_labels AS l | ||
ON l.lid = a.lid; | ||
l.labels->>'instance' AS metric, | ||
s.time, | ||
s.value | ||
FROM (( | ||
SELECT | ||
lid, | ||
bucket AS time, | ||
max_load AS value | ||
FROM | ||
agg_instance_load_long | ||
WHERE bucket < NOW() - INTERVAL '1 day' | ||
ORDER BY lid, bucket | ||
) UNION ALL ( | ||
SELECT | ||
lid, | ||
bucket AS time, | ||
max_load AS value | ||
FROM | ||
agg_instance_load | ||
WHERE bucket > NOW() - INTERVAL '1 day' | ||
ORDER BY lid, bucket | ||
) UNION ALL ( | ||
SELECT | ||
lid, | ||
"tg" AS "time", | ||
MAX("value") AS "value" | ||
FROM ( | ||
SELECT | ||
lid, | ||
time_bucket(INTERVAL '1 minute', time) AS "tg", | ||
value | ||
FROM metrics | ||
WHERE | ||
time > NOW() - INTERVAL '15 minutes' | ||
AND name = 'node_load1' | ||
AND value != 'NaN' | ||
) t | ||
GROUP BY lid, time | ||
ORDER BY lid, time | ||
)) AS s | ||
JOIN metric_labels AS l | ||
ON l.lid = s.lid | ||
ORDER BY s.time, s.lid; |
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