-
Notifications
You must be signed in to change notification settings - Fork 0
/
create.sql
64 lines (59 loc) · 3.28 KB
/
create.sql
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
do $$
begin
CREATE TABLE IF NOT EXISTS memory_tasks
(
id TEXT NOT NULL UNIQUE, -- ID of task (from kapacitor)
app TEXT NOT NULL, -- Name of app to monitor
dynotype TEXT NOT NULL, -- Dyno to monitor on app
crit TEXT NOT NULL, -- Threshold for critical alert, in MB
warn TEXT NOT NULL, -- Threshold for warning alert, in MB
wind TEXT NOT NULL, -- How far back to retrieve data (e.g. 10m, 30m, 1h)
every TEXT NOT NULL, -- Frequency to check (e.g. 30s, 1m, 10m)
slack TEXT, -- Slack channel to notify
post TEXT, -- HTTP endpoint to notify (POST)
email TEXT, -- Email address to notify
CONSTRAINT notify_present CHECK ( -- Got to have a value in either slack, post, or email
(CASE WHEN slack IS NULL THEN 0 ELSE 1 END) +
(CASE WHEN post IS NULL THEN 0 ELSE 1 END) +
(CASE WHEN email IS NULL THEN 0 ELSE 1 END) > 0
)
);
CREATE TABLE IF NOT EXISTS _5xx_tasks
(
app TEXT NOT NULL UNIQUE, -- Name of app to monitor
tolerance TEXT NOT NULL, -- How sensitive should checks be? [low, medium, high]
slack TEXT, -- Slack channel to notify
post TEXT, -- HTTP endpoint to notify (POST)
email TEXT, -- Email address to notify
CONSTRAINT notify_present CHECK ( -- Got to have a value in either slack, post, or email
(CASE WHEN slack IS NULL THEN 0 ELSE 1 END) +
(CASE WHEN post IS NULL THEN 0 ELSE 1 END) +
(CASE WHEN email IS NULL THEN 0 ELSE 1 END) > 0
)
);
CREATE TABLE IF NOT EXISTS crashed_tasks
(
app TEXT NOT NULL UNIQUE, -- Name of app to monitor
slack TEXT, -- Slack channel to notify
post TEXT, -- HTTP endpoint to notify (POST)
email TEXT, -- Email address to notify
CONSTRAINT notify_present CHECK ( -- Got to have a value in either slack, post, or email
(CASE WHEN slack IS NULL THEN 0 ELSE 1 END) +
(CASE WHEN post IS NULL THEN 0 ELSE 1 END) +
(CASE WHEN email IS NULL THEN 0 ELSE 1 END) > 0
)
);
CREATE TABLE IF NOT EXISTS released_tasks
(
app TEXT NOT NULL UNIQUE, -- Name of app to monitor
slack TEXT, -- Slack channel to notify
post TEXT, -- HTTP endpoint to notify (POST)
email TEXT, -- Email address to notify
CONSTRAINT notify_present CHECK ( -- Got to have a value in either slack, post, or email
(CASE WHEN slack IS NULL THEN 0 ELSE 1 END) +
(CASE WHEN post IS NULL THEN 0 ELSE 1 END) +
(CASE WHEN email IS NULL THEN 0 ELSE 1 END) > 0
)
);
end
$$;