-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspeedtest-schema.sql
More file actions
40 lines (34 loc) · 1.78 KB
/
Copy pathspeedtest-schema.sql
File metadata and controls
40 lines (34 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
-- speedtest-schema.sql
-- BHN (Blackhole Network) — speedtest result log.
-- Populated by per-node speedtest cron (TBD: bhn-speedtest-probe.sh) which runs
-- librespeed-cli against the local + peer LibreSpeed endpoints and inserts a row
-- per measurement. HORIZON reads via query_db for latency-trend monitoring.
--
-- Apply on the hub:
-- sudo -u postgres psql -d eventhorizon -f sql/speedtest-schema.sql
CREATE TABLE IF NOT EXISTS speedtest_results (
id BIGSERIAL PRIMARY KEY,
measured_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
source_node TEXT NOT NULL, -- which node ran the test (e.g. 'la', 'frankfurt', 'nj')
target_node TEXT NOT NULL, -- which node's endpoint was tested
ping_ms NUMERIC(7,2),
jitter_ms NUMERIC(7,2),
download_mbps NUMERIC(8,2),
upload_mbps NUMERIC(8,2),
packet_loss_pct NUMERIC(5,2),
test_mode TEXT, -- 'ping' (light, hourly) | 'bandwidth' (heavy, daily)
raw_payload JSONB
);
CREATE INDEX IF NOT EXISTS speedtest_results_time_idx
ON speedtest_results (measured_at DESC);
CREATE INDEX IF NOT EXISTS speedtest_results_pair_idx
ON speedtest_results (source_node, target_node, measured_at DESC);
-- INSERT for the probe (n8n_user is the rw role used by other ingest workflows)
GRANT SELECT, INSERT ON speedtest_results TO n8n_user;
GRANT USAGE, SELECT ON SEQUENCE speedtest_results_id_seq TO n8n_user;
-- HORIZON reads via its agent_reader role
GRANT SELECT ON speedtest_results TO agent_reader;
-- Grafana future panel
GRANT SELECT ON speedtest_results TO grafana_reader;
COMMENT ON TABLE speedtest_results IS
'Per-pair latency + bandwidth measurements from LibreSpeed probes. Populated by bhn-speedtest-probe cron on each node.';