@intentius/chant-lexicon-prometheus 0.101.0 → 0.104.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 (157) hide show
  1. package/README.md +3 -1
  2. package/dist/alertmanager.d.ts.map +1 -1
  3. package/dist/collector-metrics.d.ts +58 -0
  4. package/dist/collector-metrics.d.ts.map +1 -0
  5. package/dist/composites/genai.d.ts +1 -1
  6. package/dist/composites/genai.d.ts.map +1 -1
  7. package/dist/composites/slo.d.ts +1 -1
  8. package/dist/composites/slo.d.ts.map +1 -1
  9. package/dist/import/embedded.d.ts +12 -3
  10. package/dist/import/embedded.d.ts.map +1 -1
  11. package/dist/import/generator.d.ts +14 -0
  12. package/dist/import/generator.d.ts.map +1 -1
  13. package/dist/import/parser.d.ts.map +1 -1
  14. package/dist/index.d.ts +1 -1
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/init-templates.d.ts.map +1 -1
  17. package/dist/integrations.d.ts.map +1 -1
  18. package/dist/integrity.json +23 -7
  19. package/dist/lint/audit-catalog.d.ts +2 -0
  20. package/dist/lint/audit-catalog.d.ts.map +1 -1
  21. package/dist/lint/audit-lineage.d.ts +54 -0
  22. package/dist/lint/audit-lineage.d.ts.map +1 -0
  23. package/dist/lint/post-synth/index.d.ts.map +1 -1
  24. package/dist/lint/post-synth/prom-helpers.d.ts +9 -2
  25. package/dist/lint/post-synth/prom-helpers.d.ts.map +1 -1
  26. package/dist/lint/post-synth/prom208.d.ts +1 -1
  27. package/dist/lint/post-synth/prom209.d.ts +1 -1
  28. package/dist/lint/post-synth/prom210.d.ts +8 -0
  29. package/dist/lint/post-synth/prom210.d.ts.map +1 -0
  30. package/dist/lint/post-synth/prom211.d.ts +12 -0
  31. package/dist/lint/post-synth/prom211.d.ts.map +1 -0
  32. package/dist/lint/post-synth/prom212.d.ts +9 -0
  33. package/dist/lint/post-synth/prom212.d.ts.map +1 -0
  34. package/dist/lint/post-synth/prom213.d.ts +11 -0
  35. package/dist/lint/post-synth/prom213.d.ts.map +1 -0
  36. package/dist/lint/post-synth/prom214.d.ts +9 -0
  37. package/dist/lint/post-synth/prom214.d.ts.map +1 -0
  38. package/dist/lint/post-synth/prom215.d.ts +9 -0
  39. package/dist/lint/post-synth/prom215.d.ts.map +1 -0
  40. package/dist/lint/post-synth/prom216.d.ts +10 -0
  41. package/dist/lint/post-synth/prom216.d.ts.map +1 -0
  42. package/dist/lint/post-synth/prom217.d.ts +9 -0
  43. package/dist/lint/post-synth/prom217.d.ts.map +1 -0
  44. package/dist/lint/post-synth/prom218.d.ts +10 -0
  45. package/dist/lint/post-synth/prom218.d.ts.map +1 -0
  46. package/dist/lint/post-synth/prom219.d.ts +9 -0
  47. package/dist/lint/post-synth/prom219.d.ts.map +1 -0
  48. package/dist/lint/post-synth/prom220.d.ts +9 -0
  49. package/dist/lint/post-synth/prom220.d.ts.map +1 -0
  50. package/dist/lint/post-synth/prom221.d.ts +10 -0
  51. package/dist/lint/post-synth/prom221.d.ts.map +1 -0
  52. package/dist/lint/post-synth/prom222.d.ts +9 -0
  53. package/dist/lint/post-synth/prom222.d.ts.map +1 -0
  54. package/dist/lint/post-synth/prom223.d.ts +10 -0
  55. package/dist/lint/post-synth/prom223.d.ts.map +1 -0
  56. package/dist/lint/post-synth/prom224.d.ts +9 -0
  57. package/dist/lint/post-synth/prom224.d.ts.map +1 -0
  58. package/dist/lint/post-synth/prom301.d.ts +14 -0
  59. package/dist/lint/post-synth/prom301.d.ts.map +1 -0
  60. package/dist/lint/rules/literal-credential.d.ts.map +1 -1
  61. package/dist/manifest.json +1 -1
  62. package/dist/okf/index.md +16 -0
  63. package/dist/okf/rules/PROM210.md +11 -0
  64. package/dist/okf/rules/PROM211.md +11 -0
  65. package/dist/okf/rules/PROM212.md +11 -0
  66. package/dist/okf/rules/PROM213.md +11 -0
  67. package/dist/okf/rules/PROM214.md +11 -0
  68. package/dist/okf/rules/PROM215.md +11 -0
  69. package/dist/okf/rules/PROM216.md +11 -0
  70. package/dist/okf/rules/PROM217.md +11 -0
  71. package/dist/okf/rules/PROM218.md +11 -0
  72. package/dist/okf/rules/PROM219.md +11 -0
  73. package/dist/okf/rules/PROM220.md +11 -0
  74. package/dist/okf/rules/PROM221.md +11 -0
  75. package/dist/okf/rules/PROM222.md +11 -0
  76. package/dist/okf/rules/PROM223.md +11 -0
  77. package/dist/okf/rules/PROM224.md +11 -0
  78. package/dist/okf/rules/PROM301.md +11 -0
  79. package/dist/plugin.d.ts.map +1 -1
  80. package/dist/promql-analysis.d.ts +82 -0
  81. package/dist/promql-analysis.d.ts.map +1 -0
  82. package/dist/rule-eval.d.ts.map +1 -1
  83. package/dist/rules/literal-credential.ts +4 -0
  84. package/dist/rules/prom-helpers.ts +41 -2
  85. package/dist/rules/prom208.ts +1 -1
  86. package/dist/rules/prom209.ts +1 -1
  87. package/dist/rules/prom210.ts +17 -0
  88. package/dist/rules/prom211.ts +21 -0
  89. package/dist/rules/prom212.ts +18 -0
  90. package/dist/rules/prom213.ts +20 -0
  91. package/dist/rules/prom214.ts +18 -0
  92. package/dist/rules/prom215.ts +18 -0
  93. package/dist/rules/prom216.ts +19 -0
  94. package/dist/rules/prom217.ts +18 -0
  95. package/dist/rules/prom218.ts +19 -0
  96. package/dist/rules/prom219.ts +18 -0
  97. package/dist/rules/prom220.ts +18 -0
  98. package/dist/rules/prom221.ts +19 -0
  99. package/dist/rules/prom222.ts +18 -0
  100. package/dist/rules/prom223.ts +19 -0
  101. package/dist/rules/prom224.ts +18 -0
  102. package/dist/rules/prom301.ts +23 -0
  103. package/dist/skill-defs.d.ts +1 -1
  104. package/dist/skill-defs.d.ts.map +1 -1
  105. package/dist/skills/chant-prometheus-alertmanager.md +3 -1
  106. package/dist/validate-config.d.ts +9 -3
  107. package/dist/validate-config.d.ts.map +1 -1
  108. package/dist/validate-integrations.d.ts +38 -0
  109. package/dist/validate-integrations.d.ts.map +1 -0
  110. package/dist/validate-security.d.ts +13 -0
  111. package/dist/validate-security.d.ts.map +1 -0
  112. package/package.json +3 -3
  113. package/src/collector-metrics.ts +262 -0
  114. package/src/composites/composites.test.ts +2 -5
  115. package/src/import/embedded.test.ts +52 -3
  116. package/src/import/embedded.ts +37 -5
  117. package/src/import/generator.ts +19 -1
  118. package/src/import/testdata/alertmanager-integrations.yml +5 -1
  119. package/src/index.ts +1 -0
  120. package/src/init-templates.test.ts +3 -1
  121. package/src/lint/audit-catalog.ts +115 -2
  122. package/src/lint/audit-lineage.test.ts +74 -0
  123. package/src/lint/audit-lineage.ts +97 -0
  124. package/src/lint/post-synth/checks.test.ts +257 -0
  125. package/src/lint/post-synth/index.ts +32 -0
  126. package/src/lint/post-synth/post-synth.test.ts +37 -1
  127. package/src/lint/post-synth/prom-helpers.ts +41 -2
  128. package/src/lint/post-synth/prom208.ts +1 -1
  129. package/src/lint/post-synth/prom209.ts +1 -1
  130. package/src/lint/post-synth/prom210.ts +17 -0
  131. package/src/lint/post-synth/prom211.ts +21 -0
  132. package/src/lint/post-synth/prom212.ts +18 -0
  133. package/src/lint/post-synth/prom213.ts +20 -0
  134. package/src/lint/post-synth/prom214.ts +18 -0
  135. package/src/lint/post-synth/prom215.ts +18 -0
  136. package/src/lint/post-synth/prom216.ts +19 -0
  137. package/src/lint/post-synth/prom217.ts +18 -0
  138. package/src/lint/post-synth/prom218.ts +19 -0
  139. package/src/lint/post-synth/prom219.ts +18 -0
  140. package/src/lint/post-synth/prom220.ts +18 -0
  141. package/src/lint/post-synth/prom221.ts +19 -0
  142. package/src/lint/post-synth/prom222.ts +18 -0
  143. package/src/lint/post-synth/prom223.ts +19 -0
  144. package/src/lint/post-synth/prom224.ts +18 -0
  145. package/src/lint/post-synth/prom301.test.ts +157 -0
  146. package/src/lint/post-synth/prom301.ts +23 -0
  147. package/src/lint/rules/literal-credential.ts +4 -0
  148. package/src/lint/rules/rules.test.ts +16 -0
  149. package/src/plugin.test.ts +23 -0
  150. package/src/plugin.ts +14 -3
  151. package/src/promql-analysis.ts +365 -0
  152. package/src/skills/chant-prometheus-alertmanager.md +3 -1
  153. package/src/testdata/integration-cases.ts +96 -0
  154. package/src/tools.test.ts +6 -0
  155. package/src/validate-config.ts +279 -33
  156. package/src/validate-integrations.ts +389 -0
  157. package/src/validate-security.ts +143 -0
@@ -0,0 +1,21 @@
1
+ /**
2
+ * PROM211: An alerting rule has no for, or for: 0s
3
+ *
4
+ * The alert fires on the first evaluation that matches, so one bad scrape
5
+ * pages. Left alone when the expression reads no series (vector(1), a dead
6
+ * man's switch) or already spans a window: every selector read through a
7
+ * *_over_time function, or two conditions joined by and (the multi-window
8
+ * burn-rate form, where the short window does what for would).
9
+ */
10
+
11
+ import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
12
+ import { ruleFileDiagnostics } from "./prom-helpers";
13
+
14
+ export const prom211: PostSynthCheck = {
15
+ id: "PROM211",
16
+ description: "An alerting rule has no for, or for: 0s",
17
+
18
+ check(ctx: PostSynthContext): PostSynthDiagnostic[] {
19
+ return ruleFileDiagnostics(ctx, "PROM211");
20
+ },
21
+ };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * PROM212: An alerting rule has no runbook_url annotation (opt-in)
3
+ *
4
+ * Off unless enabled: the lint preset all, or a lint.rules entry for PROM212,
5
+ * turns it on. See validateRunbookUrls.
6
+ */
7
+
8
+ import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
9
+ import { runbookDiagnostics } from "./prom-helpers";
10
+
11
+ export const prom212: PostSynthCheck = {
12
+ id: "PROM212",
13
+ description: "An alerting rule has no runbook_url annotation (opt-in)",
14
+
15
+ check(ctx: PostSynthContext): PostSynthDiagnostic[] {
16
+ return runbookDiagnostics(ctx);
17
+ },
18
+ };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * PROM213: An alert expression has no comparison
3
+ *
4
+ * Every series the expression returns is an alert, so an expression with no
5
+ * comparison fires for all of them. absent(), absent_over_time() and unless
6
+ * count as a condition; a comparison with bool does not. An expression that
7
+ * reads no series (vector(1), a dead man's switch) is left alone.
8
+ */
9
+
10
+ import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
11
+ import { ruleFileDiagnostics } from "./prom-helpers";
12
+
13
+ export const prom213: PostSynthCheck = {
14
+ id: "PROM213",
15
+ description: "An alert expression has no comparison",
16
+
17
+ check(ctx: PostSynthContext): PostSynthDiagnostic[] {
18
+ return ruleFileDiagnostics(ctx, "PROM213");
19
+ },
20
+ };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * PROM214: An alert template reads a label the expression aggregates away
3
+ *
4
+ * A $labels.x whose x the expression's by (...) leaves out, or its without
5
+ * (...) names, renders empty. Labels the rule or its group set are left alone.
6
+ */
7
+
8
+ import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
9
+ import { ruleFileDiagnostics } from "./prom-helpers";
10
+
11
+ export const prom214: PostSynthCheck = {
12
+ id: "PROM214",
13
+ description: "An alert template reads a label the expression aggregates away",
14
+
15
+ check(ctx: PostSynthContext): PostSynthDiagnostic[] {
16
+ return ruleFileDiagnostics(ctx, "PROM214");
17
+ },
18
+ };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * PROM215: rate, irate or increase over a name that is not a counter's
3
+ *
4
+ * These functions treat every drop as a counter reset. A name not ending in
5
+ * _total, _count, _sum or _bucket is read as a gauge.
6
+ */
7
+
8
+ import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
9
+ import { ruleFileDiagnostics } from "./prom-helpers";
10
+
11
+ export const prom215: PostSynthCheck = {
12
+ id: "PROM215",
13
+ description: "rate, irate or increase over a name that is not a counter's",
14
+
15
+ check(ctx: PostSynthContext): PostSynthDiagnostic[] {
16
+ return ruleFileDiagnostics(ctx, "PROM215");
17
+ },
18
+ };
@@ -0,0 +1,19 @@
1
+ /**
2
+ * PROM216: histogram_quantile over a series without _bucket, or without le
3
+ *
4
+ * A classic histogram's quantile needs its _bucket series with the le label
5
+ * kept. A native histogram has no _bucket series, so this check does not apply
6
+ * to one.
7
+ */
8
+
9
+ import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
10
+ import { ruleFileDiagnostics } from "./prom-helpers";
11
+
12
+ export const prom216: PostSynthCheck = {
13
+ id: "PROM216",
14
+ description: "histogram_quantile over a series without _bucket, or without le",
15
+
16
+ check(ctx: PostSynthContext): PostSynthDiagnostic[] {
17
+ return ruleFileDiagnostics(ctx, "PROM216");
18
+ },
19
+ };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * PROM217: A recording rule name is not in level:metric:operations form
3
+ *
4
+ * Prometheus's naming convention for recorded series, e.g.
5
+ * job:http_requests:rate5m.
6
+ */
7
+
8
+ import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
9
+ import { ruleFileDiagnostics } from "./prom-helpers";
10
+
11
+ export const prom217: PostSynthCheck = {
12
+ id: "PROM217",
13
+ description: "A recording rule name is not in level:metric:operations form",
14
+
15
+ check(ctx: PostSynthContext): PostSynthDiagnostic[] {
16
+ return ruleFileDiagnostics(ctx, "PROM217");
17
+ },
18
+ };
@@ -0,0 +1,19 @@
1
+ /**
2
+ * PROM218: A regex matcher needs no regex, or is anchored
3
+ *
4
+ * A =~ or !~ with no regex metacharacters is an equality matcher written the
5
+ * slow way. Prometheus anchors every regex, so a leading ^ or trailing $ does
6
+ * nothing.
7
+ */
8
+
9
+ import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
10
+ import { ruleFileDiagnostics } from "./prom-helpers";
11
+
12
+ export const prom218: PostSynthCheck = {
13
+ id: "PROM218",
14
+ description: "A regex matcher needs no regex, or is anchored",
15
+
16
+ check(ctx: PostSynthContext): PostSynthDiagnostic[] {
17
+ return ruleFileDiagnostics(ctx, "PROM218");
18
+ },
19
+ };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * PROM219: An alerting rule sets the alertname label
3
+ *
4
+ * Prometheus sets alertname to the rule's name after applying the rule's
5
+ * labels, so the value is overwritten.
6
+ */
7
+
8
+ import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
9
+ import { ruleFileDiagnostics } from "./prom-helpers";
10
+
11
+ export const prom219: PostSynthCheck = {
12
+ id: "PROM219",
13
+ description: "An alerting rule sets the alertname label",
14
+
15
+ check(ctx: PostSynthContext): PostSynthDiagnostic[] {
16
+ return ruleFileDiagnostics(ctx, "PROM219");
17
+ },
18
+ };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * PROM220: A receiver turns off TLS certificate verification
3
+ *
4
+ * tls_config.insecure_skip_verify: true on a receiver, or in global, accepts
5
+ * any certificate the endpoint presents.
6
+ */
7
+
8
+ import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
9
+ import { alertmanagerDiagnostics } from "./prom-helpers";
10
+
11
+ export const prom220: PostSynthCheck = {
12
+ id: "PROM220",
13
+ description: "A receiver turns off TLS certificate verification",
14
+
15
+ check(ctx: PostSynthContext): PostSynthDiagnostic[] {
16
+ return alertmanagerDiagnostics(ctx, "PROM220");
17
+ },
18
+ };
@@ -0,0 +1,19 @@
1
+ /**
2
+ * PROM221: SMTP credentials sent with require_tls false
3
+ *
4
+ * An email receiver with SMTP auth and require_tls false (its own, or
5
+ * global.smtp_require_tls) can send the credentials in clear text. Implicit
6
+ * TLS is left alone.
7
+ */
8
+
9
+ import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
10
+ import { alertmanagerDiagnostics } from "./prom-helpers";
11
+
12
+ export const prom221: PostSynthCheck = {
13
+ id: "PROM221",
14
+ description: "SMTP credentials sent with require_tls false",
15
+
16
+ check(ctx: PostSynthContext): PostSynthDiagnostic[] {
17
+ return alertmanagerDiagnostics(ctx, "PROM221");
18
+ },
19
+ };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * PROM222: Credentials sent to an http:// receiver URL
3
+ *
4
+ * An integration whose URL is http:// and whose request carries a credential:
5
+ * user info in the URL, http_config auth, or a key or token field.
6
+ */
7
+
8
+ import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
9
+ import { alertmanagerDiagnostics } from "./prom-helpers";
10
+
11
+ export const prom222: PostSynthCheck = {
12
+ id: "PROM222",
13
+ description: "Credentials sent to an http:// receiver URL",
14
+
15
+ check(ctx: PostSynthContext): PostSynthDiagnostic[] {
16
+ return alertmanagerDiagnostics(ctx, "PROM222");
17
+ },
18
+ };
@@ -0,0 +1,19 @@
1
+ /**
2
+ * PROM223: repeat_interval is shorter than group_interval
3
+ *
4
+ * Alertmanager resends only when it flushes a group, every group_interval, so
5
+ * a shorter repeat_interval never takes effect. Intervals are inherited down
6
+ * the routing tree from Alertmanager's defaults.
7
+ */
8
+
9
+ import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
10
+ import { alertmanagerDiagnostics } from "./prom-helpers";
11
+
12
+ export const prom223: PostSynthCheck = {
13
+ id: "PROM223",
14
+ description: "repeat_interval is shorter than group_interval",
15
+
16
+ check(ctx: PostSynthContext): PostSynthDiagnostic[] {
17
+ return alertmanagerDiagnostics(ctx, "PROM223");
18
+ },
19
+ };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * PROM224: An inhibit rule matches one alert as source and target, with no equal
3
+ *
4
+ * With no equal, any alert matching the source mutes every alert matching the
5
+ * target. When one alert can match both, alerts of that kind mute each other.
6
+ */
7
+
8
+ import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
9
+ import { alertmanagerDiagnostics } from "./prom-helpers";
10
+
11
+ export const prom224: PostSynthCheck = {
12
+ id: "PROM224",
13
+ description: "An inhibit rule matches one alert as source and target, with no equal",
14
+
15
+ check(ctx: PostSynthContext): PostSynthDiagnostic[] {
16
+ return alertmanagerDiagnostics(ctx, "PROM224");
17
+ },
18
+ };
@@ -0,0 +1,23 @@
1
+ /**
2
+ * PROM301: A rule reads a connector metric no collector in the build emits
3
+ *
4
+ * For each selector in a rule whose name falls under a namespace the build's
5
+ * spanmetrics, servicegraph or GenAI connectors own (spanmetrics' and
6
+ * servicegraph's defaults included), reports a name no collector config in
7
+ * the build emits, and a by (...) label that is not a dimension the config
8
+ * declares for the metrics aggregated. Silent for names outside those
9
+ * namespaces, and when the build has no collector config. See
10
+ * ../../collector-metrics.ts.
11
+ */
12
+
13
+ import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
14
+ import { collectorMetricDiagnostics } from "./prom-helpers";
15
+
16
+ export const prom301: PostSynthCheck = {
17
+ id: "PROM301",
18
+ description: "A rule reads a connector metric no collector in the build emits",
19
+
20
+ check(ctx: PostSynthContext): PostSynthDiagnostic[] {
21
+ return collectorMetricDiagnostics(ctx);
22
+ },
23
+ };
@@ -1,3 +1,3 @@
1
1
  /** The prometheus lexicon's AI skills, read from src/skills/. */
2
- export declare const prometheusSkills: () => import("packages/core/src").SkillDefinition[];
2
+ export declare const prometheusSkills: () => import("@intentius/chant").SkillDefinition[];
3
3
  //# sourceMappingURL=skill-defs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"skill-defs.d.ts","sourceRoot":"","sources":["../src/skill-defs.ts"],"names":[],"mappings":"AAEA,iEAAiE;AACjE,eAAO,MAAM,gBAAgB,qDAuC3B,CAAC"}
1
+ {"version":3,"file":"skill-defs.d.ts","sourceRoot":"","sources":["../src/skill-defs.ts"],"names":[],"mappings":"AAEA,iEAAiE;AACjE,eAAO,MAAM,gBAAgB,oDAuC3B,CAAC"}
@@ -57,6 +57,8 @@ Import it rather than retyping it: `chant import alertmanager.yml --output src`
57
57
  - Routes name receivers and time intervals that exist (PROM201, PROM204). Reference the entity rather than a string and TypeScript does most of this.
58
58
  - Every `severity` an alert in the same build root carries is matched by some route below the root (PROM202). The check only sees one build root (chant #1939): keep the rules and the Alertmanager config in the same one, or it goes quiet.
59
59
  - Credentials go in `*_file` fields. Alertmanager does not expand environment variables in its config, and a literal `api_url`, `routing_key` or `auth_password` is flagged (PROM001).
60
- - Each integration has somewhere to send (PROM209): a webhook `url`, a Slack `api_url` (or `global.slack_api_url`), a PagerDuty key, an email `to`/`smarthost`/`from` (or the global SMTP defaults).
60
+ - Each integration has its destination, credential and required fields, or the `global` default it falls back to (PROM209): a webhook `url`, a Slack `api_url` or app token, an Opsgenie `api_key`, a Telegram `chat_id` and bot token, a Webex `room_id` and `http_config.authorization`, one SNS target, a Jira `project` and `issue_type`, an email `to`/`smarthost`/`from`, and so on.
61
+ - No setting Alertmanager rejects (PROM210): a value and its `*_file` both set, a Slack `api_url` with an app token, `update_message` without `api_url: https://slack.com/api/chat.postMessage`, a WeChat `message_type` other than `text`/`markdown`, a Telegram `parse_mode` other than `Markdown`/`MarkdownV2`/`HTML`.
62
+ - Durations parse (PROM208). Route timers and `resolve_timeout` take `1d`; the integration `timeout`s and Pushover `retry`/`expire`/`ttl` are Go durations and take `24h`, not `1d`.
61
63
 
62
64
  Run `amtoolCheckConfig(alertmanagerYaml(entities))` in a test to have `amtool check-config` confirm it when installed.
@@ -7,7 +7,7 @@
7
7
  * `PrometheusRule`'s groups, or on a file parsed by some other tool.
8
8
  */
9
9
  import { type AlertmanagerConfig, type RuleFileConfig } from "./model.js";
10
- export type PrometheusIssueCode = "PROM101" | "PROM102" | "PROM103" | "PROM104" | "PROM105" | "PROM106" | "PROM107" | "PROM201" | "PROM202" | "PROM203" | "PROM204" | "PROM205" | "PROM206" | "PROM207" | "PROM208" | "PROM209";
10
+ export type PrometheusIssueCode = "PROM101" | "PROM102" | "PROM103" | "PROM104" | "PROM105" | "PROM106" | "PROM107" | "PROM201" | "PROM202" | "PROM203" | "PROM204" | "PROM205" | "PROM206" | "PROM207" | "PROM208" | "PROM209" | "PROM210" | "PROM211" | "PROM212" | "PROM213" | "PROM214" | "PROM215" | "PROM216" | "PROM217" | "PROM218" | "PROM219" | "PROM220" | "PROM221" | "PROM222" | "PROM223" | "PROM224";
11
11
  export interface PrometheusIssue {
12
12
  code: PrometheusIssueCode;
13
13
  severity: "error" | "warning";
@@ -15,11 +15,17 @@ export interface PrometheusIssue {
15
15
  /** What the issue is about: a group, a rule (`group/rule`), a receiver or a route. */
16
16
  subject?: string;
17
17
  }
18
- /** Check a rule file (PROM101-PROM107). */
18
+ /** Check a rule file (PROM101-PROM107, PROM211 and PROM213-PROM219). PROM212 is opt-in; see {@link validateRunbookUrls}. */
19
19
  export declare function validateRuleFile(file: RuleFileConfig): PrometheusIssue[];
20
+ /**
21
+ * PROM212: alerts without a `runbook_url` annotation. Not part of
22
+ * {@link validateRuleFile}, because the check is opt-in: the lint preset
23
+ * `all`, or a `lint.rules` entry for PROM212, turns it on.
24
+ */
25
+ export declare function validateRunbookUrls(file: RuleFileConfig): PrometheusIssue[];
20
26
  /** Every severity value an alert in these rule files carries, with the alerts carrying it. */
21
27
  export declare function alertSeverities(files: RuleFileConfig[]): Map<string, string[]>;
22
- /** Check an `alertmanager.yml` on its own (PROM201, PROM203-PROM209). */
28
+ /** Check an `alertmanager.yml` on its own (PROM201, PROM203-PROM210, PROM220-PROM224). */
23
29
  export declare function validateAlertmanagerConfig(config: AlertmanagerConfig): PrometheusIssue[];
24
30
  /**
25
31
  * PROM202: every severity an alert carries is taken by some route below the
@@ -1 +1 @@
1
- {"version":3,"file":"validate-config.d.ts","sourceRoot":"","sources":["../src/validate-config.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAGL,KAAK,kBAAkB,EAIvB,KAAK,cAAc,EAEpB,MAAM,SAAS,CAAC;AAGjB,MAAM,MAAM,mBAAmB,GAC3B,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,CAAC;AAEd,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,mBAAmB,CAAC;IAC1B,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,sFAAsF;IACtF,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAmBD,2CAA2C;AAC3C,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,cAAc,GAAG,eAAe,EAAE,CAsHxE;AAED,8FAA8F;AAC9F,wBAAgB,eAAe,CAAC,KAAK,EAAE,cAAc,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAa9E;AAsBD,yEAAyE;AACzE,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,kBAAkB,GAAG,eAAe,EAAE,CA4HxF;AAYD;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,cAAc,EAAE,EAAE,MAAM,EAAE,kBAAkB,GAAG,eAAe,EAAE,CA6BlH"}
1
+ {"version":3,"file":"validate-config.d.ts","sourceRoot":"","sources":["../src/validate-config.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAGL,KAAK,kBAAkB,EAIvB,KAAK,cAAc,EAEpB,MAAM,SAAS,CAAC;AAiBjB,MAAM,MAAM,mBAAmB,GAC3B,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,CAAC;AAEd,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,mBAAmB,CAAC;IAC1B,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,sFAAsF;IACtF,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAwID,4HAA4H;AAC5H,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,cAAc,GAAG,eAAe,EAAE,CAmIxE;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,cAAc,GAAG,eAAe,EAAE,CAU3E;AAED,8FAA8F;AAC9F,wBAAgB,eAAe,CAAC,KAAK,EAAE,cAAc,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAa9E;AAkGD,0FAA0F;AAC1F,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,kBAAkB,GAAG,eAAe,EAAE,CAsHxF;AAYD;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,cAAc,EAAE,EAAE,MAAM,EAAE,kBAAkB,GAAG,eAAe,EAAE,CA6BlH"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Receiver integration and `global:` checks for `alertmanager.yml`
3
+ * (PROM208-PROM210), one case per validation Alertmanager v0.34.1 makes when
4
+ * it loads the file (see ./pin.ts). Sources, under
5
+ * github.com/prometheus/alertmanager at that tag:
6
+ *
7
+ * - `config/notifiers.go`: the `UnmarshalYAML` of the Email, Slack (and its
8
+ * fields, actions and confirmations), WeChat, VictorOps, Pushover, SNS,
9
+ * Rocket.Chat and Webex configs.
10
+ * - `notify/<name>/config.go`: the `UnmarshalYAML` of the Discord,
11
+ * incident.io, Jira, Mattermost (and its fields), MS Teams, MS Teams v2,
12
+ * Opsgenie, PagerDuty, Telegram and webhook configs.
13
+ * - `config/config.go`: `Config.UnmarshalYAML`, which fills each
14
+ * integration from its `global:` default and then rejects what is still
15
+ * missing, and the `global:` "at most one of" checks; `HostPort` for
16
+ * `smarthost`.
17
+ *
18
+ * Durations come in two grammars. `model.Duration` fields (`resolve_timeout`,
19
+ * the route timers, Jira `reopen_duration`) use Prometheus's, see
20
+ * ./duration.ts. `time.Duration` fields (the `timeout` of webhook, Slack,
21
+ * PagerDuty and incident.io, and Pushover's `retry`, `expire` and `ttl`)
22
+ * use Go's `time.ParseDuration`: `1.5s` and `300ms` are valid, `1d` is not.
23
+ *
24
+ * Alertmanager stops at the first error; these checks report every one.
25
+ * PROM209 is something missing (a destination, credential or required
26
+ * field), PROM210 a setting Alertmanager rejects (two settings that exclude
27
+ * each other, or a value outside the allowed set), PROM208 a duration.
28
+ */
29
+ import type { AlertmanagerGlobalConfig, ReceiverConfig } from "./model.js";
30
+ import type { PrometheusIssue } from "./validate-config.js";
31
+ /** True when `value` is a Go `time.ParseDuration` duration (`0`, `1.5s`, `1h30m`, `300ms`). */
32
+ export declare function isValidGoDuration(value: unknown): boolean;
33
+ export declare const SLACK_APP_URL = "https://slack.com/api/chat.postMessage";
34
+ /** PROM208-PROM210 findings for every integration of one receiver. */
35
+ export declare function validateReceiverIntegrations(receiver: ReceiverConfig, global: AlertmanagerGlobalConfig): PrometheusIssue[];
36
+ /** PROM208 and PROM210 findings for `global:` (config/config.go `Config.UnmarshalYAML`). */
37
+ export declare function validateGlobalSettings(global: AlertmanagerGlobalConfig): PrometheusIssue[];
38
+ //# sourceMappingURL=validate-integrations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-integrations.d.ts","sourceRoot":"","sources":["../src/validate-integrations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,KAAK,EAAE,wBAAwB,EAAoB,cAAc,EAAE,MAAM,SAAS,CAAC;AAC1F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAwBzD,+FAA+F;AAC/F,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAKzD;AAkBD,eAAO,MAAM,aAAa,2CAA2C,CAAC;AA2QtE,sEAAsE;AACtE,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,wBAAwB,GAAG,eAAe,EAAE,CAS1H;AAgBD,4FAA4F;AAC5F,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,wBAAwB,GAAG,eAAe,EAAE,CAe1F"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Settings Alertmanager accepts that weaken how it talks to a receiver
3
+ * (PROM220-PROM222): certificate checks turned off, SMTP credentials sent
4
+ * without TLS, and credentials sent to an `http://` URL. `amtool
5
+ * check-config` passes all three.
6
+ */
7
+ import type { AlertmanagerGlobalConfig, ReceiverConfig } from "./model.js";
8
+ import type { PrometheusIssue } from "./validate-config.js";
9
+ /** PROM220-PROM222 for one receiver. */
10
+ export declare function validateReceiverSecurity(receiver: ReceiverConfig, global: AlertmanagerGlobalConfig): PrometheusIssue[];
11
+ /** PROM220 for `global:`'s own TLS settings, which every receiver without its own inherits. */
12
+ export declare function validateGlobalSecurity(global: AlertmanagerGlobalConfig): PrometheusIssue[];
13
+ //# sourceMappingURL=validate-security.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-security.d.ts","sourceRoot":"","sources":["../src/validate-security.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACxE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AA4DzD,wCAAwC;AACxC,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,wBAAwB,GAAG,eAAe,EAAE,CA+DtH;AAED,+FAA+F;AAC/F,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,wBAAwB,GAAG,eAAe,EAAE,CAO1F"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intentius/chant-lexicon-prometheus",
3
- "version": "0.101.0",
3
+ "version": "0.104.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",
@@ -56,7 +56,7 @@
56
56
  "validate": "tsx src/validate-cli.ts",
57
57
  "docs": "tsx src/codegen/docs-cli.ts",
58
58
  "prepack": "npm run generate && npm run bundle && npm run validate && npm run build",
59
- "build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json && find dist -type f \\( -name \"*.js\" -o -name \"*.js.map\" \\) -delete"
59
+ "build": "../../scripts/tsc7.sh -p tsconfig.build.json && tsc-alias -p tsconfig.build.json && find dist -type f \\( -name \"*.js\" -o -name \"*.js.map\" \\) -delete"
60
60
  },
61
61
  "dependencies": {
62
62
  "@intentius/chant-lexicon-otel": "*",
@@ -72,7 +72,7 @@
72
72
  "typescript": "^5.9.3"
73
73
  },
74
74
  "peerDependencies": {
75
- "@intentius/chant": "^0.101.0",
75
+ "@intentius/chant": "^0.104.0",
76
76
  "typescript": "^5.9.3"
77
77
  }
78
78
  }