@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.
Files changed (224) hide show
  1. package/README.md +12 -6
  2. package/dist/annotations.d.ts +61 -0
  3. package/dist/annotations.d.ts.map +1 -0
  4. package/dist/api/apply.d.ts +8 -4
  5. package/dist/api/apply.d.ts.map +1 -1
  6. package/dist/api/fake-grafana.d.ts +2 -0
  7. package/dist/api/fake-grafana.d.ts.map +1 -1
  8. package/dist/api/folders.d.ts +53 -17
  9. package/dist/api/folders.d.ts.map +1 -1
  10. package/dist/build.d.ts +26 -5
  11. package/dist/build.d.ts.map +1 -1
  12. package/dist/catalog.d.ts +1 -1
  13. package/dist/catalog.d.ts.map +1 -1
  14. package/dist/codegen/docs.d.ts.map +1 -1
  15. package/dist/codegen/generate.d.ts +7 -1
  16. package/dist/codegen/generate.d.ts.map +1 -1
  17. package/dist/composites/shared.d.ts +4 -3
  18. package/dist/composites/shared.d.ts.map +1 -1
  19. package/dist/dashboard.d.ts +42 -14
  20. package/dist/dashboard.d.ts.map +1 -1
  21. package/dist/datasource-refs.d.ts +9 -5
  22. package/dist/datasource-refs.d.ts.map +1 -1
  23. package/dist/datasource-settings.d.ts +834 -0
  24. package/dist/datasource-settings.d.ts.map +1 -0
  25. package/dist/datasource.d.ts +53 -11
  26. package/dist/datasource.d.ts.map +1 -1
  27. package/dist/deep-observe-hooks.d.ts +1 -1
  28. package/dist/deep-observe-hooks.d.ts.map +1 -1
  29. package/dist/deep-observe.d.ts +9 -4
  30. package/dist/deep-observe.d.ts.map +1 -1
  31. package/dist/describe-resources.d.ts +1 -0
  32. package/dist/describe-resources.d.ts.map +1 -1
  33. package/dist/detect.d.ts +4 -2
  34. package/dist/detect.d.ts.map +1 -1
  35. package/dist/folder.d.ts +68 -0
  36. package/dist/folder.d.ts.map +1 -0
  37. package/dist/import/generator.d.ts.map +1 -1
  38. package/dist/import/mappings.d.ts +12 -6
  39. package/dist/import/mappings.d.ts.map +1 -1
  40. package/dist/import/model.d.ts +7 -0
  41. package/dist/import/model.d.ts.map +1 -1
  42. package/dist/import/normalize.d.ts.map +1 -1
  43. package/dist/import/parser.d.ts +16 -1
  44. package/dist/import/parser.d.ts.map +1 -1
  45. package/dist/import/testdata/fixtures.d.ts +6 -0
  46. package/dist/import/testdata/fixtures.d.ts.map +1 -1
  47. package/dist/import/v2.d.ts +4 -3
  48. package/dist/import/v2.d.ts.map +1 -1
  49. package/dist/index.d.ts +11 -9
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/init-templates.d.ts +27 -0
  52. package/dist/init-templates.d.ts.map +1 -0
  53. package/dist/integrity.json +11 -9
  54. package/dist/lint/audit-catalog.d.ts +1 -1
  55. package/dist/lint/audit-catalog.d.ts.map +1 -1
  56. package/dist/lint/post-synth/graf101.d.ts +1 -1
  57. package/dist/lint/post-synth/graf104.d.ts +2 -2
  58. package/dist/lint/post-synth/graf106.d.ts +2 -2
  59. package/dist/lint/post-synth/graf110.d.ts +8 -0
  60. package/dist/lint/post-synth/graf110.d.ts.map +1 -0
  61. package/dist/lint/post-synth/grafana-helpers.d.ts.map +1 -1
  62. package/dist/lint/post-synth/index.d.ts.map +1 -1
  63. package/dist/manifest.json +1 -1
  64. package/dist/meta.json +70 -0
  65. package/dist/okf/index.md +18 -3
  66. package/dist/okf/rules/GRAF101.md +2 -2
  67. package/dist/okf/rules/GRAF104.md +2 -2
  68. package/dist/okf/rules/GRAF106.md +2 -2
  69. package/dist/okf/rules/GRAF110.md +11 -0
  70. package/dist/okf/types/AdhocVariable.md +9 -0
  71. package/dist/okf/types/AzureMonitorQuery.md +9 -0
  72. package/dist/okf/types/BigQueryQuery.md +9 -0
  73. package/dist/okf/types/CloudMonitoringQuery.md +9 -0
  74. package/dist/okf/types/CloudWatchQuery.md +9 -0
  75. package/dist/okf/types/Dashboard.md +1 -1
  76. package/dist/okf/types/Datasource.md +1 -1
  77. package/dist/okf/types/DatasourceProvisioning.md +9 -0
  78. package/dist/okf/types/ElasticsearchQuery.md +9 -0
  79. package/dist/okf/types/ExternalDatasource.md +1 -1
  80. package/dist/okf/types/Folder.md +9 -0
  81. package/dist/okf/types/GroupByVariable.md +9 -0
  82. package/dist/okf/types/MSSQLQuery.md +9 -0
  83. package/dist/okf/types/MySQLQuery.md +9 -0
  84. package/dist/okf/types/PostgresQuery.md +9 -0
  85. package/dist/okf/types/PyroscopeQuery.md +9 -0
  86. package/dist/okf/types/SwitchVariable.md +9 -0
  87. package/dist/op/activities/grafana-apply.d.ts +11 -0
  88. package/dist/op/activities/grafana-apply.d.ts.map +1 -1
  89. package/dist/op/activities/index.d.ts +1 -1
  90. package/dist/op/activities/index.d.ts.map +1 -1
  91. package/dist/ownership.d.ts +11 -0
  92. package/dist/ownership.d.ts.map +1 -1
  93. package/dist/pin.d.ts +1 -1
  94. package/dist/pin.d.ts.map +1 -1
  95. package/dist/plugin.d.ts.map +1 -1
  96. package/dist/promql-check.d.ts.map +1 -1
  97. package/dist/query-models.d.ts +95 -0
  98. package/dist/query-models.d.ts.map +1 -0
  99. package/dist/query.d.ts +107 -10
  100. package/dist/query.d.ts.map +1 -1
  101. package/dist/rules/graf101.ts +2 -2
  102. package/dist/rules/graf104.ts +3 -3
  103. package/dist/rules/graf106.ts +3 -3
  104. package/dist/rules/graf110.ts +17 -0
  105. package/dist/rules/grafana-helpers.ts +13 -3
  106. package/dist/schema/azuremonitor.gen.d.ts +354 -0
  107. package/dist/schema/azuremonitor.gen.d.ts.map +1 -0
  108. package/dist/schema/bigquery.gen.d.ts +93 -0
  109. package/dist/schema/bigquery.gen.d.ts.map +1 -0
  110. package/dist/schema/cloudwatch.gen.d.ts +394 -0
  111. package/dist/schema/cloudwatch.gen.d.ts.map +1 -0
  112. package/dist/schema/elasticsearch.gen.d.ts +444 -0
  113. package/dist/schema/elasticsearch.gen.d.ts.map +1 -0
  114. package/dist/schema/googlecloudmonitoring.gen.d.ts +312 -0
  115. package/dist/schema/googlecloudmonitoring.gen.d.ts.map +1 -0
  116. package/dist/schema/grafanapyroscope.gen.d.ts +60 -0
  117. package/dist/schema/grafanapyroscope.gen.d.ts.map +1 -0
  118. package/dist/schema/index.d.ts +6 -0
  119. package/dist/schema/index.d.ts.map +1 -1
  120. package/dist/schema/table.gen.d.ts +13 -0
  121. package/dist/schema/table.gen.d.ts.map +1 -1
  122. package/dist/schema-validate.d.ts +9 -0
  123. package/dist/schema-validate.d.ts.map +1 -1
  124. package/dist/skill-defs.d.ts.map +1 -1
  125. package/dist/skills/chant-grafana-operations.md +108 -0
  126. package/dist/skills/chant-grafana.md +5 -4
  127. package/dist/spec/schemas.d.ts +9 -7
  128. package/dist/spec/schemas.d.ts.map +1 -1
  129. package/dist/spec/schemas.gen.d.ts +3 -0
  130. package/dist/spec/schemas.gen.d.ts.map +1 -0
  131. package/dist/validate-alerting.d.ts.map +1 -1
  132. package/dist/validate-output.d.ts +15 -2
  133. package/dist/validate-output.d.ts.map +1 -1
  134. package/dist/validate.d.ts.map +1 -1
  135. package/dist/validation.d.ts +14 -0
  136. package/dist/validation.d.ts.map +1 -0
  137. package/dist/variables.d.ts +102 -5
  138. package/dist/variables.d.ts.map +1 -1
  139. package/package.json +2 -2
  140. package/src/annotations.ts +84 -0
  141. package/src/api/apply.test.ts +19 -1
  142. package/src/api/apply.ts +18 -8
  143. package/src/api/fake-grafana.ts +6 -2
  144. package/src/api/folders.ts +106 -32
  145. package/src/build.test.ts +142 -6
  146. package/src/build.ts +126 -24
  147. package/src/catalog.ts +20 -2
  148. package/src/codegen/docs.ts +13 -6
  149. package/src/codegen/generate.ts +27 -1
  150. package/src/composites/shared.ts +3 -2
  151. package/src/dashboard.ts +59 -14
  152. package/src/datasource-refs.ts +30 -6
  153. package/src/datasource-settings.test.ts +106 -0
  154. package/src/datasource-settings.ts +941 -0
  155. package/src/datasource.ts +71 -11
  156. package/src/deep-observe-hooks.ts +16 -1
  157. package/src/deep-observe.test.ts +47 -1
  158. package/src/deep-observe.ts +36 -13
  159. package/src/describe-resources.test.ts +16 -0
  160. package/src/describe-resources.ts +36 -1
  161. package/src/detect.ts +3 -3
  162. package/src/folder.ts +118 -0
  163. package/src/generated/lexicon-grafana.json +70 -0
  164. package/src/import/generated-types.e2e.test.ts +15 -3
  165. package/src/import/generator.ts +2 -1
  166. package/src/import/mappings.ts +98 -26
  167. package/src/import/model.ts +7 -0
  168. package/src/import/normalize.ts +32 -3
  169. package/src/import/parser.test.ts +97 -21
  170. package/src/import/parser.ts +169 -18
  171. package/src/import/roundtrip.test.ts +104 -9
  172. package/src/import/testdata/fixtures.ts +8 -0
  173. package/src/import/v2.ts +4 -3
  174. package/src/index.ts +122 -13
  175. package/src/init-templates.test.ts +74 -0
  176. package/src/init-templates.ts +349 -0
  177. package/src/lint/audit-catalog.ts +9 -1
  178. package/src/lint/post-synth/graf101.ts +2 -2
  179. package/src/lint/post-synth/graf104.ts +3 -3
  180. package/src/lint/post-synth/graf106.ts +3 -3
  181. package/src/lint/post-synth/graf110.ts +17 -0
  182. package/src/lint/post-synth/grafana-helpers.ts +13 -3
  183. package/src/lint/post-synth/index.ts +2 -0
  184. package/src/lint/post-synth/post-synth.test.ts +99 -2
  185. package/src/load-cost.test.ts +35 -0
  186. package/src/op/activities/grafana-apply.e2e.test.ts +14 -5
  187. package/src/op/activities/grafana-apply.test.ts +16 -2
  188. package/src/op/activities/grafana-apply.ts +29 -3
  189. package/src/op/activities/index.ts +1 -1
  190. package/src/ownership.ts +19 -0
  191. package/src/panels.test.ts +3 -1
  192. package/src/pin.ts +12 -0
  193. package/src/plugin.test.ts +9 -2
  194. package/src/plugin.ts +9 -0
  195. package/src/promql-check.ts +5 -1
  196. package/src/query-models.ts +94 -0
  197. package/src/query.test.ts +166 -0
  198. package/src/query.ts +177 -12
  199. package/src/schema/azuremonitor.gen.ts +381 -0
  200. package/src/schema/bigquery.gen.ts +110 -0
  201. package/src/schema/cloudwatch.gen.ts +423 -0
  202. package/src/schema/elasticsearch.gen.ts +508 -0
  203. package/src/schema/googlecloudmonitoring.gen.ts +330 -0
  204. package/src/schema/grafanapyroscope.gen.ts +66 -0
  205. package/src/schema/index.ts +6 -0
  206. package/src/schema/table.gen.ts +14 -0
  207. package/src/schema-validate.ts +58 -7
  208. package/src/skill-defs.ts +17 -0
  209. package/src/skills/chant-grafana-operations.md +108 -0
  210. package/src/skills/chant-grafana.md +5 -4
  211. package/src/spec/overlay/table.overlay.json +19 -0
  212. package/src/spec/schemas/azuremonitor.jsonschema.json +679 -0
  213. package/src/spec/schemas/bigquery.jsonschema.json +290 -0
  214. package/src/spec/schemas/cloudwatch.jsonschema.json +721 -0
  215. package/src/spec/schemas/elasticsearch.jsonschema.json +1695 -0
  216. package/src/spec/schemas/googlecloudmonitoring.jsonschema.json +488 -0
  217. package/src/spec/schemas/grafanapyroscope.jsonschema.json +93 -0
  218. package/src/spec/schemas.gen.ts +40 -0
  219. package/src/spec/schemas.ts +9 -7
  220. package/src/validate-alerting.ts +4 -2
  221. package/src/validate-output.ts +96 -4
  222. package/src/validate.ts +14 -0
  223. package/src/validation.ts +27 -0
  224. package/src/variables.ts +113 -6
@@ -0,0 +1,330 @@
1
+ // Code generated by chant generate from the vendored Grafana schema
2
+ // src/spec/schemas/googlecloudmonitoring.jsonschema.json (see src/pin.ts) and its correction
3
+ // overlay in src/spec/overlay/ (see src/spec/overlay.ts). DO NOT EDIT.
4
+ /* eslint-disable */
5
+
6
+ export interface CloudMonitoringQuery {
7
+ /**
8
+ * A unique identifier for the query within the list of targets.
9
+ * In server side expressions, the refId is used as a variable name to identify results.
10
+ * By default, the UI will assign A->Z; however setting meaningful names may be useful.
11
+ */
12
+ refId?: string | null;
13
+ /**
14
+ * If hide is set to true, Grafana will filter out the response(s) associated with this query before returning it to the panel.
15
+ */
16
+ hide?: boolean;
17
+ /**
18
+ * Specify the query flavor
19
+ * TODO make this required and give it a default
20
+ */
21
+ queryType?: string;
22
+ /**
23
+ * Aliases can be set to modify the legend labels. e.g. {{metric.label.xxx}}. See docs for more detail.
24
+ */
25
+ aliasBy?: string;
26
+ /**
27
+ * GCM query type.
28
+ * queryType: #QueryType
29
+ * Time Series List sub-query properties.
30
+ */
31
+ timeSeriesList?: TimeSeriesList;
32
+ /**
33
+ * Time Series sub-query properties.
34
+ */
35
+ timeSeriesQuery?: TimeSeriesQuery;
36
+ /**
37
+ * SLO sub-query properties.
38
+ */
39
+ sloQuery?: SLOQuery;
40
+ /**
41
+ * PromQL sub-query properties.
42
+ */
43
+ promQLQuery?: PromQLQuery;
44
+ /**
45
+ * For mixed data sources the selected datasource is on the query level.
46
+ * For non mixed scenarios this is undefined.
47
+ * TODO find a better way to do this ^ that's friendly to schema
48
+ * TODO this shouldn't be unknown but DataSourceRef | null
49
+ */
50
+ datasource?: DataSourceRef;
51
+ /**
52
+ * Time interval in milliseconds.
53
+ */
54
+ intervalMs?: number;
55
+ }
56
+
57
+ /**
58
+ * Time Series List sub-query properties.
59
+ */
60
+ export interface TimeSeriesList {
61
+ /**
62
+ * GCP project to execute the query against.
63
+ */
64
+ projectName: string;
65
+ /**
66
+ * Reducer applied across a set of time-series values. Defaults to REDUCE_NONE.
67
+ */
68
+ crossSeriesReducer: string;
69
+ /**
70
+ * Alignment period to use when regularizing data. Defaults to cloud-monitoring-auto.
71
+ */
72
+ alignmentPeriod?: string;
73
+ /**
74
+ * Alignment function to be used. Defaults to ALIGN_MEAN.
75
+ */
76
+ perSeriesAligner?: string;
77
+ /**
78
+ * Array of labels to group data by.
79
+ */
80
+ groupBys?: string[];
81
+ /**
82
+ * Array of filters to query data by. Labels that can be filtered on are defined by the metric.
83
+ */
84
+ filters?: string[];
85
+ /**
86
+ * Data view, defaults to FULL.
87
+ */
88
+ view?: string;
89
+ /**
90
+ * Annotation title.
91
+ */
92
+ title?: string;
93
+ /**
94
+ * Annotation text.
95
+ */
96
+ text?: string;
97
+ /**
98
+ * Only present if a preprocessor is selected. Reducer applied across a set of time-series values. Defaults to REDUCE_NONE.
99
+ */
100
+ secondaryCrossSeriesReducer?: string;
101
+ /**
102
+ * Only present if a preprocessor is selected. Alignment period to use when regularizing data. Defaults to cloud-monitoring-auto.
103
+ */
104
+ secondaryAlignmentPeriod?: string;
105
+ /**
106
+ * Only present if a preprocessor is selected. Alignment function to be used. Defaults to ALIGN_MEAN.
107
+ */
108
+ secondaryPerSeriesAligner?: string;
109
+ /**
110
+ * Only present if a preprocessor is selected. Array of labels to group data by.
111
+ */
112
+ secondaryGroupBys?: string[];
113
+ /**
114
+ * Preprocessor is not part of the API, but is used to store the preprocessor and not affect the UI for the rest of parameters
115
+ */
116
+ preprocessor?: PreprocessorType;
117
+ }
118
+
119
+ /**
120
+ * Types of pre-processor available. Defined by the metric.
121
+ */
122
+ export type PreprocessorType = "none" | "rate" | "delta";
123
+
124
+ /**
125
+ * Time Series sub-query properties.
126
+ */
127
+ export interface TimeSeriesQuery {
128
+ /**
129
+ * GCP project to execute the query against.
130
+ */
131
+ projectName: string;
132
+ /**
133
+ * MQL query to be executed.
134
+ */
135
+ query: string;
136
+ /**
137
+ * To disable the graphPeriod, it should explictly be set to 'disabled'.
138
+ */
139
+ graphPeriod?: string;
140
+ }
141
+
142
+ /**
143
+ * SLO sub-query properties.
144
+ */
145
+ export interface SLOQuery {
146
+ /**
147
+ * GCP project to execute the query against.
148
+ */
149
+ projectName: string;
150
+ /**
151
+ * Alignment function to be used. Defaults to ALIGN_MEAN.
152
+ */
153
+ perSeriesAligner?: string;
154
+ /**
155
+ * Alignment period to use when regularizing data. Defaults to cloud-monitoring-auto.
156
+ */
157
+ alignmentPeriod?: string;
158
+ /**
159
+ * SLO selector.
160
+ */
161
+ selectorName: string;
162
+ /**
163
+ * ID for the service the SLO is in.
164
+ */
165
+ serviceId: string;
166
+ /**
167
+ * Name for the service the SLO is in.
168
+ */
169
+ serviceName: string;
170
+ /**
171
+ * ID for the SLO.
172
+ */
173
+ sloId: string;
174
+ /**
175
+ * Name of the SLO.
176
+ */
177
+ sloName: string;
178
+ /**
179
+ * SLO goal value.
180
+ */
181
+ goal?: number;
182
+ /**
183
+ * Specific lookback period for the SLO.
184
+ */
185
+ lookbackPeriod?: string;
186
+ }
187
+
188
+ /**
189
+ * PromQL sub-query properties.
190
+ */
191
+ export interface PromQLQuery {
192
+ /**
193
+ * GCP project to execute the query against.
194
+ */
195
+ projectName: string;
196
+ /**
197
+ * PromQL expression/query to be executed.
198
+ */
199
+ expr: string;
200
+ /**
201
+ * PromQL min step
202
+ */
203
+ step: string;
204
+ }
205
+
206
+ /**
207
+ * Defines the supported queryTypes.
208
+ */
209
+ export type QueryType = "timeSeriesList" | "timeSeriesQuery" | "slo" | "annotation" | "promQL";
210
+
211
+ /**
212
+ * @deprecated This type is for migration purposes only. Replaced by TimeSeriesList Metric sub-query properties.
213
+ */
214
+ export interface MetricQuery {
215
+ /**
216
+ * GCP project to execute the query against.
217
+ */
218
+ projectName: string;
219
+ /**
220
+ * Alignment function to be used. Defaults to ALIGN_MEAN.
221
+ */
222
+ perSeriesAligner?: string;
223
+ /**
224
+ * Alignment period to use when regularizing data. Defaults to cloud-monitoring-auto.
225
+ */
226
+ alignmentPeriod?: string;
227
+ /**
228
+ * Aliases can be set to modify the legend labels. e.g. {{metric.label.xxx}}. See docs for more detail.
229
+ */
230
+ aliasBy?: string;
231
+ editorMode: string;
232
+ metricType: string;
233
+ /**
234
+ * Reducer applied across a set of time-series values. Defaults to REDUCE_NONE.
235
+ */
236
+ crossSeriesReducer: string;
237
+ /**
238
+ * Array of labels to group data by.
239
+ */
240
+ groupBys?: string[];
241
+ /**
242
+ * Array of filters to query data by. Labels that can be filtered on are defined by the metric.
243
+ */
244
+ filters?: string[];
245
+ metricKind?: MetricKind;
246
+ valueType?: string;
247
+ view?: string;
248
+ /**
249
+ * MQL query to be executed.
250
+ */
251
+ query: string;
252
+ /**
253
+ * Preprocessor is not part of the API, but is used to store the preprocessor and not affect the UI for the rest of parameters
254
+ */
255
+ preprocessor?: PreprocessorType;
256
+ /**
257
+ * To disable the graphPeriod, it should explictly be set to 'disabled'.
258
+ */
259
+ graphPeriod?: string;
260
+ }
261
+
262
+ export type MetricKind = "METRIC_KIND_UNSPECIFIED" | "GAUGE" | "DELTA" | "CUMULATIVE";
263
+
264
+ export type ValueTypes = "VALUE_TYPE_UNSPECIFIED" | "BOOL" | "INT64" | "DOUBLE" | "STRING" | "DISTRIBUTION" | "MONEY";
265
+
266
+ export type AlignmentTypes = "ALIGN_DELTA" | "ALIGN_RATE" | "ALIGN_INTERPOLATE" | "ALIGN_NEXT_OLDER" | "ALIGN_MIN" | "ALIGN_MAX" | "ALIGN_MEAN" | "ALIGN_COUNT" | "ALIGN_SUM" | "ALIGN_STDDEV" | "ALIGN_COUNT_TRUE" | "ALIGN_COUNT_FALSE" | "ALIGN_FRACTION_TRUE" | "ALIGN_PERCENTILE_99" | "ALIGN_PERCENTILE_95" | "ALIGN_PERCENTILE_50" | "ALIGN_PERCENTILE_05" | "ALIGN_PERCENT_CHANGE" | "ALIGN_NONE";
267
+
268
+ /**
269
+ * @deprecated Use TimeSeriesList instead. Legacy annotation query properties for migration purposes.
270
+ */
271
+ export interface LegacyCloudMonitoringAnnotationQuery {
272
+ /**
273
+ * GCP project to execute the query against.
274
+ */
275
+ projectName: string;
276
+ metricType: string;
277
+ /**
278
+ * Query refId.
279
+ */
280
+ refId: string;
281
+ /**
282
+ * Array of filters to query data by. Labels that can be filtered on are defined by the metric.
283
+ */
284
+ filters: string[];
285
+ metricKind: MetricKind;
286
+ valueType: string;
287
+ /**
288
+ * Annotation title.
289
+ */
290
+ title: string;
291
+ /**
292
+ * Annotation text.
293
+ */
294
+ text: string;
295
+ }
296
+
297
+ /**
298
+ * Query filter representation.
299
+ */
300
+ export interface Filter {
301
+ /**
302
+ * Filter key.
303
+ */
304
+ key: string;
305
+ /**
306
+ * Filter operator.
307
+ */
308
+ operator: string;
309
+ /**
310
+ * Filter value.
311
+ */
312
+ value: string;
313
+ /**
314
+ * Filter condition.
315
+ */
316
+ condition?: string;
317
+ }
318
+
319
+ export type MetricFindQueryTypes = "projects" | "services" | "defaultProject" | "metricTypes" | "labelKeys" | "labelValues" | "resourceTypes" | "aggregations" | "aligners" | "alignmentPeriods" | "selectors" | "sloServices" | "slo";
320
+
321
+ export interface DataSourceRef {
322
+ /**
323
+ * The plugin type-id
324
+ */
325
+ type?: string;
326
+ /**
327
+ * Specific datasource instance
328
+ */
329
+ uid?: string;
330
+ }
@@ -0,0 +1,66 @@
1
+ // Code generated by chant generate from the vendored Grafana schema
2
+ // src/spec/schemas/grafanapyroscope.jsonschema.json (see src/pin.ts) and its correction
3
+ // overlay in src/spec/overlay/ (see src/spec/overlay.ts). DO NOT EDIT.
4
+ /* eslint-disable */
5
+
6
+ export type PyroscopeQueryType = "metrics" | "profile" | "both";
7
+
8
+ export interface Dataquery {
9
+ /**
10
+ * Specifies the query label selectors.
11
+ */
12
+ labelSelector: string;
13
+ /**
14
+ * Specifies the query span selectors.
15
+ */
16
+ spanSelector?: string[];
17
+ /**
18
+ * Specifies the type of profile to query.
19
+ */
20
+ profileTypeId: string;
21
+ /**
22
+ * Allows to group the results.
23
+ */
24
+ groupBy: string[];
25
+ /**
26
+ * Sets the maximum number of time series.
27
+ */
28
+ limit?: number;
29
+ /**
30
+ * Sets the maximum number of nodes in the flamegraph.
31
+ */
32
+ maxNodes?: number;
33
+ /**
34
+ * A unique identifier for the query within the list of targets.
35
+ * In server side expressions, the refId is used as a variable name to identify results.
36
+ * By default, the UI will assign A->Z; however setting meaningful names may be useful.
37
+ */
38
+ refId?: string | null;
39
+ /**
40
+ * If hide is set to true, Grafana will filter out the response(s) associated with this query before returning it to the panel.
41
+ */
42
+ hide?: boolean;
43
+ /**
44
+ * Specify the query flavor
45
+ * TODO make this required and give it a default
46
+ */
47
+ queryType?: string;
48
+ /**
49
+ * For mixed data sources the selected datasource is on the query level.
50
+ * For non mixed scenarios this is undefined.
51
+ * TODO find a better way to do this ^ that's friendly to schema
52
+ * TODO this shouldn't be unknown but DataSourceRef | null
53
+ */
54
+ datasource?: DataSourceRef;
55
+ }
56
+
57
+ export interface DataSourceRef {
58
+ /**
59
+ * The plugin type-id
60
+ */
61
+ type?: string;
62
+ /**
63
+ * Specific datasource instance
64
+ */
65
+ uid?: string;
66
+ }
@@ -25,5 +25,11 @@ export * as geomap from "./geomap.gen";
25
25
  export * as prometheus from "./prometheus.gen";
26
26
  export * as tempo from "./tempo.gen";
27
27
  export * as loki from "./loki.gen";
28
+ export * as elasticsearch from "./elasticsearch.gen";
29
+ export * as cloudwatch from "./cloudwatch.gen";
30
+ export * as azuremonitor from "./azuremonitor.gen";
31
+ export * as googlecloudmonitoring from "./googlecloudmonitoring.gen";
32
+ export * as bigquery from "./bigquery.gen";
33
+ export * as grafanapyroscope from "./grafanapyroscope.gen";
28
34
  export * as expr from "./expr.gen";
29
35
  export { DASHBOARD_SCHEMA_VERSION } from "./dashboard.gen";
@@ -88,6 +88,10 @@ export interface TableFieldOptions {
88
88
  * Hides any header for a column, useful for columns that show some static content or buttons.
89
89
  */
90
90
  hideHeader?: boolean;
91
+ /**
92
+ * options for the footer for this field
93
+ */
94
+ footer?: TableFieldFooterOptions;
91
95
  }
92
96
 
93
97
  /**
@@ -355,3 +359,13 @@ export interface TableMarkdownCellOptions {
355
359
  export interface TableGeoCellOptions {
356
360
  type: TableCellDisplayMode;
357
361
  }
362
+
363
+ /**
364
+ * The footer of one field (TableFooterOptions in the CUE; renamed here because the vendored schema already has a panel-level TableFooterOptions)
365
+ */
366
+ export interface TableFieldFooterOptions {
367
+ /**
368
+ * footer reducers to apply to this field
369
+ */
370
+ reducers?: string[];
371
+ }
@@ -26,9 +26,11 @@
26
26
  * several variants) match more than one.
27
27
  */
28
28
 
29
- import Ajv, { type ValidateFunction, type ErrorObject } from "ajv";
29
+ import { createRequire } from "module";
30
+ import type AjvClass from "ajv";
31
+ import type { ValidateFunction, ErrorObject } from "ajv";
30
32
  import type { SchemaName } from "./pin";
31
- import { loadSchema } from "./spec/schemas";
33
+ import { SCHEMA_JSON } from "./spec/schemas.gen";
32
34
  import { panelDefinitionFor } from "./panels";
33
35
  import { queryDefinitionFor } from "./query";
34
36
 
@@ -40,12 +42,61 @@ export interface SchemaProblem {
40
42
  severity: "error" | "warning";
41
43
  }
42
44
 
43
- let ajv: Ajv | undefined;
44
- function getAjv(): Ajv {
45
- ajv ??= new Ajv({ strict: false, allErrors: true, validateFormats: false });
45
+ let ajv: AjvClass | undefined;
46
+ let ajvError: string | undefined;
47
+
48
+ /**
49
+ * ajv, loaded on first use.
50
+ *
51
+ * Every `chant build`, `chant lint` and `chant list` loads the plugin, and the
52
+ * plugin's post-synth barrel reaches this module, so a top-level import would
53
+ * put ajv on every run that has grafana installed, validating or not.
54
+ * `check()` is synchronous, so `await import()` is not available;
55
+ * `createRequire` is (the same as the cedar lexicon's wasm, and ajv is
56
+ * CommonJS). Where it cannot load (a bundle with no `node_modules` beside
57
+ * it), {@link schemaValidationUnavailable} says why and GRAF107 reports that
58
+ * instead of throwing.
59
+ */
60
+ function getAjv(): AjvClass | undefined {
61
+ if (ajv || ajvError) return ajv;
62
+ try {
63
+ const mod = createRequire(import.meta.url)("ajv") as { default?: typeof AjvClass } & typeof AjvClass;
64
+ const Ajv = mod.default ?? mod;
65
+ ajv = new Ajv({ strict: false, allErrors: true, validateFormats: false });
66
+ } catch (err) {
67
+ ajvError = (err instanceof Error ? err.message : String(err)).split("\n")[0];
68
+ }
46
69
  return ajv;
47
70
  }
48
71
 
72
+ /** Why schema validation cannot run here (ajv did not load), or undefined when it can. */
73
+ export function schemaValidationUnavailable(): string | undefined {
74
+ getAjv();
75
+ return ajvError === undefined ? undefined : `ajv could not be loaded: ${ajvError}`;
76
+ }
77
+
78
+ function requireAjv(): AjvClass {
79
+ const a = getAjv();
80
+ if (!a) throw new Error(`grafana schema validation: ${schemaValidationUnavailable()}`);
81
+ return a;
82
+ }
83
+
84
+ const parsed = new Map<SchemaName, Record<string, unknown>>();
85
+
86
+ /**
87
+ * One schema as validation uses it: the vendored file with its overlay
88
+ * applied, from the generated `spec/schemas.gen.ts` (no filesystem read, so
89
+ * it works bundled), parsed on first use.
90
+ */
91
+ export function bundledSchema(name: SchemaName): Record<string, unknown> {
92
+ let schema = parsed.get(name);
93
+ if (!schema) {
94
+ schema = JSON.parse(SCHEMA_JSON[name]) as Record<string, unknown>;
95
+ parsed.set(name, schema);
96
+ }
97
+ return schema;
98
+ }
99
+
49
100
  const compiled = new Map<string, ValidateFunction>();
50
101
 
51
102
  interface Mode {
@@ -74,7 +125,7 @@ function validatorFor(name: SchemaName, def: string | undefined, mode: Mode): Va
74
125
  const key = `${name}#${def ?? ""}#${mode.lenient}#${mode.open}`;
75
126
  const hit = compiled.get(key);
76
127
  if (hit) return hit;
77
- const schema = loadSchema(name);
128
+ const schema = bundledSchema(name);
78
129
  const definitions = (schema.definitions ?? {}) as Record<string, unknown>;
79
130
  const ref = def ? `#/definitions/${def}` : (schema.$ref as string | undefined);
80
131
  if (!ref) return undefined;
@@ -84,7 +135,7 @@ function validatorFor(name: SchemaName, def: string | undefined, mode: Mode): Va
84
135
  $ref: ref,
85
136
  definitions: prepare(definitions, mode),
86
137
  };
87
- const fn = getAjv().compile(root);
138
+ const fn = requireAjv().compile(root);
88
139
  compiled.set(key, fn);
89
140
  return fn;
90
141
  }
package/src/skill-defs.ts CHANGED
@@ -45,4 +45,21 @@ export const grafanaSkills = createSkillsLoader(import.meta.url, [
45
45
  },
46
46
  ],
47
47
  },
48
+ {
49
+ file: "chant-grafana-operations.md",
50
+ name: "chant-grafana-operations",
51
+ description:
52
+ "Start a Grafana project from a template, bring existing dashboards into chant with chant import, find what changed in a running Grafana with chant lifecycle diff --live, export a Grafana as TypeScript, and apply a build over the HTTP API",
53
+ triggers: [
54
+ { type: "context" as const, value: "grafana drift" },
55
+ { type: "context" as const, value: "import grafana dashboard" },
56
+ { type: "context" as const, value: "grafana apply" },
57
+ ],
58
+ examples: [
59
+ {
60
+ title: "See what was edited in a running Grafana since the last build",
61
+ output: "chant lifecycle diff staging --live",
62
+ },
63
+ ],
64
+ },
48
65
  ]);
@@ -0,0 +1,108 @@
1
+ ---
2
+ skill: chant-grafana-operations
3
+ description: Start a Grafana project from a template, bring existing dashboards into chant with chant import, find what changed in a running Grafana with chant lifecycle diff --live, export a Grafana as TypeScript, and apply a build over the HTTP API
4
+ user-invocable: true
5
+ ---
6
+
7
+ # Operating Grafana with chant
8
+
9
+ Use this skill when a Grafana already exists: dashboards made in the UI to bring under chant, a provisioned dashboard somebody edited, or a build to push without mounting files. For writing dashboards see the chant-grafana skill; for provisioning files and ConfigMaps, chant-grafana-provisioning; for alert rules, chant-grafana-alerting.
10
+
11
+ ## Start a project
12
+
13
+ ```bash
14
+ chant init --lexicon grafana my-dashboards # a Prometheus datasource and one dashboard
15
+ chant init --lexicon grafana --template red my-dashboards # RedDashboard over span metrics, ExternalDatasource, Folder
16
+ chant init --lexicon grafana --template k8s-pods my-dashboards # pod dashboard delivered as sidecar ConfigMaps (k8s + grafana)
17
+ chant init --lexicon grafana --template slo my-dashboards # Slo rules, SloDashboard and SloAlertRules (prometheus + grafana)
18
+ ```
19
+
20
+ Every template builds clean and passes the GRAF checks as written. `k8s-pods` and `slo` ship a `chant.config.ts` naming both lexicons and a `build` script without `--lexicon`, so both outputs and both lexicons' checks run.
21
+
22
+ ## Import dashboards you already have
23
+
24
+ Export the dashboard in Grafana (Export > Export as JSON, classic or V2 resource), then:
25
+
26
+ ```bash
27
+ chant import checkout.json --output src # inside a project that lists grafana
28
+ chant import checkout.json --lexicon grafana --output src # anywhere else
29
+ chant build src --lexicon grafana -o dist/grafana/index.json
30
+ ```
31
+
32
+ The importer also reads `GET /api/dashboards/uid/<uid>` responses, `dashboard.grafana.app` v1 and v2 resources, and datasource, dashboard and alerting provisioning files. Each dashboard lands in `src/<uid>/`: `dashboard.ts`, `panels.ts`, one `row-<title>.ts` per row, `variables.ts`, and `datasources.ts` with an `ExternalDatasource` per datasource named by uid. Replace an `ExternalDatasource` with a `Datasource` of the same uid to provision it from chant too.
33
+
34
+ Read every import warning. Anything the lexicon can't express is reported, never dropped. Common ones: a v2 dashboard's tabs become rows, an export made for sharing turns `${DS_*}` inputs into `DatasourceVariable`s, and two imported dashboards naming one datasource both declare it (GRAF104; delete one declaration and import it from the other file).
35
+
36
+ A dashboard inside a Kubernetes ConfigMap imports with the k8s lexicon: `chant import grafana-configmaps.yaml` gives a grafana `Dashboard` as the ConfigMap's value.
37
+
38
+ ## Point environments at a Grafana
39
+
40
+ Observe, export and apply read `grafana.profiles.<env>` in `chant.config.ts`. Credentials are named by environment variable, never written in the file:
41
+
42
+ ```ts
43
+ import type { ChantConfig } from "@intentius/chant/config";
44
+ import "@intentius/chant-lexicon-grafana";
45
+
46
+ export default {
47
+ lexicons: ["grafana"],
48
+ ownership: { stack: "shop", env: "prod" },
49
+ grafana: {
50
+ profiles: {
51
+ staging: { url: "https://grafana.staging.example.com", token: { env: "GRAFANA_STAGING_TOKEN" } },
52
+ prod: { url: "https://grafana.example.com", token: { env: "GRAFANA_PROD_TOKEN" }, orgId: 2 },
53
+ },
54
+ },
55
+ } satisfies ChantConfig;
56
+ ```
57
+
58
+ With no profile, `GRAFANA_URL` plus `GRAFANA_TOKEN` (or `GRAFANA_USER` and `GRAFANA_PASSWORD`) is used. Grafana Cloud also needs `namespace: "stacks-<id>"`. A Viewer service account can observe and export. Applying needs Editor, or a custom role with `grafanaActionsFor("Apply", "Prune")`.
59
+
60
+ ## Find what changed in Grafana
61
+
62
+ ```bash
63
+ chant lifecycle diff staging --live
64
+ chant lifecycle diff staging --live --json # the same report as data
65
+ chant lifecycle diff staging --live --update-baseline # accept what it reported
66
+ ```
67
+
68
+ Paths are in your source's terms: `panels[0].panels[1].title` is the second panel of the first row. A value you declared that differs is drift. A value you never declared, such as a panel added in the UI, is listed as unclaimed and never proposed as a change. What the build fills in (panel ids, auto grid positions, refIds) and what Grafana adds on read are not reported. A dashboard Grafana 13 stores as v2 is read at v2 and diffed after conversion, so a tab added in the UI shows as drift in the rows.
69
+
70
+ Ownership decides what counts as chant's. A dashboard loaded by one of the project's providers (named `chant` unless you declared another `DashboardProvider`), or carrying the `app.kubernetes.io/managed-by: chant` label the applier writes, is `owned`. Anything else is `foreign`. Datasources and dashboards on Grafana 11 are `unknown`, and `--owned` leaves them out.
71
+
72
+ A `DashboardProvider` can't be observed (Grafana serves no API for provisioning files) and is reported as not observed, not missing.
73
+
74
+ ## Export a Grafana as TypeScript
75
+
76
+ ```bash
77
+ chant import --from staging --lexicon grafana --output src
78
+ chant import --from staging --lexicon grafana --type Grafana::Dashboard --name checkout --output src
79
+ chant import --from staging --lexicon grafana --owned --output src
80
+ ```
81
+
82
+ It writes every dashboard and datasource in the organisation, laid out like a file import. Datasource secrets come back as `"[REDACTED]"`, each with a warning. Replace them with `$__env{NAME}` or `$__file{path}`, which GRAF002 requires.
83
+
84
+ ## Apply over the HTTP API
85
+
86
+ When the build's files can't be mounted into Grafana, or you want real folders with pinned uids, apply from an Op:
87
+
88
+ ```ts
89
+ // ops/grafana.op.ts, with "build:grafana": "chant build src --lexicon grafana -o dist/grafana.json" in package.json
90
+ import { Op, phase, build } from "@intentius/chant/op";
91
+ import { grafanaApply } from "@intentius/chant-lexicon-grafana";
92
+
93
+ export default Op({
94
+ name: "grafana-prod",
95
+ phases: [
96
+ phase("Build", [build(".", { script: "build:grafana" })]),
97
+ phase("Apply", [grafanaApply("dist/grafana.json", { environment: "prod", prune: true })]),
98
+ ],
99
+ });
100
+ ```
101
+
102
+ Run it with `chant run grafana-prod`, or from an agent through the MCP `op-run`, `op-status` and `op-signal` tools. The applier creates folders parents first with their uids, writes library panels found in `__elements`, and sends each dashboard with the project's labels. A dashboard whose live content already matches is `unchanged` and not written; a panel title edited in the UI is put back. `prune` deletes only dashboards and folders labelled with this project's stack and env. It never touches UI-saved or file-provisioned dashboards, library panels, or anything on Grafana 11, and does nothing when no `ownership.stack` is set. Datasources still come from the provisioning file.
103
+
104
+ ## A loop that keeps UI edits
105
+
106
+ 1. `chant lifecycle diff prod --live` shows the edit.
107
+ 2. Either change the source to match and rebuild, or `chant import --from prod --name <uid>` to pull the dashboard, then copy the changed panel over.
108
+ 3. Apply, or let provisioning reload, and diff again. It should report nothing.