@ericminassian/platform-core 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,365 @@
1
+ /**
2
+ * The explorer's query model. The control plane answers it (the series
3
+ * endpoint) and evaluates alert rules with it; the console builds charts and
4
+ * alert rules from it; the CLI sends it.
5
+ *
6
+ * Every metric is read from the rollups the telemetry processor writes
7
+ * (`telemetryKeys`), except `realtime` and `service`, which come from
8
+ * CloudWatch on demand and so can't be watched by alert rules.
9
+ */
10
+ import { Schema } from 'effect';
11
+ /**
12
+ * Bucket sizes a query can ask for. `1m`, `1h` and `1d` are stored; the
13
+ * others are sums of 1-minute rollups (latency histograms add), so they
14
+ * reach back only as far as minute rollups are kept.
15
+ */
16
+ export declare const QueryResolution: Schema.Literals<readonly ["1m", "5m", "10m", "15m", "30m", "1h", "1d"]>;
17
+ export type QueryResolution = typeof QueryResolution.Type;
18
+ export declare const QUERY_RESOLUTION_MS: Record<QueryResolution, number>;
19
+ /** About this many buckets per chart when the caller doesn't pick a resolution. */
20
+ export declare const TARGET_POINTS = 150;
21
+ /**
22
+ * The smallest resolution that keeps `from`..`to` near `TARGET_POINTS`
23
+ * buckets, given how far back minute rollups reach (`minuteHorizonMs` before
24
+ * `now`): a range starting before that horizon can't be built from 1-minute
25
+ * rows, so it uses hours (or days past 14 days).
26
+ */
27
+ export declare function autoQueryResolution(from: number, to: number, now: number, minuteHorizonMs: number): QueryResolution;
28
+ /**
29
+ * What a query measures:
30
+ * - `requests`: HTTP requests (stage-wide, or of routes)
31
+ * - `latency`: their duration
32
+ * - `cold_starts`: requests served by a fresh server process
33
+ * - `jobs`: queue, event, cron, invoke and service runs
34
+ * - `job_duration`: their duration
35
+ * - `custom`: the app's `Metrics.count`/`value` series
36
+ * - `rate_limit`: `RateLimits` checks
37
+ * - `realtime`: AppSync Events activity (CloudWatch)
38
+ * - `service`: long-running services' CPU and memory (CloudWatch)
39
+ */
40
+ export declare const SeriesMetric: Schema.Literals<readonly ["requests", "latency", "cold_starts", "jobs", "job_duration", "custom", "rate_limit", "realtime", "service"]>;
41
+ export type SeriesMetric = typeof SeriesMetric.Type;
42
+ /**
43
+ * How each bucket is summarized:
44
+ * - `count`: how many (requests, runs, checks, recorded values)
45
+ * - `rate`: `count` per second
46
+ * - `percent`: the share, 0–100, of the metric's events that match the
47
+ * status or outcome filter, among all of them in the bucket (5xx % of
48
+ * requests, failed % of runs, denied % of checks)
49
+ * - `sum`, `avg`, `max`: of recorded values (custom metrics, realtime, service)
50
+ * - `p50`…`p99`: latency percentiles, from the rollups' fixed-bucket histograms
51
+ * (each is the upper bound of the bucket holding it)
52
+ * - `histogram`: every latency bucket's count, for heatmaps
53
+ */
54
+ export declare const SeriesStat: Schema.Literals<readonly ["count", "rate", "percent", "sum", "avg", "max", "p50", "p90", "p95", "p99", "histogram"]>;
55
+ export type SeriesStat = typeof SeriesStat.Type;
56
+ export declare const StatusClass: Schema.Literals<readonly ["2xx", "3xx", "4xx", "5xx"]>;
57
+ export type StatusClass = typeof StatusClass.Type;
58
+ export declare const STATUS_CLASSES: readonly StatusClass[];
59
+ /** Splits a query into one line per value of this dimension. */
60
+ export declare const SeriesGroupBy: Schema.Literals<readonly ["status", "route", "job", "outcome", "name"]>;
61
+ export type SeriesGroupBy = typeof SeriesGroupBy.Type;
62
+ export declare const SeriesOutcome: Schema.Literals<readonly ["ok", "error", "allowed", "denied"]>;
63
+ export type SeriesOutcome = typeof SeriesOutcome.Type;
64
+ export declare const SeriesFilter: Schema.Struct<{
65
+ /** Routes as rollups key them: `METHOD /pattern`, e.g. `GET /api/items/:id`. */
66
+ readonly routes: Schema.optional<Schema.$Array<Schema.String>>;
67
+ /** `requests` only. */
68
+ readonly status: Schema.optional<Schema.$Array<Schema.Literals<readonly ["2xx", "3xx", "4xx", "5xx"]>>>;
69
+ /** Jobs as `kind:name`, e.g. `queue:refresh`, `cron:digest`. */
70
+ readonly jobs: Schema.optional<Schema.$Array<Schema.String>>;
71
+ /** Custom metric names, rate limit names, or service names. */
72
+ readonly names: Schema.optional<Schema.$Array<Schema.String>>;
73
+ /** `jobs`: `ok` or `error`; `rate_limit`: `allowed` or `denied`. */
74
+ readonly outcome: Schema.optional<Schema.Literals<readonly ["ok", "error", "allowed", "denied"]>>;
75
+ /** `realtime`: `events`, `publishes`, `subscribes` or `errors`; `service`: `cpu` or `memory`. */
76
+ readonly measure: Schema.optional<Schema.String>;
77
+ }>;
78
+ export type SeriesFilter = typeof SeriesFilter.Type;
79
+ export declare const SeriesQuery: Schema.Struct<{
80
+ readonly metric: Schema.Literals<readonly ["requests", "latency", "cold_starts", "jobs", "job_duration", "custom", "rate_limit", "realtime", "service"]>;
81
+ readonly stat: Schema.Literals<readonly ["count", "rate", "percent", "sum", "avg", "max", "p50", "p90", "p95", "p99", "histogram"]>;
82
+ readonly filter: Schema.optional<Schema.Struct<{
83
+ /** Routes as rollups key them: `METHOD /pattern`, e.g. `GET /api/items/:id`. */
84
+ readonly routes: Schema.optional<Schema.$Array<Schema.String>>;
85
+ /** `requests` only. */
86
+ readonly status: Schema.optional<Schema.$Array<Schema.Literals<readonly ["2xx", "3xx", "4xx", "5xx"]>>>;
87
+ /** Jobs as `kind:name`, e.g. `queue:refresh`, `cron:digest`. */
88
+ readonly jobs: Schema.optional<Schema.$Array<Schema.String>>;
89
+ /** Custom metric names, rate limit names, or service names. */
90
+ readonly names: Schema.optional<Schema.$Array<Schema.String>>;
91
+ /** `jobs`: `ok` or `error`; `rate_limit`: `allowed` or `denied`. */
92
+ readonly outcome: Schema.optional<Schema.Literals<readonly ["ok", "error", "allowed", "denied"]>>;
93
+ /** `realtime`: `events`, `publishes`, `subscribes` or `errors`; `service`: `cpu` or `memory`. */
94
+ readonly measure: Schema.optional<Schema.String>;
95
+ }>>;
96
+ readonly groupBy: Schema.optional<Schema.Literals<readonly ["status", "route", "job", "outcome", "name"]>>;
97
+ /** Another stage than the page's. */
98
+ readonly stage: Schema.optional<Schema.String>;
99
+ }>;
100
+ export type SeriesQuery = typeof SeriesQuery.Type;
101
+ /** The statistics each metric answers; the first is its default. */
102
+ export declare const METRIC_STATS: Record<SeriesMetric, readonly SeriesStat[]>;
103
+ /** The dimensions each metric can be grouped by. */
104
+ export declare const METRIC_GROUP_BY: Record<SeriesMetric, readonly SeriesGroupBy[]>;
105
+ /** Metrics alert rules can watch: those read from rollups. */
106
+ export declare const ALERT_METRICS: readonly SeriesMetric[];
107
+ export declare const REALTIME_MEASURES: readonly ['events', 'publishes', 'subscribes', 'errors'];
108
+ export declare const SERVICE_MEASURES: readonly ['cpu', 'memory'];
109
+ /**
110
+ * Why a query can't be answered, or undefined when it can. `alert` also
111
+ * refuses what an alert rule can't watch: CloudWatch metrics, histograms,
112
+ * groups, and another stage than the rule's.
113
+ */
114
+ export declare function checkSeriesQuery(q: SeriesQuery, options?: {
115
+ readonly alert?: boolean;
116
+ }): string | undefined;
117
+ export declare function seriesUnit(q: Pick<SeriesQuery, 'metric' | 'stat' | 'filter'>): string;
118
+ /**
119
+ * A short label for a query, as charts, alert emails and the CLI show it:
120
+ * `5xx % of requests`, `p95 latency of GET /api/x`, `failed % of job runs`.
121
+ */
122
+ export declare function describeQuery(q: SeriesQuery): string;
123
+ /** A query of an explorer chart, with the id expressions refer to it by (`a`, `b`, …). */
124
+ export declare const NamedSeriesQuery: Schema.Struct<{
125
+ readonly metric: Schema.Literals<readonly ["requests", "latency", "cold_starts", "jobs", "job_duration", "custom", "rate_limit", "realtime", "service"]>;
126
+ readonly stat: Schema.Literals<readonly ["count", "rate", "percent", "sum", "avg", "max", "p50", "p90", "p95", "p99", "histogram"]>;
127
+ readonly filter: Schema.optional<Schema.Struct<{
128
+ /** Routes as rollups key them: `METHOD /pattern`, e.g. `GET /api/items/:id`. */
129
+ readonly routes: Schema.optional<Schema.$Array<Schema.String>>;
130
+ /** `requests` only. */
131
+ readonly status: Schema.optional<Schema.$Array<Schema.Literals<readonly ["2xx", "3xx", "4xx", "5xx"]>>>;
132
+ /** Jobs as `kind:name`, e.g. `queue:refresh`, `cron:digest`. */
133
+ readonly jobs: Schema.optional<Schema.$Array<Schema.String>>;
134
+ /** Custom metric names, rate limit names, or service names. */
135
+ readonly names: Schema.optional<Schema.$Array<Schema.String>>;
136
+ /** `jobs`: `ok` or `error`; `rate_limit`: `allowed` or `denied`. */
137
+ readonly outcome: Schema.optional<Schema.Literals<readonly ["ok", "error", "allowed", "denied"]>>;
138
+ /** `realtime`: `events`, `publishes`, `subscribes` or `errors`; `service`: `cpu` or `memory`. */
139
+ readonly measure: Schema.optional<Schema.String>;
140
+ }>>;
141
+ readonly groupBy: Schema.optional<Schema.Literals<readonly ["status", "route", "job", "outcome", "name"]>>;
142
+ /** Another stage than the page's. */
143
+ readonly stage: Schema.optional<Schema.String>;
144
+ readonly id: Schema.String;
145
+ readonly label: Schema.optional<Schema.String>;
146
+ /** Charted only through expressions. */
147
+ readonly hidden: Schema.optional<Schema.Boolean>;
148
+ }>;
149
+ export type NamedSeriesQuery = typeof NamedSeriesQuery.Type;
150
+ /** Arithmetic over other queries' values in the same bucket, e.g. `100 * a / b` (evaluated by the console). */
151
+ export declare const SeriesExpression: Schema.Struct<{
152
+ readonly id: Schema.String;
153
+ readonly expr: Schema.String;
154
+ readonly label: Schema.optional<Schema.String>;
155
+ readonly hidden: Schema.optional<Schema.Boolean>;
156
+ }>;
157
+ export type SeriesExpression = typeof SeriesExpression.Type;
158
+ export declare const ChartKind: Schema.Literals<readonly ["line", "area", "bar", "heatmap"]>;
159
+ export type ChartKind = typeof ChartKind.Type;
160
+ export declare const MetricsView: Schema.Struct<{
161
+ readonly kind: Schema.Literal<"metrics">;
162
+ readonly queries: Schema.$Array<Schema.Struct<{
163
+ readonly metric: Schema.Literals<readonly ["requests", "latency", "cold_starts", "jobs", "job_duration", "custom", "rate_limit", "realtime", "service"]>;
164
+ readonly stat: Schema.Literals<readonly ["count", "rate", "percent", "sum", "avg", "max", "p50", "p90", "p95", "p99", "histogram"]>;
165
+ readonly filter: Schema.optional<Schema.Struct<{
166
+ /** Routes as rollups key them: `METHOD /pattern`, e.g. `GET /api/items/:id`. */
167
+ readonly routes: Schema.optional<Schema.$Array<Schema.String>>;
168
+ /** `requests` only. */
169
+ readonly status: Schema.optional<Schema.$Array<Schema.Literals<readonly ["2xx", "3xx", "4xx", "5xx"]>>>;
170
+ /** Jobs as `kind:name`, e.g. `queue:refresh`, `cron:digest`. */
171
+ readonly jobs: Schema.optional<Schema.$Array<Schema.String>>;
172
+ /** Custom metric names, rate limit names, or service names. */
173
+ readonly names: Schema.optional<Schema.$Array<Schema.String>>;
174
+ /** `jobs`: `ok` or `error`; `rate_limit`: `allowed` or `denied`. */
175
+ readonly outcome: Schema.optional<Schema.Literals<readonly ["ok", "error", "allowed", "denied"]>>;
176
+ /** `realtime`: `events`, `publishes`, `subscribes` or `errors`; `service`: `cpu` or `memory`. */
177
+ readonly measure: Schema.optional<Schema.String>;
178
+ }>>;
179
+ readonly groupBy: Schema.optional<Schema.Literals<readonly ["status", "route", "job", "outcome", "name"]>>;
180
+ /** Another stage than the page's. */
181
+ readonly stage: Schema.optional<Schema.String>;
182
+ readonly id: Schema.String;
183
+ readonly label: Schema.optional<Schema.String>;
184
+ /** Charted only through expressions. */
185
+ readonly hidden: Schema.optional<Schema.Boolean>;
186
+ }>>;
187
+ readonly expressions: Schema.optional<Schema.$Array<Schema.Struct<{
188
+ readonly id: Schema.String;
189
+ readonly expr: Schema.String;
190
+ readonly label: Schema.optional<Schema.String>;
191
+ readonly hidden: Schema.optional<Schema.Boolean>;
192
+ }>>>;
193
+ readonly chart: Schema.Literals<readonly ["line", "area", "bar", "heatmap"]>;
194
+ readonly scale: Schema.optional<Schema.Literals<readonly ["linear", "log"]>>;
195
+ /** A line drawn across the chart, e.g. an alert threshold. */
196
+ readonly threshold: Schema.optional<Schema.Finite>;
197
+ }>;
198
+ export type MetricsView = typeof MetricsView.Type;
199
+ export declare const LogLevelName: Schema.Literals<readonly ["error", "warn", "info", "debug", "system"]>;
200
+ export type LogLevelName = typeof LogLevelName.Type;
201
+ /**
202
+ * Structured log filters. Any of them makes a search run on Logs Insights
203
+ * (CloudWatch filter patterns can't combine text with JSON fields).
204
+ */
205
+ export declare const LogFilters: Schema.Struct<{
206
+ readonly levels: Schema.optional<Schema.$Array<Schema.Literals<readonly ["error", "warn", "info", "debug", "system"]>>>;
207
+ /** `web`, `worker` or `service:<name>`. */
208
+ readonly streams: Schema.optional<Schema.$Array<Schema.String>>;
209
+ /** Route patterns (without the method), e.g. `/api/items/:id`. */
210
+ readonly routes: Schema.optional<Schema.$Array<Schema.String>>;
211
+ readonly status: Schema.optional<Schema.$Array<Schema.Literals<readonly ["2xx", "3xx", "4xx", "5xx"]>>>;
212
+ /** Deployment ids. */
213
+ readonly revs: Schema.optional<Schema.$Array<Schema.String>>;
214
+ readonly trace: Schema.optional<Schema.String>;
215
+ }>;
216
+ export type LogFilters = typeof LogFilters.Type;
217
+ export declare const TraceFilters: Schema.Struct<{
218
+ readonly kind: Schema.optional<Schema.Literals<readonly ["req", "job"]>>;
219
+ /** `METHOD /pattern`. */
220
+ readonly routes: Schema.optional<Schema.$Array<Schema.String>>;
221
+ /** `kind:name`. */
222
+ readonly jobs: Schema.optional<Schema.$Array<Schema.String>>;
223
+ /** `error`: 5xx requests and failed jobs; `ok`: the rest. */
224
+ readonly outcome: Schema.optional<Schema.Literals<readonly ["ok", "error"]>>;
225
+ readonly minMs: Schema.optional<Schema.Finite>;
226
+ /** Only traces whose spans were written (failed, slow or sampled). */
227
+ readonly recorded: Schema.optional<Schema.Boolean>;
228
+ }>;
229
+ export type TraceFilters = typeof TraceFilters.Type;
230
+ export declare const AlertState: Schema.Literals<readonly ["ok", "alarm", "no_data"]>;
231
+ export type AlertState = typeof AlertState.Type;
232
+ /** Minutes an alert rule's window can cover. */
233
+ export declare const ALERT_WINDOWS: readonly [1, 5, 10, 15, 30, 60];
234
+ /** How long the evaluator waits for a minute's telemetry to arrive before reading it. */
235
+ export declare const ALERT_LAG_MINUTES = 2;
236
+ export declare const MAX_ALERT_RULES_PER_APP = 25;
237
+ /** How long alert state changes are kept. */
238
+ export declare const ALERT_HISTORY_DAYS = 90;
239
+ export declare const AlertCondition: Schema.Struct<{
240
+ readonly op: Schema.Literals<readonly ["above", "below"]>;
241
+ readonly threshold: Schema.Finite;
242
+ /** The query is summarized over the last this many minutes (sums, shares and histograms of the window). */
243
+ readonly minutes: Schema.Literals<readonly [1, 5, 10, 15, 30, 60]>;
244
+ }>;
245
+ export type AlertCondition = typeof AlertCondition.Type;
246
+ /**
247
+ * A window with no data (no requests behind a percentage or percentile, no
248
+ * values of a custom metric): `ok` and `alarm` treat it as that state,
249
+ * `keep` keeps the current one. Counts are never missing: no events is 0.
250
+ */
251
+ export declare const AlertMissingData: Schema.Literals<readonly ["ok", "alarm", "keep"]>;
252
+ export type AlertMissingData = typeof AlertMissingData.Type;
253
+ export declare const AlertRuleInput: Schema.Struct<{
254
+ readonly name: Schema.Trim;
255
+ readonly stage: Schema.String;
256
+ readonly query: Schema.Struct<{
257
+ readonly metric: Schema.Literals<readonly ["requests", "latency", "cold_starts", "jobs", "job_duration", "custom", "rate_limit", "realtime", "service"]>;
258
+ readonly stat: Schema.Literals<readonly ["count", "rate", "percent", "sum", "avg", "max", "p50", "p90", "p95", "p99", "histogram"]>;
259
+ readonly filter: Schema.optional<Schema.Struct<{
260
+ /** Routes as rollups key them: `METHOD /pattern`, e.g. `GET /api/items/:id`. */
261
+ readonly routes: Schema.optional<Schema.$Array<Schema.String>>;
262
+ /** `requests` only. */
263
+ readonly status: Schema.optional<Schema.$Array<Schema.Literals<readonly ["2xx", "3xx", "4xx", "5xx"]>>>;
264
+ /** Jobs as `kind:name`, e.g. `queue:refresh`, `cron:digest`. */
265
+ readonly jobs: Schema.optional<Schema.$Array<Schema.String>>;
266
+ /** Custom metric names, rate limit names, or service names. */
267
+ readonly names: Schema.optional<Schema.$Array<Schema.String>>;
268
+ /** `jobs`: `ok` or `error`; `rate_limit`: `allowed` or `denied`. */
269
+ readonly outcome: Schema.optional<Schema.Literals<readonly ["ok", "error", "allowed", "denied"]>>;
270
+ /** `realtime`: `events`, `publishes`, `subscribes` or `errors`; `service`: `cpu` or `memory`. */
271
+ readonly measure: Schema.optional<Schema.String>;
272
+ }>>;
273
+ readonly groupBy: Schema.optional<Schema.Literals<readonly ["status", "route", "job", "outcome", "name"]>>;
274
+ /** Another stage than the page's. */
275
+ readonly stage: Schema.optional<Schema.String>;
276
+ }>;
277
+ readonly condition: Schema.Struct<{
278
+ readonly op: Schema.Literals<readonly ["above", "below"]>;
279
+ readonly threshold: Schema.Finite;
280
+ /** The query is summarized over the last this many minutes (sums, shares and histograms of the window). */
281
+ readonly minutes: Schema.Literals<readonly [1, 5, 10, 15, 30, 60]>;
282
+ }>;
283
+ readonly missing: Schema.Literals<readonly ["ok", "alarm", "keep"]>;
284
+ /** Email the platform's alerts topic when the rule fires and when it recovers. */
285
+ readonly notify: Schema.Boolean;
286
+ readonly enabled: Schema.Boolean;
287
+ }>;
288
+ export type AlertRuleInput = typeof AlertRuleInput.Type;
289
+ export declare const AlertRule: Schema.Struct<{
290
+ readonly name: Schema.Trim;
291
+ readonly stage: Schema.String;
292
+ readonly query: Schema.Struct<{
293
+ readonly metric: Schema.Literals<readonly ["requests", "latency", "cold_starts", "jobs", "job_duration", "custom", "rate_limit", "realtime", "service"]>;
294
+ readonly stat: Schema.Literals<readonly ["count", "rate", "percent", "sum", "avg", "max", "p50", "p90", "p95", "p99", "histogram"]>;
295
+ readonly filter: Schema.optional<Schema.Struct<{
296
+ /** Routes as rollups key them: `METHOD /pattern`, e.g. `GET /api/items/:id`. */
297
+ readonly routes: Schema.optional<Schema.$Array<Schema.String>>;
298
+ /** `requests` only. */
299
+ readonly status: Schema.optional<Schema.$Array<Schema.Literals<readonly ["2xx", "3xx", "4xx", "5xx"]>>>;
300
+ /** Jobs as `kind:name`, e.g. `queue:refresh`, `cron:digest`. */
301
+ readonly jobs: Schema.optional<Schema.$Array<Schema.String>>;
302
+ /** Custom metric names, rate limit names, or service names. */
303
+ readonly names: Schema.optional<Schema.$Array<Schema.String>>;
304
+ /** `jobs`: `ok` or `error`; `rate_limit`: `allowed` or `denied`. */
305
+ readonly outcome: Schema.optional<Schema.Literals<readonly ["ok", "error", "allowed", "denied"]>>;
306
+ /** `realtime`: `events`, `publishes`, `subscribes` or `errors`; `service`: `cpu` or `memory`. */
307
+ readonly measure: Schema.optional<Schema.String>;
308
+ }>>;
309
+ readonly groupBy: Schema.optional<Schema.Literals<readonly ["status", "route", "job", "outcome", "name"]>>;
310
+ /** Another stage than the page's. */
311
+ readonly stage: Schema.optional<Schema.String>;
312
+ }>;
313
+ readonly condition: Schema.Struct<{
314
+ readonly op: Schema.Literals<readonly ["above", "below"]>;
315
+ readonly threshold: Schema.Finite;
316
+ /** The query is summarized over the last this many minutes (sums, shares and histograms of the window). */
317
+ readonly minutes: Schema.Literals<readonly [1, 5, 10, 15, 30, 60]>;
318
+ }>;
319
+ readonly missing: Schema.Literals<readonly ["ok", "alarm", "keep"]>;
320
+ /** Email the platform's alerts topic when the rule fires and when it recovers. */
321
+ readonly notify: Schema.Boolean;
322
+ readonly enabled: Schema.Boolean;
323
+ readonly id: Schema.String;
324
+ readonly app: Schema.String;
325
+ readonly state: Schema.Literals<readonly ["ok", "alarm", "no_data"]>;
326
+ /** When `state` last changed. */
327
+ readonly stateSince: Schema.optional<Schema.String>;
328
+ /** The window's value at the last evaluation (null: no data). */
329
+ readonly value: Schema.optional<Schema.NullOr<Schema.Finite>>;
330
+ readonly evaluatedAt: Schema.optional<Schema.String>;
331
+ readonly createdBy: Schema.String;
332
+ readonly createdAt: Schema.String;
333
+ readonly updatedAt: Schema.String;
334
+ }>;
335
+ export type AlertRule = typeof AlertRule.Type;
336
+ export declare const AlertEvent: Schema.Struct<{
337
+ readonly ts: Schema.String;
338
+ readonly rule: Schema.String;
339
+ readonly name: Schema.String;
340
+ readonly stage: Schema.String;
341
+ readonly from: Schema.Literals<readonly ["ok", "alarm", "no_data"]>;
342
+ readonly to: Schema.Literals<readonly ["ok", "alarm", "no_data"]>;
343
+ readonly value: Schema.NullOr<Schema.Finite>;
344
+ readonly threshold: Schema.Finite;
345
+ }>;
346
+ export type AlertEvent = typeof AlertEvent.Type;
347
+ export declare const AlertHistoryResponse: Schema.Struct<{
348
+ readonly events: Schema.$Array<Schema.Struct<{
349
+ readonly ts: Schema.String;
350
+ readonly rule: Schema.String;
351
+ readonly name: Schema.String;
352
+ readonly stage: Schema.String;
353
+ readonly from: Schema.Literals<readonly ["ok", "alarm", "no_data"]>;
354
+ readonly to: Schema.Literals<readonly ["ok", "alarm", "no_data"]>;
355
+ readonly value: Schema.NullOr<Schema.Finite>;
356
+ readonly threshold: Schema.Finite;
357
+ }>>;
358
+ }>;
359
+ export type AlertHistoryResponse = typeof AlertHistoryResponse.Type;
360
+ export declare const breaches: (value: number, c: Pick<AlertCondition, 'op' | 'threshold'>) => boolean;
361
+ /** The state a rule moves to given its window's value (null: no data). */
362
+ export declare function nextAlertState(current: AlertState, value: number | null, rule: {
363
+ readonly condition: AlertCondition;
364
+ readonly missing: AlertMissingData;
365
+ }): AlertState;