@intentius/chant-lexicon-grafana 0.105.1 → 0.106.3

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 CHANGED
@@ -61,6 +61,6 @@ GRAF101 and GRAF102 compare dashboards with the datasources declared in the same
61
61
  ## Plain-data API
62
62
 
63
63
  - `buildGrafana(entities)` and `grafanaFiles(entities)` render every file by path, for embedding in another lexicon's output (a ConfigMap, a volume).
64
- - `GrafanaConfigMaps` and `grafanaVolumes` from `@intentius/chant-lexicon-grafana/k8s` deliver dashboards and provisioning to Kubernetes as ConfigMaps labelled for the Grafana Helm chart's sidecar (`grafana_dashboard`, `grafana_datasource`), or mounted into a plain Grafana Deployment. `GrafanaOperatorResources` from the same subpath writes `GrafanaDashboard`, `GrafanaDatasource`, `GrafanaFolder` and `GrafanaLibraryPanel` resources for a Grafana the Grafana Operator runs.
64
+ - `GrafanaConfigMaps` and `grafanaVolumes` from `@intentius/chant-lexicon-grafana/k8s` deliver dashboards and provisioning to Kubernetes as ConfigMaps labelled for the Grafana Helm chart's sidecar (`grafana_dashboard`, `grafana_datasource`), or mounted into a plain Grafana Deployment. `GrafanaOperatorResources` from the same subpath writes `GrafanaDashboard`, `GrafanaDatasource`, `GrafanaFolder` and `GrafanaLibraryPanel` resources, and `GrafanaAlertRuleGroup`, `GrafanaContactPoint`, `GrafanaNotificationPolicy`, `GrafanaMuteTiming` and `GrafanaNotificationTemplate` resources for the alerting, for a Grafana the Grafana Operator runs.
65
65
  - `renderDashboard(dashboard)` and `dashboardJson(dashboard)` render one dashboard.
66
66
  - `validateGrafanaOutput({ dashboards, datasources })` and `validateDashboardSchema(json)`, from `@intentius/chant-lexicon-grafana/validation`, run the checks without a build. They are not on the package root, so declaring dashboards does not load them; ajv loads the first time a schema is checked.
package/dist/detect.d.ts CHANGED
@@ -40,6 +40,14 @@ export declare function looksLikeDashboardProvisioning(data: unknown): data is {
40
40
  * of `name` and `rules` with `expr`) is not mistaken for one.
41
41
  */
42
42
  export declare function looksLikeAlertingProvisioning(data: unknown): data is Record<string, unknown>;
43
+ /**
44
+ * The `spec` of a Grafana Operator alerting resource (`GrafanaAlertRuleGroup`,
45
+ * `GrafanaContactPoint`, `GrafanaNotificationPolicy`, `GrafanaMuteTiming`,
46
+ * `GrafanaNotificationTemplate`) as the k8s importer offers it (#3538): every
47
+ * operator resource's spec has an `instanceSelector`, beside the field that
48
+ * holds the alerting content.
49
+ */
50
+ export declare function looksLikeOperatorAlertingSpec(data: unknown): boolean;
43
51
  /**
44
52
  * Template detection for `chant import` and friends: dashboard JSON in any
45
53
  * of the shapes above (v2 included, #2947), or a datasource, dashboard or
@@ -1 +1 @@
1
- {"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../src/detect.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,uFAAuF;AACvF,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAGjF;AAED,mFAAmF;AACnF,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAE3F;AAED,8GAA8G;AAC9G,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,CAQ1I;AAED,2GAA2G;AAC3G,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAG3D;AAED,2EAA2E;AAC3E,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI;IAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,C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G3D;AAED,2EAA2E;AAC3E,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI;IAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CAE1H;AAED,oGAAoG;AACpG,wBAAgB,+BAA+B,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI;IAAE,UAAU,EAAE,OAAO,CAAC;IAAC,WAAW,CAAC,EAAE,OAAO,EAAE,CAAC;IAAC,iBAAiB,CAAC,EAAE,OAAO,EAAE,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,CAEvK;AAED,0EAA0E;AAC1E,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI;IAAE,UAAU,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,OAAO,EAAE,CAAA;CAAE,CAEnH;AAuBD;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAO5F;AAED;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAWpE;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAYrD"}
@@ -1 +1 @@
1
- {"version":3,"file":"embedded.d.ts","sourceRoot":"","sources":["../../src/import/embedded.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAkB,MAAM,kCAAkC,CAAC;AAOhG,eAAO,MAAM,iBAAiB,EAAE,uBAyC/B,CAAC"}
1
+ {"version":3,"file":"embedded.d.ts","sourceRoot":"","sources":["../../src/import/embedded.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAkB,MAAM,kCAAkC,CAAC;AAOhG,eAAO,MAAM,iBAAiB,EAAE,uBAwC/B,CAAC"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Grafana Operator alerting resources embedded in a k8s manifest, for
3
+ * `chant import` (#3538).
4
+ *
5
+ * `GrafanaOperatorResources` (#3156) writes `GrafanaAlertRuleGroup`,
6
+ * `GrafanaContactPoint`, `GrafanaNotificationPolicy` (with, for
7
+ * `policyRoutes`, a `GrafanaNotificationPolicyRoute` per child route),
8
+ * `GrafanaMuteTiming` and
9
+ * `GrafanaNotificationTemplate` from grafana alerting declarations. The k8s
10
+ * parser offers the one field of each that holds the alerting content
11
+ * (`spec.rules`, `spec.receivers`, `spec.route`, `spec.time_intervals`,
12
+ * `spec.template`) with the whole `spec` as the document. This importer
13
+ * reads that spec back into the provisioning-file shape, which the alerting
14
+ * importer turns into declarations, and the k8s value becomes a call of the
15
+ * matching function in `@intentius/chant-lexicon-grafana/k8s` over the
16
+ * declaration, so a build gives the same field again.
17
+ *
18
+ * The reverse of what `GrafanaOperatorResources` writes:
19
+ *
20
+ * - a rule: the CRD's camel case (`missingSeriesEvalsToResolve`,
21
+ * `notificationSettings`) goes back to the file's snake case, the
22
+ * `__dashboardUid__` and `__panelId__` annotations go back to
23
+ * `dashboardUid` and `panelId`, and the values the CRD requires and the
24
+ * file leaves to Grafana's defaults (`for: 0s`, `noDataState: NoData`,
25
+ * `execErrState: Alerting`) are left out;
26
+ * - a receiver: each `valuesFrom` entry becomes `${NAME}` at its
27
+ * `targetPath` in the settings, `NAME` being the Secret key. The Secret's
28
+ * name is not part of a declaration, so a contact point that reads a
29
+ * Secret is written with a small module holding
30
+ * `operatorReceivers(contactPoint, "<secret>")`;
31
+ * - a `GrafanaNotificationPolicyRoute`: its whole `spec` is the route, read
32
+ * as the one child of a policy that has its receiver, and written back by
33
+ * `operatorRouteSpec`;
34
+ * - the policy tree: `object_matchers` go back to Alertmanager `matchers`
35
+ * strings where each can be written as one.
36
+ *
37
+ * A rule group's folder is a title in a declaration and a `GrafanaFolder`
38
+ * name (`folderRef`) in the resource, and the resource does not hold the
39
+ * title, so the declaration's `folder` is the reference, with a warning.
40
+ */
41
+ import type { EmbeddedContentImporter } from "@intentius/chant/import/embedded";
42
+ type Json = Record<string, unknown>;
43
+ /** One entry of `GrafanaAlertRuleGroup.spec.rules` as a rule of the provisioning file. */
44
+ export declare function provisionedRule(rule: Json): Json;
45
+ /**
46
+ * `GrafanaContactPoint.spec.receivers` as the provisioning file's receivers,
47
+ * each `valuesFrom` entry put back as `${NAME}` in the settings, and the name
48
+ * of the Secret they read (one Secret, as `GrafanaOperatorResources` writes).
49
+ */
50
+ export declare function provisionedReceivers(receivers: unknown[], where: string): {
51
+ receivers: Json[];
52
+ secretName?: string;
53
+ };
54
+ /** A route of the policy tree as the provisioning file holds it: `object_matchers` as `matchers` strings, in every nested route. */
55
+ export declare function provisionedRoute(route: Json): Json;
56
+ export declare const operatorImporter: EmbeddedContentImporter;
57
+ export {};
58
+ //# sourceMappingURL=operator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operator.d.ts","sourceRoot":"","sources":["../../src/import/operator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,OAAO,KAAK,EAAmB,uBAAuB,EAAkB,MAAM,kCAAkC,CAAC;AAKjH,KAAK,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAmBpC,0FAA0F;AAC1F,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAwBhD;AAYD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG;IAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,CAoBpH;AAWD,oIAAoI;AACpI,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,IAAI,GAAG,IAAI,CAWlD;AAiDD,eAAO,MAAM,gBAAgB,EAAE,uBA2C9B,CAAC"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "algorithm": "sha256",
3
3
  "artifacts": {
4
- "manifest.json": "dc2bada7e10db944b7ba69f0bfbc0ecf8f072769dc06cdf4ee19f260050bfa9d",
4
+ "manifest.json": "f95101f26cc36262685fe99c9eccc904ffca12e4e4e798d9fb0e35023060f041",
5
5
  "meta.json": "330a1598c3b35ae62267e886a3416a494b0ebe9f1d2e2379253787d0a0bcb32e",
6
6
  "types/index.d.ts": "ad385264290f2486f7a54be205684de8415a25b74eee5b809ca625ae19fb08da",
7
7
  "rules/grafana-ast.ts": "51f4fac423f7a5c6d6f577074e95b4a70d4ab0a05883a86e04970a50c63d92e8",
@@ -27,9 +27,9 @@
27
27
  "rules/graf118.ts": "e4ad3c5b944185139331a1f30488c6107a87f37872a0d52b7afc03d9a2ed6125",
28
28
  "rules/grafana-helpers.ts": "0a538daafb10f32077dd6cda4c03b541f703b0a10abc51bfd241eae9365c9be6",
29
29
  "skills/chant-grafana.md": "6a7f4ba6d8a40d339fad892c612131370ef0c2595547860ee718801bfa893163",
30
- "skills/chant-grafana-provisioning.md": "b861a848761c4db9c8c07f248650af14b254c19277b35839ff23033e484089aa",
30
+ "skills/chant-grafana-provisioning.md": "1c7f473ef4e1f9c2debed62833e4f0448ed0fef9f01c83fbbc94299715ed2602",
31
31
  "skills/chant-grafana-alerting.md": "d9648dc14c848851bdccbe069dac54ad06115066f9466c90c4137d07dde6d4ad",
32
32
  "skills/chant-grafana-operations.md": "4e665f80292ab32bde6d77940cc3f3923678c58e6db0b80613489050d2cb665b"
33
33
  },
34
- "composite": "1d0b6ed667dc20498a9b614c15f79ebe688655fa9b738a18a0771a0f92a082fb"
34
+ "composite": "d3f04256f6713df0d65a9e5470148e3e3c70a5a5bb7f28e766dafef40f8ccfa4"
35
35
  }
package/dist/k8s.d.ts CHANGED
@@ -23,16 +23,21 @@
23
23
  * A Grafana run by the Grafana Operator reads custom resources instead
24
24
  * (#3015): `GrafanaOperatorResources` writes a `GrafanaDashboard` per
25
25
  * dashboard, a `GrafanaDatasource` per datasource, a `GrafanaFolder` per
26
- * folder and a `GrafanaLibraryPanel` per library panel (#3186), all
27
- * `grafana.integreatly.org/v1beta1` as the k8s lexicon types them from the
28
- * operator's CRDs (pinned in its `crd-sources.ts`).
26
+ * folder and a `GrafanaLibraryPanel` per library panel (#3186), and for
27
+ * alerting (#3156) a `GrafanaAlertRuleGroup` per rule group, a
28
+ * `GrafanaContactPoint` per contact point, a `GrafanaNotificationPolicy`, a
29
+ * `GrafanaMuteTiming` per mute timing and a `GrafanaNotificationTemplate` per
30
+ * template, all `grafana.integreatly.org/v1beta1` as the k8s lexicon types
31
+ * them from the operator's CRDs (pinned in its `crd-sources.ts`).
29
32
  *
30
33
  * This module is the only part of the grafana lexicon that loads the k8s
31
34
  * lexicon; nothing else imports it.
32
35
  */
33
36
  import { type CompositeInstance } from "@intentius/chant/composite";
34
37
  import type { Declarable } from "@intentius/chant/declarable";
35
- import { ConfigMap, GrafanaDashboard, GrafanaDatasource, GrafanaFolder, GrafanaLibraryPanel } from "@intentius/chant-lexicon-k8s/generated/index";
38
+ import { ConfigMap, GrafanaAlertRuleGroup, GrafanaContactPoint, GrafanaDashboard, GrafanaDatasource, GrafanaFolder, GrafanaLibraryPanel, GrafanaMuteTiming, GrafanaNotificationPolicy, GrafanaNotificationPolicyRoute, GrafanaNotificationTemplate } from "@intentius/chant-lexicon-k8s/generated/index";
39
+ import { type ProvisionedAlertRule, type ProvisionedContactPoint } from "./alerting-build.js";
40
+ import type { AlertRuleGroupEntity, ContactPointEntity, MuteTimingEntity, NotificationPolicyEntity, NotificationTemplateEntity } from "./alerting.js";
36
41
  import { type ProvisionedDatasource } from "./build.js";
37
42
  /** The label the Grafana Helm chart's sidecar looks for on dashboard ConfigMaps (`sidecar.dashboards.label`). */
38
43
  export declare const SIDECAR_DASHBOARD_LABEL = "grafana_dashboard";
@@ -148,15 +153,28 @@ export interface GrafanaOperatorResourcesProps {
148
153
  */
149
154
  dashboardSource?: "json" | "configMap";
150
155
  /**
151
- * The Secret that datasource secrets come from. A datasource field written
152
- * as `${NAME}` or `$__env{NAME}` (the way file provisioning reads the
153
- * environment) becomes a `spec.valuesFrom` entry reading key `NAME` of
154
- * this Secret, which the operator substitutes for `${NAME}`. Required when
155
- * any datasource has such a reference.
156
+ * The Secret that datasource and contact point secrets come from. A
157
+ * datasource field written as `${NAME}` or `$__env{NAME}` (the way file
158
+ * provisioning reads the environment) becomes a `spec.valuesFrom` entry
159
+ * reading key `NAME` of this Secret, which the operator substitutes for
160
+ * `${NAME}`. A contact point setting that is entirely such a reference
161
+ * becomes a `valuesFrom` entry of its receiver, which the operator writes
162
+ * into the setting at `targetPath`. Required when any datasource or
163
+ * contact point has such a reference.
156
164
  */
157
165
  secretName?: string;
166
+ /**
167
+ * Write each direct child route of a notification policy as a
168
+ * `GrafanaNotificationPolicyRoute` of its own, which the policy merges in
169
+ * through `spec.route.routeSelector` (the operator allows `routes` or
170
+ * `routeSelector`, not both). The routes carry the label
171
+ * `grafana.chant.dev/policy: <policy resource name>`, which the selector
172
+ * matches. A route's own nested routes stay inline in its `spec.routes`.
173
+ * Defaults to false: the whole tree inline in `spec.route`.
174
+ */
175
+ policyRoutes?: boolean;
158
176
  }
159
- type OperatorEntity = (InstanceType<typeof GrafanaDashboard> | InstanceType<typeof GrafanaDatasource> | InstanceType<typeof GrafanaFolder> | InstanceType<typeof GrafanaLibraryPanel>) & Declarable;
177
+ type OperatorEntity = (InstanceType<typeof GrafanaDashboard> | InstanceType<typeof GrafanaDatasource> | InstanceType<typeof GrafanaFolder> | InstanceType<typeof GrafanaLibraryPanel> | InstanceType<typeof GrafanaAlertRuleGroup> | InstanceType<typeof GrafanaContactPoint> | InstanceType<typeof GrafanaNotificationPolicy> | InstanceType<typeof GrafanaNotificationPolicyRoute> | InstanceType<typeof GrafanaMuteTiming> | InstanceType<typeof GrafanaNotificationTemplate>) & Declarable;
160
178
  export type GrafanaOperatorResourcesMembers = Record<string, OperatorEntity>;
161
179
  export type GrafanaOperatorResourcesInstance = CompositeInstance<GrafanaOperatorResourcesMembers> & GrafanaOperatorResourcesMembers;
162
180
  /**
@@ -170,6 +188,56 @@ export declare function operatorDatasource(ds: ProvisionedDatasource, secretName
170
188
  datasource: Record<string, unknown>;
171
189
  valuesFrom: Array<Record<string, unknown>>;
172
190
  };
191
+ /** The label a `GrafanaNotificationPolicyRoute` carries for the policy whose `routeSelector` merges it in. */
192
+ export declare const POLICY_ROUTE_LABEL = "grafana.chant.dev/policy";
193
+ /**
194
+ * One contact point receiver's settings for `spec.receivers[].settings`, and
195
+ * the `valuesFrom` entries for the secrets in it. A setting that is wholly
196
+ * `${NAME}` (or `$__env{NAME}`, `$NAME`) is taken out of `settings` and read
197
+ * from key `NAME` of `secretName` into the same path by the operator, whose
198
+ * `targetPath` is a dotted path inside the settings. A reference inside
199
+ * longer text, or a `$__file` or `$__vault` one, is an error: the operator
200
+ * can only replace a whole value.
201
+ */
202
+ export declare function operatorReceiverSettings(where: string, settings: Record<string, unknown>, secretName: string | undefined): {
203
+ settings: Record<string, unknown>;
204
+ valuesFrom: Array<Record<string, unknown>>;
205
+ };
206
+ /** One contact point as `GrafanaContactPoint.spec`: its name, and its receivers with their secrets in `valuesFrom`. */
207
+ export declare function operatorContactPoint(cp: ProvisionedContactPoint, secretName: string | undefined): Record<string, unknown>;
208
+ /**
209
+ * One rule as an entry of `GrafanaAlertRuleGroup.spec.rules`. The CRD spells
210
+ * two fields in camel case (`missingSeriesEvalsToResolve`,
211
+ * `notificationSettings`), requires `for`, `noDataState` and `execErrState`
212
+ * (Grafana's defaults fill them), and has no use for `dashboardUid` and
213
+ * `panelId`, which it reads from the `__dashboardUid__` and `__panelId__`
214
+ * annotations.
215
+ */
216
+ export declare function operatorRule(rule: ProvisionedAlertRule): Record<string, unknown>;
217
+ /** One policy tree as `GrafanaNotificationPolicy.spec.route`. `orgId` is the operator's to set, so it is left out. */
218
+ export declare function operatorPolicyRoute(policy: Record<string, unknown>): Record<string, unknown>;
219
+ /**
220
+ * The fields `chant import` writes into an imported Grafana Operator
221
+ * resource (#3538): each takes the alerting declaration the field was read
222
+ * into and gives the field `GrafanaOperatorResources` writes for it, so the
223
+ * resource builds back to what was imported.
224
+ */
225
+ /** `GrafanaAlertRuleGroup.spec.rules` for a rule group. */
226
+ export declare function operatorRules(group: AlertRuleGroupEntity): Array<Record<string, unknown>>;
227
+ /** `GrafanaContactPoint.spec.receivers` for a contact point, its `${NAME}` secrets read from `secretName`. */
228
+ export declare function operatorReceivers(cp: ContactPointEntity, secretName?: string): Array<Record<string, unknown>>;
229
+ /** `GrafanaNotificationPolicy.spec.route` for a policy tree. */
230
+ export declare function operatorPolicy(policy: NotificationPolicyEntity): Record<string, unknown>;
231
+ /**
232
+ * `GrafanaNotificationPolicyRoute.spec` for a policy declaration holding the
233
+ * route as its one child: the child's fields, with `receiver` always set
234
+ * (the CRD requires it, so a child that inherits it gets the policy's).
235
+ */
236
+ export declare function operatorRouteSpec(policy: NotificationPolicyEntity): Record<string, unknown>;
237
+ /** `GrafanaMuteTiming.spec.time_intervals` for a mute timing. */
238
+ export declare function operatorTimeIntervals(timing: MuteTimingEntity): Array<Record<string, unknown>>;
239
+ /** `GrafanaNotificationTemplate.spec.template` for a template. */
240
+ export declare function operatorTemplate(template: NotificationTemplateEntity): string;
173
241
  /**
174
242
  * The Grafana Operator's custom resources for a set of grafana declarations
175
243
  * (`grafana.integreatly.org/v1beta1`, Grafana Operator v5.25.0):
@@ -184,7 +252,17 @@ export declare function operatorDatasource(ds: ProvisionedDatasource, secretName
184
252
  * - a `GrafanaDashboard` per dashboard, `<name>-dashboard-<uid>`, holding
185
253
  * `dashboardJson(dashboard)` in `spec.json` and naming its folder with
186
254
  * `folderRef`;
187
- * - a `GrafanaDatasource` per datasource, `<name>-datasource-<uid>`.
255
+ * - a `GrafanaDatasource` per datasource, `<name>-datasource-<uid>`;
256
+ * - for the alerting the build declares: a `GrafanaAlertRuleGroup` per rule
257
+ * group, `<name>-rule-group-<folder>-<group>`, in the `GrafanaFolder` whose
258
+ * title is the group's `folder` (one is written when no folder has it);
259
+ * a `GrafanaContactPoint` per contact point, `<name>-contact-point-<name>`,
260
+ * whose `${NAME}` secrets go to each receiver's `valuesFrom`; a
261
+ * `GrafanaNotificationPolicy`, `<name>-notification-policy`, with its
262
+ * nested routes inline (or, with `policyRoutes`, one
263
+ * `GrafanaNotificationPolicyRoute` per direct child route, selected by
264
+ * label); a `GrafanaMuteTiming` per mute timing and a
265
+ * `GrafanaNotificationTemplate` per template.
188
266
  *
189
267
  * Every resource carries `instanceSelector`. Export the result from a k8s
190
268
  * build root, beside or instead of `GrafanaConfigMaps`.
package/dist/k8s.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"k8s.d.ts","sourceRoot":"","sources":["../src/k8s.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAa,KAAK,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AAClJ,OAAO,EAA4E,KAAK,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAI/H,iHAAiH;AACjH,eAAO,MAAM,uBAAuB,sBAAsB,CAAC;AAC3D,qFAAqF;AACrF,eAAO,MAAM,wBAAwB,uBAAuB,CAAC;AAC7D,kHAAkH;AAClH,eAAO,MAAM,yBAAyB,iCAAiC,CAAC;AAExE,8CAA8C;AAC9C,eAAO,MAAM,yBAAyB,8BAA8B,CAAC;AAErE,MAAM,WAAW,sBAAsB;IACrC,oH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
  "intrinsics": [],
@@ -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;AAmD9D;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,EAAE,aA6I3B,CAAC"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAoD9D;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,EAAE,aA6I3B,CAAC"}
@@ -25,7 +25,7 @@ docker run -p 3000:3000 \
25
25
 
26
26
  ## Kubernetes
27
27
 
28
- Use `GrafanaConfigMaps({ entities, namespace })` from `@intentius/chant-lexicon-grafana/k8s` in a k8s build root. It writes one ConfigMap per dashboard labelled `grafana_dashboard: "1"`, with the folder in the `k8s-sidecar-target-directory` annotation. The datasource file goes in a ConfigMap labelled `grafana_datasource: "1"`, and the provider file in a third. The Grafana Helm chart's sidecar picks these up as they are. For a Grafana without the sidecar, spread `grafanaVolumes({ entities })`'s `volumes` and `volumeMounts` into the Deployment: provisioning goes under `/etc/grafana/provisioning`, and each dashboard folder gets a projected volume of its own. For a Grafana the Grafana Operator runs, use `GrafanaOperatorResources({ entities, namespace, instanceSelector })` instead: a `GrafanaFolder` per folder, a `GrafanaLibraryPanel` per library panel the dashboards place, a `GrafanaDashboard` per dashboard (JSON in `spec.json`, folder by `folderRef`) and a `GrafanaDatasource` per datasource. `instanceSelector` is required and must match the labels on your `Grafana` resource. A datasource secret written `${NAME}` or `$__env{NAME}` needs `secretName`, the Secret holding key `NAME`. `grafanaFiles(entities)` still returns every file by path for any other layout.
28
+ Use `GrafanaConfigMaps({ entities, namespace })` from `@intentius/chant-lexicon-grafana/k8s` in a k8s build root. It writes one ConfigMap per dashboard labelled `grafana_dashboard: "1"`, with the folder in the `k8s-sidecar-target-directory` annotation. The datasource file goes in a ConfigMap labelled `grafana_datasource: "1"`, and the provider file in a third. The Grafana Helm chart's sidecar picks these up as they are. For a Grafana without the sidecar, spread `grafanaVolumes({ entities })`'s `volumes` and `volumeMounts` into the Deployment: provisioning goes under `/etc/grafana/provisioning`, and each dashboard folder gets a projected volume of its own. For a Grafana the Grafana Operator runs, use `GrafanaOperatorResources({ entities, namespace, instanceSelector })` instead: a `GrafanaFolder` per folder, a `GrafanaLibraryPanel` per library panel the dashboards place, a `GrafanaDashboard` per dashboard (JSON in `spec.json`, folder by `folderRef`) a `GrafanaDatasource` per datasource, and for alerting a `GrafanaAlertRuleGroup` per rule group, a `GrafanaContactPoint` per contact point, a `GrafanaNotificationPolicy`, a `GrafanaMuteTiming` per mute timing and a `GrafanaNotificationTemplate` per template. `instanceSelector` is required and must match the labels on your `Grafana` resource. A datasource secret, or a contact point setting that is wholly a variable, written `${NAME}` or `$__env{NAME}` needs `secretName`, the Secret holding key `NAME`; contact point secrets go in each receiver's `valuesFrom`. `grafanaFiles(entities)` still returns every file by path for any other layout.
29
29
 
30
30
  ## Changing where dashboards live
31
31
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intentius/chant-lexicon-grafana",
3
- "version": "0.105.1",
3
+ "version": "0.106.3",
4
4
  "description": "Grafana lexicon for chant — typed dashboards, panels, queries and datasources, serialized to dashboard JSON and Grafana provisioning files",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://intentius.io/chant",
@@ -83,7 +83,7 @@
83
83
  "zod": "^4.3.6"
84
84
  },
85
85
  "peerDependencies": {
86
- "@intentius/chant": "^0.105.1",
86
+ "@intentius/chant": "^0.106.3",
87
87
  "typescript": "^5.9.3",
88
88
  "zod": "^4.3.6"
89
89
  }
package/src/detect.ts CHANGED
@@ -88,6 +88,26 @@ export function looksLikeAlertingProvisioning(data: unknown): data is Record<str
88
88
  return data.apiVersion !== undefined || Array.isArray(data.groups);
89
89
  }
90
90
 
91
+ /**
92
+ * The `spec` of a Grafana Operator alerting resource (`GrafanaAlertRuleGroup`,
93
+ * `GrafanaContactPoint`, `GrafanaNotificationPolicy`, `GrafanaMuteTiming`,
94
+ * `GrafanaNotificationTemplate`) as the k8s importer offers it (#3538): every
95
+ * operator resource's spec has an `instanceSelector`, beside the field that
96
+ * holds the alerting content.
97
+ */
98
+ export function looksLikeOperatorAlertingSpec(data: unknown): boolean {
99
+ if (typeof data !== "object" || data === null || Array.isArray(data)) return false;
100
+ const d = data as Record<string, unknown>;
101
+ if (typeof d.instanceSelector !== "object" || d.instanceSelector === null) return false;
102
+ return (
103
+ (typeof d.name === "string" && Array.isArray(d.rules)) ||
104
+ (typeof d.name === "string" && Array.isArray(d.receivers)) ||
105
+ (typeof d.route === "object" && d.route !== null) ||
106
+ (typeof d.name === "string" && Array.isArray(d.time_intervals)) ||
107
+ (typeof d.name === "string" && typeof d.template === "string")
108
+ );
109
+ }
110
+
91
111
  /**
92
112
  * Template detection for `chant import` and friends: dashboard JSON in any
93
113
  * of the shapes above (v2 included, #2947), or a datasource, dashboard or
@@ -95,6 +115,7 @@ export function looksLikeAlertingProvisioning(data: unknown): data is Record<str
95
115
  */
96
116
  export function detectTemplate(data: unknown): boolean {
97
117
  return (
118
+ looksLikeOperatorAlertingSpec(data) ||
98
119
  looksLikeDashboard(data) ||
99
120
  looksLikeLegacyRowsDashboard(data) ||
100
121
  looksLikeDashboardResource(data) ||
@@ -2,6 +2,7 @@ import { describe, expect, test } from "vitest";
2
2
  import { embeddedDocument, type EmbeddedContent } from "@intentius/chant/import/embedded";
3
3
  import { grafanaPlugin } from "../plugin";
4
4
  import { dashboardImporter } from "./embedded";
5
+ import { operatorImporter } from "./operator";
5
6
 
6
7
  const DASHBOARD = JSON.stringify({
7
8
  title: "API",
@@ -22,7 +23,7 @@ const site = (text: string): EmbeddedContent => ({
22
23
 
23
24
  describe("dashboard JSON embedded in another lexicon's resource (#2962)", () => {
24
25
  test("the plugin registers the importer", () => {
25
- expect(grafanaPlugin.embeddedImporters?.()).toEqual([dashboardImporter]);
26
+ expect(grafanaPlugin.embeddedImporters?.()).toEqual([dashboardImporter, operatorImporter]);
26
27
  });
27
28
 
28
29
  test("matches classic and v2 dashboard JSON; not other text", () => {
@@ -54,4 +55,11 @@ describe("dashboard JSON embedded in another lexicon's resource (#2962)", () =>
54
55
  const file = out.files.find((f) => f.path === binding.from);
55
56
  expect(file?.content).toContain(`const ${binding.name} = new Dashboard(`);
56
57
  });
58
+
59
+ test("panels and queries are written inline, as `chant import dashboard.json` writes them (#3184)", () => {
60
+ const out = dashboardImporter.import(site(DASHBOARD));
61
+ const text = out.files.map((f) => f.content).join("\n");
62
+ expect(text).toContain("new StatPanel(");
63
+ expect(text).not.toMatch(/const panel\d* = new StatPanel/);
64
+ });
57
65
  });
@@ -45,12 +45,11 @@ export const dashboardImporter: EmbeddedContentImporter = {
45
45
  const resource = ir.resources.find((r) => r.type === DASHBOARD_RESOURCE_TYPE);
46
46
  if (!resource) throw new Error((ir.warnings ?? []).join(" ") || "no dashboard was read");
47
47
  const { plan } = resource.properties as unknown as PlanResourceProperties;
48
- // Core gives the content a directory of its own; the plan's would nest a second one inside it. The host's
49
- // project need not list grafana (a k8s project holding a dashboard ConfigMap), and then core lint does not know
50
- // grafana's panels and queries are property-kind, so they keep the flat shape that lints clean without it: a
51
- // const per declaration, nested values lifted, eight to a module (#2988).
52
- const flat = { ...plan, directory: "", main: undefined, declarations: plan.declarations.map(({ property: _, ...d }) => d) };
53
- const { files, exported } = generatePlanModules(flat);
48
+ // Core gives the content a directory of its own; the plan's would nest a second one inside it. Panels and
49
+ // queries stay inline: core lint takes property-kind classes from every lexicon the source imports (#3184), so
50
+ // the host's project need not list grafana.
51
+ const nested = { ...plan, directory: "", main: undefined };
52
+ const { files, exported } = generatePlanModules(nested);
54
53
  const dashboard = exported.get("dashboard");
55
54
  if (!dashboard) throw new Error("the import declared no dashboard");
56
55
  return {