@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.
- package/README.md +3 -1
- package/dist/alertmanager.d.ts.map +1 -1
- package/dist/collector-metrics.d.ts +58 -0
- package/dist/collector-metrics.d.ts.map +1 -0
- package/dist/composites/genai.d.ts +1 -1
- package/dist/composites/genai.d.ts.map +1 -1
- package/dist/composites/slo.d.ts +1 -1
- package/dist/composites/slo.d.ts.map +1 -1
- package/dist/import/embedded.d.ts +12 -3
- package/dist/import/embedded.d.ts.map +1 -1
- package/dist/import/generator.d.ts +14 -0
- package/dist/import/generator.d.ts.map +1 -1
- package/dist/import/parser.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/init-templates.d.ts.map +1 -1
- package/dist/integrations.d.ts.map +1 -1
- package/dist/integrity.json +23 -7
- package/dist/lint/audit-catalog.d.ts +2 -0
- package/dist/lint/audit-catalog.d.ts.map +1 -1
- package/dist/lint/audit-lineage.d.ts +54 -0
- package/dist/lint/audit-lineage.d.ts.map +1 -0
- package/dist/lint/post-synth/index.d.ts.map +1 -1
- package/dist/lint/post-synth/prom-helpers.d.ts +9 -2
- package/dist/lint/post-synth/prom-helpers.d.ts.map +1 -1
- package/dist/lint/post-synth/prom208.d.ts +1 -1
- package/dist/lint/post-synth/prom209.d.ts +1 -1
- package/dist/lint/post-synth/prom210.d.ts +8 -0
- package/dist/lint/post-synth/prom210.d.ts.map +1 -0
- package/dist/lint/post-synth/prom211.d.ts +12 -0
- package/dist/lint/post-synth/prom211.d.ts.map +1 -0
- package/dist/lint/post-synth/prom212.d.ts +9 -0
- package/dist/lint/post-synth/prom212.d.ts.map +1 -0
- package/dist/lint/post-synth/prom213.d.ts +11 -0
- package/dist/lint/post-synth/prom213.d.ts.map +1 -0
- package/dist/lint/post-synth/prom214.d.ts +9 -0
- package/dist/lint/post-synth/prom214.d.ts.map +1 -0
- package/dist/lint/post-synth/prom215.d.ts +9 -0
- package/dist/lint/post-synth/prom215.d.ts.map +1 -0
- package/dist/lint/post-synth/prom216.d.ts +10 -0
- package/dist/lint/post-synth/prom216.d.ts.map +1 -0
- package/dist/lint/post-synth/prom217.d.ts +9 -0
- package/dist/lint/post-synth/prom217.d.ts.map +1 -0
- package/dist/lint/post-synth/prom218.d.ts +10 -0
- package/dist/lint/post-synth/prom218.d.ts.map +1 -0
- package/dist/lint/post-synth/prom219.d.ts +9 -0
- package/dist/lint/post-synth/prom219.d.ts.map +1 -0
- package/dist/lint/post-synth/prom220.d.ts +9 -0
- package/dist/lint/post-synth/prom220.d.ts.map +1 -0
- package/dist/lint/post-synth/prom221.d.ts +10 -0
- package/dist/lint/post-synth/prom221.d.ts.map +1 -0
- package/dist/lint/post-synth/prom222.d.ts +9 -0
- package/dist/lint/post-synth/prom222.d.ts.map +1 -0
- package/dist/lint/post-synth/prom223.d.ts +10 -0
- package/dist/lint/post-synth/prom223.d.ts.map +1 -0
- package/dist/lint/post-synth/prom224.d.ts +9 -0
- package/dist/lint/post-synth/prom224.d.ts.map +1 -0
- package/dist/lint/post-synth/prom301.d.ts +14 -0
- package/dist/lint/post-synth/prom301.d.ts.map +1 -0
- package/dist/lint/rules/literal-credential.d.ts.map +1 -1
- package/dist/manifest.json +1 -1
- package/dist/okf/index.md +16 -0
- package/dist/okf/rules/PROM210.md +11 -0
- package/dist/okf/rules/PROM211.md +11 -0
- package/dist/okf/rules/PROM212.md +11 -0
- package/dist/okf/rules/PROM213.md +11 -0
- package/dist/okf/rules/PROM214.md +11 -0
- package/dist/okf/rules/PROM215.md +11 -0
- package/dist/okf/rules/PROM216.md +11 -0
- package/dist/okf/rules/PROM217.md +11 -0
- package/dist/okf/rules/PROM218.md +11 -0
- package/dist/okf/rules/PROM219.md +11 -0
- package/dist/okf/rules/PROM220.md +11 -0
- package/dist/okf/rules/PROM221.md +11 -0
- package/dist/okf/rules/PROM222.md +11 -0
- package/dist/okf/rules/PROM223.md +11 -0
- package/dist/okf/rules/PROM224.md +11 -0
- package/dist/okf/rules/PROM301.md +11 -0
- package/dist/plugin.d.ts.map +1 -1
- package/dist/promql-analysis.d.ts +82 -0
- package/dist/promql-analysis.d.ts.map +1 -0
- package/dist/rule-eval.d.ts.map +1 -1
- package/dist/rules/literal-credential.ts +4 -0
- package/dist/rules/prom-helpers.ts +41 -2
- package/dist/rules/prom208.ts +1 -1
- package/dist/rules/prom209.ts +1 -1
- package/dist/rules/prom210.ts +17 -0
- package/dist/rules/prom211.ts +21 -0
- package/dist/rules/prom212.ts +18 -0
- package/dist/rules/prom213.ts +20 -0
- package/dist/rules/prom214.ts +18 -0
- package/dist/rules/prom215.ts +18 -0
- package/dist/rules/prom216.ts +19 -0
- package/dist/rules/prom217.ts +18 -0
- package/dist/rules/prom218.ts +19 -0
- package/dist/rules/prom219.ts +18 -0
- package/dist/rules/prom220.ts +18 -0
- package/dist/rules/prom221.ts +19 -0
- package/dist/rules/prom222.ts +18 -0
- package/dist/rules/prom223.ts +19 -0
- package/dist/rules/prom224.ts +18 -0
- package/dist/rules/prom301.ts +23 -0
- package/dist/skill-defs.d.ts +1 -1
- package/dist/skill-defs.d.ts.map +1 -1
- package/dist/skills/chant-prometheus-alertmanager.md +3 -1
- package/dist/validate-config.d.ts +9 -3
- package/dist/validate-config.d.ts.map +1 -1
- package/dist/validate-integrations.d.ts +38 -0
- package/dist/validate-integrations.d.ts.map +1 -0
- package/dist/validate-security.d.ts +13 -0
- package/dist/validate-security.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/collector-metrics.ts +262 -0
- package/src/composites/composites.test.ts +2 -5
- package/src/import/embedded.test.ts +52 -3
- package/src/import/embedded.ts +37 -5
- package/src/import/generator.ts +19 -1
- package/src/import/testdata/alertmanager-integrations.yml +5 -1
- package/src/index.ts +1 -0
- package/src/init-templates.test.ts +3 -1
- package/src/lint/audit-catalog.ts +115 -2
- package/src/lint/audit-lineage.test.ts +74 -0
- package/src/lint/audit-lineage.ts +97 -0
- package/src/lint/post-synth/checks.test.ts +257 -0
- package/src/lint/post-synth/index.ts +32 -0
- package/src/lint/post-synth/post-synth.test.ts +37 -1
- package/src/lint/post-synth/prom-helpers.ts +41 -2
- package/src/lint/post-synth/prom208.ts +1 -1
- package/src/lint/post-synth/prom209.ts +1 -1
- package/src/lint/post-synth/prom210.ts +17 -0
- package/src/lint/post-synth/prom211.ts +21 -0
- package/src/lint/post-synth/prom212.ts +18 -0
- package/src/lint/post-synth/prom213.ts +20 -0
- package/src/lint/post-synth/prom214.ts +18 -0
- package/src/lint/post-synth/prom215.ts +18 -0
- package/src/lint/post-synth/prom216.ts +19 -0
- package/src/lint/post-synth/prom217.ts +18 -0
- package/src/lint/post-synth/prom218.ts +19 -0
- package/src/lint/post-synth/prom219.ts +18 -0
- package/src/lint/post-synth/prom220.ts +18 -0
- package/src/lint/post-synth/prom221.ts +19 -0
- package/src/lint/post-synth/prom222.ts +18 -0
- package/src/lint/post-synth/prom223.ts +19 -0
- package/src/lint/post-synth/prom224.ts +18 -0
- package/src/lint/post-synth/prom301.test.ts +157 -0
- package/src/lint/post-synth/prom301.ts +23 -0
- package/src/lint/rules/literal-credential.ts +4 -0
- package/src/lint/rules/rules.test.ts +16 -0
- package/src/plugin.test.ts +23 -0
- package/src/plugin.ts +14 -3
- package/src/promql-analysis.ts +365 -0
- package/src/skills/chant-prometheus-alertmanager.md +3 -1
- package/src/testdata/integration-cases.ts +96 -0
- package/src/tools.test.ts +6 -0
- package/src/validate-config.ts +279 -33
- package/src/validate-integrations.ts +389 -0
- package/src/validate-security.ts +143 -0
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
import type { PostSynthCheck } from "@intentius/chant/lint/post-synth";
|
|
9
|
+
export declare const prom216: PostSynthCheck;
|
|
10
|
+
//# sourceMappingURL=prom216.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prom216.d.ts","sourceRoot":"","sources":["../../../src/lint/post-synth/prom216.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAyC,MAAM,kCAAkC,CAAC;AAG9G,eAAO,MAAM,OAAO,EAAE,cAOrB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
import type { PostSynthCheck } from "@intentius/chant/lint/post-synth";
|
|
8
|
+
export declare const prom217: PostSynthCheck;
|
|
9
|
+
//# sourceMappingURL=prom217.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prom217.d.ts","sourceRoot":"","sources":["../../../src/lint/post-synth/prom217.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAyC,MAAM,kCAAkC,CAAC;AAG9G,eAAO,MAAM,OAAO,EAAE,cAOrB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
import type { PostSynthCheck } from "@intentius/chant/lint/post-synth";
|
|
9
|
+
export declare const prom218: PostSynthCheck;
|
|
10
|
+
//# sourceMappingURL=prom218.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prom218.d.ts","sourceRoot":"","sources":["../../../src/lint/post-synth/prom218.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAyC,MAAM,kCAAkC,CAAC;AAG9G,eAAO,MAAM,OAAO,EAAE,cAOrB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
import type { PostSynthCheck } from "@intentius/chant/lint/post-synth";
|
|
8
|
+
export declare const prom219: PostSynthCheck;
|
|
9
|
+
//# sourceMappingURL=prom219.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prom219.d.ts","sourceRoot":"","sources":["../../../src/lint/post-synth/prom219.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAyC,MAAM,kCAAkC,CAAC;AAG9G,eAAO,MAAM,OAAO,EAAE,cAOrB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
import type { PostSynthCheck } from "@intentius/chant/lint/post-synth";
|
|
8
|
+
export declare const prom220: PostSynthCheck;
|
|
9
|
+
//# sourceMappingURL=prom220.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prom220.d.ts","sourceRoot":"","sources":["../../../src/lint/post-synth/prom220.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAyC,MAAM,kCAAkC,CAAC;AAG9G,eAAO,MAAM,OAAO,EAAE,cAOrB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
import type { PostSynthCheck } from "@intentius/chant/lint/post-synth";
|
|
9
|
+
export declare const prom221: PostSynthCheck;
|
|
10
|
+
//# sourceMappingURL=prom221.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prom221.d.ts","sourceRoot":"","sources":["../../../src/lint/post-synth/prom221.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAyC,MAAM,kCAAkC,CAAC;AAG9G,eAAO,MAAM,OAAO,EAAE,cAOrB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
import type { PostSynthCheck } from "@intentius/chant/lint/post-synth";
|
|
8
|
+
export declare const prom222: PostSynthCheck;
|
|
9
|
+
//# sourceMappingURL=prom222.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prom222.d.ts","sourceRoot":"","sources":["../../../src/lint/post-synth/prom222.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAyC,MAAM,kCAAkC,CAAC;AAG9G,eAAO,MAAM,OAAO,EAAE,cAOrB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
import type { PostSynthCheck } from "@intentius/chant/lint/post-synth";
|
|
9
|
+
export declare const prom223: PostSynthCheck;
|
|
10
|
+
//# sourceMappingURL=prom223.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prom223.d.ts","sourceRoot":"","sources":["../../../src/lint/post-synth/prom223.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAyC,MAAM,kCAAkC,CAAC;AAG9G,eAAO,MAAM,OAAO,EAAE,cAOrB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
import type { PostSynthCheck } from "@intentius/chant/lint/post-synth";
|
|
8
|
+
export declare const prom224: PostSynthCheck;
|
|
9
|
+
//# sourceMappingURL=prom224.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prom224.d.ts","sourceRoot":"","sources":["../../../src/lint/post-synth/prom224.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAyC,MAAM,kCAAkC,CAAC;AAG9G,eAAO,MAAM,OAAO,EAAE,cAOrB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
import type { PostSynthCheck } from "@intentius/chant/lint/post-synth";
|
|
13
|
+
export declare const prom301: PostSynthCheck;
|
|
14
|
+
//# sourceMappingURL=prom301.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prom301.d.ts","sourceRoot":"","sources":["../../../src/lint/post-synth/prom301.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAyC,MAAM,kCAAkC,CAAC;AAG9G,eAAO,MAAM,OAAO,EAAE,cAOrB,CAAC"}
|
|
@@ -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;
|
|
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;AAIxF;;;GAGG;AACH,eAAO,MAAM,aAAa,aA8BxB,CAAC;AAYH;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,EAAE,QA+DnC,CAAC"}
|
package/dist/manifest.json
CHANGED
package/dist/okf/index.md
CHANGED
|
@@ -32,3 +32,19 @@ okf_version: '0.2'
|
|
|
32
32
|
* [PROM207](/rules/PROM207.md) - A receiver is declared but no route sends to it
|
|
33
33
|
* [PROM208](/rules/PROM208.md) - An Alertmanager duration is not a duration
|
|
34
34
|
* [PROM209](/rules/PROM209.md) - A receiver integration is missing its destination or credential
|
|
35
|
+
* [PROM210](/rules/PROM210.md) - A receiver integration or global setting is one Alertmanager rejects
|
|
36
|
+
* [PROM211](/rules/PROM211.md) - An alerting rule has no for, or for: 0s
|
|
37
|
+
* [PROM212](/rules/PROM212.md) - An alerting rule has no runbook_url annotation (opt-in)
|
|
38
|
+
* [PROM213](/rules/PROM213.md) - An alert expression has no comparison
|
|
39
|
+
* [PROM214](/rules/PROM214.md) - An alert template reads a label the expression aggregates away
|
|
40
|
+
* [PROM215](/rules/PROM215.md) - rate, irate or increase over a name that is not a counter's
|
|
41
|
+
* [PROM216](/rules/PROM216.md) - histogram_quantile over a series without _bucket, or without le
|
|
42
|
+
* [PROM217](/rules/PROM217.md) - A recording rule name is not in level:metric:operations form
|
|
43
|
+
* [PROM218](/rules/PROM218.md) - A regex matcher needs no regex, or is anchored
|
|
44
|
+
* [PROM219](/rules/PROM219.md) - An alerting rule sets the alertname label
|
|
45
|
+
* [PROM220](/rules/PROM220.md) - A receiver turns off TLS certificate verification
|
|
46
|
+
* [PROM221](/rules/PROM221.md) - SMTP credentials sent with require_tls false
|
|
47
|
+
* [PROM222](/rules/PROM222.md) - Credentials sent to an http:// receiver URL
|
|
48
|
+
* [PROM223](/rules/PROM223.md) - repeat_interval is shorter than group_interval
|
|
49
|
+
* [PROM224](/rules/PROM224.md) - An inhibit rule matches one alert as source and target, with no equal
|
|
50
|
+
* [PROM301](/rules/PROM301.md) - A rule reads a connector metric no collector in the build emits
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: post-synth-check
|
|
3
|
+
title: PROM210
|
|
4
|
+
description: A receiver integration or global setting is one Alertmanager rejects
|
|
5
|
+
id: PROM210
|
|
6
|
+
severity: error
|
|
7
|
+
category: post-synth
|
|
8
|
+
lexicon: prometheus
|
|
9
|
+
docs: https://intentius.io/chant/lexicons/prometheus/rules/
|
|
10
|
+
---
|
|
11
|
+
A receiver integration or global setting is one Alertmanager rejects
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: post-synth-check
|
|
3
|
+
title: PROM211
|
|
4
|
+
description: 'An alerting rule has no for, or for: 0s'
|
|
5
|
+
id: PROM211
|
|
6
|
+
severity: error
|
|
7
|
+
category: post-synth
|
|
8
|
+
lexicon: prometheus
|
|
9
|
+
docs: https://intentius.io/chant/lexicons/prometheus/rules/
|
|
10
|
+
---
|
|
11
|
+
An alerting rule has no for, or for: 0s
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: post-synth-check
|
|
3
|
+
title: PROM212
|
|
4
|
+
description: An alerting rule has no runbook_url annotation (opt-in)
|
|
5
|
+
id: PROM212
|
|
6
|
+
severity: error
|
|
7
|
+
category: post-synth
|
|
8
|
+
lexicon: prometheus
|
|
9
|
+
docs: https://intentius.io/chant/lexicons/prometheus/rules/
|
|
10
|
+
---
|
|
11
|
+
An alerting rule has no runbook_url annotation (opt-in)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: post-synth-check
|
|
3
|
+
title: PROM213
|
|
4
|
+
description: An alert expression has no comparison
|
|
5
|
+
id: PROM213
|
|
6
|
+
severity: error
|
|
7
|
+
category: post-synth
|
|
8
|
+
lexicon: prometheus
|
|
9
|
+
docs: https://intentius.io/chant/lexicons/prometheus/rules/
|
|
10
|
+
---
|
|
11
|
+
An alert expression has no comparison
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: post-synth-check
|
|
3
|
+
title: PROM214
|
|
4
|
+
description: An alert template reads a label the expression aggregates away
|
|
5
|
+
id: PROM214
|
|
6
|
+
severity: error
|
|
7
|
+
category: post-synth
|
|
8
|
+
lexicon: prometheus
|
|
9
|
+
docs: https://intentius.io/chant/lexicons/prometheus/rules/
|
|
10
|
+
---
|
|
11
|
+
An alert template reads a label the expression aggregates away
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: post-synth-check
|
|
3
|
+
title: PROM215
|
|
4
|
+
description: rate, irate or increase over a name that is not a counter's
|
|
5
|
+
id: PROM215
|
|
6
|
+
severity: error
|
|
7
|
+
category: post-synth
|
|
8
|
+
lexicon: prometheus
|
|
9
|
+
docs: https://intentius.io/chant/lexicons/prometheus/rules/
|
|
10
|
+
---
|
|
11
|
+
rate, irate or increase over a name that is not a counter's
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: post-synth-check
|
|
3
|
+
title: PROM216
|
|
4
|
+
description: histogram_quantile over a series without _bucket, or without le
|
|
5
|
+
id: PROM216
|
|
6
|
+
severity: error
|
|
7
|
+
category: post-synth
|
|
8
|
+
lexicon: prometheus
|
|
9
|
+
docs: https://intentius.io/chant/lexicons/prometheus/rules/
|
|
10
|
+
---
|
|
11
|
+
histogram_quantile over a series without _bucket, or without le
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: post-synth-check
|
|
3
|
+
title: PROM217
|
|
4
|
+
description: A recording rule name is not in level:metric:operations form
|
|
5
|
+
id: PROM217
|
|
6
|
+
severity: error
|
|
7
|
+
category: post-synth
|
|
8
|
+
lexicon: prometheus
|
|
9
|
+
docs: https://intentius.io/chant/lexicons/prometheus/rules/
|
|
10
|
+
---
|
|
11
|
+
A recording rule name is not in level:metric:operations form
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: post-synth-check
|
|
3
|
+
title: PROM218
|
|
4
|
+
description: A regex matcher needs no regex, or is anchored
|
|
5
|
+
id: PROM218
|
|
6
|
+
severity: error
|
|
7
|
+
category: post-synth
|
|
8
|
+
lexicon: prometheus
|
|
9
|
+
docs: https://intentius.io/chant/lexicons/prometheus/rules/
|
|
10
|
+
---
|
|
11
|
+
A regex matcher needs no regex, or is anchored
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: post-synth-check
|
|
3
|
+
title: PROM219
|
|
4
|
+
description: An alerting rule sets the alertname label
|
|
5
|
+
id: PROM219
|
|
6
|
+
severity: error
|
|
7
|
+
category: post-synth
|
|
8
|
+
lexicon: prometheus
|
|
9
|
+
docs: https://intentius.io/chant/lexicons/prometheus/rules/
|
|
10
|
+
---
|
|
11
|
+
An alerting rule sets the alertname label
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: post-synth-check
|
|
3
|
+
title: PROM220
|
|
4
|
+
description: A receiver turns off TLS certificate verification
|
|
5
|
+
id: PROM220
|
|
6
|
+
severity: error
|
|
7
|
+
category: post-synth
|
|
8
|
+
lexicon: prometheus
|
|
9
|
+
docs: https://intentius.io/chant/lexicons/prometheus/rules/
|
|
10
|
+
---
|
|
11
|
+
A receiver turns off TLS certificate verification
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: post-synth-check
|
|
3
|
+
title: PROM221
|
|
4
|
+
description: SMTP credentials sent with require_tls false
|
|
5
|
+
id: PROM221
|
|
6
|
+
severity: error
|
|
7
|
+
category: post-synth
|
|
8
|
+
lexicon: prometheus
|
|
9
|
+
docs: https://intentius.io/chant/lexicons/prometheus/rules/
|
|
10
|
+
---
|
|
11
|
+
SMTP credentials sent with require_tls false
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: post-synth-check
|
|
3
|
+
title: PROM222
|
|
4
|
+
description: Credentials sent to an http:// receiver URL
|
|
5
|
+
id: PROM222
|
|
6
|
+
severity: error
|
|
7
|
+
category: post-synth
|
|
8
|
+
lexicon: prometheus
|
|
9
|
+
docs: https://intentius.io/chant/lexicons/prometheus/rules/
|
|
10
|
+
---
|
|
11
|
+
Credentials sent to an http:// receiver URL
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: post-synth-check
|
|
3
|
+
title: PROM223
|
|
4
|
+
description: repeat_interval is shorter than group_interval
|
|
5
|
+
id: PROM223
|
|
6
|
+
severity: error
|
|
7
|
+
category: post-synth
|
|
8
|
+
lexicon: prometheus
|
|
9
|
+
docs: https://intentius.io/chant/lexicons/prometheus/rules/
|
|
10
|
+
---
|
|
11
|
+
repeat_interval is shorter than group_interval
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: post-synth-check
|
|
3
|
+
title: PROM224
|
|
4
|
+
description: An inhibit rule matches one alert as source and target, with no equal
|
|
5
|
+
id: PROM224
|
|
6
|
+
severity: error
|
|
7
|
+
category: post-synth
|
|
8
|
+
lexicon: prometheus
|
|
9
|
+
docs: https://intentius.io/chant/lexicons/prometheus/rules/
|
|
10
|
+
---
|
|
11
|
+
An inhibit rule matches one alert as source and target, with no equal
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
type: post-synth-check
|
|
3
|
+
title: PROM301
|
|
4
|
+
description: A rule reads a connector metric no collector in the build emits
|
|
5
|
+
id: PROM301
|
|
6
|
+
severity: error
|
|
7
|
+
category: post-synth
|
|
8
|
+
lexicon: prometheus
|
|
9
|
+
docs: https://intentius.io/chant/lexicons/prometheus/rules/
|
|
10
|
+
---
|
|
11
|
+
A rule reads a connector metric no collector in the build emits
|
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AA+B9D;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AA+B9D;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,EAAE,aAwH9B,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading a parsed PromQL expression: the selectors it reads, the labels its
|
|
3
|
+
* result keeps, and whether it filters with a comparison. The rule-file
|
|
4
|
+
* checks PROM211-PROM219 (./validate-config.ts) are built on these.
|
|
5
|
+
*
|
|
6
|
+
* The tree is the one `checkPromql` (./promql.ts) parses with
|
|
7
|
+
* `@prometheus-io/lezer-promql`. Every function here returns nothing for an
|
|
8
|
+
* expression that does not parse; PROM104 reports that.
|
|
9
|
+
*/
|
|
10
|
+
import { parser } from "@prometheus-io/lezer-promql";
|
|
11
|
+
import type { MatchOp } from "./matchers.js";
|
|
12
|
+
type SyntaxNode = ReturnType<typeof parser.parse>["topNode"];
|
|
13
|
+
/** The expression under the tree's `PromQL` root, or undefined when it does not parse. */
|
|
14
|
+
export declare function parsePromql(expr: string): SyntaxNode | undefined;
|
|
15
|
+
/** The value of a PromQL string literal: double- or single-quoted with escapes, or a raw backtick string. */
|
|
16
|
+
export declare function stringValue(literal: string): string;
|
|
17
|
+
export interface SelectorMatcher {
|
|
18
|
+
name: string;
|
|
19
|
+
op: MatchOp;
|
|
20
|
+
value: string;
|
|
21
|
+
}
|
|
22
|
+
/** One vector selector in an expression. */
|
|
23
|
+
export interface Selector {
|
|
24
|
+
/** The metric name, from the identifier or a `__name__="..."` matcher; undefined when neither names one. */
|
|
25
|
+
name?: string;
|
|
26
|
+
matchers: SelectorMatcher[];
|
|
27
|
+
/** The selector as written. */
|
|
28
|
+
text: string;
|
|
29
|
+
/** The functions it sits inside, innermost first, e.g. `["rate", "sum"]` for `sum(rate(x[5m]))`. */
|
|
30
|
+
within: string[];
|
|
31
|
+
}
|
|
32
|
+
/** Every vector selector in the expression, with the functions around it. */
|
|
33
|
+
export declare function selectors(expr: string): Selector[];
|
|
34
|
+
/**
|
|
35
|
+
* Whether the expression filters its result: a comparison without `bool`,
|
|
36
|
+
* `absent()`/`absent_over_time()`, or `unless`, anywhere a series can pass
|
|
37
|
+
* through to the result. An expression without one returns every series it
|
|
38
|
+
* reads, so an alert on it fires for all of them (pint alerts/comparison).
|
|
39
|
+
* `or` needs a condition on both sides, since either side alone reaches the
|
|
40
|
+
* result.
|
|
41
|
+
*/
|
|
42
|
+
export declare function hasCondition(expr: string): boolean | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* The labels an expression's result carries, as far as the expression says:
|
|
45
|
+
* `{ only }` when it keeps exactly these labels (`sum by (job)`), `{ except }`
|
|
46
|
+
* when it keeps every label but these (`sum without (instance)`), or
|
|
47
|
+
* undefined when it keeps whatever the series it reads carry.
|
|
48
|
+
*/
|
|
49
|
+
export type LabelScope = {
|
|
50
|
+
only: Set<string>;
|
|
51
|
+
} | {
|
|
52
|
+
except: Set<string>;
|
|
53
|
+
};
|
|
54
|
+
/** The labels the expression's result keeps; see {@link LabelScope}. */
|
|
55
|
+
export declare function resultLabels(expr: string): LabelScope | undefined;
|
|
56
|
+
/** Whether a label survives a scope. An undefined scope keeps every label. */
|
|
57
|
+
export declare function keepsLabel(scope: LabelScope | undefined, label: string): boolean;
|
|
58
|
+
/** One `histogram_quantile` call and what is wrong with its histogram argument. */
|
|
59
|
+
export interface HistogramProblem {
|
|
60
|
+
call: string;
|
|
61
|
+
problem: "no-bucket" | "no-le";
|
|
62
|
+
}
|
|
63
|
+
/** `histogram_quantile` calls over a selector with no `_bucket` in its name, or an aggregation that drops `le`. */
|
|
64
|
+
export declare function histogramProblems(expr: string): HistogramProblem[];
|
|
65
|
+
/** `rate`, `irate` or `increase` read straight from a named selector whose name does not end in a counter suffix. */
|
|
66
|
+
export declare function nonCounterRates(expr: string): Array<{
|
|
67
|
+
fn: string;
|
|
68
|
+
name: string;
|
|
69
|
+
}>;
|
|
70
|
+
/** A regex matcher that could be an equality matcher, or that carries anchors Prometheus already adds. */
|
|
71
|
+
export interface RegexProblem {
|
|
72
|
+
matcher: string;
|
|
73
|
+
problem: "literal" | "anchored";
|
|
74
|
+
}
|
|
75
|
+
/** The `=~` and `!~` matchers in an expression that need no regex, or that are anchored (pint promql/regexp). */
|
|
76
|
+
export declare function regexProblems(expr: string): RegexProblem[];
|
|
77
|
+
/** Whether every selector in the expression is read through a `*_over_time` function, so the expression already spans a window. */
|
|
78
|
+
export declare function readsOnlyOverTime(expr: string): boolean;
|
|
79
|
+
/** Whether the expression is two conditions joined by `and`: the multi-window form, where the short window does what `for` would. */
|
|
80
|
+
export declare function isMultiWindow(expr: string): boolean;
|
|
81
|
+
export {};
|
|
82
|
+
//# sourceMappingURL=promql-analysis.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promql-analysis.d.ts","sourceRoot":"","sources":["../src/promql-analysis.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,KAAK,UAAU,GAAG,UAAU,CAAC,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC;AAE7D,0FAA0F;AAC1F,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAWhE;AAMD,6GAA6G;AAC7G,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAQnD;AAmBD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,OAAO,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf;AAED,4CAA4C;AAC5C,MAAM,WAAW,QAAQ;IACvB,4GAA4G;IAC5G,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,oGAAoG;IACpG,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAiCD,6EAA6E;AAC7E,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,EAAE,CAelD;AAkBD;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAgC9D;AAED;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG;IAAE,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;CAAE,CAAC;AAuBzE,wEAAwE;AACxE,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAiEjE;AAED,8EAA8E;AAC9E,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAGhF;AAED,mFAAmF;AACnF,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC;CAChC;AAED,mHAAmH;AACnH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAmBlE;AAKD,qHAAqH;AACrH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAMjF;AAID,0GAA0G;AAC1G,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,SAAS,GAAG,UAAU,CAAC;CACjC;AAED,iHAAiH;AACjH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,EAAE,CAW1D;AAED,mIAAmI;AACnI,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAGvD;AAED,qIAAqI;AACrI,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAOnD"}
|
package/dist/rule-eval.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rule-eval.d.ts","sourceRoot":"","sources":["../src/rule-eval.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAIH,OAAO,EAA8D,KAAK,eAAe,EAAE,MAAM,SAAS,CAAC;AAI3G,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC5C,MAAM,WAAW,MAAM;IACrB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AACD,MAAM,WAAW,MAAM;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AACD,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAGD,0CAA0C;AAC1C,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAkCD,8DAA8D;AAC9D,qBAAa,aAAa;IAKZ,OAAO,CAAC,QAAQ,CAAC,MAAM;IAJnC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA6B;IACpD,yDAAyD;IACzD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA0C;
|
|
1
|
+
{"version":3,"file":"rule-eval.d.ts","sourceRoot":"","sources":["../src/rule-eval.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAIH,OAAO,EAA8D,KAAK,eAAe,EAAE,MAAM,SAAS,CAAC;AAI3G,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC5C,MAAM,WAAW,MAAM;IACrB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AACD,MAAM,WAAW,MAAM;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AACD,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAGD,0CAA0C;AAC1C,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAkCD,8DAA8D;AAC9D,qBAAa,aAAa;IAKZ,OAAO,CAAC,QAAQ,CAAC,MAAM;IAJnC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA6B;IACpD,yDAAyD;IACzD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA0C;IAElE,YAA6B,MAAM,EAAE,eAAe,EAAE,EAAI;IAE1D,wEAAwE;IACxE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAQ9C;IAED,yFAAyF;IACzF,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,WAAW,EAAE,CA4B7B;IAED,yFAAyF;IACzF,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,aAAa,EAAE,CAG9C;IAED,OAAO,CAAC,IAAI;IAOZ,OAAO,CAAC,IAAI;IAIZ,OAAO,CAAC,QAAQ;IAiBhB,OAAO,CAAC,MAAM;IAId,iCAAiC;IACjC,OAAO,CAAC,MAAM;IAcd,OAAO,CAAC,IAAI;IAyBZ,OAAO,CAAC,IAAI;IAQZ,OAAO,CAAC,IAAI;IA0CZ,OAAO,CAAC,iBAAiB;IAuCzB,OAAO,CAAC,SAAS;IA4BjB,OAAO,CAAC,MAAM;CA2Hf"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as ts from "typescript";
|
|
2
2
|
import type { LintRule, LintDiagnostic, LintContext } from "@intentius/chant/lint/rule";
|
|
3
|
+
import { SLACK_APP_URL } from "../../validate-integrations";
|
|
3
4
|
import { calleeName, constInitializers, CREDENTIAL_CLASS, literalText, position, propertyName, resolveConst } from "./prom-ast";
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -89,6 +90,9 @@ export const literalCredentialRule: LintRule = {
|
|
|
89
90
|
if (only && integration !== undefined && integration !== only) return;
|
|
90
91
|
const text = literalText(init);
|
|
91
92
|
if (text === undefined || text === "") return;
|
|
93
|
+
// A Slack bot posts to the public chat.postMessage endpoint with its token
|
|
94
|
+
// in http_config, and update_message needs exactly that api_url (PROM210).
|
|
95
|
+
if (key === "api_url" && text === SLACK_APP_URL) return;
|
|
92
96
|
diagnostics.push({
|
|
93
97
|
ruleId: "PROM001",
|
|
94
98
|
severity: "error",
|
|
@@ -13,10 +13,12 @@
|
|
|
13
13
|
import type { PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
|
|
14
14
|
import type { SerializerResult } from "@intentius/chant/serializer";
|
|
15
15
|
import { loadAll } from "js-yaml";
|
|
16
|
+
import { buildCollectorConfigs, collectorMetricIssues, collectorMetrics } from "../../collector-metrics";
|
|
16
17
|
import { looksLikeAlertmanagerConfig, looksLikeRuleFile, type AlertmanagerConfig, type RuleFileConfig } from "../../model";
|
|
17
18
|
import {
|
|
18
19
|
validateAlertmanagerConfig,
|
|
19
20
|
validateRuleFile,
|
|
21
|
+
validateRunbookUrls,
|
|
20
22
|
validateSeverityRouting,
|
|
21
23
|
type PrometheusIssue,
|
|
22
24
|
type PrometheusIssueCode,
|
|
@@ -62,7 +64,7 @@ function toDiagnostic(issue: PrometheusIssue, source: string): PostSynthDiagnost
|
|
|
62
64
|
};
|
|
63
65
|
}
|
|
64
66
|
|
|
65
|
-
/** Diagnostics for one rule-file code (PROM101-PROM107) across every rule file in the output. */
|
|
67
|
+
/** Diagnostics for one rule-file code (PROM101-PROM107, PROM211, PROM213-PROM219) across every rule file in the output. */
|
|
66
68
|
export function ruleFileDiagnostics(ctx: PostSynthContext, code: PrometheusIssueCode): PostSynthDiagnostic[] {
|
|
67
69
|
return prometheusDocs(ctx).ruleFiles.flatMap(({ source, config }) =>
|
|
68
70
|
validateRuleFile(config)
|
|
@@ -71,7 +73,7 @@ export function ruleFileDiagnostics(ctx: PostSynthContext, code: PrometheusIssue
|
|
|
71
73
|
);
|
|
72
74
|
}
|
|
73
75
|
|
|
74
|
-
/** Diagnostics for one Alertmanager code (PROM201, PROM203-
|
|
76
|
+
/** Diagnostics for one Alertmanager code (PROM201, PROM203-PROM210, PROM220-PROM224) across every `alertmanager.yml` in the output. */
|
|
75
77
|
export function alertmanagerDiagnostics(ctx: PostSynthContext, code: PrometheusIssueCode): PostSynthDiagnostic[] {
|
|
76
78
|
return prometheusDocs(ctx).alertmanager.flatMap(({ source, config }) =>
|
|
77
79
|
validateAlertmanagerConfig(config)
|
|
@@ -80,6 +82,43 @@ export function alertmanagerDiagnostics(ctx: PostSynthContext, code: PrometheusI
|
|
|
80
82
|
);
|
|
81
83
|
}
|
|
82
84
|
|
|
85
|
+
/** PROM212 across every rule file in the output. Opt-in: the lexicon's `recommended` lint preset leaves it out (see ../../plugin.ts). */
|
|
86
|
+
export function runbookDiagnostics(ctx: PostSynthContext): PostSynthDiagnostic[] {
|
|
87
|
+
return prometheusDocs(ctx).ruleFiles.flatMap(({ source, config }) => validateRunbookUrls(config).map((i) => toDiagnostic(i, source)));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* PROM301: every rule expression in the output against the metrics the
|
|
92
|
+
* build's collector configs emit. Silent when the build has none.
|
|
93
|
+
*/
|
|
94
|
+
export function collectorMetricDiagnostics(ctx: PostSynthContext): PostSynthDiagnostic[] {
|
|
95
|
+
const { ruleFiles } = prometheusDocs(ctx);
|
|
96
|
+
if (ruleFiles.length === 0) return [];
|
|
97
|
+
const emitted = collectorMetrics(buildCollectorConfigs(ctx));
|
|
98
|
+
if (!emitted) return [];
|
|
99
|
+
const out: PostSynthDiagnostic[] = [];
|
|
100
|
+
for (const { source, config } of ruleFiles) {
|
|
101
|
+
for (const group of Array.isArray(config?.groups) ? config.groups : []) {
|
|
102
|
+
for (const rule of Array.isArray(group?.rules) ? group.rules : []) {
|
|
103
|
+
const r = rule as unknown as Record<string, unknown>;
|
|
104
|
+
if (typeof r.expr !== "string") continue;
|
|
105
|
+
const subject = `${group.name}/${typeof r.record === "string" ? r.record : String(r.alert ?? "")}`;
|
|
106
|
+
for (const issue of collectorMetricIssues(r.expr, emitted)) {
|
|
107
|
+
const message = `rule ${subject} ${issue.message}`;
|
|
108
|
+
out.push({
|
|
109
|
+
checkId: "PROM301",
|
|
110
|
+
severity: "warning",
|
|
111
|
+
message: source && source !== "prometheus" ? `${source}: ${message}` : message,
|
|
112
|
+
entity: subject,
|
|
113
|
+
lexicon: "prometheus",
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return out;
|
|
120
|
+
}
|
|
121
|
+
|
|
83
122
|
/** PROM202: joins every rule file in the output against every Alertmanager config in it. Silent when either is absent. */
|
|
84
123
|
export function routingDiagnostics(ctx: PostSynthContext): PostSynthDiagnostic[] {
|
|
85
124
|
const { ruleFiles, alertmanager } = prometheusDocs(ctx);
|
package/dist/rules/prom208.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* PROM208: An Alertmanager duration is not a duration
|
|
3
3
|
*
|
|
4
|
-
* group_wait, group_interval, repeat_interval, resolve_timeout and
|
|
4
|
+
* group_wait, group_interval, repeat_interval, resolve_timeout and Jira reopen_duration take Prometheus durations (30s, 4h, 1d); the timeout of webhook, Slack, PagerDuty and incident.io, and Pushover retry, expire and ttl take Go durations (10s, 1m30s, 500ms).
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
|
package/dist/rules/prom209.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* PROM209: A receiver integration is missing its destination or credential
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Every one of Alertmanager's 18 integrations is checked for the destination, credential and required fields its config validation asks for, with the global defaults it falls back to: e.g. a webhook url, an Opsgenie api_key (or global.opsgenie_api_key), a Telegram chat_id and bot token, a Webex room_id and authorization, an SNS target, a Jira project and issue_type.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PROM210: A receiver integration or global setting is one Alertmanager rejects
|
|
3
|
+
*
|
|
4
|
+
* Two settings that exclude each other (a value and its *_file, a Slack api_url and app_token, Pushover html and monospace, two SNS targets), or a value outside the allowed set (WeChat message_type, Telegram parse_mode, Jira api_type, an Opsgenie responder type, a VictorOps reserved custom field, a smarthost that is not host:port, a Slack or Mattermost field without title and value).
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
|
|
8
|
+
import { alertmanagerDiagnostics } from "./prom-helpers";
|
|
9
|
+
|
|
10
|
+
export const prom210: PostSynthCheck = {
|
|
11
|
+
id: "PROM210",
|
|
12
|
+
description: "A receiver integration or global setting is one Alertmanager rejects",
|
|
13
|
+
|
|
14
|
+
check(ctx: PostSynthContext): PostSynthDiagnostic[] {
|
|
15
|
+
return alertmanagerDiagnostics(ctx, "PROM210");
|
|
16
|
+
},
|
|
17
|
+
};
|