@intentius/chant-lexicon-grafana 0.99.0 → 0.100.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 +12 -6
- package/dist/annotations.d.ts +61 -0
- package/dist/annotations.d.ts.map +1 -0
- package/dist/api/apply.d.ts +8 -4
- package/dist/api/apply.d.ts.map +1 -1
- package/dist/api/fake-grafana.d.ts +2 -0
- package/dist/api/fake-grafana.d.ts.map +1 -1
- package/dist/api/folders.d.ts +53 -17
- package/dist/api/folders.d.ts.map +1 -1
- package/dist/build.d.ts +26 -5
- package/dist/build.d.ts.map +1 -1
- package/dist/catalog.d.ts +1 -1
- package/dist/catalog.d.ts.map +1 -1
- package/dist/codegen/docs.d.ts.map +1 -1
- package/dist/codegen/generate.d.ts +7 -1
- package/dist/codegen/generate.d.ts.map +1 -1
- package/dist/composites/shared.d.ts +4 -3
- package/dist/composites/shared.d.ts.map +1 -1
- package/dist/dashboard.d.ts +42 -14
- package/dist/dashboard.d.ts.map +1 -1
- package/dist/datasource-refs.d.ts +9 -5
- package/dist/datasource-refs.d.ts.map +1 -1
- package/dist/datasource-settings.d.ts +834 -0
- package/dist/datasource-settings.d.ts.map +1 -0
- package/dist/datasource.d.ts +53 -11
- package/dist/datasource.d.ts.map +1 -1
- package/dist/deep-observe-hooks.d.ts +1 -1
- package/dist/deep-observe-hooks.d.ts.map +1 -1
- package/dist/deep-observe.d.ts +9 -4
- package/dist/deep-observe.d.ts.map +1 -1
- package/dist/describe-resources.d.ts +1 -0
- package/dist/describe-resources.d.ts.map +1 -1
- package/dist/detect.d.ts +4 -2
- package/dist/detect.d.ts.map +1 -1
- package/dist/folder.d.ts +68 -0
- package/dist/folder.d.ts.map +1 -0
- package/dist/import/generator.d.ts.map +1 -1
- package/dist/import/mappings.d.ts +12 -6
- package/dist/import/mappings.d.ts.map +1 -1
- package/dist/import/model.d.ts +7 -0
- package/dist/import/model.d.ts.map +1 -1
- package/dist/import/normalize.d.ts.map +1 -1
- package/dist/import/parser.d.ts +16 -1
- package/dist/import/parser.d.ts.map +1 -1
- package/dist/import/testdata/fixtures.d.ts +6 -0
- package/dist/import/testdata/fixtures.d.ts.map +1 -1
- package/dist/import/v2.d.ts +4 -3
- package/dist/import/v2.d.ts.map +1 -1
- package/dist/index.d.ts +11 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/init-templates.d.ts +27 -0
- package/dist/init-templates.d.ts.map +1 -0
- package/dist/integrity.json +11 -9
- package/dist/lint/audit-catalog.d.ts +1 -1
- package/dist/lint/audit-catalog.d.ts.map +1 -1
- package/dist/lint/post-synth/graf101.d.ts +1 -1
- package/dist/lint/post-synth/graf104.d.ts +2 -2
- package/dist/lint/post-synth/graf106.d.ts +2 -2
- package/dist/lint/post-synth/graf110.d.ts +8 -0
- package/dist/lint/post-synth/graf110.d.ts.map +1 -0
- package/dist/lint/post-synth/grafana-helpers.d.ts.map +1 -1
- package/dist/lint/post-synth/index.d.ts.map +1 -1
- package/dist/manifest.json +1 -1
- package/dist/meta.json +70 -0
- package/dist/okf/index.md +18 -3
- package/dist/okf/rules/GRAF101.md +2 -2
- package/dist/okf/rules/GRAF104.md +2 -2
- package/dist/okf/rules/GRAF106.md +2 -2
- package/dist/okf/rules/GRAF110.md +11 -0
- package/dist/okf/types/AdhocVariable.md +9 -0
- package/dist/okf/types/AzureMonitorQuery.md +9 -0
- package/dist/okf/types/BigQueryQuery.md +9 -0
- package/dist/okf/types/CloudMonitoringQuery.md +9 -0
- package/dist/okf/types/CloudWatchQuery.md +9 -0
- package/dist/okf/types/Dashboard.md +1 -1
- package/dist/okf/types/Datasource.md +1 -1
- package/dist/okf/types/DatasourceProvisioning.md +9 -0
- package/dist/okf/types/ElasticsearchQuery.md +9 -0
- package/dist/okf/types/ExternalDatasource.md +1 -1
- package/dist/okf/types/Folder.md +9 -0
- package/dist/okf/types/GroupByVariable.md +9 -0
- package/dist/okf/types/MSSQLQuery.md +9 -0
- package/dist/okf/types/MySQLQuery.md +9 -0
- package/dist/okf/types/PostgresQuery.md +9 -0
- package/dist/okf/types/PyroscopeQuery.md +9 -0
- package/dist/okf/types/SwitchVariable.md +9 -0
- package/dist/op/activities/grafana-apply.d.ts +11 -0
- package/dist/op/activities/grafana-apply.d.ts.map +1 -1
- package/dist/op/activities/index.d.ts +1 -1
- package/dist/op/activities/index.d.ts.map +1 -1
- package/dist/ownership.d.ts +11 -0
- package/dist/ownership.d.ts.map +1 -1
- package/dist/pin.d.ts +1 -1
- package/dist/pin.d.ts.map +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/promql-check.d.ts.map +1 -1
- package/dist/query-models.d.ts +95 -0
- package/dist/query-models.d.ts.map +1 -0
- package/dist/query.d.ts +107 -10
- package/dist/query.d.ts.map +1 -1
- package/dist/rules/graf101.ts +2 -2
- package/dist/rules/graf104.ts +3 -3
- package/dist/rules/graf106.ts +3 -3
- package/dist/rules/graf110.ts +17 -0
- package/dist/rules/grafana-helpers.ts +13 -3
- package/dist/schema/azuremonitor.gen.d.ts +354 -0
- package/dist/schema/azuremonitor.gen.d.ts.map +1 -0
- package/dist/schema/bigquery.gen.d.ts +93 -0
- package/dist/schema/bigquery.gen.d.ts.map +1 -0
- package/dist/schema/cloudwatch.gen.d.ts +394 -0
- package/dist/schema/cloudwatch.gen.d.ts.map +1 -0
- package/dist/schema/elasticsearch.gen.d.ts +444 -0
- package/dist/schema/elasticsearch.gen.d.ts.map +1 -0
- package/dist/schema/googlecloudmonitoring.gen.d.ts +312 -0
- package/dist/schema/googlecloudmonitoring.gen.d.ts.map +1 -0
- package/dist/schema/grafanapyroscope.gen.d.ts +60 -0
- package/dist/schema/grafanapyroscope.gen.d.ts.map +1 -0
- package/dist/schema/index.d.ts +6 -0
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/table.gen.d.ts +13 -0
- package/dist/schema/table.gen.d.ts.map +1 -1
- package/dist/schema-validate.d.ts +9 -0
- package/dist/schema-validate.d.ts.map +1 -1
- package/dist/skill-defs.d.ts.map +1 -1
- package/dist/skills/chant-grafana-operations.md +108 -0
- package/dist/skills/chant-grafana.md +5 -4
- package/dist/spec/schemas.d.ts +9 -7
- package/dist/spec/schemas.d.ts.map +1 -1
- package/dist/spec/schemas.gen.d.ts +3 -0
- package/dist/spec/schemas.gen.d.ts.map +1 -0
- package/dist/validate-alerting.d.ts.map +1 -1
- package/dist/validate-output.d.ts +15 -2
- package/dist/validate-output.d.ts.map +1 -1
- package/dist/validate.d.ts.map +1 -1
- package/dist/validation.d.ts +14 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/variables.d.ts +102 -5
- package/dist/variables.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/annotations.ts +84 -0
- package/src/api/apply.test.ts +19 -1
- package/src/api/apply.ts +18 -8
- package/src/api/fake-grafana.ts +6 -2
- package/src/api/folders.ts +106 -32
- package/src/build.test.ts +142 -6
- package/src/build.ts +126 -24
- package/src/catalog.ts +20 -2
- package/src/codegen/docs.ts +13 -6
- package/src/codegen/generate.ts +27 -1
- package/src/composites/shared.ts +3 -2
- package/src/dashboard.ts +59 -14
- package/src/datasource-refs.ts +30 -6
- package/src/datasource-settings.test.ts +106 -0
- package/src/datasource-settings.ts +941 -0
- package/src/datasource.ts +71 -11
- package/src/deep-observe-hooks.ts +16 -1
- package/src/deep-observe.test.ts +47 -1
- package/src/deep-observe.ts +36 -13
- package/src/describe-resources.test.ts +16 -0
- package/src/describe-resources.ts +36 -1
- package/src/detect.ts +3 -3
- package/src/folder.ts +118 -0
- package/src/generated/lexicon-grafana.json +70 -0
- package/src/import/generated-types.e2e.test.ts +15 -3
- package/src/import/generator.ts +2 -1
- package/src/import/mappings.ts +98 -26
- package/src/import/model.ts +7 -0
- package/src/import/normalize.ts +32 -3
- package/src/import/parser.test.ts +97 -21
- package/src/import/parser.ts +169 -18
- package/src/import/roundtrip.test.ts +104 -9
- package/src/import/testdata/fixtures.ts +8 -0
- package/src/import/v2.ts +4 -3
- package/src/index.ts +122 -13
- package/src/init-templates.test.ts +74 -0
- package/src/init-templates.ts +349 -0
- package/src/lint/audit-catalog.ts +9 -1
- package/src/lint/post-synth/graf101.ts +2 -2
- package/src/lint/post-synth/graf104.ts +3 -3
- package/src/lint/post-synth/graf106.ts +3 -3
- package/src/lint/post-synth/graf110.ts +17 -0
- package/src/lint/post-synth/grafana-helpers.ts +13 -3
- package/src/lint/post-synth/index.ts +2 -0
- package/src/lint/post-synth/post-synth.test.ts +99 -2
- package/src/load-cost.test.ts +35 -0
- package/src/op/activities/grafana-apply.e2e.test.ts +14 -5
- package/src/op/activities/grafana-apply.test.ts +16 -2
- package/src/op/activities/grafana-apply.ts +29 -3
- package/src/op/activities/index.ts +1 -1
- package/src/ownership.ts +19 -0
- package/src/panels.test.ts +3 -1
- package/src/pin.ts +12 -0
- package/src/plugin.test.ts +9 -2
- package/src/plugin.ts +9 -0
- package/src/promql-check.ts +5 -1
- package/src/query-models.ts +94 -0
- package/src/query.test.ts +166 -0
- package/src/query.ts +177 -12
- package/src/schema/azuremonitor.gen.ts +381 -0
- package/src/schema/bigquery.gen.ts +110 -0
- package/src/schema/cloudwatch.gen.ts +423 -0
- package/src/schema/elasticsearch.gen.ts +508 -0
- package/src/schema/googlecloudmonitoring.gen.ts +330 -0
- package/src/schema/grafanapyroscope.gen.ts +66 -0
- package/src/schema/index.ts +6 -0
- package/src/schema/table.gen.ts +14 -0
- package/src/schema-validate.ts +58 -7
- package/src/skill-defs.ts +17 -0
- package/src/skills/chant-grafana-operations.md +108 -0
- package/src/skills/chant-grafana.md +5 -4
- package/src/spec/overlay/table.overlay.json +19 -0
- package/src/spec/schemas/azuremonitor.jsonschema.json +679 -0
- package/src/spec/schemas/bigquery.jsonschema.json +290 -0
- package/src/spec/schemas/cloudwatch.jsonschema.json +721 -0
- package/src/spec/schemas/elasticsearch.jsonschema.json +1695 -0
- package/src/spec/schemas/googlecloudmonitoring.jsonschema.json +488 -0
- package/src/spec/schemas/grafanapyroscope.jsonschema.json +93 -0
- package/src/spec/schemas.gen.ts +40 -0
- package/src/spec/schemas.ts +9 -7
- package/src/validate-alerting.ts +4 -2
- package/src/validate-output.ts +96 -4
- package/src/validate.ts +14 -0
- package/src/validation.ts +27 -0
- package/src/variables.ts +113 -6
|
@@ -19,6 +19,7 @@ import type { OwnershipMarker } from "@intentius/chant/ownership";
|
|
|
19
19
|
import { type ApplyResult } from "@intentius/chant/apply";
|
|
20
20
|
import type { GrafanaHttp } from "../../api/client.js";
|
|
21
21
|
import { type BuiltDashboardInput, type GrafanaApplyOutcome } from "../../api/apply.js";
|
|
22
|
+
import type { FolderPlan } from "../../api/folders.js";
|
|
22
23
|
export type { GrafanaApplyOutcome } from "../../api/apply.js";
|
|
23
24
|
export interface GrafanaApplyArgs {
|
|
24
25
|
/**
|
|
@@ -54,6 +55,16 @@ export interface GrafanaApplyDeps {
|
|
|
54
55
|
* it. Pure but for the file reads.
|
|
55
56
|
*/
|
|
56
57
|
export declare function readBuiltDashboards(indexPath: string, read?: (path: string) => string): BuiltDashboardInput[];
|
|
58
|
+
/**
|
|
59
|
+
* The dashboards a build wrote, with their folders, and the folders its
|
|
60
|
+
* index lists (every level of every folder, `Folder`s holding no dashboard
|
|
61
|
+
* included). An index written before folders were listed has none, and the
|
|
62
|
+
* plan derives them from the dashboards' paths.
|
|
63
|
+
*/
|
|
64
|
+
export declare function readBuiltIndex(indexPath: string, read?: (path: string) => string): {
|
|
65
|
+
dashboards: BuiltDashboardInput[];
|
|
66
|
+
folders: FolderPlan[];
|
|
67
|
+
};
|
|
57
68
|
/** The marker to stamp and prune by: the arguments, else the project's `ownership` config. */
|
|
58
69
|
export declare function resolveMarker(args: Pick<GrafanaApplyArgs, "stack" | "ownershipEnv">, config: Pick<ChantConfig, "ownership"> | undefined): OwnershipMarker | undefined;
|
|
59
70
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grafana-apply.d.ts","sourceRoot":"","sources":["../../../src/op/activities/grafana-apply.ts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;AAED,oHAAoH;AACpH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,MAAM,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,SAAS,GAAG,WAAW,CAAC,CAAC;IACpD,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;CAC1C;AAQD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAuC,GAAG,mBAAmB,EAAE,CAE7I;AAUD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAuC,GAAG;IAAE,UAAU,EAAE,mBAAmB,EAAE,CAAC;IAAC,OAAO,EAAE,UAAU,EAAE,CAAA;CAAE,CAiB/K;AAWD,8FAA8F;AAC9F,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,gBAAgB,EAAE,OAAO,GAAG,cAAc,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,GAAG,SAAS,GAAG,eAAe,GAAG,SAAS,CAUrK;AAED;;;;;;GAMG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,gBAAgB,EAAE,MAAM,CAAC,EAAE,WAAW,EAAE,IAAI,GAAE,gBAAqB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAsC1I;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,mBAAmB,GAAG,WAAW,CAOvE"}
|
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
* API applier (`grafanaApply`, #2948) and its envelope projection
|
|
5
5
|
* (`toApplyResult`), which core's apply activity looks up by name.
|
|
6
6
|
*/
|
|
7
|
-
export { grafanaApply, toApplyResult, readBuiltDashboards, resolveMarker } from "./grafana-apply.js";
|
|
7
|
+
export { grafanaApply, toApplyResult, readBuiltDashboards, readBuiltIndex, resolveMarker } from "./grafana-apply.js";
|
|
8
8
|
export type { GrafanaApplyArgs, GrafanaApplyDeps, GrafanaApplyOutcome } from "./grafana-apply.js";
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/op/activities/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/op/activities/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,mBAAmB,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAClH,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/ownership.d.ts
CHANGED
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
*/
|
|
31
31
|
import { type ChannelKeys, type OwnershipMarker } from "@intentius/chant/ownership";
|
|
32
32
|
import type { LiveDashboard } from "./api/dashboards.js";
|
|
33
|
+
import type { LiveFolder } from "./api/folders.js";
|
|
33
34
|
/** The label keys chant's marker uses on a `dashboard.grafana.app` resource. */
|
|
34
35
|
export declare const GRAFANA_OWNERSHIP_KEYS: ChannelKeys;
|
|
35
36
|
export declare const MANAGED_BY_ANNOTATION = "grafana.app/managedBy";
|
|
@@ -64,4 +65,14 @@ export declare function dashboardOwnership(dashboard: LiveDashboard, providers:
|
|
|
64
65
|
ownership: OwnershipVerdict;
|
|
65
66
|
marker?: OwnershipMarker;
|
|
66
67
|
};
|
|
68
|
+
/**
|
|
69
|
+
* A folder's ownership verdict, read the way a dashboard's is: chant's labels
|
|
70
|
+
* (the API applier's), else the manager annotations Grafana writes on a
|
|
71
|
+
* folder that file provisioning made for one of this project's providers.
|
|
72
|
+
* A folder read over `/api/folders` (Grafana 11) has neither: `unknown`.
|
|
73
|
+
*/
|
|
74
|
+
export declare function folderOwnership(folder: LiveFolder, providers: ReadonlySet<string>): {
|
|
75
|
+
ownership: OwnershipVerdict;
|
|
76
|
+
marker?: OwnershipMarker;
|
|
77
|
+
};
|
|
67
78
|
//# sourceMappingURL=ownership.d.ts.map
|
package/dist/ownership.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ownership.d.ts","sourceRoot":"","sources":["../src/ownership.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAOL,KAAK,WAAW,EAChB,KAAK,eAAe,EACrB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"ownership.d.ts","sourceRoot":"","sources":["../src/ownership.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAOL,KAAK,WAAW,EAChB,KAAK,eAAe,EACrB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,gFAAgF;AAChF,eAAO,MAAM,sBAAsB,EAAE,WAAkC,CAAC;AAExE,eAAO,MAAM,qBAAqB,0BAA0B,CAAC;AAC7D,eAAO,MAAM,qBAAqB,0BAA0B,CAAC;AAC7D,yEAAyE;AACzE,eAAO,MAAM,yBAAyB,8BAA8B,CAAC;AAErE;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,UAA6B,CAAC;AAEhE,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC;AAE/D,2GAA2G;AAC3G,wBAAgB,sBAAsB,CAAC,SAAS,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAEzG;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,CAO1H;AAED,8FAA8F;AAC9F,wBAAgB,YAAY,CAAC,SAAS,EAAE,aAAa,GAAG,MAAM,CAI7D;AAED,2FAA2F;AAC3F,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,aAAa,EACxB,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,GAC7B;IAAE,SAAS,EAAE,gBAAgB,CAAC;IAAC,MAAM,CAAC,EAAE,eAAe,CAAA;CAAE,CAW3D;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG;IAAE,SAAS,EAAE,gBAAgB,CAAC;IAAC,MAAM,CAAC,EAAE,eAAe,CAAA;CAAE,CAU7I"}
|
package/dist/pin.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export interface GrafanaSchemaPin {
|
|
|
34
34
|
/** sha256 of each vendored file, keyed by schema name (`src/spec/schemas/<name>.jsonschema.json`). */
|
|
35
35
|
files: Readonly<Record<VendoredSchemaName, string>>;
|
|
36
36
|
}
|
|
37
|
-
export declare const SCHEMA_NAMES: readonly ["dashboard", "timeseries", "stat", "gauge", "table", "logs", "heatmap", "text", "barchart", "bargauge", "piechart", "statetimeline", "statushistory", "histogram", "nodegraph", "xychart", "trend", "canvas", "geomap", "prometheus", "tempo", "loki", "expr"];
|
|
37
|
+
export declare const SCHEMA_NAMES: readonly ["dashboard", "timeseries", "stat", "gauge", "table", "logs", "heatmap", "text", "barchart", "bargauge", "piechart", "statetimeline", "statushistory", "histogram", "nodegraph", "xychart", "trend", "canvas", "geomap", "prometheus", "tempo", "loki", "elasticsearch", "cloudwatch", "azuremonitor", "googlecloudmonitoring", "bigquery", "grafanapyroscope", "expr"];
|
|
38
38
|
export type SchemaName = (typeof SCHEMA_NAMES)[number];
|
|
39
39
|
/**
|
|
40
40
|
* Schemas vendored from the same commit for reading, not for types: no
|
package/dist/pin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pin.d.ts","sourceRoot":"","sources":["../src/pin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,MAAM,WAAW,gBAAgB;IAC/B,wCAAwC;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,GAAG,EAAE,MAAM,CAAC;IACZ,2DAA2D;IAC3D,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB,sGAAsG;IACtG,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC,CAAC;CACrD;AAED,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"pin.d.ts","sourceRoot":"","sources":["../src/pin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,MAAM,WAAW,gBAAgB;IAC/B,wCAAwC;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,GAAG,EAAE,MAAM,CAAC;IACZ,2DAA2D;IAC3D,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB,sGAAsG;IACtG,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC,CAAC;CACrD;AAED,eAAO,MAAM,YAAY,kXA8Bf,CAAC;AAEX,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvD;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,0BAA2B,CAAC;AAEjE,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE7E,mDAAmD;AACnD,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG,oBAAoB,CAAC;AAEnE,eAAO,MAAM,qBAAqB,EAAE,SAAS,kBAAkB,EAAmD,CAAC;AAEnH,eAAO,MAAM,kBAAkB,EAAE,gBAqC/B,CAAC;AAEH,2DAA2D;AAC3D,wBAAgB,SAAS,CAAC,IAAI,EAAE,kBAAkB,EAAE,GAAG,GAAE,gBAAqC,GAAG,MAAM,CAEtG"}
|
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;
|
|
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,aAkI3B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promql-check.d.ts","sourceRoot":"","sources":["../src/promql-check.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EAA+B,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEtF,KAAK,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;A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AACjF,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAS9D;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAWtD;AASD,oFAAoF;AACpF,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAuBD,kJAAkJ;AAClJ,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG,SAAS,EAAE,CAa3G"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hand-written query models for the datasources that have no schema.
|
|
3
|
+
*
|
|
4
|
+
* PostgreSQL, MySQL and Microsoft SQL Server share one query model, defined
|
|
5
|
+
* in TypeScript in Grafana's `@grafana/sql` package with no CUE kind, so
|
|
6
|
+
* foundation-sdk publishes no JSON Schema for it and `npm run generate` has
|
|
7
|
+
* nothing to read. The types here follow `packages/grafana-sql/src` at
|
|
8
|
+
* Grafana v13.2.2, cited per type. The three plugins bundled with
|
|
9
|
+
* grafana/grafana:13.2.2 (grafana-postgresql-datasource 13.0.3, mysql 13.1.2,
|
|
10
|
+
* mssql 13.0.5) use this model unchanged. GRAF107 does not check these
|
|
11
|
+
* queries' fields; the dashboard schema's `Panel` still checks the panel.
|
|
12
|
+
*/
|
|
13
|
+
/** `QueryEditorExpressionType`, packages/grafana-sql/src/expressions.ts:34-42. */
|
|
14
|
+
export type SqlExpressionType = "property" | "operator" | "or" | "and" | "groupBy" | "function" | "functionParameter";
|
|
15
|
+
/** `QueryEditorProperty`, packages/grafana-sql/src/expressions.ts:5-8 (its type is the one-member `QueryEditorPropertyType`). */
|
|
16
|
+
export interface SqlProperty {
|
|
17
|
+
type: "string";
|
|
18
|
+
name?: string;
|
|
19
|
+
}
|
|
20
|
+
/** `QueryEditorFunctionParameterExpression`, packages/grafana-sql/src/expressions.ts:64-67. */
|
|
21
|
+
export interface SqlFunctionParameterExpression {
|
|
22
|
+
type: "functionParameter";
|
|
23
|
+
name?: string;
|
|
24
|
+
}
|
|
25
|
+
/** `QueryEditorFunctionExpression`, packages/grafana-sql/src/expressions.ts:57-62: a selected column, optionally wrapped in an aggregation. */
|
|
26
|
+
export interface SqlFunctionExpression {
|
|
27
|
+
type: "function";
|
|
28
|
+
name?: string;
|
|
29
|
+
alias?: string;
|
|
30
|
+
parameters?: SqlFunctionParameterExpression[];
|
|
31
|
+
}
|
|
32
|
+
/** `QueryEditorGroupByExpression`, packages/grafana-sql/src/expressions.ts:52-55. */
|
|
33
|
+
export interface SqlGroupByExpression {
|
|
34
|
+
type: "groupBy";
|
|
35
|
+
property: SqlProperty;
|
|
36
|
+
}
|
|
37
|
+
/** `QueryEditorPropertyExpression`, packages/grafana-sql/src/expressions.ts:29-32. */
|
|
38
|
+
export interface SqlPropertyExpression {
|
|
39
|
+
type: "property";
|
|
40
|
+
property: SqlProperty;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The visual builder's query: `SQLExpression`, packages/grafana-sql/src/types.ts:67-77.
|
|
44
|
+
* `whereJsonTree` is react-awesome-query-builder's `JsonTree`, carried as data.
|
|
45
|
+
*/
|
|
46
|
+
export interface SqlBuilderQuery {
|
|
47
|
+
columns?: SqlFunctionExpression[];
|
|
48
|
+
whereJsonTree?: Record<string, unknown>;
|
|
49
|
+
whereString?: string;
|
|
50
|
+
filters?: Array<{
|
|
51
|
+
name: string;
|
|
52
|
+
value: string;
|
|
53
|
+
}>;
|
|
54
|
+
groupBy?: SqlGroupByExpression[];
|
|
55
|
+
orderBy?: SqlPropertyExpression;
|
|
56
|
+
orderByDirection?: "ASC" | "DESC";
|
|
57
|
+
limit?: number;
|
|
58
|
+
offset?: number;
|
|
59
|
+
}
|
|
60
|
+
/** `QueryFormat`, packages/grafana-sql/src/types.ts:39-42. */
|
|
61
|
+
export type SqlQueryFormat = "time_series" | "table";
|
|
62
|
+
/**
|
|
63
|
+
* A PostgreSQL, MySQL or MSSQL query: `SQLQuery`, packages/grafana-sql/src/types.ts:46-56,
|
|
64
|
+
* over `DataQuery` from @grafana/schema (refId, hide, key, queryType, datasource).
|
|
65
|
+
*
|
|
66
|
+
* In code mode (`editorMode: "code"`, `rawQuery: true`) `rawSql` is the
|
|
67
|
+
* query; in builder mode `dataset`, `table` and `sql` describe it and Grafana
|
|
68
|
+
* writes the generated SQL to `rawSql`.
|
|
69
|
+
*/
|
|
70
|
+
export interface SqlQueryModel {
|
|
71
|
+
refId?: string;
|
|
72
|
+
hide?: boolean;
|
|
73
|
+
key?: string;
|
|
74
|
+
queryType?: string;
|
|
75
|
+
datasource?: {
|
|
76
|
+
type?: string;
|
|
77
|
+
uid?: string;
|
|
78
|
+
};
|
|
79
|
+
/** The SQL, with Grafana's `$__timeFilter()` and other macros. */
|
|
80
|
+
rawSql?: string;
|
|
81
|
+
format?: SqlQueryFormat;
|
|
82
|
+
alias?: string;
|
|
83
|
+
dataset?: string;
|
|
84
|
+
table?: string;
|
|
85
|
+
sql?: SqlBuilderQuery;
|
|
86
|
+
/** `EditorMode` from @grafana/plugin-ui: the raw SQL editor or the visual builder. */
|
|
87
|
+
editorMode?: "code" | "builder";
|
|
88
|
+
rawQuery?: boolean;
|
|
89
|
+
/** `SQLQueryMeta`, packages/grafana-sql/src/types.ts:44: which columns a variable query takes its values and texts from. */
|
|
90
|
+
meta?: {
|
|
91
|
+
valueField?: string;
|
|
92
|
+
textField?: string;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=query-models.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-models.d.ts","sourceRoot":"","sources":["../src/query-models.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,kFAAkF;AAClF,MAAM,MAAM,iBAAiB,GAAG,UAAU,GAAG,UAAU,GAAG,I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MAAM,cAAc,GAAG,aAAa,GAAG,OAAO,CAAC;AAErD;;;;;;;GAOG;AACH,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7C,kEAAkE;IAClE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,eAAe,CAAC;IACtB,sFAAsF;IACtF,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,4HAA4H;IAC5H,IAAI,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACpD"}
|
package/dist/query.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Typed queries, one class per datasource plugin
|
|
3
|
-
* `TempoQuery` (TraceQL)
|
|
4
|
-
*
|
|
2
|
+
* Typed queries, one class per datasource plugin. `PromQuery` (PromQL),
|
|
3
|
+
* `TempoQuery` (TraceQL), `LokiQuery` (LogQL), `ElasticsearchQuery`,
|
|
4
|
+
* `CloudWatchQuery`, `AzureMonitorQuery`, `CloudMonitoringQuery`,
|
|
5
|
+
* `BigQueryQuery` and `PyroscopeQuery` are typed from that plugin's query
|
|
6
|
+
* schema at `GRAFANA_SCHEMA_PIN`. `PostgresQuery`, `MySQLQuery` and
|
|
7
|
+
* `MSSQLQuery` have no schema upstream and are typed by hand from Grafana's
|
|
8
|
+
* source (`./query-models.ts`).
|
|
5
9
|
*
|
|
6
10
|
* The expression is a string. What the lexicon checks is where the query
|
|
7
11
|
* goes: `datasource` only accepts a datasource of the query's own plugin
|
|
@@ -19,10 +23,34 @@ import type { SchemaName } from "./pin.js";
|
|
|
19
23
|
import type { Dataquery as PrometheusDataquery } from "./schema/prometheus.gen.js";
|
|
20
24
|
import type { Dataquery as TempoDataquery } from "./schema/tempo.gen.js";
|
|
21
25
|
import type { Dataquery as LokiDataquery } from "./schema/loki.gen.js";
|
|
26
|
+
import type { Dataquery as ElasticsearchDataquery } from "./schema/elasticsearch.gen.js";
|
|
27
|
+
import type { Request as CloudWatchRequest } from "./schema/cloudwatch.gen.js";
|
|
28
|
+
import type { MonitorQuery as AzureMonitorDataquery } from "./schema/azuremonitor.gen.js";
|
|
29
|
+
import type { CloudMonitoringQuery as CloudMonitoringDataquery } from "./schema/googlecloudmonitoring.gen.js";
|
|
30
|
+
import type { Dataquery as BigQueryDataquery } from "./schema/bigquery.gen.js";
|
|
31
|
+
import type { Dataquery as PyroscopeDataquery } from "./schema/grafanapyroscope.gen.js";
|
|
32
|
+
import type { SqlQueryModel } from "./query-models.js";
|
|
22
33
|
/** Where a query or panel sends its request: a declared or external datasource, a datasource variable, or the ref of one declared elsewhere. */
|
|
23
34
|
export type DatasourceInput<T extends string = string> = DatasourceEntity<T> | ExternalDatasourceEntity<T> | DatasourceVariableEntity<T> | DatasourceRef<T>;
|
|
24
|
-
/**
|
|
25
|
-
|
|
35
|
+
/**
|
|
36
|
+
* A query model's fields, less what chant fills in (`datasource`, `refId`
|
|
37
|
+
* stays optional). A model that is a union (CloudWatch's metrics, logs and
|
|
38
|
+
* annotation queries) stays one, member by member.
|
|
39
|
+
*/
|
|
40
|
+
export type QueryModel<M> = M extends unknown ? Omit<M, "datasource"> : never;
|
|
41
|
+
/** `M` with the fields `K` optional, member by member: for fields a schema requires that Grafana fills in when they are missing. */
|
|
42
|
+
export type Loosen<M, K extends PropertyKey> = M extends unknown ? Omit<M, K> & Partial<Pick<M, K & keyof M>> : never;
|
|
43
|
+
type KeysOfUnion<U> = U extends unknown ? keyof U : never;
|
|
44
|
+
/**
|
|
45
|
+
* A union of models as one object type: every member's fields, each
|
|
46
|
+
* optional, typed as the union of what the members allow there. A class
|
|
47
|
+
* whose props are a union could not have a single prop named by
|
|
48
|
+
* `PropsOf<typeof Class>["key"]`, which is how imported source types its
|
|
49
|
+
* lifted consts.
|
|
50
|
+
*/
|
|
51
|
+
export type MergedModel<U> = {
|
|
52
|
+
[K in KeysOfUnion<U>]?: U extends unknown ? (K extends keyof U ? U[K] : never) : never;
|
|
53
|
+
};
|
|
26
54
|
export type QueryProps<M, T extends string> = QueryModel<M> & {
|
|
27
55
|
/** Overrides the panel's datasource for this query. */
|
|
28
56
|
datasource?: DatasourceInput<T>;
|
|
@@ -41,6 +69,12 @@ export interface QueryDefinition<T extends string = string, M = Record<string, u
|
|
|
41
69
|
defaults?: Partial<M>;
|
|
42
70
|
/** True only for the queries this package ships. */
|
|
43
71
|
builtin: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Other plugin ids Grafana accepts for the same plugin (`aliasIDs` in its
|
|
74
|
+
* plugin.json), e.g. `postgres` for `grafana-postgresql-datasource`. The
|
|
75
|
+
* class is registered under each, so imports and GRAF107 find it by either.
|
|
76
|
+
*/
|
|
77
|
+
aliases?: readonly string[];
|
|
44
78
|
}
|
|
45
79
|
export interface QueryEntity<T extends string = string, M = Record<string, unknown>> extends Declarable {
|
|
46
80
|
readonly props: QueryProps<M, T>;
|
|
@@ -51,7 +85,7 @@ export interface QueryClass<T extends string = string, M = Record<string, unknow
|
|
|
51
85
|
readonly definition: QueryDefinition<T, M>;
|
|
52
86
|
}
|
|
53
87
|
export declare const QUERY_TYPE_PREFIX = "Grafana::Query::";
|
|
54
|
-
/** Every registered query definition,
|
|
88
|
+
/** Every registered query definition, once each (a definition with aliases is registered under several types). */
|
|
55
89
|
export declare function registeredQueries(): QueryDefinition[];
|
|
56
90
|
export declare function queryDefinitionFor(datasourceType: string): QueryDefinition | undefined;
|
|
57
91
|
/**
|
|
@@ -59,11 +93,11 @@ export declare function queryDefinitionFor(datasourceType: string): QueryDefinit
|
|
|
59
93
|
*
|
|
60
94
|
* @example
|
|
61
95
|
* ```ts
|
|
62
|
-
* interface
|
|
96
|
+
* interface OpenSearchQueryModel { query: string; queryType?: "lucene" | "PPL"; refId?: string }
|
|
63
97
|
*
|
|
64
|
-
* export const
|
|
65
|
-
* datasourceType: "
|
|
66
|
-
* className: "
|
|
98
|
+
* export const OpenSearchQuery = defineQuery<OpenSearchQueryModel>()({
|
|
99
|
+
* datasourceType: "grafana-opensearch-datasource",
|
|
100
|
+
* className: "OpenSearchQuery",
|
|
67
101
|
* expressionField: "query",
|
|
68
102
|
* });
|
|
69
103
|
* ```
|
|
@@ -76,7 +110,70 @@ export declare const PromQuery: QueryClass<"prometheus", PrometheusDataquery>;
|
|
|
76
110
|
export declare const TempoQuery: QueryClass<"tempo", Omit<TempoDataquery, "filters"> & Partial<Pick<TempoDataquery, "filters">>>;
|
|
77
111
|
/** A Loki query: `expr` is LogQL. */
|
|
78
112
|
export declare const LokiQuery: QueryClass<"loki", LokiDataquery>;
|
|
113
|
+
/**
|
|
114
|
+
* An Elasticsearch query: `query` is Lucene (or the query string of a raw
|
|
115
|
+
* data, raw document or logs query), `metrics` and `bucketAggs` the
|
|
116
|
+
* aggregations.
|
|
117
|
+
*/
|
|
118
|
+
export declare const ElasticsearchQuery: QueryClass<"elasticsearch", ElasticsearchDataquery>;
|
|
119
|
+
/**
|
|
120
|
+
* A CloudWatch query: a metrics query (`queryMode: "Metrics"`), a Logs
|
|
121
|
+
* Insights query (`queryMode: "Logs"`, `expression` in `queryLanguage`) or an
|
|
122
|
+
* annotation query. The three schema definitions are merged into one type
|
|
123
|
+
* with every field but `queryMode` optional, so each field is one prop;
|
|
124
|
+
* GRAF107 checks the fields against the three definitions. Grafana's editor
|
|
125
|
+
* starts `id` and `region` at `""` and `"default"`
|
|
126
|
+
* (public/app/plugins/datasource/cloudwatch/defaultQueries.ts:12-27 and
|
|
127
|
+
* 41-52 at v13.2.2), and the backend reads a missing region as the
|
|
128
|
+
* datasource's default (pkg/tsdb/cloudwatch/cloudwatch.go:65).
|
|
129
|
+
*/
|
|
130
|
+
export declare const CloudWatchQuery: QueryClass<"cloudwatch", MergedModel<CloudWatchRequest> & Pick<CloudWatchRequest, "queryMode">>;
|
|
131
|
+
/**
|
|
132
|
+
* An Azure Monitor query: `queryType` picks which of `azureMonitor`,
|
|
133
|
+
* `azureLogAnalytics` (KQL), `azureResourceGraph` or `azureTraces` holds it.
|
|
134
|
+
*/
|
|
135
|
+
export declare const AzureMonitorQuery: QueryClass<"grafana-azure-monitor-datasource", AzureMonitorDataquery>;
|
|
136
|
+
/**
|
|
137
|
+
* A Google Cloud Monitoring query (plugin id `stackdriver`): `queryType`
|
|
138
|
+
* picks which of `timeSeriesList`, `timeSeriesQuery` (MQL), `sloQuery` or
|
|
139
|
+
* `promQLQuery` holds it.
|
|
140
|
+
*/
|
|
141
|
+
export declare const CloudMonitoringQuery: QueryClass<"stackdriver", CloudMonitoringDataquery>;
|
|
142
|
+
/**
|
|
143
|
+
* A BigQuery query: `rawSql` is GoogleSQL. `format` and `rawSql` may be left
|
|
144
|
+
* out: the plugin fills in `table` and `""` (src/utils.ts:147-160 in
|
|
145
|
+
* grafana/google-bigquery-datasource v3.4.2).
|
|
146
|
+
*/
|
|
147
|
+
export declare const BigQueryQuery: QueryClass<"grafana-bigquery-datasource", Omit<BigQueryDataquery, "format" | "rawSql"> & Partial<Pick<BigQueryDataquery, "format" | "rawSql">>>;
|
|
148
|
+
/**
|
|
149
|
+
* A Grafana Pyroscope query: `labelSelector` selects the profiles of
|
|
150
|
+
* `profileTypeId`. `labelSelector` and `groupBy` may be left out: the plugin
|
|
151
|
+
* starts them at `{}` and none (dataquery.ts:67-75 and datasource.ts:156-164
|
|
152
|
+
* in grafana-pyroscope-datasource 13.0.4, the version bundled with
|
|
153
|
+
* grafana/grafana:13.2.2).
|
|
154
|
+
*/
|
|
155
|
+
export declare const PyroscopeQuery: QueryClass<"grafana-pyroscope-datasource", Omit<PyroscopeDataquery, "groupBy" | "labelSelector"> & Partial<Pick<PyroscopeDataquery, "groupBy" | "labelSelector">>>;
|
|
156
|
+
/**
|
|
157
|
+
* A PostgreSQL query: `rawSql` is SQL with Grafana's macros. Also used for
|
|
158
|
+
* the plugin's old id, `postgres` (an `aliasIDs` entry in the plugin.json of
|
|
159
|
+
* grafana-postgresql-datasource 13.0.3, bundled with grafana/grafana:13.2.2).
|
|
160
|
+
*/
|
|
161
|
+
export declare const PostgresQuery: QueryClass<"grafana-postgresql-datasource" | "postgres", SqlQueryModel>;
|
|
162
|
+
/** A MySQL query: `rawSql` is SQL with Grafana's macros. */
|
|
163
|
+
export declare const MySQLQuery: QueryClass<"mysql", SqlQueryModel>;
|
|
164
|
+
/** A Microsoft SQL Server query: `rawSql` is T-SQL with Grafana's macros. */
|
|
165
|
+
export declare const MSSQLQuery: QueryClass<"mssql", SqlQueryModel>;
|
|
79
166
|
export type PromQueryEntity = InstanceType<typeof PromQuery>;
|
|
80
167
|
export type TempoQueryEntity = InstanceType<typeof TempoQuery>;
|
|
81
168
|
export type LokiQueryEntity = InstanceType<typeof LokiQuery>;
|
|
169
|
+
export type ElasticsearchQueryEntity = InstanceType<typeof ElasticsearchQuery>;
|
|
170
|
+
export type CloudWatchQueryEntity = InstanceType<typeof CloudWatchQuery>;
|
|
171
|
+
export type AzureMonitorQueryEntity = InstanceType<typeof AzureMonitorQuery>;
|
|
172
|
+
export type CloudMonitoringQueryEntity = InstanceType<typeof CloudMonitoringQuery>;
|
|
173
|
+
export type BigQueryQueryEntity = InstanceType<typeof BigQueryQuery>;
|
|
174
|
+
export type PyroscopeQueryEntity = InstanceType<typeof PyroscopeQuery>;
|
|
175
|
+
export type PostgresQueryEntity = InstanceType<typeof PostgresQuery>;
|
|
176
|
+
export type MySQLQueryEntity = InstanceType<typeof MySQLQuery>;
|
|
177
|
+
export type MSSQLQueryEntity = InstanceType<typeof MSSQLQuery>;
|
|
178
|
+
export {};
|
|
82
179
|
//# sourceMappingURL=query.d.ts.map
|
package/dist/query.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAC9F,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,KAAK,EAAE,SAAS,IAAI,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,KAAK,EAAE,SAAS,IAAI,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,KAAK,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,KAAK,EAAE,SAAS,IAAI,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACtF,OAAO,KAAK,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5E,OAAO,KAAK,EAAE,YAAY,IAAI,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AACvF,OAAO,KAAK,EAAE,oBAAoB,IAAI,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AAC3G,OAAO,KAAK,EAAE,SAAS,IAAI,iBAAiB,EAAE,MAAM,u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AC,OAAO,SAAS,CAAC,CAAC;AAC7D,MAAM,MAAM,wBAAwB,GAAG,YAAY,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAC/E,MAAM,MAAM,qBAAqB,GAAG,YAAY,CAAC,OAAO,eAAe,CAAC,CAAC;AACzE,MAAM,MAAM,uBAAuB,GAAG,YAAY,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC7E,MAAM,MAAM,0BAA0B,GAAG,YAAY,CAAC,OAAO,oBAAoB,CAAC,CAAC;AACnF,MAAM,MAAM,mBAAmB,GAAG,YAAY,CAAC,OAAO,aAAa,CAAC,CAAC;AACrE,MAAM,MAAM,oBAAoB,GAAG,YAAY,CAAC,OAAO,cAAc,CAAC,CAAC;AACvE,MAAM,MAAM,mBAAmB,GAAG,YAAY,CAAC,OAAO,aAAa,CAAC,CAAC;AACrE,MAAM,MAAM,gBAAgB,GAAG,YAAY,CAAC,OAAO,UAAU,CAAC,CAAC;AAC/D,MAAM,MAAM,gBAAgB,GAAG,YAAY,CAAC,OAAO,UAAU,CAAC,CAAC"}
|
package/dist/rules/graf101.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* GRAF101: A panel, query or
|
|
2
|
+
* GRAF101: A panel, query, variable or annotation uses a datasource no Datasource or ExternalDatasource in the build declares, or one the build deletes
|
|
3
3
|
*
|
|
4
4
|
* Grafana shows "datasource not found" on the panel. Typed references cannot go wrong this way, so it mostly catches a { type, uid } ref or a hand-edited dashboard. A datasource variable whose plugin type no declared datasource has is an error too. A panel with queries and no datasource at all is a warning: Grafana sends them to its default datasource. This check joins dashboards against the datasources of the same build root (chant #1939): declare one that exists in Grafana but is provisioned elsewhere with ExternalDatasource, which the check counts and the build never provisions. A build that declares no datasource at all gets one warning per dashboard that references any, since nothing can be checked.
|
|
5
5
|
*/
|
|
@@ -9,7 +9,7 @@ import { grafanaDiagnostics } from "./grafana-helpers";
|
|
|
9
9
|
|
|
10
10
|
export const graf101: PostSynthCheck = {
|
|
11
11
|
id: "GRAF101",
|
|
12
|
-
description: "A panel, query or
|
|
12
|
+
description: "A panel, query, variable or annotation uses a datasource no Datasource or ExternalDatasource in the build declares, or one the build deletes",
|
|
13
13
|
|
|
14
14
|
check(ctx: PostSynthContext): PostSynthDiagnostic[] {
|
|
15
15
|
return grafanaDiagnostics(ctx, "GRAF101");
|
package/dist/rules/graf104.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* GRAF104: Two dashboards, datasources, panels, variables or queries share an id
|
|
2
|
+
* GRAF104: Two dashboards, datasources, folders, panels, variables or queries share an id
|
|
3
3
|
*
|
|
4
|
-
* Dashboard
|
|
4
|
+
* Dashboard, folder and datasource uids and datasource names must be unique across the build, panel ids and variable names within a dashboard, and refIds within a panel. Grafana keeps one of two dashboards with the same uid and silently drops the other.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
|
|
@@ -9,7 +9,7 @@ import { grafanaDiagnostics } from "./grafana-helpers";
|
|
|
9
9
|
|
|
10
10
|
export const graf104: PostSynthCheck = {
|
|
11
11
|
id: "GRAF104",
|
|
12
|
-
description: "Two dashboards, datasources, panels, variables or queries share an id",
|
|
12
|
+
description: "Two dashboards, datasources, folders, panels, variables or queries share an id",
|
|
13
13
|
|
|
14
14
|
check(ctx: PostSynthContext): PostSynthDiagnostic[] {
|
|
15
15
|
return grafanaDiagnostics(ctx, "GRAF104");
|
package/dist/rules/graf106.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* GRAF106: A dashboard or datasource uid Grafana rejects, or a dashboard with no title
|
|
2
|
+
* GRAF106: A dashboard, folder or datasource uid Grafana rejects, or a dashboard with no title
|
|
3
3
|
*
|
|
4
|
-
* Grafana accepts uids of 1-40 letters, digits, - and _, and refuses to save a dashboard without a title.
|
|
4
|
+
* Grafana accepts uids of 1-40 letters, digits, - and _, refuses the folder uid general (its root), and refuses to save a dashboard without a title.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
|
|
@@ -9,7 +9,7 @@ import { grafanaDiagnostics } from "./grafana-helpers";
|
|
|
9
9
|
|
|
10
10
|
export const graf106: PostSynthCheck = {
|
|
11
11
|
id: "GRAF106",
|
|
12
|
-
description: "A dashboard or datasource uid Grafana rejects, or a dashboard with no title",
|
|
12
|
+
description: "A dashboard, folder or datasource uid Grafana rejects, or a dashboard with no title",
|
|
13
13
|
|
|
14
14
|
check(ctx: PostSynthContext): PostSynthDiagnostic[] {
|
|
15
15
|
return grafanaDiagnostics(ctx, "GRAF106");
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GRAF110: A panel or row repeats over a variable that cannot give it more than one value
|
|
3
|
+
*
|
|
4
|
+
* Grafana repeats a panel or row once per selected value of a query, custom, datasource or group by variable. Over an ad hoc, constant, interval, textbox or switch variable it shows the panel once and logs an error; over a query, custom or datasource variable with neither multi nor includeAll there is only ever one value. A repeat naming no variable is GRAF103.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
|
|
8
|
+
import { grafanaDiagnostics } from "./grafana-helpers";
|
|
9
|
+
|
|
10
|
+
export const graf110: PostSynthCheck = {
|
|
11
|
+
id: "GRAF110",
|
|
12
|
+
description: "A panel or row repeats over a variable that cannot give it more than one value",
|
|
13
|
+
|
|
14
|
+
check(ctx: PostSynthContext): PostSynthDiagnostic[] {
|
|
15
|
+
return grafanaDiagnostics(ctx, "GRAF110");
|
|
16
|
+
},
|
|
17
|
+
};
|
|
@@ -33,10 +33,15 @@ function parse(text: string, name: string): unknown[] {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
/** The grafana serializer's primary output (build.ts `GrafanaIndex`), which lists the folders the build resolved. */
|
|
37
|
+
function isGrafanaIndex(doc: unknown): doc is { folders?: Array<{ uid: string; title: string; path?: string; parentUid?: string }> } {
|
|
38
|
+
return typeof doc === "object" && doc !== null && typeof (doc as { grafanaSchema?: unknown }).grafanaSchema === "string" && Array.isArray((doc as { dashboards?: unknown }).dashboards);
|
|
39
|
+
}
|
|
40
|
+
|
|
36
41
|
/** Every dashboard, provisioned datasource and dashboard provider and alerting provisioning file in the build's output, and every `ExternalDatasource` it declares. */
|
|
37
42
|
export function grafanaArtifacts(ctx: PostSynthContext): GrafanaArtifacts {
|
|
38
43
|
const externalDatasources = [...(ctx.entities?.values() ?? [])].filter(isExternalDatasource).map(externalDatasourceRecord);
|
|
39
|
-
const out: GrafanaArtifacts = { dashboards: [], datasources: [], externalDatasources, providers: [], alerting: [] };
|
|
44
|
+
const out: GrafanaArtifacts = { dashboards: [], datasources: [], externalDatasources, providers: [], alerting: [], folders: [], deleteDatasources: [] };
|
|
40
45
|
for (const [lexicon, output] of ctx.outputs) {
|
|
41
46
|
const texts: Array<[string, string]> =
|
|
42
47
|
typeof output === "string"
|
|
@@ -49,8 +54,13 @@ export function grafanaArtifacts(ctx: PostSynthContext): GrafanaArtifacts {
|
|
|
49
54
|
else if (looksLikeDashboardProvisioning(doc)) {
|
|
50
55
|
for (const p of doc.providers) if (p && typeof p === "object" && !Array.isArray(p)) out.providers!.push(p as Record<string, unknown>);
|
|
51
56
|
} else if (looksLikeAlertingProvisioning(doc)) out.alerting!.push({ source, json: doc });
|
|
52
|
-
else if (
|
|
53
|
-
for (const
|
|
57
|
+
else if (isGrafanaIndex(doc)) {
|
|
58
|
+
for (const f of doc.folders ?? []) if (f && typeof f.uid === "string" && typeof f.title === "string") out.folders!.push(f);
|
|
59
|
+
} else if (looksLikeDatasourceProvisioning(doc)) {
|
|
60
|
+
for (const d of doc.deleteDatasources ?? []) {
|
|
61
|
+
if (d && typeof d === "object" && typeof (d as { name?: unknown }).name === "string") out.deleteDatasources!.push(d as { name: string; orgId?: number });
|
|
62
|
+
}
|
|
63
|
+
for (const d of doc.datasources ?? []) {
|
|
54
64
|
if (d && typeof d === "object" && typeof (d as ProvisionedDatasource).name === "string") {
|
|
55
65
|
const ds = d as ProvisionedDatasource;
|
|
56
66
|
out.datasources.push({ ...ds, uid: typeof ds.uid === "string" ? ds.uid : ds.name });
|