-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
40 lines (35 loc) · 1.19 KB
/
Copy pathschema.sql
File metadata and controls
40 lines (35 loc) · 1.19 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
CREATE DATABASE netstream;
\c netstream
CREATE TABLE IF NOT EXISTS events (
id SERIAL PRIMARY KEY,
agent_id VARCHAR(255) NOT NULL,
timestamp TIMESTAMP NOT NULL,
source VARCHAR(255) NOT NULL,
source_name VARCHAR(255),
raw_message TEXT NOT NULL,
severity VARCHAR(50),
category VARCHAR(100),
metadata JSONB,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS alerts (
id SERIAL PRIMARY KEY,
agent_id VARCHAR(255) NOT NULL,
timestamp TIMESTAMP NOT NULL,
alert_type VARCHAR(255) NOT NULL,
description TEXT,
source VARCHAR(255) NOT NULL,
raw_message TEXT NOT NULL,
severity VARCHAR(50),
category VARCHAR(100),
metadata JSONB,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX idx_events_agent_id ON events(agent_id);
CREATE INDEX idx_events_timestamp ON events(timestamp);
CREATE INDEX idx_events_category ON events(category);
CREATE INDEX idx_events_severity ON events(severity);
CREATE INDEX idx_alerts_agent_id ON alerts(agent_id);
CREATE INDEX idx_alerts_timestamp ON alerts(timestamp);
CREATE INDEX idx_alerts_type ON alerts(alert_type);
CREATE INDEX idx_alerts_severity ON alerts(severity);