mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-21 05:04:32 +08:00
Add telemetry for continuous aggs
This adds a top-level telemetry entry for `num_continuous_aggs`. 2 designs were considered: 1) add entry to telemetry_metadata that's modified on add/drop continuous aggs. 2) scan the catalogs for number of continuous aggs when making the report. After briefly trying (1), I switched to (2) for 2 reasons: 1) This avoids the dependency from continous_aggs on telemetry and reverses that dependency. I think the other way is cleaner. 2) The code became simpler and more self-contained.
This commit is contained in:
parent
58601cc3a0
commit
c463d2634c
@ -595,3 +595,14 @@ ts_continuous_agg_rename_view(char *old_schema, char *name, char *new_schema, ch
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TSDLLEXPORT int32
|
||||||
|
ts_number_of_continuous_aggs()
|
||||||
|
{
|
||||||
|
int32 count = 0;
|
||||||
|
ScanIterator iterator =
|
||||||
|
ts_scan_iterator_create(CONTINUOUS_AGG, AccessShareLock, CurrentMemoryContext);
|
||||||
|
ts_scanner_foreach(&iterator) { count++; }
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
@ -66,4 +66,6 @@ extern void ts_continuous_agg_rename_schema_name(char *old_schema, char *new_sch
|
|||||||
extern void ts_continuous_agg_rename_view(char *old_schema, char *name, char *new_schema,
|
extern void ts_continuous_agg_rename_view(char *old_schema, char *name, char *new_schema,
|
||||||
char *new_name);
|
char *new_name);
|
||||||
|
|
||||||
|
extern TSDLLEXPORT int32 ts_number_of_continuous_aggs(void);
|
||||||
|
|
||||||
#endif /* TIMESCALEDB_TSL_CONTINUOUS_AGGS_CONTIGUOUS_AGG_H */
|
#endif /* TIMESCALEDB_TSL_CONTINUOUS_AGGS_CONTIGUOUS_AGG_H */
|
||||||
|
@ -47,6 +47,7 @@
|
|||||||
#define REQ_BUILD_OS_VERSION "build_os_version"
|
#define REQ_BUILD_OS_VERSION "build_os_version"
|
||||||
#define REQ_DATA_VOLUME "data_volume"
|
#define REQ_DATA_VOLUME "data_volume"
|
||||||
#define REQ_NUM_HYPERTABLES "num_hypertables"
|
#define REQ_NUM_HYPERTABLES "num_hypertables"
|
||||||
|
#define REQ_NUM_CONTINUOUS_AGGS "num_continuous_aggs"
|
||||||
#define REQ_RELATED_EXTENSIONS "related_extensions"
|
#define REQ_RELATED_EXTENSIONS "related_extensions"
|
||||||
#define REQ_TELEMETRY_METADATA "db_metadata"
|
#define REQ_TELEMETRY_METADATA "db_metadata"
|
||||||
#define REQ_LICENSE_INFO "license"
|
#define REQ_LICENSE_INFO "license"
|
||||||
@ -163,6 +164,15 @@ get_num_hypertables()
|
|||||||
return buf->data;
|
return buf->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *
|
||||||
|
get_num_continuous_aggs()
|
||||||
|
{
|
||||||
|
StringInfo buf = makeStringInfo();
|
||||||
|
|
||||||
|
appendStringInfo(buf, "%d", ts_number_of_continuous_aggs());
|
||||||
|
return buf->data;
|
||||||
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
get_database_size()
|
get_database_size()
|
||||||
{
|
{
|
||||||
@ -252,6 +262,7 @@ build_version_body(void)
|
|||||||
ts_jsonb_add_str(parseState, REQ_BUILD_OS_VERSION, BUILD_OS_VERSION);
|
ts_jsonb_add_str(parseState, REQ_BUILD_OS_VERSION, BUILD_OS_VERSION);
|
||||||
ts_jsonb_add_str(parseState, REQ_DATA_VOLUME, get_database_size());
|
ts_jsonb_add_str(parseState, REQ_DATA_VOLUME, get_database_size());
|
||||||
ts_jsonb_add_str(parseState, REQ_NUM_HYPERTABLES, get_num_hypertables());
|
ts_jsonb_add_str(parseState, REQ_NUM_HYPERTABLES, get_num_hypertables());
|
||||||
|
ts_jsonb_add_str(parseState, REQ_NUM_CONTINUOUS_AGGS, get_num_continuous_aggs());
|
||||||
|
|
||||||
/* Add related extensions, which is a nested JSON */
|
/* Add related extensions, which is a nested JSON */
|
||||||
ext_key.type = jbvString;
|
ext_key.type = jbvString;
|
||||||
|
@ -305,8 +305,15 @@ WHERE key != 'os_name_pretty';
|
|||||||
last_tuned_version
|
last_tuned_version
|
||||||
postgresql_version
|
postgresql_version
|
||||||
related_extensions
|
related_extensions
|
||||||
|
num_continuous_aggs
|
||||||
timescaledb_version
|
timescaledb_version
|
||||||
(19 rows)
|
(20 rows)
|
||||||
|
|
||||||
|
SELECT json_object_field(get_telemetry_report()::json,'num_continuous_aggs');
|
||||||
|
json_object_field
|
||||||
|
-------------------
|
||||||
|
"0"
|
||||||
|
(1 row)
|
||||||
|
|
||||||
-- check telemetry picks up content from telemetry_metadata
|
-- check telemetry picks up content from telemetry_metadata
|
||||||
SELECT json_object_field(get_telemetry_report()::json,'db_metadata');
|
SELECT json_object_field(get_telemetry_report()::json,'db_metadata');
|
||||||
@ -322,3 +329,34 @@ SELECT json_object_field(get_telemetry_report()::json,'instance_metadata');
|
|||||||
{"cloud": "ci"}
|
{"cloud": "ci"}
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
--create a continuous agg
|
||||||
|
CREATE TABLE device_readings (
|
||||||
|
observation_time TIMESTAMPTZ NOT NULL
|
||||||
|
);
|
||||||
|
SELECT table_name FROM create_hypertable('device_readings', 'observation_time');
|
||||||
|
table_name
|
||||||
|
-----------------
|
||||||
|
device_readings
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
CREATE VIEW device_summary
|
||||||
|
WITH (timescaledb.continuous) AS
|
||||||
|
SELECT
|
||||||
|
time_bucket('1 hour', observation_time) as bucket,
|
||||||
|
min(observation_time)
|
||||||
|
FROM
|
||||||
|
device_readings
|
||||||
|
GROUP BY bucket;
|
||||||
|
NOTICE: adding not-null constraint to column "time_partition_col"
|
||||||
|
SELECT json_object_field(get_telemetry_report()::json,'num_continuous_aggs');
|
||||||
|
json_object_field
|
||||||
|
-------------------
|
||||||
|
"1"
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT json_object_field(get_telemetry_report()::json,'num_hypertables');
|
||||||
|
json_object_field
|
||||||
|
-------------------
|
||||||
|
"2"
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
@ -126,6 +126,8 @@ SET timescaledb.telemetry_level=off;
|
|||||||
SELECT * FROM json_object_keys(get_telemetry_report()::json) AS key
|
SELECT * FROM json_object_keys(get_telemetry_report()::json) AS key
|
||||||
WHERE key != 'os_name_pretty';
|
WHERE key != 'os_name_pretty';
|
||||||
|
|
||||||
|
SELECT json_object_field(get_telemetry_report()::json,'num_continuous_aggs');
|
||||||
|
|
||||||
-- check telemetry picks up content from telemetry_metadata
|
-- check telemetry picks up content from telemetry_metadata
|
||||||
SELECT json_object_field(get_telemetry_report()::json,'db_metadata');
|
SELECT json_object_field(get_telemetry_report()::json,'db_metadata');
|
||||||
|
|
||||||
@ -133,3 +135,19 @@ SELECT json_object_field(get_telemetry_report()::json,'db_metadata');
|
|||||||
SELECT json_object_field(get_telemetry_report()::json,'instance_metadata');
|
SELECT json_object_field(get_telemetry_report()::json,'instance_metadata');
|
||||||
|
|
||||||
|
|
||||||
|
--create a continuous agg
|
||||||
|
CREATE TABLE device_readings (
|
||||||
|
observation_time TIMESTAMPTZ NOT NULL
|
||||||
|
);
|
||||||
|
SELECT table_name FROM create_hypertable('device_readings', 'observation_time');
|
||||||
|
CREATE VIEW device_summary
|
||||||
|
WITH (timescaledb.continuous) AS
|
||||||
|
SELECT
|
||||||
|
time_bucket('1 hour', observation_time) as bucket,
|
||||||
|
min(observation_time)
|
||||||
|
FROM
|
||||||
|
device_readings
|
||||||
|
GROUP BY bucket;
|
||||||
|
|
||||||
|
SELECT json_object_field(get_telemetry_report()::json,'num_continuous_aggs');
|
||||||
|
SELECT json_object_field(get_telemetry_report()::json,'num_hypertables');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user