/
cloudwatch.clj
145 lines (110 loc) · 5.23 KB
/
cloudwatch.clj
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
(ns crucible.aws.cloudwatch
"Resources in AWS::CloudWatch::*"
(:require [crucible.resources :refer [spec-or-ref defresource] :as res]
[crucible.values :as v]
[crucible.encoding.keys :refer [->key]]
[clojure.spec.alpha :as s]))
(defmethod ->key :ok-actions [_] "OKActions")
(s/def ::actions-enabled (spec-or-ref boolean?))
(s/def ::actions (s/coll-of (spec-or-ref string?) :kind vector?))
(s/def ::alarm-actions ::actions)
(s/def ::alarm-description (spec-or-ref string?))
(s/def ::alarm-name (spec-or-ref string?))
(s/def ::comparison-operator (spec-or-ref #{"GreaterThanOrEqualToThreshold"
"GreaterThanThreshold"
"LessThanThreshold"
"LessThanOrEqualToThreshold"
"LessThanLowerThreshold"
"LessThanLowerOrGreaterThanUpperThreshold"}))
(s/def ::value (spec-or-ref string?))
(s/def ::name (spec-or-ref string?))
(s/def ::datapoints-to-alarm (spec-or-ref int?))
(s/def ::dimension (s/keys :req [::name ::value]))
(s/def ::dimensions (s/coll-of ::dimension :kind vector?))
(s/def ::evaluate-low-sample-count-percentile (spec-or-ref string?))
(s/def ::evaluation-periods (spec-or-ref pos-int?))
;; The percentile statistic for the metric. Specify a value between p0.0 and p100.
(s/def ::extended-statistic (spec-or-ref (s/and string?
#(clojure.string/starts-with? % "p"))))
(s/def ::insufficient-data-actions ::actions)
(s/def ::metric-name (spec-or-ref string?))
(s/def ::expression (spec-or-ref string?))
(s/def ::id (spec-or-ref string?))
(s/def ::label (spec-or-ref string?))
(s/def ::metric (s/keys :opt [::dimensions
::metric-name
::namespace]))
(s/def ::metric-stat (s/keys :req [::metric
::period
::stat]
:opt [::unit]))
(s/def ::return-data (spec-or-ref boolean?))
(s/def ::metric-data-query (s/keys :req [::id]
:opt [::expression
::label
::metric-stat
::return-data]))
(s/def ::metrics (s/coll-of ::metric-data-query))
(s/def ::namespace (spec-or-ref string?))
(s/def ::ok-actions ::actions)
;; The time over which the specified statistic is applied.
;; Specify time in seconds, in multiples of 60.
(s/def ::period (spec-or-ref (s/and pos-int?
#(zero? (mod % 60)))))
(s/def ::statistic (spec-or-ref #{"SampleCount"
"Average"
"Sum"
"Minimum"
"Maximum"}))
(s/def ::threshold (spec-or-ref double?))
(s/def ::threshold-metric-id (spec-or-ref string?))
(s/def ::treat-missing-data (spec-or-ref #{"breaching"
"notBreaching"
"ignore"
"missing"}))
(s/def ::unit (spec-or-ref #{"Seconds"
"Microseconds"
"Milliseconds"
"Bytes" "Kilobytes"
"Megabytes"
"Gigabytes"
"Terabytes"
"Bits"
"Kilobits"
"Megabits"
"Gigabits"
"Terabits"
"Percent"
"Count"
"Bytes/Second"
"Kilobytes/Second"
"Megabytes/Second"
"Gigabytes/Second"
"Terabytes/Second"
"Bits/Second"
"Kilobits/Second"
"Megabits/Second"
"Gigabits/Second"
"Terabits/Second"
"Count/Second"
"None"}))
(s/def ::alarm (s/keys :req [::comparison-operator
::evaluation-periods]
:opt [::namespace
::metric-name
::actions-enabled
::alarm-actions
::alarm-description
::alarm-name
::dimensions
::insufficient-data-actions
::ok-actions
::statistic
::unit
::datapoints-to-alarm
::evaluate-low-sample-count-percentile
::metrics
::period
::threshold
::threshold-metric-id]))
(defresource alarm "AWS::CloudWatch::Alarm" ::alarm)