Skip to content

Commit

Permalink
task: add edge observability tables (#9307)
Browse files Browse the repository at this point in the history
Adds two stat tables to store edge observability data.
  • Loading branch information
chriswk authored Feb 14, 2025
1 parent fa43420 commit 1dad28f
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/migrations/20250210130408-add-edge-observability-tables.js
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 src/migrations/20250212130610-add-stat-edge-traffic-table.js
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);
};

0 comments on commit 1dad28f

Please sign in to comment.