@intentius/chant-lexicon-prometheus 0.96.0

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.
Files changed (237) hide show
  1. package/README.md +58 -0
  2. package/dist/alertmanager.d.ts +81 -0
  3. package/dist/alertmanager.d.ts.map +1 -0
  4. package/dist/build.d.ts +33 -0
  5. package/dist/build.d.ts.map +1 -0
  6. package/dist/catalog.d.ts +17 -0
  7. package/dist/catalog.d.ts.map +1 -0
  8. package/dist/codegen/docs-cli.d.ts +3 -0
  9. package/dist/codegen/docs-cli.d.ts.map +1 -0
  10. package/dist/codegen/docs.d.ts +9 -0
  11. package/dist/codegen/docs.d.ts.map +1 -0
  12. package/dist/codegen/generate-cli.d.ts +3 -0
  13. package/dist/codegen/generate-cli.d.ts.map +1 -0
  14. package/dist/codegen/generate.d.ts +19 -0
  15. package/dist/codegen/generate.d.ts.map +1 -0
  16. package/dist/codegen/package.d.ts +7 -0
  17. package/dist/codegen/package.d.ts.map +1 -0
  18. package/dist/composites/catalog.d.ts +3 -0
  19. package/dist/composites/catalog.d.ts.map +1 -0
  20. package/dist/composites/index.d.ts +6 -0
  21. package/dist/composites/index.d.ts.map +1 -0
  22. package/dist/composites/slo.d.ts +205 -0
  23. package/dist/composites/slo.d.ts.map +1 -0
  24. package/dist/detect.d.ts +2 -0
  25. package/dist/detect.d.ts.map +1 -0
  26. package/dist/duration.d.ts +16 -0
  27. package/dist/duration.d.ts.map +1 -0
  28. package/dist/index.d.ts +14 -0
  29. package/dist/index.d.ts.map +1 -0
  30. package/dist/init-templates.d.ts +13 -0
  31. package/dist/init-templates.d.ts.map +1 -0
  32. package/dist/integrity.json +33 -0
  33. package/dist/lint/audit-catalog.d.ts +13 -0
  34. package/dist/lint/audit-catalog.d.ts.map +1 -0
  35. package/dist/lint/post-synth/index.d.ts +3 -0
  36. package/dist/lint/post-synth/index.d.ts.map +1 -0
  37. package/dist/lint/post-synth/prom-helpers.d.ts +33 -0
  38. package/dist/lint/post-synth/prom-helpers.d.ts.map +1 -0
  39. package/dist/lint/post-synth/prom101.d.ts +8 -0
  40. package/dist/lint/post-synth/prom101.d.ts.map +1 -0
  41. package/dist/lint/post-synth/prom102.d.ts +8 -0
  42. package/dist/lint/post-synth/prom102.d.ts.map +1 -0
  43. package/dist/lint/post-synth/prom103.d.ts +8 -0
  44. package/dist/lint/post-synth/prom103.d.ts.map +1 -0
  45. package/dist/lint/post-synth/prom104.d.ts +8 -0
  46. package/dist/lint/post-synth/prom104.d.ts.map +1 -0
  47. package/dist/lint/post-synth/prom105.d.ts +8 -0
  48. package/dist/lint/post-synth/prom105.d.ts.map +1 -0
  49. package/dist/lint/post-synth/prom106.d.ts +8 -0
  50. package/dist/lint/post-synth/prom106.d.ts.map +1 -0
  51. package/dist/lint/post-synth/prom107.d.ts +8 -0
  52. package/dist/lint/post-synth/prom107.d.ts.map +1 -0
  53. package/dist/lint/post-synth/prom201.d.ts +8 -0
  54. package/dist/lint/post-synth/prom201.d.ts.map +1 -0
  55. package/dist/lint/post-synth/prom202.d.ts +8 -0
  56. package/dist/lint/post-synth/prom202.d.ts.map +1 -0
  57. package/dist/lint/post-synth/prom203.d.ts +8 -0
  58. package/dist/lint/post-synth/prom203.d.ts.map +1 -0
  59. package/dist/lint/post-synth/prom204.d.ts +8 -0
  60. package/dist/lint/post-synth/prom204.d.ts.map +1 -0
  61. package/dist/lint/post-synth/prom205.d.ts +8 -0
  62. package/dist/lint/post-synth/prom205.d.ts.map +1 -0
  63. package/dist/lint/post-synth/prom206.d.ts +8 -0
  64. package/dist/lint/post-synth/prom206.d.ts.map +1 -0
  65. package/dist/lint/post-synth/prom207.d.ts +8 -0
  66. package/dist/lint/post-synth/prom207.d.ts.map +1 -0
  67. package/dist/lint/post-synth/prom208.d.ts +8 -0
  68. package/dist/lint/post-synth/prom208.d.ts.map +1 -0
  69. package/dist/lint/post-synth/prom209.d.ts +8 -0
  70. package/dist/lint/post-synth/prom209.d.ts.map +1 -0
  71. package/dist/lint/rules/index.d.ts +7 -0
  72. package/dist/lint/rules/index.d.ts.map +1 -0
  73. package/dist/lint/rules/literal-credential.d.ts +18 -0
  74. package/dist/lint/rules/literal-credential.d.ts.map +1 -0
  75. package/dist/lint/rules/prom-ast.d.ts +14 -0
  76. package/dist/lint/rules/prom-ast.d.ts.map +1 -0
  77. package/dist/lint/rules/promql-literal.d.ts +11 -0
  78. package/dist/lint/rules/promql-literal.d.ts.map +1 -0
  79. package/dist/lint/rules/slo-literal.d.ts +13 -0
  80. package/dist/lint/rules/slo-literal.d.ts.map +1 -0
  81. package/dist/lsp/completions.d.ts +4 -0
  82. package/dist/lsp/completions.d.ts.map +1 -0
  83. package/dist/lsp/hover.d.ts +4 -0
  84. package/dist/lsp/hover.d.ts.map +1 -0
  85. package/dist/manifest.json +8 -0
  86. package/dist/matchers.d.ts +29 -0
  87. package/dist/matchers.d.ts.map +1 -0
  88. package/dist/meta.json +32 -0
  89. package/dist/model.d.ts +262 -0
  90. package/dist/model.d.ts.map +1 -0
  91. package/dist/okf/index.md +34 -0
  92. package/dist/okf/rules/PROM001.md +16 -0
  93. package/dist/okf/rules/PROM002.md +15 -0
  94. package/dist/okf/rules/PROM003.md +11 -0
  95. package/dist/okf/rules/PROM101.md +11 -0
  96. package/dist/okf/rules/PROM102.md +11 -0
  97. package/dist/okf/rules/PROM103.md +11 -0
  98. package/dist/okf/rules/PROM104.md +11 -0
  99. package/dist/okf/rules/PROM105.md +11 -0
  100. package/dist/okf/rules/PROM106.md +11 -0
  101. package/dist/okf/rules/PROM107.md +11 -0
  102. package/dist/okf/rules/PROM201.md +11 -0
  103. package/dist/okf/rules/PROM202.md +11 -0
  104. package/dist/okf/rules/PROM203.md +11 -0
  105. package/dist/okf/rules/PROM204.md +11 -0
  106. package/dist/okf/rules/PROM205.md +11 -0
  107. package/dist/okf/rules/PROM206.md +11 -0
  108. package/dist/okf/rules/PROM207.md +11 -0
  109. package/dist/okf/rules/PROM208.md +11 -0
  110. package/dist/okf/rules/PROM209.md +11 -0
  111. package/dist/okf/types/AlertmanagerSettings.md +13 -0
  112. package/dist/okf/types/InhibitRule.md +9 -0
  113. package/dist/okf/types/Receiver.md +13 -0
  114. package/dist/okf/types/Route.md +9 -0
  115. package/dist/okf/types/RuleGroup.md +13 -0
  116. package/dist/okf/types/TimeInterval.md +9 -0
  117. package/dist/package-cli.d.ts +3 -0
  118. package/dist/package-cli.d.ts.map +1 -0
  119. package/dist/pin.d.ts +20 -0
  120. package/dist/pin.d.ts.map +1 -0
  121. package/dist/plugin.d.ts +10 -0
  122. package/dist/plugin.d.ts.map +1 -0
  123. package/dist/promql.d.ts +25 -0
  124. package/dist/promql.d.ts.map +1 -0
  125. package/dist/rule-eval.d.ts +67 -0
  126. package/dist/rule-eval.d.ts.map +1 -0
  127. package/dist/rules/literal-credential.ts +84 -0
  128. package/dist/rules/prom-ast.ts +30 -0
  129. package/dist/rules/prom-helpers.ts +89 -0
  130. package/dist/rules/prom101.ts +17 -0
  131. package/dist/rules/prom102.ts +17 -0
  132. package/dist/rules/prom103.ts +17 -0
  133. package/dist/rules/prom104.ts +17 -0
  134. package/dist/rules/prom105.ts +17 -0
  135. package/dist/rules/prom106.ts +17 -0
  136. package/dist/rules/prom107.ts +17 -0
  137. package/dist/rules/prom201.ts +17 -0
  138. package/dist/rules/prom202.ts +17 -0
  139. package/dist/rules/prom203.ts +17 -0
  140. package/dist/rules/prom204.ts +17 -0
  141. package/dist/rules/prom205.ts +17 -0
  142. package/dist/rules/prom206.ts +17 -0
  143. package/dist/rules/prom207.ts +17 -0
  144. package/dist/rules/prom208.ts +17 -0
  145. package/dist/rules/prom209.ts +17 -0
  146. package/dist/rules/promql-literal.ts +55 -0
  147. package/dist/rules/slo-literal.ts +81 -0
  148. package/dist/rules.d.ts +59 -0
  149. package/dist/rules.d.ts.map +1 -0
  150. package/dist/serializer.d.ts +27 -0
  151. package/dist/serializer.d.ts.map +1 -0
  152. package/dist/skill-defs.d.ts +3 -0
  153. package/dist/skill-defs.d.ts.map +1 -0
  154. package/dist/skills/chant-prometheus-alertmanager.md +58 -0
  155. package/dist/skills/chant-prometheus-kubernetes.md +48 -0
  156. package/dist/skills/chant-prometheus.md +91 -0
  157. package/dist/tools.d.ts +30 -0
  158. package/dist/tools.d.ts.map +1 -0
  159. package/dist/types/index.d.ts +3 -0
  160. package/dist/validate-cli.d.ts +3 -0
  161. package/dist/validate-cli.d.ts.map +1 -0
  162. package/dist/validate-config.d.ts +35 -0
  163. package/dist/validate-config.d.ts.map +1 -0
  164. package/dist/validate.d.ts +11 -0
  165. package/dist/validate.d.ts.map +1 -0
  166. package/package.json +77 -0
  167. package/src/alertmanager.ts +143 -0
  168. package/src/build.ts +199 -0
  169. package/src/catalog.ts +65 -0
  170. package/src/codegen/docs-cli.ts +4 -0
  171. package/src/codegen/docs.ts +104 -0
  172. package/src/codegen/generate-cli.ts +8 -0
  173. package/src/codegen/generate.ts +49 -0
  174. package/src/codegen/package.ts +41 -0
  175. package/src/composites/catalog.test.ts +37 -0
  176. package/src/composites/catalog.ts +65 -0
  177. package/src/composites/composites.test.ts +256 -0
  178. package/src/composites/index.ts +23 -0
  179. package/src/composites/slo-burn.test.ts +289 -0
  180. package/src/composites/slo.ts +471 -0
  181. package/src/detect.ts +12 -0
  182. package/src/duration.ts +51 -0
  183. package/src/generated/lexicon-prometheus.json +32 -0
  184. package/src/index.ts +97 -0
  185. package/src/init-templates.test.ts +29 -0
  186. package/src/init-templates.ts +76 -0
  187. package/src/lint/audit-catalog.ts +123 -0
  188. package/src/lint/post-synth/index.ts +37 -0
  189. package/src/lint/post-synth/post-synth.test.ts +256 -0
  190. package/src/lint/post-synth/prom-helpers.ts +89 -0
  191. package/src/lint/post-synth/prom101.ts +17 -0
  192. package/src/lint/post-synth/prom102.ts +17 -0
  193. package/src/lint/post-synth/prom103.ts +17 -0
  194. package/src/lint/post-synth/prom104.ts +17 -0
  195. package/src/lint/post-synth/prom105.ts +17 -0
  196. package/src/lint/post-synth/prom106.ts +17 -0
  197. package/src/lint/post-synth/prom107.ts +17 -0
  198. package/src/lint/post-synth/prom201.ts +17 -0
  199. package/src/lint/post-synth/prom202.ts +17 -0
  200. package/src/lint/post-synth/prom203.ts +17 -0
  201. package/src/lint/post-synth/prom204.ts +17 -0
  202. package/src/lint/post-synth/prom205.ts +17 -0
  203. package/src/lint/post-synth/prom206.ts +17 -0
  204. package/src/lint/post-synth/prom207.ts +17 -0
  205. package/src/lint/post-synth/prom208.ts +17 -0
  206. package/src/lint/post-synth/prom209.ts +17 -0
  207. package/src/lint/rules/index.ts +11 -0
  208. package/src/lint/rules/literal-credential.ts +84 -0
  209. package/src/lint/rules/prom-ast.ts +30 -0
  210. package/src/lint/rules/promql-literal.ts +55 -0
  211. package/src/lint/rules/rules.test.ts +114 -0
  212. package/src/lint/rules/slo-literal.ts +81 -0
  213. package/src/lsp/completions.test.ts +23 -0
  214. package/src/lsp/completions.ts +15 -0
  215. package/src/lsp/hover.test.ts +27 -0
  216. package/src/lsp/hover.ts +26 -0
  217. package/src/matchers.ts +132 -0
  218. package/src/model.test.ts +104 -0
  219. package/src/model.ts +290 -0
  220. package/src/package-cli.ts +17 -0
  221. package/src/pin.ts +13 -0
  222. package/src/plugin.test.ts +73 -0
  223. package/src/plugin.ts +129 -0
  224. package/src/promql.ts +46 -0
  225. package/src/rule-eval.ts +397 -0
  226. package/src/rules.ts +127 -0
  227. package/src/serializer.test.ts +179 -0
  228. package/src/serializer.ts +55 -0
  229. package/src/skill-defs.ts +43 -0
  230. package/src/skills/chant-prometheus-alertmanager.md +58 -0
  231. package/src/skills/chant-prometheus-kubernetes.md +48 -0
  232. package/src/skills/chant-prometheus.md +91 -0
  233. package/src/tools.test.ts +119 -0
  234. package/src/tools.ts +70 -0
  235. package/src/validate-cli.ts +7 -0
  236. package/src/validate-config.ts +400 -0
  237. package/src/validate.ts +66 -0
package/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # @intentius/chant-lexicon-prometheus
2
+
3
+ Prometheus lexicon for [chant](https://github.com/INTENTIUS/chant): typed recording and alerting rule groups, serialized to the rule file Prometheus loads, and Alertmanager routes, receivers, inhibit rules and time intervals, serialized to `alertmanager.yml`.
4
+
5
+ ```ts
6
+ import { RuleGroup, Receiver, Route, type Rule, type RouteProps } from "@intentius/chant-lexicon-prometheus";
7
+
8
+ const rules: Rule[] = [
9
+ { record: "job:http_errors:ratio5m", expr: 'sum by (job) (rate(http_requests_total{code=~"5.."}[5m])) / sum by (job) (rate(http_requests_total[5m]))' },
10
+ { alert: "ApiErrors", expr: "job:http_errors:ratio5m > 0.05", for: "10m", labels: { severity: "page" }, annotations: { summary: "5xx above 5%" } },
11
+ ];
12
+ const api = new RuleGroup({ name: "api", rules });
13
+
14
+ const oncall = new Receiver({ name: "oncall", pagerduty_configs: [{ routing_key_file: "/etc/alertmanager/pd-key" }] });
15
+ const fallback = new Receiver({ name: "default" });
16
+ const children: RouteProps[] = [{ matchers: ['severity="page"'], receiver: oncall }];
17
+ const root = new Route({ receiver: fallback, routes: children });
18
+
19
+ export { api, oncall, fallback, root };
20
+ ```
21
+
22
+ `chant build src --lexicon prometheus -o dist/rules.yml` writes `dist/rules.yml` and `dist/alertmanager.yml`.
23
+
24
+ ## Entities
25
+
26
+ | Class | File |
27
+ |---|---|
28
+ | `RuleGroup` | rule file |
29
+ | `Slo` (composite) | rule file: SLI recording rules, error budget and multiwindow burn-rate alerts |
30
+ | `Route`, `Receiver` (webhook, email, Slack, PagerDuty), `InhibitRule`, `TimeInterval`, `AlertmanagerSettings` | `alertmanager.yml` |
31
+
32
+ Types follow Prometheus `v3.15.0` and Alertmanager `v0.34.1` (`PROMETHEUS_PIN`).
33
+
34
+ ## Checks
35
+
36
+ PROM001 to PROM003 run on source (literal credentials, PromQL syntax in literals, `Slo` objective, window and SLI literals). PROM101 to PROM107 run over the built rule file: unique group names, duplicate rules, durations, PromQL syntax, rule shape, severity labels and summaries. PROM201 to PROM209 run over `alertmanager.yml`: receivers and time intervals that exist, every alert severity routed (PROM202, one build root at a time), root route shape, matcher syntax, unused receivers, durations and integrations without a destination.
37
+
38
+ PromQL is parsed with `@prometheus-io/lezer-promql`, the Prometheus project's own grammar. `promtoolCheckRules` and `amtoolCheckConfig` run the upstream tools when they are installed.
39
+
40
+ ## Plain-data API
41
+
42
+ - `ruleGroupConfig(group)`, `ruleFileYaml(entities)`, `alertmanagerYaml(entities)` render the files inside another lexicon. The k8s lexicon's `PrometheusRule` and `MonitoredService` take `RuleGroup`s through the first.
43
+ - `validateRuleFile`, `validateAlertmanagerConfig`, `validateSeverityRouting` run the checks without a build.
44
+ - `checkPromql`, `parseMatchers`, `isValidDuration` are the pieces underneath.
45
+ - `sloMetrics(slo)` names the series an `Slo` records and its burn-rate thresholds, for dashboards.
46
+
47
+ ## Project structure
48
+
49
+ - `src/model.ts`: the plain-data shapes of both files
50
+ - `src/rules.ts`: `RuleGroup`
51
+ - `src/alertmanager.ts`: the Alertmanager entities
52
+ - `src/composites/slo.ts`: `Slo` and `sloMetrics`
53
+ - `src/build.ts`: entities to config to YAML
54
+ - `src/promql.ts`, `src/matchers.ts`, `src/duration.ts`: parsing
55
+ - `src/validate-config.ts`, `src/lint/`: checks
56
+ - `src/tools.ts`: promtool and amtool
57
+ - `src/rule-eval.ts`: a small rule evaluator the SLO tests run over synthetic series
58
+ - `examples/`: getting-started, alerting, rules-from-data, slo, k3d-stack
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Alertmanager entities: `Route`, `Receiver`, `InhibitRule`, `TimeInterval`
3
+ * and `AlertmanagerSettings`, which together serialize to `alertmanager.yml`.
4
+ *
5
+ * A route names its receiver and its time intervals either by the declared
6
+ * entity, which keeps the reference checked by TypeScript, or by name string
7
+ * for one declared somewhere chant can't see. PROM201 and PROM204 catch a
8
+ * string that names nothing declared.
9
+ *
10
+ * The routing tree is built from `Route`s: the root is the one route no other
11
+ * route lists as a child. Child routes may be `Route` entities or plain
12
+ * objects.
13
+ */
14
+ import type { Declarable } from "@intentius/chant/declarable";
15
+ import type { AlertmanagerGlobalConfig, InhibitRuleConfig, ReceiverConfig, RouteConfig, TimeIntervalConfig } from "./model.js";
16
+ export declare const RECEIVER_TYPE = "Prometheus::Alertmanager::Receiver";
17
+ export declare const ROUTE_TYPE = "Prometheus::Alertmanager::Route";
18
+ export declare const INHIBIT_RULE_TYPE = "Prometheus::Alertmanager::InhibitRule";
19
+ export declare const TIME_INTERVAL_TYPE = "Prometheus::Alertmanager::TimeInterval";
20
+ export declare const SETTINGS_TYPE = "Prometheus::Alertmanager::Settings";
21
+ type Ctor<P, E> = new (props: P) => E;
22
+ export type ReceiverProps = ReceiverConfig;
23
+ export interface ReceiverEntity extends Declarable {
24
+ readonly props: ReceiverProps;
25
+ readonly receiverName: string;
26
+ }
27
+ /**
28
+ * A notification receiver: webhook, email, Slack and PagerDuty integrations.
29
+ *
30
+ * Credentials (Slack `api_url`, PagerDuty `routing_key`, SMTP passwords)
31
+ * belong in the `*_file` fields; Alertmanager does not expand environment
32
+ * variables in its config, and PROM001 flags a literal.
33
+ */
34
+ export declare const Receiver: Ctor<ReceiverConfig, ReceiverEntity>;
35
+ export type TimeIntervalProps = TimeIntervalConfig;
36
+ export interface TimeIntervalEntity extends Declarable {
37
+ readonly props: TimeIntervalProps;
38
+ readonly intervalName: string;
39
+ }
40
+ /** A named set of time periods a route can mute or activate on. */
41
+ export declare const TimeInterval: Ctor<TimeIntervalConfig, TimeIntervalEntity>;
42
+ export type ReceiverRef = ReceiverEntity | string;
43
+ export type TimeIntervalRef = TimeIntervalEntity | string;
44
+ export interface RouteProps extends Omit<RouteConfig, "receiver" | "routes" | "mute_time_intervals" | "active_time_intervals"> {
45
+ /** The receiver alerts matching this route go to. Required on the root route. */
46
+ receiver?: ReceiverRef;
47
+ /** Child routes, tried in order. */
48
+ routes?: Array<RouteEntity | RouteProps>;
49
+ mute_time_intervals?: TimeIntervalRef[];
50
+ active_time_intervals?: TimeIntervalRef[];
51
+ }
52
+ export interface RouteEntity extends Declarable {
53
+ readonly props: RouteProps;
54
+ }
55
+ /** A node in the routing tree. Declare one root route; nest the rest under `routes`. */
56
+ export declare const Route: Ctor<RouteProps, RouteEntity>;
57
+ export type InhibitRuleProps = InhibitRuleConfig;
58
+ export interface InhibitRuleEntity extends Declarable {
59
+ readonly props: InhibitRuleProps;
60
+ }
61
+ /** Mutes alerts matching `target_matchers` while an alert matching `source_matchers` fires. */
62
+ export declare const InhibitRule: Ctor<InhibitRuleConfig, InhibitRuleEntity>;
63
+ export interface AlertmanagerSettingsProps {
64
+ global?: AlertmanagerGlobalConfig;
65
+ /** Paths of notification template files. */
66
+ templates?: string[];
67
+ }
68
+ export interface AlertmanagerSettingsEntity extends Declarable {
69
+ readonly props: AlertmanagerSettingsProps;
70
+ }
71
+ /** The `global:` block and `templates:` list. Optional; declare at most one. */
72
+ export declare const AlertmanagerSettings: Ctor<AlertmanagerSettingsProps, AlertmanagerSettingsEntity>;
73
+ export declare const isReceiver: (value: unknown) => value is ReceiverEntity;
74
+ export declare const isRoute: (value: unknown) => value is RouteEntity;
75
+ export declare const isInhibitRule: (value: unknown) => value is InhibitRuleEntity;
76
+ export declare const isTimeInterval: (value: unknown) => value is TimeIntervalEntity;
77
+ export declare const isAlertmanagerSettings: (value: unknown) => value is AlertmanagerSettingsEntity;
78
+ /** True for any of the Alertmanager entity kinds. */
79
+ export declare function isAlertmanagerEntity(value: unknown): boolean;
80
+ export {};
81
+ //# sourceMappingURL=alertmanager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alertmanager.d.ts","sourceRoot":"","sources":["../src/alertmanager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EACV,wBAAwB,EACxB,iBAAiB,EACjB,cAAc,EACd,WAAW,EACX,kBAAkB,EACnB,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,aAAa,uCAAuC,CA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K,EAAE,UAAU,CAAC;CAC5B;AAED,wFAAwF;AACxF,eAAO,MAAM,KAAK,+BAA4D,CAAC;AAI/E,MAAM,MAAM,gBAAgB,GAAG,iBAAiB,CAAC;AAEjD,MAAM,WAAW,iBAAkB,SAAQ,UAAU;IACnD,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAC;CAClC;AAED,+FAA+F;AAC/F,eAAO,MAAM,WAAW,4CAAqF,CAAC;AAI9G,MAAM,WAAW,yBAAyB;IACxC,MAAM,CAAC,EAAE,wBAAwB,CAAC;IAClC,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,MAAM,WAAW,0BAA2B,SAAQ,UAAU;IAC5D,QAAQ,CAAC,KAAK,EAAE,yBAAyB,CAAC;CAC3C;AAED,gFAAgF;AAChF,eAAO,MAAM,oBAAoB,6DAGhC,CAAC;AASF,eAAO,MAAM,UAAU,UAJN,OAAO,KAAG,KAAK,kBAI+B,CAAC;AAChE,eAAO,MAAM,OAAO,UALH,OAAO,KAAG,KAAK,eAKsB,CAAC;AACvD,eAAO,MAAM,aAAa,UANT,OAAO,KAAG,KAAK,qBAMyC,CAAC;AAC1E,eAAO,MAAM,cAAc,UAPV,OAAO,KAAG,KAAK,sBAO4C,CAAC;AAC7E,eAAO,MAAM,sBAAsB,UARlB,OAAO,KAAG,KAAK,8BAQuD,CAAC;AAExF,qDAAqD;AACrD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAE5D"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Declared entities -> `RuleFileConfig` / `AlertmanagerConfig` -> YAML.
3
+ *
4
+ * The serializer runs these over a build's entities, and a composite in
5
+ * another lexicon (the k8s `PrometheusRule` path, a ConfigMap holding
6
+ * `alertmanager.yml`) runs them over the entities it has. Both get the same
7
+ * config and the same text.
8
+ */
9
+ import type { Declarable } from "@intentius/chant/declarable";
10
+ import type { AlertmanagerConfig, RuleFileConfig } from "./model.js";
11
+ import { type RuleGroupEntity } from "./rules.js";
12
+ export interface BuiltRuleFile {
13
+ config: RuleFileConfig;
14
+ groups: RuleGroupEntity[];
15
+ }
16
+ /** The rule file for a set of declared entities. Entities that aren't `RuleGroup`s are ignored. */
17
+ export declare function buildRuleFile(entities: Iterable<Declarable> | Map<string, Declarable>): BuiltRuleFile;
18
+ export interface BuiltAlertmanager {
19
+ config: AlertmanagerConfig;
20
+ /** Non-fatal problems, e.g. more than one root route. */
21
+ warnings: string[];
22
+ /** Every Alertmanager entity that took part, including ones reached only by reference. */
23
+ count: number;
24
+ }
25
+ /** The `alertmanager.yml` for a set of declared entities. Entities that aren't Alertmanager ones are ignored. */
26
+ export declare function buildAlertmanagerConfig(entities: Iterable<Declarable> | Map<string, Declarable>): BuiltAlertmanager;
27
+ /** Print a rule file or Alertmanager config as YAML, keys in the order given. */
28
+ export declare function emitYaml(value: unknown): string;
29
+ /** The rule file YAML for a set of declared entities, exactly as the serializer emits it. */
30
+ export declare function ruleFileYaml(entities: Iterable<Declarable> | Map<string, Declarable>): string;
31
+ /** The `alertmanager.yml` text for a set of declared entities, exactly as the serializer emits it. */
32
+ export declare function alertmanagerYaml(entities: Iterable<Declarable> | Map<string, Declarable>): string;
33
+ //# sourceMappingURL=build.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAc9D,OAAO,KAAK,EACV,kBAAkB,EAIlB,cAAc,EAEf,MAAM,SAAS,CAAC;AACjB,OAAO,EAAgC,KAAK,eAAe,EAAE,MAAM,SAAS,CAAC;AA4B7E,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,cAAc,CAAC;IACvB,MAAM,EAAE,eAAe,EAAE,CAAC;CAC3B;AAED,mGAAmG;AACnG,wBAAgB,aAAa,CAAC,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,aAAa,CAUrG;AAID,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,kBAAkB,CAAC;IAC3B,yDAAyD;IACzD,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,0FAA0F;IAC1F,KAAK,EAAE,MAAM,CAAC;CACf;AA8BD,iHAAiH;AACjH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,iBAAiB,CAiEnH;AAID,iFAAiF;AACjF,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAE/C;AAED,6FAA6F;AAC7F,wBAAgB,YAAY,CAAC,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,MAAM,CAE7F;AAED,sGAAsG;AACtG,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,MAAM,CAEjG"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The entity catalog: every class this package exports, keyed by class name.
3
+ * It feeds the packaged registry (`dist/meta.json`), LSP completions and
4
+ * hover, and the docs.
5
+ */
6
+ import type { LexiconEntry } from "@intentius/chant/lsp/lexicon-providers";
7
+ export interface CatalogEntry {
8
+ className: string;
9
+ entityType: string;
10
+ /** The file the entity serializes into. */
11
+ file: "rule file" | "alertmanager.yml";
12
+ description: string;
13
+ }
14
+ export declare const CATALOG: CatalogEntry[];
15
+ /** The catalog as a chant lexicon registry, keyed by class name. */
16
+ export declare function lexiconRegistry(): Record<string, LexiconEntry>;
17
+ //# sourceMappingURL=catalog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAI3E,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,2CAA2C;IAC3C,IAAI,EAAE,WAAW,GAAG,kBAAkB,CAAC;IACvC,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,OAAO,EAAE,YAAY,EAqCjC,CAAC;AAEF,oEAAoE;AACpE,wBAAgB,eAAe,IAAI,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAM9D"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env tsx
2
+ export {};
3
+ //# sourceMappingURL=docs-cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docs-cli.d.ts","sourceRoot":"","sources":["../../src/codegen/docs-cli.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Documentation generation for the prometheus lexicon: the generated
3
+ * reference pages from the core docs pipeline, plus the authored pages in
4
+ * docs/pages/.
5
+ */
6
+ export declare function generateDocs(opts?: {
7
+ verbose?: boolean;
8
+ }): Promise<void>;
9
+ //# sourceMappingURL=docs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../src/codegen/docs.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA4EH,wBAAsB,YAAY,CAAC,IAAI,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAuB9E"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env tsx
2
+ export {};
3
+ //# sourceMappingURL=generate-cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-cli.d.ts","sourceRoot":"","sources":["../../src/codegen/generate-cli.ts"],"names":[],"mappings":""}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * The prometheus lexicon's "generation" step.
3
+ *
4
+ * There is no upstream schema to fetch: Prometheus and Alertmanager define
5
+ * their config files as Go structs and publish no machine-readable schema for
6
+ * them. The types are written by hand against the releases in
7
+ * `PROMETHEUS_PIN` (src/pin.ts), and this step derives the registry from the
8
+ * entity catalog, so the packaged `dist/meta.json` can never disagree with
9
+ * the classes the package exports.
10
+ */
11
+ import type { GenerateResult } from "@intentius/chant/codegen/generate";
12
+ export type { GenerateResult };
13
+ export declare function generate(opts?: {
14
+ verbose?: boolean;
15
+ force?: boolean;
16
+ }): Promise<GenerateResult>;
17
+ /** Write the registry to src/generated/lexicon-prometheus.json, for tools that read it from there. */
18
+ export declare function writeGeneratedFiles(result: GenerateResult): void;
19
+ //# sourceMappingURL=generate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/codegen/generate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAGxE,YAAY,EAAE,cAAc,EAAE,CAAC;AAQ/B,wBAAsB,QAAQ,CAAC,IAAI,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,cAAc,CAAC,CAerG;AAED,sGAAsG;AACtG,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAKhE"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * prometheus lexicon packaging, delegating to core's packagePipeline.
3
+ */
4
+ import { type PackageOptions, type PackageResult } from "@intentius/chant/codegen/package";
5
+ export type { PackageOptions, PackageResult };
6
+ export declare function packageLexicon(opts?: PackageOptions): Promise<PackageResult>;
7
+ //# sourceMappingURL=package.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.d.ts","sourceRoot":"","sources":["../../src/codegen/package.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,aAAa,EACnB,MAAM,kCAAkC,CAAC;AAI1C,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,CAAC;AAK9C,wBAAsB,cAAc,CAAC,IAAI,GAAE,cAAmB,GAAG,OAAO,CAAC,aAAa,CAAC,CAmBtF"}
@@ -0,0 +1,3 @@
1
+ import type { CompositeEntry } from "@intentius/chant/lexicon";
2
+ export declare const compositeCatalog: CompositeEntry[];
3
+ //# sourceMappingURL=catalog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../src/composites/catalog.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE/D,eAAO,MAAM,gBAAgB,EAAE,cAAc,EA2D5C,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Prometheus lexicon composites: declarations that expand to rule groups.
3
+ */
4
+ export { Slo, sloMetrics, sloPropsProblem, sliExprProblem, DEFAULT_BURN_RATES, SLO_WINDOW_PLACEHOLDER, } from "./slo.js";
5
+ export type { SloProps, SloSli, SloAlerting, SloAlertTier, BurnRateWindow, SloMembers, SloInstance, SloMetrics, SloBurnRate, } from "./slo.js";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/composites/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,GAAG,EACH,UAAU,EACV,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,OAAO,CAAC;AACf,YAAY,EACV,QAAQ,EACR,MAAM,EACN,WAAW,EACX,YAAY,EACZ,cAAc,EACd,UAAU,EACV,WAAW,EACX,UAAU,EACV,WAAW,GACZ,MAAM,OAAO,CAAC"}
@@ -0,0 +1,205 @@
1
+ /**
2
+ * `Slo`: a service level objective that builds to Prometheus rules.
3
+ *
4
+ * One declaration expands to one `RuleGroup`, `slo-<name>`, holding:
5
+ *
6
+ * - recording rules: the SLI's error ratio over every window the alerts read
7
+ * (`slo:sli_error:ratio_rate<window>`), the error ratio over the whole SLO
8
+ * window, the objective (`slo:objective:ratio`) and the share of the error
9
+ * budget left (`slo:error_budget:remaining`). Every series carries an
10
+ * `slo` label with the SLO's name.
11
+ * - multiwindow, multi-burn-rate alerts from the Google SRE Workbook
12
+ * ("Alerting on SLOs", alert 6). Each alert pairs a long window with a
13
+ * short one and fires while both burn the error budget faster than the
14
+ * pair's factor: the long window keeps a short spike from paging, the
15
+ * short window stops the alert soon after the burn does.
16
+ *
17
+ * Both kinds share a group because Prometheus evaluates a group's rules in
18
+ * order: the alerts read the ratios recorded in the same evaluation. In
19
+ * separate groups they would read the previous evaluation's, and with an
20
+ * evaluation interval of 5m (the lookback) not at all.
21
+ *
22
+ * The Workbook's factors (14.4, 6, 3 and 1) assume a 30-day SLO window: each
23
+ * is the share of the budget a pair may burn over its long window, times the
24
+ * SLO window, over the long window (2% of the budget in 1h is
25
+ * 0.02 * 720h / 1h = 14.4). For any other window the lexicon keeps the
26
+ * windows and budget shares and recomputes the factor the same way, so a
27
+ * 28-day SLO pages at 0.02 * 672h / 1h = 13.44.
28
+ *
29
+ * `sloMetrics()` returns the recorded series names, the objective, the
30
+ * window and the burn-rate thresholds, so a dashboard or another rule reads
31
+ * them from the declaration instead of repeating them.
32
+ */
33
+ import { type CompositeInstance } from "@intentius/chant/composite";
34
+ import { type RuleGroupEntity } from "../rules.js";
35
+ import type { LabelSet } from "../model.js";
36
+ /** The placeholder an SLI expression writes where its range goes, e.g. `[{{window}}]`. */
37
+ export declare const SLO_WINDOW_PLACEHOLDER = "{{window}}";
38
+ /**
39
+ * The SLI as two PromQL expressions over the same events, each with
40
+ * `{{window}}` where the range goes. Either good and total events, or
41
+ * errors (bad events) and total events.
42
+ */
43
+ export type SloSli = {
44
+ /** Rate of good events, e.g. `sum(rate(http_requests_total{code!~"5.."}[{{window}}]))`. */
45
+ good: string;
46
+ /** Rate of all events, e.g. `sum(rate(http_requests_total[{{window}}]))`. */
47
+ total: string;
48
+ } | {
49
+ /** Rate of bad events, e.g. `sum(rate(http_requests_total{code=~"5.."}[{{window}}]))`. */
50
+ errors: string;
51
+ /** Rate of all events. */
52
+ total: string;
53
+ };
54
+ /** One long/short window pair and the burn rate it alerts at. */
55
+ export interface BurnRateWindow {
56
+ /** The long window, e.g. `1h`. At most the SLO window. */
57
+ long: string;
58
+ /** The short window, e.g. `5m`. Shorter than `long`; the Workbook uses a twelfth of it. */
59
+ short: string;
60
+ /**
61
+ * Share of the whole error budget this pair may burn over its long window
62
+ * before it alerts, e.g. `0.02`. The factor is derived from it and the SLO
63
+ * window. Set this or `factor`.
64
+ */
65
+ budgetConsumed?: number;
66
+ /** The burn rate itself, used as written for any SLO window. Set this or `budgetConsumed`. */
67
+ factor?: number;
68
+ }
69
+ /** One alert tier: paging or tickets. */
70
+ export interface SloAlertTier {
71
+ /** Window pairs, or `"default"` for the Workbook's pairs for this tier. */
72
+ burnRates?: "default" | BurnRateWindow[];
73
+ /** The `severity` label, which Alertmanager routes on (default: the tier's name, `page` or `ticket`). */
74
+ severity?: string;
75
+ /** How long a pair must hold before its alert fires (default: none; the short window already filters blips). */
76
+ for?: string;
77
+ /** More labels on this tier's alerts. */
78
+ labels?: LabelSet;
79
+ /** More annotations on this tier's alerts, e.g. `runbook_url`. */
80
+ annotations?: LabelSet;
81
+ }
82
+ export interface SloAlerting {
83
+ /** Fast burns that need someone now (default: on, 1h/5m at 2% and 6h/30m at 5% of the budget). `false` turns it off. */
84
+ page?: SloAlertTier | false;
85
+ /** Slow burns for working hours (default: on, 1d/2h at 10% and 3d/6h at 10% of the budget). `false` turns it off. */
86
+ ticket?: SloAlertTier | false;
87
+ /** The alert name every pair fires under (default: `ErrorBudgetBurn`). Pairs differ by labels. */
88
+ alertName?: string;
89
+ }
90
+ export interface SloProps {
91
+ /**
92
+ * The SLO's name, the `slo` label on every series and alert it builds and
93
+ * part of its group names. Letters, digits, `.`, `_` and `-`.
94
+ */
95
+ name: string;
96
+ /** The target share of good events, strictly between 0 and 1, e.g. `0.995`. */
97
+ objective: number;
98
+ /** The rolling window the objective holds over, a Prometheus duration, e.g. `28d` or `30d`. */
99
+ window: string;
100
+ /** The SLI: good (or error) events over total events, with `{{window}}` for the range. */
101
+ sli: SloSli;
102
+ /** A sentence for the alerts' description, e.g. what the SLO measures. */
103
+ description?: string;
104
+ /** Burn-rate alerts (default: both tiers with the Workbook's windows). */
105
+ alerting?: SloAlerting;
106
+ /** Labels added to every rule, e.g. `team` or `service`. */
107
+ labels?: LabelSet;
108
+ /** Evaluation interval of the group (default: Prometheus's `evaluation_interval`). */
109
+ interval?: string;
110
+ }
111
+ export type SloMembers = {
112
+ /** The recording rules, then the burn-rate alerts. */
113
+ rules: RuleGroupEntity;
114
+ };
115
+ /** What `Slo(...)` returns: its rule group, as `rules`. */
116
+ export type SloInstance = CompositeInstance<SloMembers> & SloMembers;
117
+ /** One burn-rate pair as built, for dashboards and tests. */
118
+ export interface SloBurnRate {
119
+ /** `page` or `ticket`. */
120
+ tier: "page" | "ticket";
121
+ /** The `severity` label the alert carries. */
122
+ severity: string;
123
+ long: string;
124
+ short: string;
125
+ /** The burn rate the pair fires above. */
126
+ factor: number;
127
+ /** The error ratio the pair fires above: `factor * (1 - objective)`. */
128
+ threshold: number;
129
+ /** The recorded error-ratio series each window reads. */
130
+ longRecord: string;
131
+ shortRecord: string;
132
+ /** The alert name. */
133
+ alert: string;
134
+ /** The labels that tell this pair's alert apart, `alertname` excluded. */
135
+ labels: LabelSet;
136
+ /** How long the budget lasts at exactly this burn rate. */
137
+ exhaustsIn: string;
138
+ }
139
+ /** The series and numbers an `Slo` builds, read by dashboards instead of repeating names. */
140
+ export interface SloMetrics {
141
+ /** The SLO's name, the value of the `slo` label. */
142
+ name: string;
143
+ objective: number;
144
+ /** `1 - objective`: the share of events allowed to be bad. */
145
+ errorBudget: number;
146
+ window: string;
147
+ /** The label every recorded series and alert carries. */
148
+ labels: {
149
+ slo: string;
150
+ };
151
+ /** `{slo="<name>"}`, ready to append to a recorded series name. */
152
+ selector: string;
153
+ /** Every window with an error-ratio series, shortest first; the SLO window is last. */
154
+ windows: string[];
155
+ /** Error-ratio series by window, e.g. `errorRatio["5m"]` is `slo:sli_error:ratio_rate5m`. */
156
+ errorRatio: Record<string, string>;
157
+ /** The error-ratio series over the whole SLO window. */
158
+ windowErrorRatio: string;
159
+ /** `slo:error_budget:remaining`: 1 is untouched, 0 is spent, below 0 is overspent. */
160
+ errorBudgetRemaining: string;
161
+ /** `slo:objective:ratio`: the objective as a series. */
162
+ objectiveRatio: string;
163
+ /** The burn-rate pairs, page tier first. Empty when alerting is off. */
164
+ burnRates: SloBurnRate[];
165
+ /** The alert name every pair fires under. */
166
+ alertName: string;
167
+ /** The rule group's name. */
168
+ group: string;
169
+ }
170
+ /** The Workbook's pairs ("Alerting on SLOs", table 5-8), as shares of the budget. */
171
+ export declare const DEFAULT_BURN_RATES: Readonly<Record<"page" | "ticket", readonly Readonly<BurnRateWindow>[]>>;
172
+ /**
173
+ * What is wrong with an SLO's objective, window or SLI, or `undefined`.
174
+ * `Slo()` throws with this message; the PROM003 lint rule reports it at the
175
+ * literal in the source.
176
+ */
177
+ export declare function sloPropsProblem(props: Partial<SloProps>): string | undefined;
178
+ /** What is wrong with one SLI expression, or `undefined`. */
179
+ export declare function sliExprProblem(expr: unknown): string | undefined;
180
+ /**
181
+ * An SLO, built to recording rules and multiwindow multi-burn-rate alerts.
182
+ *
183
+ * @example
184
+ * ```ts
185
+ * export const orderAck = Slo({
186
+ * name: "order-acknowledged",
187
+ * objective: 0.995,
188
+ * window: "28d",
189
+ * sli: {
190
+ * good: 'sum(rate(traces_span_metrics_calls_total{span_name="order.ack",status_code!="STATUS_CODE_ERROR"}[{{window}}]))',
191
+ * total: 'sum(rate(traces_span_metrics_calls_total{span_name="order.ack"}[{{window}}]))',
192
+ * },
193
+ * });
194
+ * // orderAck.rules is a RuleGroup; sloMetrics(orderAck) names its series.
195
+ * ```
196
+ */
197
+ export declare const Slo: import("@intentius/chant/composite").CompositeDefinition<SloProps, SloMembers>;
198
+ /**
199
+ * The recorded series names, objective, window and burn-rate thresholds of
200
+ * an SLO. Pass the `Slo(...)` result, its rule group, or the props
201
+ * it was built from; a dashboard reads names from here, so renaming or
202
+ * re-windowing the SLO moves its panels with it.
203
+ */
204
+ export declare function sloMetrics(slo: SloInstance | RuleGroupEntity | SloProps): SloMetrics;
205
+ //# sourceMappingURL=slo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slo.d.ts","sourceRoot":"","sources":["../../src/composites/slo.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAa,KAAK,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,EAA+D,KAAK,eAAe,EAAE,MAAM,UAAU,CAAC;AAC7G,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAIzC,0FAA0F;AAC1F,eAAO,MAAM,sBAAsB,eAAe,CAAC;AAEnD;;;;GAIG;AACH,MAAM,MAAM,MAAM,GACd;IACE,2FAA2F;IAC3F,IAAI,EAAE,MAAM,CAAC;IACb,6EAA6E;IAC7E,KAAK,EAAE,MAAM,CAAC;CACf,GACD;IACE,0FAA0F;IAC1F,MAAM,EAAE,MAAM,CAAC;IACf,0BAA0B;IAC1B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEN,iEAAiE;AACjE,MAAM,WAAW,cAAc;IAC7B,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAC;IACb,2FAA2F;IAC3F,KAAK,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,8FAA8F;IAC9F,MAA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,QAAQ,EAAE,SAAS,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,CAStG,CAAC;AA8GH;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG,MAAM,GAAG,SAAS,CAkB5E;AAED,6DAA6D;AAC7D,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAQhE;AAyFD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,GAAG,gFAYP,CAAC;AAEV;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,WAAW,GAAG,eAAe,GAAG,QAAQ,GAAG,UAAU,CAOpF"}
@@ -0,0 +1,2 @@
1
+ export declare function detectTemplate(data: unknown): boolean;
2
+ //# sourceMappingURL=detect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../src/detect.ts"],"names":[],"mappings":"AASA,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAErD"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Prometheus durations, as `model.ParseDuration` reads them.
3
+ *
4
+ * A duration is one or more `<number><unit>` terms, units in descending
5
+ * order and each at most once: `y`, `w`, `d`, `h`, `m`, `s`, `ms`. `1h30m`
6
+ * is valid, `30m1h` and `1.5h` are not. `0` on its own is valid. Prometheus
7
+ * (rule `for`, `interval`, range selectors) and Alertmanager (`group_wait`,
8
+ * `resolve_timeout`) share this grammar.
9
+ */
10
+ /** True when `value` is a Prometheus duration string. */
11
+ export declare function isValidDuration(value: unknown): value is string;
12
+ /** A duration in milliseconds, or `undefined` when it isn't a valid duration. */
13
+ export declare function durationMs(value: string): number | undefined;
14
+ /** Write a millisecond count as the shortest Prometheus duration, e.g. `5400000` -> `1h30m`. */
15
+ export declare function formatDuration(ms: number): string;
16
+ //# sourceMappingURL=duration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"duration.d.ts","sourceRoot":"","sources":["../src/duration.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,yDAAyD;AACzD,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAI/D;AAED,iFAAiF;AACjF,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAW5D;AAED,gGAAgG;AAChG,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAcjD"}
@@ -0,0 +1,14 @@
1
+ export { prometheusPlugin } from "./plugin.js";
2
+ export { prometheusSerializer, ALERTMANAGER_FILE } from "./serializer.js";
3
+ export { RuleGroup, RULE_GROUP_TYPE, isRuleGroup, ruleGroupConfig, ruleConfig, type RuleGroupProps, type RuleGroupEntity, type Rule, type RecordingRule, type AlertingRule, } from "./rules.js";
4
+ export { Route, Receiver, InhibitRule, TimeInterval, AlertmanagerSettings, ROUTE_TYPE, RECEIVER_TYPE, INHIBIT_RULE_TYPE, TIME_INTERVAL_TYPE, SETTINGS_TYPE, isRoute, isReceiver, isInhibitRule, isTimeInterval, isAlertmanagerSettings, isAlertmanagerEntity, type RouteProps, type RouteEntity, type ReceiverProps, type ReceiverEntity, type ReceiverRef, type InhibitRuleProps, type InhibitRuleEntity, type TimeIntervalProps, type TimeIntervalEntity, type TimeIntervalRef, type AlertmanagerSettingsProps, type AlertmanagerSettingsEntity, } from "./alertmanager.js";
5
+ export * from "./model.js";
6
+ export { buildRuleFile, buildAlertmanagerConfig, ruleFileYaml, alertmanagerYaml, emitYaml, type BuiltRuleFile, type BuiltAlertmanager, } from "./build.js";
7
+ export { isValidDuration, durationMs, formatDuration } from "./duration.js";
8
+ export { parseMatchers, matcherMatches, matcher, type Matcher, type MatchOp, type ParsedMatchers } from "./matchers.js";
9
+ export { checkPromql, PROMQL_GRAMMAR, type PromqlCheck } from "./promql.js";
10
+ export { validateRuleFile, validateAlertmanagerConfig, validateSeverityRouting, alertSeverities, type PrometheusIssue, type PrometheusIssueCode, } from "./validate-config.js";
11
+ export { PROMETHEUS_PIN } from "./pin.js";
12
+ export { promtoolCheckRules, promtoolTestRules, amtoolCheckConfig, hasTool, type ToolResult } from "./tools.js";
13
+ export { Slo, sloMetrics, sloPropsProblem, sliExprProblem, DEFAULT_BURN_RATES, SLO_WINDOW_PLACEHOLDER, type SloProps, type SloSli, type SloAlerting, type SloAlertTier, type BurnRateWindow, type SloMembers, type SloInstance, type SloMetrics, type SloBurnRate, } from "./composites/index.js";
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGvE,OAAO,EACL,SAAS,EACT,eAAe,EACf,WAAW,EACX,eAAe,EACf,UAAU,EACV,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,IAAI,EACT,KAAK,aAAa,EAClB,KAAK,YAAY,GAClB,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,KAAK,EACL,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,oBAAoB,EACpB,UAAU,EACV,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,OAAO,EACP,UAAU,EACV,aAAa,EACb,cAAc,EACd,sBAAsB,EACtB,oBAAoB,EACpB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,yBAAyB,EAC9B,KAAK,0BAA0B,GAChC,MAAM,gBAAgB,CAAC;AAGxB,cAAc,SAAS,CAAC;AACxB,OAAO,EACL,aAAa,EACb,uBAAuB,EACvB,YAAY,EACZ,gBAAgB,EAChB,QAAQ,EACR,KAAK,aAAa,EAClB,KAAK,iBAAiB,GACvB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AACrH,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AACzE,OAAO,EACL,gBAAgB,EAChB,0BAA0B,EAC1B,uBAAuB,EACvB,eAAe,EACf,KAAK,eAAe,EACpB,KAAK,mBAAmB,GACzB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;AAG7G,OAAO,EACL,GAAG,EACH,UAAU,EACV,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,sBAAsB,EACtB,KAAK,QAAQ,EACb,KAAK,MAAM,EACX,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,WAAW,GACjB,MAAM,cAAc,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * `chant init --lexicon prometheus` scaffolds.
3
+ *
4
+ * - default: one rule group and the Alertmanager routing for it, in one build
5
+ * root so PROM202 checks every severity is routed.
6
+ * - `rules`: rule groups only, for a setup whose Alertmanager config lives
7
+ * elsewhere.
8
+ * - `slo-style`: a recording rule per window and alerts on two severities,
9
+ * the shape SLO burn-rate rules take.
10
+ */
11
+ import type { InitTemplateSet } from "@intentius/chant/lexicon";
12
+ export declare function initTemplates(template?: string): InitTemplateSet;
13
+ //# sourceMappingURL=init-templates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init-templates.d.ts","sourceRoot":"","sources":["../src/init-templates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AA6DhE,wBAAgB,aAAa,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,eAAe,CAIhE"}
@@ -0,0 +1,33 @@
1
+ {
2
+ "algorithm": "sha256",
3
+ "artifacts": {
4
+ "manifest.json": "260b1be2d402063a2ca612ae6ea1a1698de052cb2d5da98fb2c914b9d98840ee",
5
+ "meta.json": "6aeeb24f8a09f61582620870021cdb0d781690d4a9d0efebc729d054df3eaebb",
6
+ "types/index.d.ts": "150d72287453a24a40cdeffb8cf3e9dc6e77ab58b342b48d01902dc58fb5f85d",
7
+ "rules/literal-credential.ts": "7373d82f89faaa798627490f3d3ecbaeb09226b76a255b752479667d91f47ca7",
8
+ "rules/prom-ast.ts": "96590392cf1b81ab58d5c51728afa99c1d54f2f53802aceabbfa0410f4fc2e6b",
9
+ "rules/promql-literal.ts": "6b72a80a6bd3d55d4b77588bedd8da448594577913c2c50fa37f5b9191fc83a0",
10
+ "rules/slo-literal.ts": "13f86da17d11939ebbcf64be38b092b602f6c9e95876e1615c00a032638d75b1",
11
+ "rules/prom-helpers.ts": "3b70c77935602f7f93a4c74886bd2cff2f75cec36f2578b58a765fc531cd319c",
12
+ "rules/prom101.ts": "f153c2b0b5f43b51e15053d732f27321aeb33c76683416b47982a95986704935",
13
+ "rules/prom102.ts": "d40d7d4690ada12efcf50c471739b2254376cbd382c1d8c547bbadca3205a1fa",
14
+ "rules/prom103.ts": "7801469c838023083ef3c196fffc6ab71b05270dba439fc19cb1dc383a6a8f64",
15
+ "rules/prom104.ts": "229857688b4b1825a9d6d5617dceaa0f8a427d655c47d425d2aae64c0265b2f3",
16
+ "rules/prom105.ts": "ea178b2124bbf5f79afbfb8fc7b8ae7bb136e3e4509670edb40df24ccb450533",
17
+ "rules/prom106.ts": "dfd30c9f876e38a8a40104243899a44396c07157487d3d7e2db8e62d8c02e009",
18
+ "rules/prom107.ts": "4963bf905947163ddac83c801046c381a39b1245eef89329c638473dc8ccfe04",
19
+ "rules/prom201.ts": "0cb548ef466924bd409676b1a37c4b45e3a4af8ad1900601f91bb665602f1e79",
20
+ "rules/prom202.ts": "90880c65e6406a634d160afad859718d0741bfb4d15de660d0ffa30c36fee8af",
21
+ "rules/prom203.ts": "43a7b014a0081be63af86423e77802a01cf5e261c84c27dfc7101d6063bac1fd",
22
+ "rules/prom204.ts": "0877ac086be641b3add2efd5d839fcd60e669f7b4e3fe01227255aa9f14bbdc2",
23
+ "rules/prom205.ts": "c0f7b3ffcaee9b278da8146c6e26bfaadd4285c0a18c095fce2b7215b2878682",
24
+ "rules/prom206.ts": "3153f5ebc883494017277225f3315a55180f6b5660add6ffedac0c5fcccab8d8",
25
+ "rules/prom207.ts": "60b9fb8017da191f43d174ac6173c31abfb151d536b9994408f104fc6e25cdb4",
26
+ "rules/prom208.ts": "692b4ae103b762199a51ab9fb64b1d6686dfbc0356676f6cf6afb393a89ef83a",
27
+ "rules/prom209.ts": "5c4fe651e51e1eea7fa5f03a7f6331d98399629c7c7d53f4ea8620982d419bbd",
28
+ "skills/chant-prometheus.md": "bc8153f349d9eaeb7690d4b1fdb5a848281c580679c7dcdd76b7144bc1db5a05",
29
+ "skills/chant-prometheus-alertmanager.md": "048c047edbf074d9aaa6ee84ebf29d5b9d3dd5194116f213f2b1468d1d0def3f",
30
+ "skills/chant-prometheus-kubernetes.md": "cca016857891f4cabf1feb6f9db83c220a2e6ece200cd89e635851079f8070a8"
31
+ },
32
+ "composite": "a3bd43c75d606ca0275e63d0914a6a408b8440cd959bed0f7b1851e95f764c3d"
33
+ }