@intentius/chant-lexicon-grafana 0.96.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 +50 -0
- package/dist/build.d.ts +116 -0
- package/dist/build.d.ts.map +1 -0
- package/dist/catalog.d.ts +26 -0
- package/dist/catalog.d.ts.map +1 -0
- package/dist/codegen/docs-cli.d.ts +3 -0
- package/dist/codegen/docs-cli.d.ts.map +1 -0
- package/dist/codegen/docs.d.ts +8 -0
- package/dist/codegen/docs.d.ts.map +1 -0
- package/dist/codegen/generate-cli.d.ts +3 -0
- package/dist/codegen/generate-cli.d.ts.map +1 -0
- package/dist/codegen/generate.d.ts +21 -0
- package/dist/codegen/generate.d.ts.map +1 -0
- package/dist/codegen/package.d.ts +7 -0
- package/dist/codegen/package.d.ts.map +1 -0
- package/dist/codegen/schema-types.d.ts +41 -0
- package/dist/codegen/schema-types.d.ts.map +1 -0
- package/dist/composites/agent-dashboard.d.ts +70 -0
- package/dist/composites/agent-dashboard.d.ts.map +1 -0
- package/dist/composites/catalog.d.ts +3 -0
- package/dist/composites/catalog.d.ts.map +1 -0
- package/dist/composites/index.d.ts +12 -0
- package/dist/composites/index.d.ts.map +1 -0
- package/dist/composites/red-dashboard.d.ts +58 -0
- package/dist/composites/red-dashboard.d.ts.map +1 -0
- package/dist/composites/shared.d.ts +68 -0
- package/dist/composites/shared.d.ts.map +1 -0
- package/dist/composites/slo-dashboard.d.ts +62 -0
- package/dist/composites/slo-dashboard.d.ts.map +1 -0
- package/dist/dashboard.d.ts +84 -0
- package/dist/dashboard.d.ts.map +1 -0
- package/dist/datasource.d.ts +67 -0
- package/dist/datasource.d.ts.map +1 -0
- package/dist/detect.d.ts +20 -0
- package/dist/detect.d.ts.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/integrity.json +22 -0
- package/dist/lint/audit-catalog.d.ts +13 -0
- package/dist/lint/audit-catalog.d.ts.map +1 -0
- package/dist/lint/post-synth/graf101.d.ts +8 -0
- package/dist/lint/post-synth/graf101.d.ts.map +1 -0
- package/dist/lint/post-synth/graf102.d.ts +8 -0
- package/dist/lint/post-synth/graf102.d.ts.map +1 -0
- package/dist/lint/post-synth/graf103.d.ts +8 -0
- package/dist/lint/post-synth/graf103.d.ts.map +1 -0
- package/dist/lint/post-synth/graf104.d.ts +8 -0
- package/dist/lint/post-synth/graf104.d.ts.map +1 -0
- package/dist/lint/post-synth/graf105.d.ts +8 -0
- package/dist/lint/post-synth/graf105.d.ts.map +1 -0
- package/dist/lint/post-synth/graf106.d.ts +8 -0
- package/dist/lint/post-synth/graf106.d.ts.map +1 -0
- package/dist/lint/post-synth/graf107.d.ts +8 -0
- package/dist/lint/post-synth/graf107.d.ts.map +1 -0
- package/dist/lint/post-synth/grafana-helpers.d.ts +16 -0
- package/dist/lint/post-synth/grafana-helpers.d.ts.map +1 -0
- package/dist/lint/post-synth/index.d.ts +3 -0
- package/dist/lint/post-synth/index.d.ts.map +1 -0
- package/dist/lint/rules/grafana-ast.d.ts +21 -0
- package/dist/lint/rules/grafana-ast.d.ts.map +1 -0
- package/dist/lint/rules/index.d.ts +6 -0
- package/dist/lint/rules/index.d.ts.map +1 -0
- package/dist/lint/rules/literal-secret.d.ts +12 -0
- package/dist/lint/rules/literal-secret.d.ts.map +1 -0
- package/dist/lint/rules/uid-syntax.d.ts +12 -0
- package/dist/lint/rules/uid-syntax.d.ts.map +1 -0
- package/dist/lsp/completions.d.ts +4 -0
- package/dist/lsp/completions.d.ts.map +1 -0
- package/dist/lsp/hover.d.ts +4 -0
- package/dist/lsp/hover.d.ts.map +1 -0
- package/dist/manifest.json +8 -0
- package/dist/meta.json +107 -0
- package/dist/okf/index.md +39 -0
- package/dist/okf/rules/GRAF001.md +16 -0
- package/dist/okf/rules/GRAF002.md +15 -0
- package/dist/okf/rules/GRAF101.md +15 -0
- package/dist/okf/rules/GRAF102.md +15 -0
- package/dist/okf/rules/GRAF103.md +11 -0
- package/dist/okf/rules/GRAF104.md +15 -0
- package/dist/okf/rules/GRAF105.md +11 -0
- package/dist/okf/rules/GRAF106.md +11 -0
- package/dist/okf/rules/GRAF107.md +11 -0
- package/dist/okf/types/ConstantVariable.md +9 -0
- package/dist/okf/types/CustomVariable.md +9 -0
- package/dist/okf/types/Dashboard.md +14 -0
- package/dist/okf/types/DashboardProvider.md +9 -0
- package/dist/okf/types/Datasource.md +16 -0
- package/dist/okf/types/DatasourceVariable.md +9 -0
- package/dist/okf/types/GaugePanel.md +9 -0
- package/dist/okf/types/HeatmapPanel.md +9 -0
- package/dist/okf/types/IntervalVariable.md +9 -0
- package/dist/okf/types/LogsPanel.md +9 -0
- package/dist/okf/types/LokiQuery.md +9 -0
- package/dist/okf/types/PromQuery.md +9 -0
- package/dist/okf/types/QueryVariable.md +9 -0
- package/dist/okf/types/Row.md +9 -0
- package/dist/okf/types/StatPanel.md +9 -0
- package/dist/okf/types/TablePanel.md +9 -0
- package/dist/okf/types/TempoQuery.md +9 -0
- package/dist/okf/types/TextPanel.md +9 -0
- package/dist/okf/types/TextboxVariable.md +9 -0
- package/dist/okf/types/TimeSeriesPanel.md +9 -0
- package/dist/okf/types/TracesPanel.md +9 -0
- package/dist/package-cli.d.ts +3 -0
- package/dist/package-cli.d.ts.map +1 -0
- package/dist/panels.d.ts +138 -0
- package/dist/panels.d.ts.map +1 -0
- package/dist/pin.d.ts +32 -0
- package/dist/pin.d.ts.map +1 -0
- package/dist/plugin.d.ts +12 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/query.d.ts +81 -0
- package/dist/query.d.ts.map +1 -0
- package/dist/rules/graf101.ts +17 -0
- package/dist/rules/graf102.ts +17 -0
- package/dist/rules/graf103.ts +17 -0
- package/dist/rules/graf104.ts +17 -0
- package/dist/rules/graf105.ts +17 -0
- package/dist/rules/graf106.ts +17 -0
- package/dist/rules/graf107.ts +17 -0
- package/dist/rules/grafana-ast.ts +70 -0
- package/dist/rules/grafana-helpers.ts +68 -0
- package/dist/rules/literal-secret.ts +48 -0
- package/dist/rules/uid-syntax.ts +56 -0
- package/dist/schema/dashboard.gen.d.ts +1231 -0
- package/dist/schema/dashboard.gen.d.ts.map +1 -0
- package/dist/schema/gauge.gen.d.ts +57 -0
- package/dist/schema/gauge.gen.d.ts.map +1 -0
- package/dist/schema/heatmap.gen.d.ts +295 -0
- package/dist/schema/heatmap.gen.d.ts.map +1 -0
- package/dist/schema/index.d.ts +18 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/logs.gen.d.ts +29 -0
- package/dist/schema/logs.gen.d.ts.map +1 -0
- package/dist/schema/loki.gen.d.ts +69 -0
- package/dist/schema/loki.gen.d.ts.map +1 -0
- package/dist/schema/prometheus.gen.d.ts +169 -0
- package/dist/schema/prometheus.gen.d.ts.map +1 -0
- package/dist/schema/stat.gen.d.ts +75 -0
- package/dist/schema/stat.gen.d.ts.map +1 -0
- package/dist/schema/table.gen.d.ts +295 -0
- package/dist/schema/table.gen.d.ts.map +1 -0
- package/dist/schema/tempo.gen.d.ts +136 -0
- package/dist/schema/tempo.gen.d.ts.map +1 -0
- package/dist/schema/text.gen.d.ts +16 -0
- package/dist/schema/text.gen.d.ts.map +1 -0
- package/dist/schema/timeseries.gen.d.ts +179 -0
- package/dist/schema/timeseries.gen.d.ts.map +1 -0
- package/dist/schema-validate.d.ts +20 -0
- package/dist/schema-validate.d.ts.map +1 -0
- package/dist/serializer.d.ts +22 -0
- package/dist/serializer.d.ts.map +1 -0
- package/dist/skill-defs.d.ts +3 -0
- package/dist/skill-defs.d.ts.map +1 -0
- package/dist/skills/chant-grafana-provisioning.md +42 -0
- package/dist/skills/chant-grafana.md +93 -0
- package/dist/spec/fetch-cli.d.ts +3 -0
- package/dist/spec/fetch-cli.d.ts.map +1 -0
- package/dist/spec/schemas.d.ts +25 -0
- package/dist/spec/schemas.d.ts.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/util.d.ts +17 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/validate-cli.d.ts +3 -0
- package/dist/validate-cli.d.ts.map +1 -0
- package/dist/validate-output.d.ts +42 -0
- package/dist/validate-output.d.ts.map +1 -0
- package/dist/validate.d.ts +12 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/variables.d.ts +100 -0
- package/dist/variables.d.ts.map +1 -0
- package/package.json +79 -0
- package/src/build.test.ts +210 -0
- package/src/build.ts +573 -0
- package/src/catalog.ts +116 -0
- package/src/codegen/docs-cli.ts +4 -0
- package/src/codegen/docs.ts +97 -0
- package/src/codegen/generate-cli.ts +8 -0
- package/src/codegen/generate.ts +83 -0
- package/src/codegen/package.ts +41 -0
- package/src/codegen/schema-types.ts +173 -0
- package/src/composites/agent-dashboard.ts +235 -0
- package/src/composites/catalog.test.ts +37 -0
- package/src/composites/catalog.ts +223 -0
- package/src/composites/composites.test.ts +314 -0
- package/src/composites/index.ts +12 -0
- package/src/composites/red-dashboard.ts +159 -0
- package/src/composites/shared.ts +94 -0
- package/src/composites/slo-dashboard.ts +177 -0
- package/src/dashboard.ts +123 -0
- package/src/datasource.ts +93 -0
- package/src/detect.ts +30 -0
- package/src/generated/lexicon-grafana.json +107 -0
- package/src/import.e2e.test.ts +147 -0
- package/src/import.test.ts +45 -0
- package/src/index.ts +178 -0
- package/src/lint/audit-catalog.ts +87 -0
- package/src/lint/post-synth/graf101.ts +17 -0
- package/src/lint/post-synth/graf102.ts +17 -0
- package/src/lint/post-synth/graf103.ts +17 -0
- package/src/lint/post-synth/graf104.ts +17 -0
- package/src/lint/post-synth/graf105.ts +17 -0
- package/src/lint/post-synth/graf106.ts +17 -0
- package/src/lint/post-synth/graf107.ts +17 -0
- package/src/lint/post-synth/grafana-helpers.ts +68 -0
- package/src/lint/post-synth/index.ts +19 -0
- package/src/lint/post-synth/post-synth.test.ts +231 -0
- package/src/lint/rules/grafana-ast.ts +70 -0
- package/src/lint/rules/index.ts +9 -0
- package/src/lint/rules/literal-secret.ts +48 -0
- package/src/lint/rules/rules.test.ts +70 -0
- package/src/lint/rules/uid-syntax.ts +56 -0
- package/src/lsp/completions.test.ts +31 -0
- package/src/lsp/completions.ts +15 -0
- package/src/lsp/hover.test.ts +25 -0
- package/src/lsp/hover.ts +28 -0
- package/src/package-cli.ts +17 -0
- package/src/panels.ts +275 -0
- package/src/pin.ts +68 -0
- package/src/plugin.test.ts +50 -0
- package/src/plugin.ts +116 -0
- package/src/query.ts +160 -0
- package/src/schema/dashboard.gen.ts +1289 -0
- package/src/schema/gauge.gen.ts +64 -0
- package/src/schema/heatmap.gen.ts +321 -0
- package/src/schema/index.ts +17 -0
- package/src/schema/logs.gen.ts +34 -0
- package/src/schema/loki.gen.ts +77 -0
- package/src/schema/prometheus.gen.ts +181 -0
- package/src/schema/stat.gen.ts +86 -0
- package/src/schema/table.gen.ts +334 -0
- package/src/schema/tempo.gen.ts +146 -0
- package/src/schema/text.gen.ts +22 -0
- package/src/schema/timeseries.gen.ts +208 -0
- package/src/schema-validate.ts +143 -0
- package/src/schema.test.ts +76 -0
- package/src/serializer.test.ts +170 -0
- package/src/serializer.ts +37 -0
- package/src/skill-defs.ts +31 -0
- package/src/skills/chant-grafana-provisioning.md +42 -0
- package/src/skills/chant-grafana.md +93 -0
- package/src/spec/fetch-cli.ts +27 -0
- package/src/spec/schemas/dashboard.jsonschema.json +1901 -0
- package/src/spec/schemas/gauge.jsonschema.json +114 -0
- package/src/spec/schemas/heatmap.jsonschema.json +480 -0
- package/src/spec/schemas/logs.jsonschema.json +94 -0
- package/src/spec/schemas/loki.jsonschema.json +118 -0
- package/src/spec/schemas/prometheus.jsonschema.json +276 -0
- package/src/spec/schemas/stat.jsonschema.json +163 -0
- package/src/spec/schemas/table.jsonschema.json +751 -0
- package/src/spec/schemas/tempo.jsonschema.json +225 -0
- package/src/spec/schemas/text.jsonschema.json +72 -0
- package/src/spec/schemas/timeseries.jsonschema.json +471 -0
- package/src/spec/schemas.ts +56 -0
- package/src/util.ts +43 -0
- package/src/validate-cli.ts +7 -0
- package/src/validate-output.ts +380 -0
- package/src/validate.ts +108 -0
- package/src/variables.ts +161 -0
package/README.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# @intentius/chant-lexicon-grafana
|
|
2
|
+
|
|
3
|
+
Grafana lexicon for [chant](https://github.com/INTENTIUS/chant): typed dashboards, panels, queries, variables and datasources, built to the dashboard JSON Grafana imports as it is and to Grafana's provisioning files.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { Datasource, PromQuery, TimeSeriesPanel, Dashboard } from "@intentius/chant-lexicon-grafana";
|
|
7
|
+
|
|
8
|
+
const prometheus = new Datasource({ name: "Prometheus", type: "prometheus", url: "http://prometheus:9090" });
|
|
9
|
+
const rate = new PromQuery({ expr: "sum(rate(http_requests_total[$__rate_interval]))" });
|
|
10
|
+
const requests = new TimeSeriesPanel({ title: "Requests per second", datasource: prometheus, targets: [rate] });
|
|
11
|
+
const overview = new Dashboard({ title: "Overview", panels: [requests] });
|
|
12
|
+
|
|
13
|
+
export { prometheus, rate, requests, overview };
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
`chant build src --lexicon grafana -o dist/grafana/index.json` writes `dashboards/overview.json`, `provisioning/datasources/chant.yaml` and `provisioning/dashboards/chant.yaml`.
|
|
17
|
+
|
|
18
|
+
## What it types
|
|
19
|
+
|
|
20
|
+
| Kind | Classes |
|
|
21
|
+
|---|---|
|
|
22
|
+
| dashboards | `Dashboard`, `Row`, `DashboardProvider` |
|
|
23
|
+
| panels | `TimeSeriesPanel`, `StatPanel`, `GaugePanel`, `TablePanel`, `LogsPanel`, `TracesPanel`, `HeatmapPanel`, `TextPanel` |
|
|
24
|
+
| queries | `PromQuery` (PromQL), `TempoQuery` (TraceQL), `LokiQuery` (LogQL) |
|
|
25
|
+
| variables | `QueryVariable`, `CustomVariable`, `IntervalVariable`, `DatasourceVariable`, `ConstantVariable`, `TextboxVariable` |
|
|
26
|
+
| datasources | `Datasource`, generic in its plugin type |
|
|
27
|
+
|
|
28
|
+
Panel options, field config and query fields are generated from Grafana's JSON Schemas as published by `grafana/grafana-foundation-sdk`, vendored in `src/spec/schemas/` and pinned by commit and digest in `GRAFANA_SCHEMA_PIN`. `definePanel` and `defineQuery` add plugins chant doesn't ship.
|
|
29
|
+
|
|
30
|
+
## Dashboards from other declarations
|
|
31
|
+
|
|
32
|
+
`RedDashboard`, `SloDashboard` and `AgentDashboard` build a dashboard from a declaration in another lexicon: rate, errors and duration per service from an otel `SpanMetricsConnector`; SLI, error budget and burn rate per alert window from a prometheus `Slo`; latency, errors and tokens per model and tool from the otel GenAI preset. Metric names are read from the declaration, so renaming a namespace or an SLO moves the panel queries.
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
export const services = RedDashboard({ spanMetrics: spans, datasource: prometheus });
|
|
36
|
+
export const checkoutSlo = SloDashboard({ slo: checkout, datasource: prometheus });
|
|
37
|
+
export const agents = AgentDashboard({ genAi: genAiMetrics(), datasource: prometheus });
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Checks
|
|
41
|
+
|
|
42
|
+
GRAF001 and GRAF002 run on source (uid and variable-name syntax, literal secrets). GRAF101 to GRAF107 run after a build: undeclared or mistyped datasources, undeclared variables, duplicate uids and ids, panels off the grid or overlapping, uids Grafana rejects, and validation against the pinned dashboard, panel and query schemas.
|
|
43
|
+
|
|
44
|
+
GRAF101 and GRAF102 compare dashboards with the datasources declared in the same build root (chant #1939); keep them together.
|
|
45
|
+
|
|
46
|
+
## Plain-data API
|
|
47
|
+
|
|
48
|
+
- `buildGrafana(entities)` and `grafanaFiles(entities)` render every file by path, for embedding in another lexicon's output (a ConfigMap, a volume).
|
|
49
|
+
- `renderDashboard(dashboard)` and `dashboardJson(dashboard)` render one dashboard.
|
|
50
|
+
- `validateGrafanaOutput({ dashboards, datasources })` and `validateDashboardSchema(json)` run the checks without a build.
|
package/dist/build.d.ts
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* From declared entities to Grafana's own files: dashboard JSON, the
|
|
3
|
+
* datasource provisioning file and the dashboard provisioning file.
|
|
4
|
+
*
|
|
5
|
+
* Plain functions, so another lexicon (a k8s ConfigMap, a docker volume)
|
|
6
|
+
* can render the same files with `grafanaFiles()` or one dashboard with
|
|
7
|
+
* `dashboardJson()`, and the serializer is a thin wrapper around
|
|
8
|
+
* `buildGrafana()`.
|
|
9
|
+
*/
|
|
10
|
+
import type { Declarable } from "@intentius/chant/declarable";
|
|
11
|
+
import { type DatasourceEntity } from "./datasource.js";
|
|
12
|
+
import { type DashboardEntity, type DashboardProviderProps } from "./dashboard.js";
|
|
13
|
+
import { type PanelEntity, type RowEntity } from "./panels.js";
|
|
14
|
+
import { type QueryEntity, type DatasourceInput } from "./query.js";
|
|
15
|
+
import { type VariableEntity } from "./variables.js";
|
|
16
|
+
import type { Dashboard as DashboardJson, DataSourceRef, Panel as PanelJson, RowPanel as RowPanelJson, VariableModel } from "./schema/dashboard.gen.js";
|
|
17
|
+
export type { DashboardJson, PanelJson, RowPanelJson, VariableModel, DataSourceRef };
|
|
18
|
+
/** Grafana's grid is 24 columns wide. */
|
|
19
|
+
export declare const GRID_COLUMNS = 24;
|
|
20
|
+
/** Where each file goes, relative to the build output directory. */
|
|
21
|
+
export declare const DATASOURCES_FILE = "provisioning/datasources/chant.yaml";
|
|
22
|
+
export declare const DASHBOARD_PROVIDERS_FILE = "provisioning/dashboards/chant.yaml";
|
|
23
|
+
export declare const DASHBOARDS_DIR = "dashboards";
|
|
24
|
+
/** One entry of `datasources:` in a provisioning file. */
|
|
25
|
+
export interface ProvisionedDatasource {
|
|
26
|
+
name: string;
|
|
27
|
+
type: string;
|
|
28
|
+
uid: string;
|
|
29
|
+
access?: string;
|
|
30
|
+
url?: string;
|
|
31
|
+
isDefault?: boolean;
|
|
32
|
+
basicAuth?: boolean;
|
|
33
|
+
basicAuthUser?: string;
|
|
34
|
+
user?: string;
|
|
35
|
+
database?: string;
|
|
36
|
+
withCredentials?: boolean;
|
|
37
|
+
jsonData?: Record<string, unknown>;
|
|
38
|
+
secureJsonData?: Record<string, string>;
|
|
39
|
+
editable?: boolean;
|
|
40
|
+
orgId?: number;
|
|
41
|
+
version?: number;
|
|
42
|
+
}
|
|
43
|
+
/** One entry of `providers:` in a dashboard provisioning file. */
|
|
44
|
+
export interface ProvisionedProvider {
|
|
45
|
+
name: string;
|
|
46
|
+
orgId: number;
|
|
47
|
+
folder: string;
|
|
48
|
+
folderUid?: string;
|
|
49
|
+
type: "file";
|
|
50
|
+
disableDeletion: boolean;
|
|
51
|
+
allowUiUpdates: boolean;
|
|
52
|
+
updateIntervalSeconds: number;
|
|
53
|
+
options: {
|
|
54
|
+
path: string;
|
|
55
|
+
foldersFromFilesStructure: boolean;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export interface BuiltDashboard {
|
|
59
|
+
uid: string;
|
|
60
|
+
title: string;
|
|
61
|
+
folder?: string;
|
|
62
|
+
/** Path of its JSON file, relative to the output directory. */
|
|
63
|
+
file: string;
|
|
64
|
+
json: DashboardJson;
|
|
65
|
+
}
|
|
66
|
+
export interface BuiltGrafana {
|
|
67
|
+
dashboards: BuiltDashboard[];
|
|
68
|
+
datasources: ProvisionedDatasource[];
|
|
69
|
+
providers: ProvisionedProvider[];
|
|
70
|
+
/** Every output file by path, ready to write. */
|
|
71
|
+
files: Record<string, string>;
|
|
72
|
+
/** A short summary of what was built: the serializer's primary output. */
|
|
73
|
+
index: GrafanaIndex;
|
|
74
|
+
}
|
|
75
|
+
export interface GrafanaIndex {
|
|
76
|
+
grafanaSchema: string;
|
|
77
|
+
dashboards: Array<{
|
|
78
|
+
uid: string;
|
|
79
|
+
title: string;
|
|
80
|
+
folder?: string;
|
|
81
|
+
file: string;
|
|
82
|
+
}>;
|
|
83
|
+
datasources: Array<{
|
|
84
|
+
name: string;
|
|
85
|
+
type: string;
|
|
86
|
+
uid: string;
|
|
87
|
+
}>;
|
|
88
|
+
files: string[];
|
|
89
|
+
}
|
|
90
|
+
/** The `{ type, uid }` Grafana stores for a datasource, a datasource variable, or a ref. */
|
|
91
|
+
export declare function datasourceRef(input: DatasourceInput | undefined): DataSourceRef | undefined;
|
|
92
|
+
/** One variable as Grafana's `templating.list` entry. */
|
|
93
|
+
export declare function variableModel(variable: VariableEntity): VariableModel;
|
|
94
|
+
/** One query as a panel target. */
|
|
95
|
+
export declare function targetJson(query: QueryEntity, index: number, panelDatasource?: DataSourceRef): Record<string, unknown>;
|
|
96
|
+
/** A dashboard's `panels` array: rows and panels, laid out, with ids. */
|
|
97
|
+
export declare function panelsJson(items: Array<PanelEntity | RowEntity>): Array<PanelJson | RowPanelJson>;
|
|
98
|
+
/** The dashboard's uid: its own, else from its export name, else from its title. */
|
|
99
|
+
export declare function dashboardUid(dashboard: DashboardEntity, exportName?: string): string;
|
|
100
|
+
/** One dashboard as the JSON Grafana imports. */
|
|
101
|
+
export declare function renderDashboard(dashboard: DashboardEntity, exportName?: string): DashboardJson;
|
|
102
|
+
/** One dashboard as formatted JSON text. */
|
|
103
|
+
export declare function dashboardJson(dashboard: DashboardEntity, exportName?: string): string;
|
|
104
|
+
/** One datasource as a provisioning entry. */
|
|
105
|
+
export declare function provisionedDatasource(ds: DatasourceEntity): ProvisionedDatasource;
|
|
106
|
+
/** One dashboard provider as a provisioning entry. */
|
|
107
|
+
export declare function provisionedProvider(p: DashboardProviderProps): ProvisionedProvider;
|
|
108
|
+
/** The datasource provisioning file for these datasources. */
|
|
109
|
+
export declare function datasourcesYaml(datasources: ProvisionedDatasource[]): string;
|
|
110
|
+
/** The dashboard provisioning file for these providers. */
|
|
111
|
+
export declare function dashboardProvidersYaml(providers: ProvisionedProvider[]): string;
|
|
112
|
+
/** Everything the grafana entities in a build render to. */
|
|
113
|
+
export declare function buildGrafana(entities: Map<string, Declarable> | Iterable<Declarable>): BuiltGrafana;
|
|
114
|
+
/** Every file the grafana entities render to, by path relative to the output directory. */
|
|
115
|
+
export declare function grafanaFiles(entities: Map<string, Declarable> | Iterable<Declarable>): Record<string, string>;
|
|
116
|
+
//# sourceMappingURL=build.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAsB,KAAK,gBAAgB,EAAsB,MAAM,cAAc,CAAC;AAC7F,OAAO,EAIL,KAAK,eAAe,EAEpB,KAAK,sBAAsB,EAC5B,MAAM,aAAa,CAAC;AACrB,OAAO,EAA8B,KAAK,WAAW,EAAE,KAAK,SAAS,EAAkB,MAAM,UAAU,CAAC;AACxG,OAAO,EAAiB,KAAK,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,SAAS,CAAC;AAChF,OAAO,EAA0C,KAAK,cAAc,EAAqB,MAAM,aAAa,CAAC;AAC7G,OAAO,KAAK,EACV,SAAS,IAAI,aAAa,EAE1B,aAAa,EAEb,KAAK,IAAI,SAAS,EAClB,QAAQ,IAAI,YAAY,EACxB,aAAa,EACd,MAAM,wBAAwB,CAAC;AAKhC,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC;AAErF,yCAAyC;AACzC,eAAO,MAAM,YAAY,KAAK,CAAC;AAE/B,oEAAoE;AACpE,eAAO,MAAM,gBAAgB,wCAAwC,CAAC;AACtE,eAAO,MAAM,wBAAwB,uCAAuC,CAAC;AAC7E,eAAO,MAAM,cAAc,eAAe,CAAC;AAE3C,0DAA0D;AAC1D,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,O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EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAErF;AAcD,8CAA8C;AAC9C,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,gBAAgB,GAAG,qBAAqB,CAoBjF;AAED,sDAAsD;AACtD,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,sBAAsB,GAAG,mBAAmB,CAgBlF;AAMD,8DAA8D;AAC9D,wBAAgB,eAAe,CAAC,WAAW,EAAE,qBAAqB,EAAE,GAAG,MAAM,CAE5E;AAED,2DAA2D;AAC3D,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,mBAAmB,EAAE,GAAG,MAAM,CAE/E;AAQD,4DAA4D;AAC5D,wBAAgB,YAAY,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,UAAU,CAAC,GAAG,YAAY,CA0CnG;AAED,2FAA2F;AAC3F,wBAAgB,YAAY,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAE7G"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The built-in entity catalog: every class this package exports, keyed by
|
|
3
|
+
* class name. It feeds the packaged registry (`dist/meta.json`), LSP
|
|
4
|
+
* completions and hover, and the docs.
|
|
5
|
+
*/
|
|
6
|
+
import type { LexiconEntry } from "@intentius/chant/lsp/lexicon-providers";
|
|
7
|
+
export type CatalogKind = "dashboard" | "datasource" | "provider" | "panel" | "row" | "query" | "variable";
|
|
8
|
+
export interface CatalogEntry {
|
|
9
|
+
className: string;
|
|
10
|
+
entityType: string;
|
|
11
|
+
kind: CatalogKind;
|
|
12
|
+
/** Resource entities are emitted; property entities live inside one. */
|
|
13
|
+
entityKind: "resource" | "property";
|
|
14
|
+
/** The Grafana plugin id, for panels and queries. */
|
|
15
|
+
pluginId?: string;
|
|
16
|
+
description: string;
|
|
17
|
+
}
|
|
18
|
+
export declare const BUILTIN_CATALOG: CatalogEntry[];
|
|
19
|
+
/**
|
|
20
|
+
* The catalog as a chant lexicon registry, keyed by class name. Every class
|
|
21
|
+
* is listed as a resource, including the property-kind panels, queries and
|
|
22
|
+
* variables: the registry drives `new …` completions, and an author writes
|
|
23
|
+
* `new TimeSeriesPanel(…)` the same way as `new Dashboard(…)`.
|
|
24
|
+
*/
|
|
25
|
+
export declare function lexiconRegistry(): Record<string, LexiconEntry>;
|
|
26
|
+
//# sourceMappingURL=catalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAO3E,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG,YAAY,GAAG,UAAU,GAAG,OAAO,GAAG,KAAK,GAAG,OAAO,GAAG,UAAU,CAAC;AAE3G,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,WAAW,CAAC;IAClB,wEAAwE;IACxE,UAAU,EAAE,UAAU,GAAG,UAAU,CAAC;IACpC,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB;AAqCD,eAAO,MAAM,eAAe,EAAE,YAAY,EAwCzC,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAM9D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs-cli.d.ts","sourceRoot":"","sources":["../../src/codegen/docs-cli.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Documentation generation for the grafana lexicon: the generated reference
|
|
3
|
+
* pages from the core docs pipeline, plus the authored pages in docs/pages/.
|
|
4
|
+
*/
|
|
5
|
+
export declare function generateDocs(opts?: {
|
|
6
|
+
verbose?: boolean;
|
|
7
|
+
}): Promise<void>;
|
|
8
|
+
//# sourceMappingURL=docs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../src/codegen/docs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAsEH,wBAAsB,YAAY,CAAC,IAAI,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAuB9E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-cli.d.ts","sourceRoot":"","sources":["../../src/codegen/generate-cli.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The grafana lexicon's generate step, offline and deterministic.
|
|
3
|
+
*
|
|
4
|
+
* 1. `src/schema/<name>.gen.ts` from each vendored schema in `src/spec/schemas/`
|
|
5
|
+
* (see `src/pin.ts`). These are committed, and a test fails when they
|
|
6
|
+
* drift from what this step would write.
|
|
7
|
+
* 2. `src/generated/lexicon-grafana.json`, the registry of entity classes
|
|
8
|
+
* the package exports, derived from the catalog so the packaged
|
|
9
|
+
* `dist/meta.json` cannot disagree with the classes.
|
|
10
|
+
*/
|
|
11
|
+
import type { GenerateResult } from "@intentius/chant/codegen/generate";
|
|
12
|
+
export type { GenerateResult };
|
|
13
|
+
/** Every generated schema module, keyed by path relative to the package root. */
|
|
14
|
+
export declare function schemaModules(): Record<string, string>;
|
|
15
|
+
export declare function generate(opts?: {
|
|
16
|
+
verbose?: boolean;
|
|
17
|
+
force?: boolean;
|
|
18
|
+
}): Promise<GenerateResult>;
|
|
19
|
+
/** Write the registry to src/generated/lexicon-grafana.json, for tools that read it from there. */
|
|
20
|
+
export declare function writeGeneratedFiles(result: GenerateResult): void;
|
|
21
|
+
//# sourceMappingURL=generate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/codegen/generate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAKxE,YAAY,EAAE,cAAc,EAAE,CAAC;AAY/B,iFAAiF;AACjF,wBAAgB,aAAa,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAQtD;AAQD,wBAAsB,QAAQ,CAAC,IAAI,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,cAAc,CAAC,CA2BrG;AAED,mGAAmG;AACnG,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAIhE"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* grafana lexicon packaging, delegating to core's packagePipeline.
|
|
3
|
+
*/
|
|
4
|
+
import { type PackageOptions, type PackageResult } from "@intentius/chant/codegen/package";
|
|
5
|
+
export type { PackageOptions, PackageResult };
|
|
6
|
+
export declare function packageLexicon(opts?: PackageOptions): Promise<PackageResult>;
|
|
7
|
+
//# sourceMappingURL=package.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package.d.ts","sourceRoot":"","sources":["../../src/codegen/package.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,aAAa,EACnB,MAAM,kCAAkC,CAAC;AAI1C,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,CAAC;AAK9C,wBAAsB,cAAc,CAAC,IAAI,GAAE,cAAmB,GAAG,OAAO,CAAC,aAAa,CAAC,CAmBtF"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON Schema (draft-07, the subset cog emits) to TypeScript declarations.
|
|
3
|
+
*
|
|
4
|
+
* Each vendored schema becomes one module under `src/schema/`: one exported
|
|
5
|
+
* type per entry in `definitions`, with the schema's descriptions as doc
|
|
6
|
+
* comments. `required` is kept, so the types say what the schema says; the
|
|
7
|
+
* entity props wrap panel options in `DeepPartial` where Grafana fills the
|
|
8
|
+
* rest in on import.
|
|
9
|
+
*/
|
|
10
|
+
import type { SchemaName } from "../pin.js";
|
|
11
|
+
interface Node {
|
|
12
|
+
type?: string | string[];
|
|
13
|
+
$ref?: string;
|
|
14
|
+
enum?: unknown[];
|
|
15
|
+
const?: unknown;
|
|
16
|
+
oneOf?: Node[];
|
|
17
|
+
anyOf?: Node[];
|
|
18
|
+
allOf?: Node[];
|
|
19
|
+
items?: Node | Node[];
|
|
20
|
+
properties?: Record<string, Node>;
|
|
21
|
+
additionalProperties?: boolean | Node;
|
|
22
|
+
required?: string[];
|
|
23
|
+
description?: string;
|
|
24
|
+
deprecated?: boolean;
|
|
25
|
+
default?: unknown;
|
|
26
|
+
[key: string]: unknown;
|
|
27
|
+
}
|
|
28
|
+
/** `dataquery` -> `Dataquery`: every exported type starts upper-case. */
|
|
29
|
+
export declare function typeName(defName: string): string;
|
|
30
|
+
/** The TypeScript type for one schema node. */
|
|
31
|
+
export declare function tsType(node: Node | boolean | undefined, indent?: string): string;
|
|
32
|
+
export interface GeneratedModule {
|
|
33
|
+
/** Module source, ready to write. */
|
|
34
|
+
source: string;
|
|
35
|
+
/** Exported type names, in definition order. */
|
|
36
|
+
types: string[];
|
|
37
|
+
}
|
|
38
|
+
/** One schema file to one TypeScript module. */
|
|
39
|
+
export declare function schemaModule(name: SchemaName, schema: Record<string, unknown>, extra?: string[]): GeneratedModule;
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=schema-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"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AE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,GAAE,MAAM,EAAO,GAAG,eAAe,CAoBrH"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `AgentDashboard`: latency and errors per model and per tool, and token
|
|
3
|
+
* usage per model, from the otel lexicon's GenAI preset.
|
|
4
|
+
*
|
|
5
|
+
* Metric names come from `genAiMetrics()` (or the `metrics` of
|
|
6
|
+
* `genAiComponents()`), and label names from the preset's GenAI attribute
|
|
7
|
+
* keys, so a preset with another `namespace` moves every query here.
|
|
8
|
+
*/
|
|
9
|
+
import { type CompositeInstance } from "@intentius/chant/composite";
|
|
10
|
+
import { type GenAiMetrics } from "@intentius/chant-lexicon-otel/genai";
|
|
11
|
+
import { type DashboardEntity } from "../dashboard.js";
|
|
12
|
+
import { type DashboardOptions } from "./shared.js";
|
|
13
|
+
export interface AgentDashboardProps extends DashboardOptions {
|
|
14
|
+
/** The preset's metrics: `genAiMetrics(options)` with the options the collector was built with, or `genAiComponents(options)`. */
|
|
15
|
+
genAi: GenAiMetrics | {
|
|
16
|
+
metrics: GenAiMetrics;
|
|
17
|
+
};
|
|
18
|
+
/** The latency quantile per model and per tool (default 0.95). */
|
|
19
|
+
quantile?: number;
|
|
20
|
+
}
|
|
21
|
+
export type AgentDashboardMembers = {
|
|
22
|
+
dashboard: DashboardEntity;
|
|
23
|
+
};
|
|
24
|
+
/** What `AgentDashboard(...)` returns: its dashboard, as `dashboard`. */
|
|
25
|
+
export type AgentDashboardInstance = CompositeInstance<AgentDashboardMembers> & AgentDashboardMembers;
|
|
26
|
+
/** The PromQL the agent dashboard runs, from the preset's metrics. Exposed for tests and for panels of your own. */
|
|
27
|
+
export declare function agentQueries(m: GenAiMetrics, q?: number): {
|
|
28
|
+
labels: {
|
|
29
|
+
model: string;
|
|
30
|
+
tool: string;
|
|
31
|
+
errorType: string;
|
|
32
|
+
status: string;
|
|
33
|
+
service: string;
|
|
34
|
+
tokenModel: string;
|
|
35
|
+
};
|
|
36
|
+
services: string;
|
|
37
|
+
models: string;
|
|
38
|
+
model: {
|
|
39
|
+
rate: string;
|
|
40
|
+
errorRatio: string;
|
|
41
|
+
latency: string;
|
|
42
|
+
};
|
|
43
|
+
tool: {
|
|
44
|
+
rate: string;
|
|
45
|
+
errorRatio: string;
|
|
46
|
+
latency: string;
|
|
47
|
+
};
|
|
48
|
+
errorsByType: string;
|
|
49
|
+
tokens: {
|
|
50
|
+
inputRate: string;
|
|
51
|
+
outputRate: string;
|
|
52
|
+
inputTotal: string;
|
|
53
|
+
outputTotal: string;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* A dashboard for agents instrumented with GenAI spans: calls, errors and
|
|
58
|
+
* latency per model and per tool, errors by type, and token usage per
|
|
59
|
+
* model, from the GenAI preset's metrics.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* import { genAiMetrics } from "@intentius/chant-lexicon-otel";
|
|
64
|
+
* import { AgentDashboard } from "@intentius/chant-lexicon-grafana";
|
|
65
|
+
*
|
|
66
|
+
* export const agents = AgentDashboard({ genAi: genAiMetrics(), datasource: prometheus });
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export declare const AgentDashboard: import("@intentius/chant/composite").CompositeDefinition<AgentDashboardProps, AgentDashboardMembers>;
|
|
70
|
+
//# sourceMappingURL=agent-dashboard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-dashboard.d.ts","sourceRoot":"","sources":["../../src/composites/agent-dashboard.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAa,KAAK,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,EAAsC,KAAK,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAE5G,OAAO,EAAa,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAK/D,OAAO,EASL,KAAK,gBAAgB,EAEtB,MAAM,UAAU,CAAC;AAElB,MAAM,WAAW,mBAAoB,SAAQ,gBAAgB;IAC3D,kIAAkI;IAClI,KAAK,EAAE,YAAY,GAAG;QAAE,OAAO,EAAE,YAAY,CAAA;KAAE,CAAC;IAChD,kEAAkE;IAClE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,qBAAqB,GAAG;IAAE,SAAS,EAAE,eAAe,CAAA;CAAE,CAAC;AAEnE,yEAAyE;AACzE,MAAM,MAAM,sBAAsB,GAAG,iBAAiB,CAAC,qBAAqB,CAAC,GAAG,qBAAqB,CAAC;AAiBtG,oHAAoH;AACpH,wBAAgB,YAAY,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,SAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6CrD;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,cAAc,sGAoHP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../src/composites/catalog.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE/D,eAAO,MAAM,gBAAgB,EAAE,cAAc,EAyN5C,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Grafana lexicon composites: dashboards built from the declarations they
|
|
3
|
+
* read, so renaming a metric at its source moves it in the panels.
|
|
4
|
+
*/
|
|
5
|
+
export { RedDashboard, redQueries } from "./red-dashboard.js";
|
|
6
|
+
export type { RedDashboardProps, RedDashboardMembers, RedDashboardInstance } from "./red-dashboard.js";
|
|
7
|
+
export { SloDashboard, sloQueries } from "./slo-dashboard.js";
|
|
8
|
+
export type { SloDashboardProps, SloDashboardMembers, SloDashboardInstance } from "./slo-dashboard.js";
|
|
9
|
+
export { AgentDashboard, agentQueries } from "./agent-dashboard.js";
|
|
10
|
+
export type { AgentDashboardProps, AgentDashboardMembers, AgentDashboardInstance } from "./agent-dashboard.js";
|
|
11
|
+
export type { DashboardOptions } from "./shared.js";
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/composites/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC3D,YAAY,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACpG,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC3D,YAAY,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACpG,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjE,YAAY,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC5G,YAAY,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `RedDashboard`: rate, errors and duration per service, from a
|
|
3
|
+
* `spanmetrics` connector declaration.
|
|
4
|
+
*
|
|
5
|
+
* The metric names come from the connector's config through the otel
|
|
6
|
+
* lexicon's `spanMetricsNames()`: its namespace, its histogram unit, the
|
|
7
|
+
* default dimensions it keeps, and optionally the `prometheus` exporter's
|
|
8
|
+
* namespace. Renaming the connector's namespace moves every query here.
|
|
9
|
+
*/
|
|
10
|
+
import { type CompositeInstance } from "@intentius/chant/composite";
|
|
11
|
+
import { type PrometheusNaming, type SpanMetricsNames } from "@intentius/chant-lexicon-otel/metric-names";
|
|
12
|
+
import type { OTelComponent } from "@intentius/chant-lexicon-otel/define";
|
|
13
|
+
import type { SpanMetricsConnectorConfig } from "@intentius/chant-lexicon-otel/components/connectors";
|
|
14
|
+
import type { PrometheusExporterConfig } from "@intentius/chant-lexicon-otel/components/exporters";
|
|
15
|
+
import { type DashboardEntity } from "../dashboard.js";
|
|
16
|
+
import { type DashboardOptions } from "./shared.js";
|
|
17
|
+
export interface RedDashboardProps extends DashboardOptions {
|
|
18
|
+
/**
|
|
19
|
+
* The `spanmetrics` connector the metrics come from, or the names
|
|
20
|
+
* `spanMetricsNames()` returned for it.
|
|
21
|
+
*/
|
|
22
|
+
spanMetrics: OTelComponent<"connector", "spanmetrics", SpanMetricsConnectorConfig> | SpanMetricsNames;
|
|
23
|
+
/** The `prometheus` exporter that serves them, when its `namespace` or `add_metric_suffixes` changes the names. */
|
|
24
|
+
exporter?: OTelComponent<"exporter", "prometheus", PrometheusExporterConfig> | PrometheusNaming;
|
|
25
|
+
/** Duration quantiles, one panel each (default p50, p95 and p99). */
|
|
26
|
+
quantiles?: number[];
|
|
27
|
+
}
|
|
28
|
+
export type RedDashboardMembers = {
|
|
29
|
+
dashboard: DashboardEntity;
|
|
30
|
+
};
|
|
31
|
+
/** What `RedDashboard(...)` returns: its dashboard, as `dashboard`. */
|
|
32
|
+
export type RedDashboardInstance = CompositeInstance<RedDashboardMembers> & RedDashboardMembers;
|
|
33
|
+
/** The PromQL the RED dashboard runs, from the connector's names. Exposed for tests and for panels of your own. */
|
|
34
|
+
export declare function redQueries(names: SpanMetricsNames, quantiles?: number[], serviceFilter?: string): {
|
|
35
|
+
rate: string;
|
|
36
|
+
errorRatio: string;
|
|
37
|
+
duration: {
|
|
38
|
+
quantile: number;
|
|
39
|
+
expr: string;
|
|
40
|
+
}[];
|
|
41
|
+
services: string;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* A RED dashboard (rate, errors, duration) per service, built from a
|
|
45
|
+
* `spanmetrics` connector declaration.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* import { SpanMetricsConnector } from "@intentius/chant-lexicon-otel";
|
|
50
|
+
* import { Datasource, RedDashboard } from "@intentius/chant-lexicon-grafana";
|
|
51
|
+
*
|
|
52
|
+
* export const spans = new SpanMetricsConnector({ namespace: "shop", histogram: { unit: "s" } });
|
|
53
|
+
* export const prometheus = new Datasource({ name: "Prometheus", type: "prometheus", url: "http://prometheus:9090" });
|
|
54
|
+
* export const red = RedDashboard({ spanMetrics: spans, datasource: prometheus });
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare const RedDashboard: import("@intentius/chant/composite").CompositeDefinition<RedDashboardProps, RedDashboardMembers>;
|
|
58
|
+
//# sourceMappingURL=red-dashboard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"red-dashboard.d.ts","sourceRoot":"","sources":["../../src/composites/red-dashboard.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAa,KAAK,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,EAAoB,KAAK,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAC5H,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,qDAAqD,CAAC;AACtG,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,oDAAoD,CAAC;AACnG,OAAO,EAAa,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAK/D,OAAO,EASL,KAAK,gBAAgB,EAEtB,MAAM,UAAU,CAAC;AAElB,MAAM,WAAW,iBAAkB,SAAQ,gBAAgB;IACzD;;;OAGG;IACH,WAAW,EAAE,aAAa,CAAC,WAAW,EAAE,aAAa,EAAE,0BAA0B,CAAC,GAAG,gBAAgB,CAAC;IACtG,mHAAmH;IACnH,QAAQ,CAAC,EAAE,aAAa,CAAC,UAAU,EAAE,YAAY,EAAE,wBAAwB,CAAC,GAAG,gBAAgB,CAAC;IAChG,qEAAqE;IACrE,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,MAAM,MAAM,mBAAmB,GAAG;IAAE,SAAS,EAAE,eAAe,CAAA;CAAE,CAAC;AAEjE,uEAAuE;AACvE,MAAM,MAAM,oBAAoB,GAAG,iBAAiB,CAAC,mBAAmB,CAAC,GAAG,mBAAmB,CAAC;AAQhG,mHAAmH;AACnH,wBAAgB,UAAU,CAAC,KAAK,EAAE,gBAAgB,EAAE,SAAS,GAAE,MAAM,EAAsB,EAAE,aAAa,SAAa;;;;;;;;EAetH;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,YAAY,kGAsEP,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the dashboard composites share: the dashboard-level props they all
|
|
3
|
+
* take, a PromQL selector builder, and the field configs they reuse.
|
|
4
|
+
*/
|
|
5
|
+
import type { DatasourceInput } from "../query.js";
|
|
6
|
+
import type { DashboardLinkInput } from "../dashboard.js";
|
|
7
|
+
import type { ThresholdsConfig } from "../schema/dashboard.gen.js";
|
|
8
|
+
/** Dashboard settings every composite takes; each has a default derived from what it reads. */
|
|
9
|
+
export interface DashboardOptions {
|
|
10
|
+
/** The Prometheus the metrics are queried from: a declared `Datasource`, or `{ type: "prometheus", uid }` for one declared elsewhere. */
|
|
11
|
+
datasource: DatasourceInput<"prometheus">;
|
|
12
|
+
title?: string;
|
|
13
|
+
/** The dashboard uid. Defaults to one derived from the source declaration. */
|
|
14
|
+
uid?: string;
|
|
15
|
+
description?: string;
|
|
16
|
+
tags?: string[];
|
|
17
|
+
/** The Grafana folder to provision it into. */
|
|
18
|
+
folder?: string;
|
|
19
|
+
/** Initial time range. */
|
|
20
|
+
time?: {
|
|
21
|
+
from: string;
|
|
22
|
+
to: string;
|
|
23
|
+
};
|
|
24
|
+
/** Auto-refresh interval, e.g. `30s`. */
|
|
25
|
+
refresh?: string;
|
|
26
|
+
links?: DashboardLinkInput[];
|
|
27
|
+
}
|
|
28
|
+
/** A label matcher: `[label, op, value]`. */
|
|
29
|
+
export type Matcher = [label: string, op: "=" | "!=" | "=~" | "!~", value: string];
|
|
30
|
+
/** `metric{a="x", b=~"y"}`; just `metric` with no matchers. */
|
|
31
|
+
export declare function selector(metric: string, matchers: Matcher[]): string;
|
|
32
|
+
/** `sum by (labels) (rate(sel[range]))`, or `sum (...)` with no labels. */
|
|
33
|
+
export declare function sumRate(sel: string, by: string[], range?: string): string;
|
|
34
|
+
/** `histogram_quantile(q, sum by (le, labels) (rate(bucket[range])))`. */
|
|
35
|
+
export declare function quantile(q: number, bucketSel: string, by: string[]): string;
|
|
36
|
+
/** A number as PromQL and Grafana thresholds write it, without float noise. */
|
|
37
|
+
export declare function num(n: number): string;
|
|
38
|
+
/** `p95` for 0.95, `p99.9` for 0.999. */
|
|
39
|
+
export declare function quantileName(q: number): string;
|
|
40
|
+
/** Legend text naming the label, `{{service_name}}`. */
|
|
41
|
+
export declare function legend(...labels: string[]): string;
|
|
42
|
+
/** Grafana's unit id for a spanmetrics histogram unit (`ms` or `s`). */
|
|
43
|
+
export declare function durationUnit(unit: string | undefined): string;
|
|
44
|
+
/** Absolute thresholds from a base colour and `[value, colour]` steps. */
|
|
45
|
+
export declare function thresholds(base: string, steps: Array<[number, string]>): ThresholdsConfig;
|
|
46
|
+
/** The props a composite passes to `Dashboard`, from the options and its own defaults. */
|
|
47
|
+
export declare function dashboardProps(o: DashboardOptions, defaults: {
|
|
48
|
+
title: string;
|
|
49
|
+
uid: string;
|
|
50
|
+
description: string;
|
|
51
|
+
tags: string[];
|
|
52
|
+
}): {
|
|
53
|
+
links?: DashboardLinkInput[] | undefined;
|
|
54
|
+
folder?: string | undefined;
|
|
55
|
+
graphTooltip: "sharedCrosshair";
|
|
56
|
+
refresh: string;
|
|
57
|
+
title: string;
|
|
58
|
+
uid: string;
|
|
59
|
+
description: string;
|
|
60
|
+
tags: string[];
|
|
61
|
+
time: {
|
|
62
|
+
from: string;
|
|
63
|
+
to: string;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
/** Throw unless a Prometheus datasource was passed. */
|
|
67
|
+
export declare function requireDatasource(composite: string, ds: unknown): void;
|
|
68
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/composites/shared.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,+FAA+F;AAC/F,MAAM,WAAW,gBAAgB;IAC/B,yIAAyI;IACzI,UAAU,EAAE,eAAe,CAAC,YAAY,CAAC,CAAC;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8EAA8E;IAC9E,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,+CAA+C;IAC/C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,0BAA0B;IAC1B,IAAI,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IACpC,yCAAyC;IACzC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,kBAAkB,EAAE,CAAC;CAC9B;AAED,6CAA6C;AAC7C,MAAM,MAAM,OAAO,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AAEnF,+DAA+D;AAC/D,wBAAgB,QAAQ,CAAC,MAAM,EAAE,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SLI, error budget and burn rates, from an `Slo`
|
|
3
|
+
* declaration.
|
|
4
|
+
*
|
|
5
|
+
* Every series name, the objective, the window and the burn-rate pairs come
|
|
6
|
+
* from the prometheus lexicon's `sloMetrics()`, which reads the same
|
|
7
|
+
* declaration the rules are built from. Renaming the SLO, changing its
|
|
8
|
+
* objective or its windows moves the panels and their threshold lines with
|
|
9
|
+
* it.
|
|
10
|
+
*/
|
|
11
|
+
import { type CompositeInstance } from "@intentius/chant/composite";
|
|
12
|
+
import { type SloInstance, type SloMetrics } from "@intentius/chant-lexicon-prometheus/composites/slo";
|
|
13
|
+
import type { RuleGroupEntity } from "@intentius/chant-lexicon-prometheus/rules";
|
|
14
|
+
import { type DashboardEntity } from "../dashboard.js";
|
|
15
|
+
import { type DashboardOptions } from "./shared.js";
|
|
16
|
+
export interface SloDashboardProps extends DashboardOptions {
|
|
17
|
+
/** The `Slo(...)` the dashboard reads, its rule group, or what `sloMetrics()` returned for it. */
|
|
18
|
+
slo: SloInstance | RuleGroupEntity | SloMetrics;
|
|
19
|
+
}
|
|
20
|
+
export type SloDashboardMembers = {
|
|
21
|
+
dashboard: DashboardEntity;
|
|
22
|
+
};
|
|
23
|
+
/** What `SloDashboard(...)` returns: its dashboard, as `dashboard`. */
|
|
24
|
+
export type SloDashboardInstance = CompositeInstance<SloDashboardMembers> & SloDashboardMembers;
|
|
25
|
+
/** The PromQL the SLO dashboard runs, from `sloMetrics()`. Exposed for tests and for panels of your own. */
|
|
26
|
+
export declare function sloQueries(m: SloMetrics): {
|
|
27
|
+
sli: string;
|
|
28
|
+
objective: string;
|
|
29
|
+
errorBudgetRemaining: string;
|
|
30
|
+
alertsFiring: string;
|
|
31
|
+
burnRates: {
|
|
32
|
+
longExpr: string;
|
|
33
|
+
shortExpr: string;
|
|
34
|
+
tier: "page" | "ticket";
|
|
35
|
+
severity: string;
|
|
36
|
+
long: string;
|
|
37
|
+
short: string;
|
|
38
|
+
factor: number;
|
|
39
|
+
threshold: number;
|
|
40
|
+
longRecord: string;
|
|
41
|
+
shortRecord: string;
|
|
42
|
+
alert: string;
|
|
43
|
+
labels: import("lexicons/prometheus/src/model").LabelSet;
|
|
44
|
+
exhaustsIn: string;
|
|
45
|
+
}[];
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* A dashboard for one SLO: the SLI over its window against the objective,
|
|
49
|
+
* the error budget left, and each burn-rate alert's two windows with the
|
|
50
|
+
* rate it fires at drawn as a threshold line.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* import { Slo } from "@intentius/chant-lexicon-prometheus";
|
|
55
|
+
* import { SloDashboard } from "@intentius/chant-lexicon-grafana";
|
|
56
|
+
*
|
|
57
|
+
* export const checkout = Slo({ name: "checkout", objective: 0.999, window: "30d", sli: { ... } });
|
|
58
|
+
* export const checkoutSlo = SloDashboard({ slo: checkout, datasource: prometheus });
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export declare const SloDashboard: import("@intentius/chant/composite").CompositeDefinition<SloDashboardProps, SloDashboardMembers>;
|
|
62
|
+
//# sourceMappingURL=slo-dashboard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slo-dashboard.d.ts","sourceRoot":"","sources":["../../src/composites/slo-dashboard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAa,KAAK,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,EAAc,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,oDAAoD,CAAC;AACnH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAa,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAI/D,OAAO,EAAgE,KAAK,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE/G,MAAM,WAAW,iBAAkB,SAAQ,gBAAgB;IACzD,kGAAkG;IAClG,GAAG,EAAE,WAAW,GAAG,eAAe,GAAG,UAAU,CAAC;CACjD;AAED,MAAM,MAAM,mBAAmB,GAAG;IAAE,SAAS,EAAE,eAAe,CAAA;CAAE,CAAC;AAEjE,uEAAuE;AACvE,MAAM,MAAM,oBAAoB,GAAG,iBAAiB,CAAC,mBAAmB,CAAC,GAAG,mBAAmB,CAAC;AAMhG,4GAA4G;AAC5G,wBAAgB,UAAU,CAAC,CAAC,EAAE,UAAU;;;;;;;;;;;;;;;;;;;;EAkBvC;AAID;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,YAAY,kGAyGP,CAAC"}
|