Skip to content
This repository has been archived by the owner on Dec 29, 2020. It is now read-only.

Commit

Permalink
fix(schema): sort queries into subdirs
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Nov 29, 2019
1 parent fcaf073 commit 6b2b32c
Show file tree
Hide file tree
Showing 15 changed files with 73 additions and 70 deletions.
15 changes: 0 additions & 15 deletions schema/query/alert-mem-rule.sql

This file was deleted.

15 changes: 0 additions & 15 deletions schema/query/alert-root-rule.sql

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
-- this query relies on the node_pct prometheus rules
SELECT
l.labels->>'nodename' AS "instance",
$__timeGroup(m."time", $__interval),
MIN(m.value) AS value
FROM metrics AS m
JOIN metric_labels AS l
ON l.labels->>'__name__' = 'node_uname_info' AND
m.labels->>'instance' = l.labels->>'instance'
WHERE
$__timeFilter(m."time") AND
m.name = 'node_memory_free_pct' AND
m.value != 'NaN'
GROUP BY instance, m.time
ORDER BY instance, m.time;

-- this query does not need any prometheus rules, but
-- does a low join across two metrics
SELECT
REGEXP_REPLACE(instance, '(.+):[0-9]+', '\1') AS "metric",
time,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
-- this query relies on the node_pct prometheus rules
SELECT
l.labels->>'nodename' AS "instance",
$__timeGroup(m."time", $__interval),
MIN(m.value) AS value
FROM metrics AS m
JOIN metric_labels AS l
ON l.labels->>'__name__' = 'node_uname_info' AND
m.labels->>'instance' = l.labels->>'instance'
WHERE
$__timeFilter(m."time") AND
m.name = 'node_filesystem_free_pct' AND
m.value != 'NaN'
GROUP BY instance, m.time
ORDER BY instance, m.time;

-- this query does not rely on any prometheus rules, but
-- does a slow join across two metrics
SELECT
REGEXP_REPLACE(instance, '(.+):[0-9]+', '\1') AS "metric",
time,
Expand Down
File renamed without changes.
File renamed without changes.
40 changes: 0 additions & 40 deletions schema/query/schema-sizes.sql

This file was deleted.

8 changes: 8 additions & 0 deletions schema/query/schema/compressed-chunks.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- get chunk sizes
SELECT
hypertable_name,
chunk_name,
compressed_total_bytes,
uncompressed_total_bytes
FROM timescaledb_information.compressed_chunk_stats
WHERE compression_status = 'Compressed';
7 changes: 7 additions & 0 deletions schema/query/schema/compressed-ratio.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- get compression ratio
SELECT
hypertable_name,
1 - AVG(pg_size_bytes(compressed_total_bytes)::float / pg_size_bytes(uncompressed_total_bytes)) AS compression_ratio
FROM timescaledb_information.compressed_chunk_stats
WHERE compression_status = 'Compressed'
GROUP BY hypertable_name;
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions schema/query/schema/size-labels.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-- get labels size
SELECT
nspname || '.' || relname AS "relation",
pg_size_pretty(pg_total_relation_size(C.oid)) AS "total_size"
FROM pg_class C
LEFT JOIN pg_namespace N
ON (N.oid = C.relnamespace)
WHERE
nspname NOT IN ('pg_catalog', 'information_schema') AND
C.relkind <> 'i' AND
nspname !~ '^pg_toast' AND
relname LIKE 'metric%'
ORDER BY pg_total_relation_size(C.oid) DESC;
9 changes: 9 additions & 0 deletions schema/query/schema/size-tables.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- get table sizes
SELECT
CONCAT(table_schema, '.', table_name),
num_dimensions,
num_chunks,
total_size
FROM timescaledb_information.hypertable;
-- this can have a WHERE table_name LIKE 'metric%', but that will
-- omit compressed and aggregate hypertables from the list
File renamed without changes.

0 comments on commit 6b2b32c

Please sign in to comment.