@intentius/chant-lexicon-prometheus 0.96.0 → 0.98.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 (53) hide show
  1. package/README.md +5 -0
  2. package/dist/alertmanager.d.ts +4 -2
  3. package/dist/alertmanager.d.ts.map +1 -1
  4. package/dist/build.d.ts.map +1 -1
  5. package/dist/codegen/docs.d.ts.map +1 -1
  6. package/dist/import/generator.d.ts +35 -0
  7. package/dist/import/generator.d.ts.map +1 -0
  8. package/dist/import/parser.d.ts +52 -0
  9. package/dist/import/parser.d.ts.map +1 -0
  10. package/dist/import/slo.d.ts +15 -0
  11. package/dist/import/slo.d.ts.map +1 -0
  12. package/dist/integrity.json +7 -7
  13. package/dist/lint/rules/literal-credential.d.ts.map +1 -1
  14. package/dist/lint/rules/prom-ast.d.ts +8 -0
  15. package/dist/lint/rules/prom-ast.d.ts.map +1 -1
  16. package/dist/lint/rules/promql-literal.d.ts.map +1 -1
  17. package/dist/manifest.json +1 -1
  18. package/dist/model.d.ts +21 -0
  19. package/dist/model.d.ts.map +1 -1
  20. package/dist/plugin.d.ts.map +1 -1
  21. package/dist/rules/literal-credential.ts +17 -11
  22. package/dist/rules/prom-ast.ts +36 -0
  23. package/dist/rules/promql-literal.ts +15 -1
  24. package/dist/skills/chant-prometheus-alertmanager.md +4 -0
  25. package/dist/skills/chant-prometheus.md +11 -0
  26. package/package.json +2 -2
  27. package/src/alertmanager.ts +4 -1
  28. package/src/build.ts +2 -0
  29. package/src/codegen/docs.ts +5 -1
  30. package/src/import/cli.test.ts +98 -0
  31. package/src/import/generated-types.e2e.test.ts +75 -0
  32. package/src/import/generator.test.ts +121 -0
  33. package/src/import/generator.ts +570 -0
  34. package/src/import/parser.test.ts +120 -0
  35. package/src/import/parser.ts +348 -0
  36. package/src/import/roundtrip.test.ts +321 -0
  37. package/src/import/slo.ts +175 -0
  38. package/src/import/testdata/alertmanager-full.yml +89 -0
  39. package/src/import/testdata/fixtures.ts +114 -0
  40. package/src/import/testdata/rules-full.yml +42 -0
  41. package/src/import/testdata/upstream/alertmanager-route-labels.yml +65 -0
  42. package/src/import/testdata/upstream/alertmanager-simple.yml +130 -0
  43. package/src/import/testdata/upstream/prometheus-alerting-rules.yml +15 -0
  44. package/src/import/testdata/upstream/prometheus-alerting-templates.yml +23 -0
  45. package/src/import/testdata/upstream/prometheus-recording-rules.yml +7 -0
  46. package/src/lint/rules/literal-credential.ts +17 -11
  47. package/src/lint/rules/prom-ast.ts +36 -0
  48. package/src/lint/rules/promql-literal.ts +15 -1
  49. package/src/lint/rules/rules.test.ts +28 -0
  50. package/src/model.ts +22 -0
  51. package/src/plugin.ts +10 -0
  52. package/src/skills/chant-prometheus-alertmanager.md +4 -0
  53. package/src/skills/chant-prometheus.md +11 -0
package/README.md CHANGED
@@ -31,6 +31,10 @@ export { api, oncall, fallback, root };
31
31
 
32
32
  Types follow Prometheus `v3.15.0` and Alertmanager `v0.34.1` (`PROMETHEUS_PIN`).
33
33
 
34
+ ## Importing existing files
35
+
36
+ `chant import rules.yml --output src` and `chant import alertmanager.yml --output src` turn an existing rule file or Alertmanager config into this lexicon's TypeScript (`--lexicon prometheus` skips detection). Rules stay plain objects in a `Rule[]` const beside each `RuleGroup`; a group an `Slo()` built comes back as the `Slo` call. Routes reference receivers and time intervals by variable. `*_file` credential paths and Go templates are kept as written, and a literal credential is imported as found for PROM001 to report. `chant build` on the result gives back the same files: the round-trip tests in `src/import/roundtrip.test.ts` hold every example's output, `Slo()` output, and samples from the Prometheus docs and Alertmanager's example configs to that, and run `promtool` and `amtool` over the rebuilt files when installed.
37
+
34
38
  ## Checks
35
39
 
36
40
  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.
@@ -54,5 +58,6 @@ PromQL is parsed with `@prometheus-io/lezer-promql`, the Prometheus project's ow
54
58
  - `src/promql.ts`, `src/matchers.ts`, `src/duration.ts`: parsing
55
59
  - `src/validate-config.ts`, `src/lint/`: checks
56
60
  - `src/tools.ts`: promtool and amtool
61
+ - `src/import/`: `chant import` for rule files and `alertmanager.yml` (parser, generator, `Slo` recognition, round-trip tests and fixtures)
57
62
  - `src/rule-eval.ts`: a small rule evaluator the SLO tests run over synthetic series
58
63
  - `examples/`: getting-started, alerting, rules-from-data, slo, k3d-stack
@@ -12,7 +12,7 @@
12
12
  * objects.
13
13
  */
14
14
  import type { Declarable } from "@intentius/chant/declarable";
15
- import type { AlertmanagerGlobalConfig, InhibitRuleConfig, ReceiverConfig, RouteConfig, TimeIntervalConfig } from "./model.js";
15
+ import type { AlertmanagerGlobalConfig, AlertmanagerTracingConfig, InhibitRuleConfig, ReceiverConfig, RouteConfig, TimeIntervalConfig } from "./model.js";
16
16
  export declare const RECEIVER_TYPE = "Prometheus::Alertmanager::Receiver";
17
17
  export declare const ROUTE_TYPE = "Prometheus::Alertmanager::Route";
18
18
  export declare const INHIBIT_RULE_TYPE = "Prometheus::Alertmanager::InhibitRule";
@@ -64,11 +64,13 @@ export interface AlertmanagerSettingsProps {
64
64
  global?: AlertmanagerGlobalConfig;
65
65
  /** Paths of notification template files. */
66
66
  templates?: string[];
67
+ /** Where Alertmanager sends its own traces. */
68
+ tracing?: AlertmanagerTracingConfig;
67
69
  }
68
70
  export interface AlertmanagerSettingsEntity extends Declarable {
69
71
  readonly props: AlertmanagerSettingsProps;
70
72
  }
71
- /** The `global:` block and `templates:` list. Optional; declare at most one. */
73
+ /** The `global:` block, `templates:` list and `tracing:` block. Optional; declare at most one. */
72
74
  export declare const AlertmanagerSettings: Ctor<AlertmanagerSettingsProps, AlertmanagerSettingsEntity>;
73
75
  export declare const isReceiver: (value: unknown) => value is ReceiverEntity;
74
76
  export declare const isRoute: (value: unknown) => value is RouteEntity;
@@ -1 +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,CAAC;AAClE,eAAO,MAAM,UAAU,oCAAoC,CAAC;AAC5D,eAAO,MAAM,iBAAiB,0CAA0C,CAAC;AACzE,eAAO,MAAM,kBAAkB,2CAA2C,CAAC;AAC3E,eAAO,MAAM,aAAa,uCAAuC,CAAC;AAElE,KAAK,IAAI,CAAC,CAAC,EAAE,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC;AActC,MAAM,MAAM,aAAa,GAAG,cAAc,CAAC;AAE3C,MAAM,WAAW,cAAe,SAAQ,UAAU;IAChD,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B;AAED;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,sCAEnB,CAAC;AAIH,MAAM,MAAM,iBAAiB,GAAG,kBAAkB,CAAC;AAEnD,MAAM,WAAW,kBAAmB,SAAQ,UAAU;IACpD,QAAQ,CAAC,KAAK,EAAE,iBAAiB,CAAC;IAClC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B;AAED,mEAAmE;AACnE,eAAO,MAAM,YAAY,8CAEvB,CAAC;AAIH,MAAM,MAAM,WAAW,GAAG,cAAc,GAAG,MAAM,CAAC;AAClD,MAAM,MAAM,eAAe,GAAG,kBAAkB,GAAG,MAAM,CAAC;AAE1D,MAAM,WAAW,UAAW,SAAQ,IAAI,CAAC,WAAW,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,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,MAAM,CAEjG"}
@@ -1 +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"}
1
+ {"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../src/codegen/docs.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAgFH,wBAAsB,YAAY,CAAC,IAAI,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAuB9E"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * `TemplateIR` -> TypeScript, for `chant import`.
3
+ *
4
+ * Writes the files the way the lexicon's examples are written: nested
5
+ * settings lifted into named consts typed by the model (COR001), at most
6
+ * eight declarables per module (COR009), and an `export { ... }` list at the
7
+ * end of each module (COR004 flags an exported declaration nothing in its
8
+ * file uses).
9
+ *
10
+ * A rule file becomes `rules.ts`: per group, its rules as a `Rule[]` const
11
+ * of plain objects, the same shape `ruleGroupConfig` emits, and a
12
+ * `RuleGroup`. A group an `Slo()` built is written as that `Slo` call in
13
+ * `slos.ts` instead (see ./slo.ts).
14
+ *
15
+ * An `alertmanager.yml` becomes `receivers.ts`, `time-intervals.ts`,
16
+ * `routes.ts` (the root `Route`, its children as `RouteProps` objects),
17
+ * `inhibit-rules.ts` and `settings.ts`. Routes name their receivers and time
18
+ * intervals by the declared variable, imported from the module that
19
+ * declares it; a name nothing declares stays a string, and PROM201 / PROM204
20
+ * report it.
21
+ */
22
+ import type { GeneratedFile, TypeScriptGenerator } from "@intentius/chant/import/generator";
23
+ import type { TemplateIR } from "@intentius/chant/import/parser";
24
+ import type { AlertmanagerConfig, RuleFileConfig } from "../model.js";
25
+ /** A value as a TypeScript expression, starting at column `col`, indented by `indent` spaces. */
26
+ export declare function tsLiteral(v: unknown, indent: number, col?: number): string;
27
+ /** Generate the TypeScript declaring one rule file. */
28
+ export declare function generateRuleFileFiles(file: RuleFileConfig): GeneratedFile[];
29
+ /** Generate the TypeScript declaring one `alertmanager.yml`. */
30
+ export declare function generateAlertmanagerFiles(config: AlertmanagerConfig): GeneratedFile[];
31
+ /** The rule file and `alertmanager.yml` TypeScript generator `chant import` runs. */
32
+ export declare class PrometheusGenerator implements TypeScriptGenerator {
33
+ generate(ir: TemplateIR): GeneratedFile[];
34
+ }
35
+ //# sourceMappingURL=generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/import/generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAC5F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,EACV,kBAAkB,EAIlB,cAAc,EAGf,MAAM,UAAU,CAAC;AAiFlB,iGAAiG;AACjG,wBAAgB,SAAS,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,GAAG,MAAM,CAmB1E;AAyID,uDAAuD;AACvD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,cAAc,GAAG,aAAa,EAAE,CAsD3E;AAgDD,gEAAgE;AAChE,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,kBAAkB,GAAG,aAAa,EAAE,CAmLrF;AAED,qFAAqF;AACrF,qBAAa,mBAAoB,YAAW,mBAAmB;IAC7D,QAAQ,CAAC,EAAE,EAAE,UAAU,GAAG,aAAa,EAAE;CAY1C"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Rule file or `alertmanager.yml` -> `TemplateIR`, for `chant import`.
3
+ *
4
+ * Either file is one document whose parts name each other (a route names a
5
+ * receiver and time intervals), so the IR carries the whole file as one
6
+ * resource and the generator lays out the modules itself, turning those
7
+ * names into imports of declared entities. Core splits an IR with more than
8
+ * three resources into one generate() call per category and keeps only the
9
+ * first file of each, which would lose the imports between a route and the
10
+ * receivers it names.
11
+ *
12
+ * Values are carried as written: `*_file` credential paths, Go templates in
13
+ * annotations and notifier fields, and literal credentials, which PROM001
14
+ * then reports in the generated source. What the lexicon has no place for is
15
+ * named in `warnings`. Two deprecated Alertmanager spellings are rewritten to
16
+ * the ones Alertmanager treats the same way: `match` / `match_re` (and the
17
+ * inhibit rules' `source_match*` / `target_match*`) become matcher strings,
18
+ * and the top-level `mute_time_intervals` list joins `time_intervals`.
19
+ */
20
+ import type { TemplateIR, TemplateParser } from "@intentius/chant/import/parser";
21
+ import { type AlertmanagerConfig, type RuleFileConfig } from "../model.js";
22
+ /** The IR resource type for a whole rule file. */
23
+ export declare const RULE_FILE_RESOURCE_TYPE = "Prometheus::RuleFile";
24
+ /** The IR resource type for a whole `alertmanager.yml`. */
25
+ export declare const ALERTMANAGER_RESOURCE_TYPE = "Prometheus::Alertmanager::Config";
26
+ /** `properties` of the `Prometheus::RuleFile` resource. */
27
+ export interface RuleFileResourceProperties {
28
+ file: RuleFileConfig;
29
+ }
30
+ /** `properties` of the `Prometheus::Alertmanager::Config` resource. */
31
+ export interface AlertmanagerResourceProperties {
32
+ config: AlertmanagerConfig;
33
+ }
34
+ /** What the parser read. */
35
+ export type ParsedPrometheusFile = {
36
+ kind: "rules";
37
+ file: RuleFileConfig;
38
+ warnings: string[];
39
+ } | {
40
+ kind: "alertmanager";
41
+ config: AlertmanagerConfig;
42
+ warnings: string[];
43
+ };
44
+ /** A matcher string Alertmanager parses back to `name op value`. */
45
+ export declare function matcherString(name: string, op: "=" | "=~", value: string): string;
46
+ /** Parse a rule file or `alertmanager.yml`, telling them apart by shape. */
47
+ export declare function parsePrometheusYaml(content: string): ParsedPrometheusFile;
48
+ /** The rule file and `alertmanager.yml` parser `chant import` runs. */
49
+ export declare class PrometheusParser implements TemplateParser {
50
+ parse(content: string): TemplateIR;
51
+ }
52
+ //# sourceMappingURL=parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/import/parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACjF,OAAO,EAGL,KAAK,kBAAkB,EAKvB,KAAK,cAAc,EAGpB,MAAM,UAAU,CAAC;AAElB,kDAAkD;AAClD,eAAO,MAAM,uBAAuB,yBAAyB,CAAC;AAC9D,2DAA2D;AAC3D,eAAO,MAAM,0BAA0B,qCAAqC,CAAC;AAE7E,2DAA2D;AAC3D,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,cAAc,CAAC;CACtB;AAED,uEAAuE;AACvE,MAAM,WAAW,8BAA8B;IAC7C,MAAM,EAAE,kBAAkB,CAAC;CAC5B;AAED,4BAA4B;AAC5B,MAAM,MAAM,oBAAoB,GAC5B;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,cAAc,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,GAC3D;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,MAAM,EAAE,kBAAkB,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAgH7E,oEAAoE;AACpE,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAGjF;AA8ID,4EAA4E;AAC5E,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,oBAAoB,CAezE;AAED,uEAAuE;AACvE,qBAAa,gBAAiB,YAAW,cAAc;IACrD,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU;CAgBnC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Recognise a rule group that `Slo()` built, so the importer can write the
3
+ * `Slo` declaration instead of its forty-odd lines of rules.
4
+ *
5
+ * The group's name, recorded series, objective and burn-rate alerts give
6
+ * back candidate props; the candidate is accepted only when `Slo()` builds
7
+ * it to the same group, rule for rule. Anything else (a hand-edited
8
+ * threshold, an extra rule, a different description) fails that check and
9
+ * the group is imported as a plain `RuleGroup`.
10
+ */
11
+ import { type SloProps } from "../composites/slo.js";
12
+ import { type RuleGroupConfig } from "../model.js";
13
+ /** The `Slo` props that build exactly `group`, or `undefined` when no `Slo()` call does. */
14
+ export declare function recognizeSlo(group: RuleGroupConfig): SloProps | undefined;
15
+ //# sourceMappingURL=slo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slo.d.ts","sourceRoot":"","sources":["../../src/import/slo.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAsE,KAAK,QAAQ,EAAuB,MAAM,mBAAmB,CAAC;AAG3I,OAAO,EAAuF,KAAK,eAAe,EAAE,MAAM,UAAU,CAAC;AA8DrI,4FAA4F;AAC5F,wBAAgB,YAAY,CAAC,KAAK,EAAE,eAAe,GAAG,QAAQ,GAAG,SAAS,CAiGzE"}
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "algorithm": "sha256",
3
3
  "artifacts": {
4
- "manifest.json": "260b1be2d402063a2ca612ae6ea1a1698de052cb2d5da98fb2c914b9d98840ee",
4
+ "manifest.json": "98d08c362d144d9cac01a4bc4343ae8c3c529ed62c2a79284d61ebe8b6631939",
5
5
  "meta.json": "6aeeb24f8a09f61582620870021cdb0d781690d4a9d0efebc729d054df3eaebb",
6
6
  "types/index.d.ts": "150d72287453a24a40cdeffb8cf3e9dc6e77ab58b342b48d01902dc58fb5f85d",
7
- "rules/literal-credential.ts": "7373d82f89faaa798627490f3d3ecbaeb09226b76a255b752479667d91f47ca7",
8
- "rules/prom-ast.ts": "96590392cf1b81ab58d5c51728afa99c1d54f2f53802aceabbfa0410f4fc2e6b",
9
- "rules/promql-literal.ts": "6b72a80a6bd3d55d4b77588bedd8da448594577913c2c50fa37f5b9191fc83a0",
7
+ "rules/literal-credential.ts": "2d3b3c2e6eff96df09620e3e6a763d24ec40c8f5a55c8697038506f612ccfb23",
8
+ "rules/prom-ast.ts": "6de6f83cfa81505efeb2c55aa1e9872ead9b09695a400c92bec8fa11059a551f",
9
+ "rules/promql-literal.ts": "c734b6d9f0949ac7529edd6e687f7a5a1e62f37e614492f0e92e7062260e85db",
10
10
  "rules/slo-literal.ts": "13f86da17d11939ebbcf64be38b092b602f6c9e95876e1615c00a032638d75b1",
11
11
  "rules/prom-helpers.ts": "3b70c77935602f7f93a4c74886bd2cff2f75cec36f2578b58a765fc531cd319c",
12
12
  "rules/prom101.ts": "f153c2b0b5f43b51e15053d732f27321aeb33c76683416b47982a95986704935",
@@ -25,9 +25,9 @@
25
25
  "rules/prom207.ts": "60b9fb8017da191f43d174ac6173c31abfb151d536b9994408f104fc6e25cdb4",
26
26
  "rules/prom208.ts": "692b4ae103b762199a51ab9fb64b1d6686dfbc0356676f6cf6afb393a89ef83a",
27
27
  "rules/prom209.ts": "5c4fe651e51e1eea7fa5f03a7f6331d98399629c7c7d53f4ea8620982d419bbd",
28
- "skills/chant-prometheus.md": "bc8153f349d9eaeb7690d4b1fdb5a848281c580679c7dcdd76b7144bc1db5a05",
29
- "skills/chant-prometheus-alertmanager.md": "048c047edbf074d9aaa6ee84ebf29d5b9d3dd5194116f213f2b1468d1d0def3f",
28
+ "skills/chant-prometheus.md": "ebbb08a4a14056984490a130a55ceebbee774eb0fb757989b6885d57c743f03a",
29
+ "skills/chant-prometheus-alertmanager.md": "9974300a9dc92983362e0092ef70d059d509d7c502116b7241e06496f46303d1",
30
30
  "skills/chant-prometheus-kubernetes.md": "cca016857891f4cabf1feb6f9db83c220a2e6ece200cd89e635851079f8070a8"
31
31
  },
32
- "composite": "a3bd43c75d606ca0275e63d0914a6a408b8440cd959bed0f7b1851e95f764c3d"
32
+ "composite": "8b2ba0ff40ccef3c1d249feb781800864ff140a2c2481e858a9064323432bbd3"
33
33
  }
@@ -1 +1 @@
1
- {"version":3,"file":"literal-credential.d.ts","sourceRoot":"","sources":["../../../src/lint/rules/literal-credential.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAA+B,MAAM,4BAA4B,CAAC;AAGxF;;;GAGG;AACH,eAAO,MAAM,aAAa,aAaxB,CAAC;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,EAAE,QAkDnC,CAAC"}
1
+ {"version":3,"file":"literal-credential.d.ts","sourceRoot":"","sources":["../../../src/lint/rules/literal-credential.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAA+B,MAAM,4BAA4B,CAAC;AAGxF;;;GAGG;AACH,eAAO,MAAM,aAAa,aAaxB,CAAC;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,EAAE,QAwDnC,CAAC"}
@@ -11,4 +11,12 @@ export declare function position(source: ts.SourceFile, node: ts.Node): {
11
11
  line: number;
12
12
  column: number;
13
13
  };
14
+ /**
15
+ * Every `const name = <initializer>` in the file, so a rule can follow a
16
+ * value lifted out of a constructor into a named const (the way COR001 asks
17
+ * for it, and the way `chant import` writes it) back to its literal.
18
+ */
19
+ export declare function constInitializers(source: ts.SourceFile): Map<string, ts.Expression>;
20
+ /** `expr` itself, or the initializer of the const it names (followed through `as` and `satisfies`). */
21
+ export declare function resolveConst(expr: ts.Expression, consts: Map<string, ts.Expression>): ts.Expression;
14
22
  //# sourceMappingURL=prom-ast.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"prom-ast.d.ts","sourceRoot":"","sources":["../../../src/lint/rules/prom-ast.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,sGAAsG;AACtG,wBA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;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,GAAG,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,CAYnF;AAED,uGAAuG;AACvG,wBAAgB,YAAY,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,UAAU,CAcnG"}
@@ -1 +1 @@
1
- {"version":3,"file":"promql-literal.d.ts","sourceRoot":"","sources":["../../../src/lint/rules/promql-literal.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAA+B,MAAM,4BAA4B,CAAC;AAIxF;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,EAAE,QAyC/B,CAAC"}
1
+ {"version":3,"file":"promql-literal.d.ts","sourceRoot":"","sources":["../../../src/lint/rules/promql-literal.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAA+B,MAAM,4BAA4B,CAAC;AAIxF;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,EAAE,QAuD/B,CAAC"}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prometheus",
3
- "version": "0.96.0",
3
+ "version": "0.98.0",
4
4
  "chantVersion": ">=0.1.0",
5
5
  "namespace": "Prometheus",
6
6
  "intrinsics": [],
package/dist/model.d.ts CHANGED
@@ -176,6 +176,8 @@ export interface PagerDutyConfig extends NotifierBase {
176
176
  /** One entry under `receivers:`. */
177
177
  export interface ReceiverConfig {
178
178
  name: string;
179
+ /** Labels on the receiver, exposed to notification templates. */
180
+ labels?: LabelSet;
179
181
  webhook_configs?: WebhookConfig[];
180
182
  email_configs?: EmailConfig[];
181
183
  slack_configs?: SlackConfig[];
@@ -193,10 +195,17 @@ export interface RouteConfig {
193
195
  repeat_interval?: string;
194
196
  mute_time_intervals?: string[];
195
197
  active_time_intervals?: string[];
198
+ /**
199
+ * Labels on the route, inherited by child routes and exposed to
200
+ * notification templates as `routeLabels`. Values may be Go templates.
201
+ */
202
+ labels?: LabelSet;
196
203
  routes?: RouteConfig[];
197
204
  }
198
205
  /** One entry under `inhibit_rules:`. */
199
206
  export interface InhibitRuleConfig {
207
+ /** A name for the rule, shown in Alertmanager's logs and metrics. */
208
+ name?: string;
200
209
  source_matchers?: string[];
201
210
  target_matchers?: string[];
202
211
  /** Labels that must be equal on source and target for the inhibition to apply. */
@@ -243,6 +252,17 @@ export interface AlertmanagerGlobalConfig {
243
252
  pagerduty_url?: string;
244
253
  http_config?: HttpClientConfig;
245
254
  }
255
+ /** `tracing:` settings: where Alertmanager sends its own traces. */
256
+ export interface AlertmanagerTracingConfig {
257
+ client_type?: "grpc" | "http";
258
+ endpoint?: string;
259
+ sampling_fraction?: number;
260
+ insecure?: boolean;
261
+ headers?: Record<string, string>;
262
+ compression?: string;
263
+ timeout?: string;
264
+ tls_config?: HttpClientConfig["tls_config"];
265
+ }
246
266
  /** A whole `alertmanager.yml`, the file `amtool check-config` reads. */
247
267
  export interface AlertmanagerConfig {
248
268
  global?: AlertmanagerGlobalConfig;
@@ -251,6 +271,7 @@ export interface AlertmanagerConfig {
251
271
  inhibit_rules?: InhibitRuleConfig[];
252
272
  receivers?: ReceiverConfig[];
253
273
  time_intervals?: TimeIntervalConfig[];
274
+ tracing?: AlertmanagerTracingConfig;
254
275
  }
255
276
  /** The four receiver integrations this lexicon types. */
256
277
  export declare const RECEIVER_INTEGRATIONS: readonly ["webhook_configs", "email_configs", "slack_configs", "pagerduty_configs"];
@@ -1 +1 @@
1
- {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,2DAA2D;AAC3D,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE9C,uFAAuF;AACvF,MAAM,WAAW,mBAAmB;IAClC,mFAAmF;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BAAgB,EAAE,aA6F9B,CAAC"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AA8B9D;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,EAAE,aAqG9B,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import * as ts from "typescript";
2
2
  import type { LintRule, LintDiagnostic, LintContext } from "@intentius/chant/lint/rule";
3
- import { calleeName, CREDENTIAL_CLASS, literalText, position, propertyName } from "./prom-ast";
3
+ import { calleeName, constInitializers, CREDENTIAL_CLASS, literalText, position, propertyName, resolveConst } from "./prom-ast";
4
4
 
5
5
  /**
6
6
  * Alertmanager fields that hold a secret, each with a `*_file` sibling that
@@ -41,13 +41,18 @@ export const literalCredentialRule: LintRule = {
41
41
  const diagnostics: LintDiagnostic[] = [];
42
42
  const source = context.sourceFile;
43
43
 
44
- const scanValue = (key: string | undefined, init: ts.Expression) => {
45
- if (ts.isObjectLiteralExpression(init)) {
46
- scan(init);
47
- return;
48
- }
49
- if (ts.isArrayLiteralExpression(init)) {
50
- for (const el of init.elements) if (ts.isObjectLiteralExpression(el)) scan(el);
44
+ const consts = constInitializers(source);
45
+ const scanned = new Set<ts.Node>();
46
+
47
+ // A value is followed to the const it names, so a list lifted out of the
48
+ // constructor (`email_configs: heartbeatEmail`) is scanned where it is used.
49
+ const scanValue = (key: string | undefined, value: ts.Expression) => {
50
+ const init = resolveConst(value, consts);
51
+ if (ts.isObjectLiteralExpression(init) || ts.isArrayLiteralExpression(init)) {
52
+ if (scanned.has(init)) return;
53
+ scanned.add(init);
54
+ if (ts.isObjectLiteralExpression(init)) scan(init);
55
+ else for (const el of init.elements) scanValue(undefined, el);
51
56
  return;
52
57
  }
53
58
  if (!key || !SECRET_FIELDS.has(key)) return;
@@ -64,8 +69,9 @@ export const literalCredentialRule: LintRule = {
64
69
 
65
70
  const scan = (obj: ts.ObjectLiteralExpression) => {
66
71
  for (const prop of obj.properties) {
67
- if (!ts.isPropertyAssignment(prop)) continue;
68
- scanValue(propertyName(prop), prop.initializer);
72
+ if (ts.isPropertyAssignment(prop)) scanValue(propertyName(prop), prop.initializer);
73
+ else if (ts.isShorthandPropertyAssignment(prop)) scanValue(prop.name.text, prop.name);
74
+ else if (ts.isSpreadAssignment(prop)) scanValue(undefined, prop.expression);
69
75
  }
70
76
  };
71
77
 
@@ -73,7 +79,7 @@ export const literalCredentialRule: LintRule = {
73
79
  if (ts.isNewExpression(node) || ts.isCallExpression(node)) {
74
80
  const name = calleeName(node);
75
81
  const arg = node.arguments?.[0];
76
- if (name && CREDENTIAL_CLASS.test(name) && arg && ts.isObjectLiteralExpression(arg)) scan(arg);
82
+ if (name && CREDENTIAL_CLASS.test(name) && arg) scanValue(undefined, arg);
77
83
  }
78
84
  ts.forEachChild(node, visit);
79
85
  };
@@ -28,3 +28,39 @@ export function position(source: ts.SourceFile, node: ts.Node): { line: number;
28
28
  const { line, character } = source.getLineAndCharacterOfPosition(node.getStart(source));
29
29
  return { line: line + 1, column: character + 1 };
30
30
  }
31
+
32
+ /**
33
+ * Every `const name = <initializer>` in the file, so a rule can follow a
34
+ * value lifted out of a constructor into a named const (the way COR001 asks
35
+ * for it, and the way `chant import` writes it) back to its literal.
36
+ */
37
+ export function constInitializers(source: ts.SourceFile): Map<string, ts.Expression> {
38
+ const consts = new Map<string, ts.Expression>();
39
+ const collect = (node: ts.Node) => {
40
+ if (ts.isVariableDeclarationList(node) && node.flags & ts.NodeFlags.Const) {
41
+ for (const d of node.declarations) {
42
+ if (ts.isIdentifier(d.name) && d.initializer) consts.set(d.name.text, d.initializer);
43
+ }
44
+ }
45
+ ts.forEachChild(node, collect);
46
+ };
47
+ collect(source);
48
+ return consts;
49
+ }
50
+
51
+ /** `expr` itself, or the initializer of the const it names (followed through `as` and `satisfies`). */
52
+ export function resolveConst(expr: ts.Expression, consts: Map<string, ts.Expression>): ts.Expression {
53
+ let cur = expr;
54
+ for (let hops = 0; hops < 8; hops++) {
55
+ if (ts.isAsExpression(cur) || ts.isSatisfiesExpression(cur) || ts.isParenthesizedExpression(cur)) {
56
+ cur = cur.expression;
57
+ continue;
58
+ }
59
+ if (ts.isIdentifier(cur) && consts.has(cur.text)) {
60
+ cur = consts.get(cur.text)!;
61
+ continue;
62
+ }
63
+ break;
64
+ }
65
+ return cur;
66
+ }
@@ -1,6 +1,6 @@
1
1
  import * as ts from "typescript";
2
2
  import type { LintRule, LintDiagnostic, LintContext } from "@intentius/chant/lint/rule";
3
- import { calleeName, literalText, position, propertyName } from "./prom-ast";
3
+ import { calleeName, constInitializers, literalText, position, propertyName, resolveConst } from "./prom-ast";
4
4
  import { checkPromql } from "../../promql";
5
5
 
6
6
  /**
@@ -21,7 +21,21 @@ export const promqlLiteralRule: LintRule = {
21
21
  const diagnostics: LintDiagnostic[] = [];
22
22
  const source = context.sourceFile;
23
23
 
24
+ const consts = constInitializers(source);
25
+ const scanned = new Set<ts.Node>();
26
+
27
+ // Rules lifted into a const (`rules: apiRules`) are followed to it and
28
+ // checked where the group uses them.
29
+ const follow = (value: ts.Expression) => {
30
+ const init = resolveConst(value, consts);
31
+ if (init !== value && !scanned.has(init)) {
32
+ scanned.add(init);
33
+ scan(init);
34
+ }
35
+ };
24
36
  const scan = (node: ts.Node) => {
37
+ if (ts.isShorthandPropertyAssignment(node)) follow(node.name);
38
+ if (ts.isPropertyAssignment(node) && ts.isIdentifier(node.initializer)) follow(node.initializer);
25
39
  if (ts.isPropertyAssignment(node) && propertyName(node) === "expr") {
26
40
  const text = literalText(node.initializer);
27
41
  if (text !== undefined) {
@@ -47,6 +47,10 @@ export const pageMutesTicket = new InhibitRule({
47
47
  });
48
48
  ```
49
49
 
50
+ ## Starting from an existing alertmanager.yml
51
+
52
+ Import it rather than retyping it: `chant import alertmanager.yml --output src` (with `--lexicon prometheus` outside a chant project). The importer writes `receivers.ts`, `time-intervals.ts`, `routes.ts` (the root `Route`, children as `RouteProps` that reference receivers and time intervals by variable), `inhibit-rules.ts` and `settings.ts`. `*_file` paths and Go templates are kept as written; a literal credential is imported as found and PROM001 reports it, so offer to move it to the `*_file` field. Integrations the lexicon doesn't type (`opsgenie_configs`, `msteams_configs`, ...) are spread in from an untyped const. `match`/`match_re` and the top-level `mute_time_intervals` come back in their current spelling (`matchers`, `time_intervals`), and `chant import` prints a warning for each.
53
+
50
54
  ## What the checks hold you to
51
55
 
52
56
  - One root route (the `Route` no other route nests), with a receiver and no matchers (PROM205).
@@ -15,6 +15,17 @@ The prometheus lexicon (`@intentius/chant-lexicon-prometheus`) types Prometheus
15
15
  export default { lexicons: ["prometheus"] };
16
16
  ```
17
17
 
18
+ ## Starting from an existing rule file
19
+
20
+ When the user already has a rule file, import it rather than retyping it:
21
+
22
+ ```bash
23
+ chant import rules.yml --output src # add --lexicon prometheus outside a chant project
24
+ chant build src --lexicon prometheus -o rules.yml # the same groups back
25
+ ```
26
+
27
+ The importer writes `rules.ts` (per group, a `Rule[]` const of plain objects and a `RuleGroup`) and `slos.ts` for any group an `Slo()` built, as the `Slo` call. Multi-line expressions become template literals and Go templates in annotations stay as written. Read the warnings `chant import` prints: they name any field Prometheus doesn't define, which is not carried.
28
+
18
29
  ## Declaring a group
19
30
 
20
31
  A group takes the rule file's own keys (`name`, `interval`, `query_offset`, `limit`, `labels`, `rules`). Rules are plain objects: `record` + `expr` for a recording rule, `alert` + `expr` (+ `for`, `keep_firing_for`, `labels`, `annotations`) for an alerting rule.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intentius/chant-lexicon-prometheus",
3
- "version": "0.96.0",
3
+ "version": "0.98.0",
4
4
  "description": "Prometheus lexicon for chant — typed recording and alerting rule groups and Alertmanager routing, serialized to a rule file and alertmanager.yml",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://intentius.io/chant",
@@ -71,7 +71,7 @@
71
71
  "typescript": "^5.9.3"
72
72
  },
73
73
  "peerDependencies": {
74
- "@intentius/chant": "^0.96.0",
74
+ "@intentius/chant": "^0.98.0",
75
75
  "typescript": "^5.9.3"
76
76
  }
77
77
  }
@@ -16,6 +16,7 @@ import { createResource } from "@intentius/chant/runtime";
16
16
  import type { Declarable } from "@intentius/chant/declarable";
17
17
  import type {
18
18
  AlertmanagerGlobalConfig,
19
+ AlertmanagerTracingConfig,
19
20
  InhibitRuleConfig,
20
21
  ReceiverConfig,
21
22
  RouteConfig,
@@ -112,13 +113,15 @@ export interface AlertmanagerSettingsProps {
112
113
  global?: AlertmanagerGlobalConfig;
113
114
  /** Paths of notification template files. */
114
115
  templates?: string[];
116
+ /** Where Alertmanager sends its own traces. */
117
+ tracing?: AlertmanagerTracingConfig;
115
118
  }
116
119
 
117
120
  export interface AlertmanagerSettingsEntity extends Declarable {
118
121
  readonly props: AlertmanagerSettingsProps;
119
122
  }
120
123
 
121
- /** The `global:` block and `templates:` list. Optional; declare at most one. */
124
+ /** The `global:` block, `templates:` list and `tracing:` block. Optional; declare at most one. */
122
125
  export const AlertmanagerSettings = entityClass<AlertmanagerSettingsProps, AlertmanagerSettingsEntity>(
123
126
  SETTINGS_TYPE,
124
127
  "AlertmanagerSettings",
package/src/build.ts CHANGED
@@ -109,6 +109,7 @@ function routeConfig(route: RouteEntity | RouteProps): RouteConfig {
109
109
  if (p.repeat_interval !== undefined) out.repeat_interval = p.repeat_interval;
110
110
  if (p.mute_time_intervals !== undefined) out.mute_time_intervals = p.mute_time_intervals.map(intervalName);
111
111
  if (p.active_time_intervals !== undefined) out.active_time_intervals = p.active_time_intervals.map(intervalName);
112
+ if (p.labels !== undefined) out.labels = { ...p.labels };
112
113
  if (p.routes !== undefined) out.routes = p.routes.map(routeConfig);
113
114
  return out;
114
115
  }
@@ -177,6 +178,7 @@ export function buildAlertmanagerConfig(entities: Iterable<Declarable> | Map<str
177
178
  intervals.sort((a, b) => byName(a.props.name, b.props.name));
178
179
  if (receivers.length > 0) config.receivers = receivers.map((r) => plain(r.props) as ReceiverConfig);
179
180
  if (intervals.length > 0) config.time_intervals = intervals.map((t) => plain(t.props) as TimeIntervalConfig);
181
+ if (settings?.props.tracing) config.tracing = plain(settings.props.tracing) as AlertmanagerConfig["tracing"];
180
182
 
181
183
  return { config, warnings, count };
182
184
  }
@@ -47,6 +47,10 @@ group names (PROM101), valid durations (PROM103), routes that name
47
47
  declared receivers (PROM201), and every alert severity routed by some route
48
48
  (PROM202). \`promtool check rules\` and \`amtool check-config\` are wrapped as
49
49
  helpers for tests and CI, and run when installed.
50
+
51
+ \`chant import\` turns an existing rule file or \`alertmanager.yml\` into this
52
+ TypeScript, and \`chant build\` on the result gives the file back (see
53
+ Importing Rule Files and alertmanager.yml).
50
54
  `;
51
55
 
52
56
  const outputFormat = `The prometheus lexicon serializes two files:
@@ -58,7 +62,7 @@ const outputFormat = `The prometheus lexicon serializes two files:
58
62
  - **\`alertmanager.yml\`**, from the \`AlertmanagerSettings\`, \`Route\`,
59
63
  \`InhibitRule\`, \`Receiver\` and \`TimeInterval\` entities, in that section
60
64
  order: \`global\`, \`templates\`, \`route\`, \`inhibit_rules\`, \`receivers\`,
61
- \`time_intervals\`.
65
+ \`time_intervals\`, \`tracing\`.
62
66
 
63
67
  The rule file is the primary output when the build declares any rule
64
68
  groups, and \`alertmanager.yml\` is written beside it (\`-o dist/rules.yml\`