-
-
Notifications
You must be signed in to change notification settings - Fork 743
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
task: add edge observability tables (#9307)
Adds two stat tables to store edge observability data.
- Loading branch information
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
src/migrations/20250210130408-add-edge-observability-tables.js
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 @@ | ||
exports.up = (db, cb) => { | ||
db.runSql(` | ||
CREATE TABLE stat_edge_observability ( | ||
instance_id TEXT NOT NULL PRIMARY KEY, | ||
reported_at TIMESTAMP WITH TIME ZONE NOT NULL, | ||
app_name TEXT, | ||
started TIMESTAMP WITH TIME ZONE NOT NULL, | ||
edge_version TEXT NOT NULL, | ||
region TEXT, | ||
cpu_usage NUMERIC DEFAULT 0.0, | ||
memory_usage INTEGER DEFAULT 0, | ||
connected_streaming_clients INTEGER NOT NULL DEFAULT 0, | ||
connected_via TEXT, | ||
client_features_average_latency_ms NUMERIC DEFAULT 0.0, | ||
client_features_p99_latency_ms NUMERIC DEFAULT 0.0, | ||
frontend_api_average_latency_ms NUMERIC DEFAULT 0.0, | ||
frontend_api_p99_latency_ms NUMERIC DEFAULT 0.0, | ||
upstream_features_average_latency_ms NUMERIC DEFAULT 0.0, | ||
upstream_features_p99_latency_ms NUMERIC DEFAULT 0.0, | ||
upstream_metrics_average_latency_ms NUMERIC DEFAULT 0.0, | ||
upstream_metrics_p99_latency_ms NUMERIC DEFAULT 0.0, | ||
upstream_edge_average_latency_ms NUMERIC DEFAULT 0.0, | ||
upstream_edge_p99_latency_ms NUMERIC DEFAULT 0.0 | ||
); | ||
CREATE INDEX edge_observability_connected_via_idx ON stat_edge_observability(connected_via) WHERE connected_via IS NOT NULL; | ||
CREATE INDEX edge_observability_app_name_idx ON stat_edge_observability(app_name) WHERE app_name IS NOT NULL; | ||
`, cb); | ||
}; | ||
|
||
exports.down = (db, cb) => { | ||
db.runSql(`DROP TABLE IF EXISTS stat_edge_observability;`, cb); | ||
}; |
16 changes: 16 additions & 0 deletions
16
src/migrations/20250212130610-add-stat-edge-traffic-table.js
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,16 @@ | ||
exports.up = (db, cb) => { | ||
db.runSql(`CREATE TABLE stat_edge_traffic_usage( | ||
instance_id TEXT NOT NULL, | ||
day DATE NOT NULL, | ||
traffic_group TEXT NOT NULL, | ||
count BIGINT NOT NULL DEFAULT 0, | ||
PRIMARY KEY (instance_id, day, traffic_group) | ||
); | ||
CREATE INDEX stat_edge_traffic_usage_traffic_group_idx ON stat_edge_traffic_usage(traffic_group); | ||
CREATE INDEX stat_edge_traffic_usage_day_idx ON stat_edge_traffic_usage(day); | ||
`, cb); | ||
}; | ||
|
||
exports.down = (db, cb) => { | ||
db.runSql(`DROP TABLE stat_edge_traffic_usage;`, cb); | ||
}; |