@intentius/chant-lexicon-k8s 0.97.0 → 0.99.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/dist/import/embedded.d.ts +27 -0
- package/dist/import/embedded.d.ts.map +1 -0
- package/dist/import/generator.d.ts +2 -0
- package/dist/import/generator.d.ts.map +1 -1
- package/dist/import/parser.d.ts +9 -3
- package/dist/import/parser.d.ts.map +1 -1
- package/dist/import/testdata/embedded/fixtures.d.ts +21 -0
- package/dist/import/testdata/embedded/fixtures.d.ts.map +1 -0
- package/dist/integrity.json +2 -2
- package/dist/manifest.json +1 -1
- package/package.json +3 -3
- package/src/import/embedded-roundtrip.test.ts +231 -0
- package/src/import/embedded-types.e2e.test.ts +43 -0
- package/src/import/embedded.test.ts +125 -0
- package/src/import/embedded.ts +104 -0
- package/src/import/generator.ts +36 -7
- package/src/import/parser.test.ts +18 -0
- package/src/import/parser.ts +19 -11
- package/src/import/testdata/embedded/README.md +11 -0
- package/src/import/testdata/embedded/agent-observability.yaml +2905 -0
- package/src/import/testdata/embedded/fixtures.ts +53 -0
- package/src/import/testdata/embedded/grafana-dashboard-configmap.yaml +364 -0
- package/src/import/testdata/embedded/node-exporter-prometheusrule.yaml +425 -0
- package/src/import/testdata/embedded/otel-collector-daemonset.yaml +225 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared by the embedded-content round trip (embedded-roundtrip.test.ts) and
|
|
3
|
+
* the type check of what it generates (embedded-types.e2e.test.ts): run
|
|
4
|
+
* `chant import` over a manifest file the way a user does, through
|
|
5
|
+
* `importCommand`, in a project inside this package so the lexicons resolve
|
|
6
|
+
* as they would for them.
|
|
7
|
+
*/
|
|
8
|
+
import { mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "fs";
|
|
9
|
+
import { join, relative, resolve } from "path";
|
|
10
|
+
import { importCommand, type ImportResult } from "@intentius/chant/cli/commands/import";
|
|
11
|
+
|
|
12
|
+
export const pkgDir = resolve(import.meta.dirname, "../../../..");
|
|
13
|
+
export const repoRoot = resolve(pkgDir, "../..");
|
|
14
|
+
export const read = (name: string) => readFileSync(join(import.meta.dirname, name), "utf-8");
|
|
15
|
+
|
|
16
|
+
export interface Imported {
|
|
17
|
+
result: ImportResult;
|
|
18
|
+
/** The project directory; the generated source is in `src/`. The caller removes it. */
|
|
19
|
+
dir: string;
|
|
20
|
+
srcDir: string;
|
|
21
|
+
/** Every generated file by its path under `src/`. */
|
|
22
|
+
files: Record<string, string>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function walk(dir: string, root: string, out: Record<string, string>): void {
|
|
26
|
+
for (const entry of readdirSync(dir)) {
|
|
27
|
+
const path = join(dir, entry);
|
|
28
|
+
if (statSync(path).isDirectory()) walk(path, root, out);
|
|
29
|
+
else out[relative(root, path)] = readFileSync(path, "utf-8");
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* `chant import manifest.yaml --lexicon k8s` into a fresh project, or with
|
|
35
|
+
* `detect`, `chant import manifest.yaml` with the lexicon detected.
|
|
36
|
+
*/
|
|
37
|
+
export async function importManifest(yaml: string, options: { detect?: boolean } = {}): Promise<Imported> {
|
|
38
|
+
const dir = mkdtempSync(join(pkgDir, ".roundtrip-tmp-"));
|
|
39
|
+
writeFileSync(join(dir, "package.json"), '{ "name": "k8s-embedded-roundtrip", "private": true, "type": "module" }\n');
|
|
40
|
+
writeFileSync(join(dir, "chant.config.ts"), 'export default { lexicons: ["k8s"] };\n');
|
|
41
|
+
const srcDir = join(dir, "src");
|
|
42
|
+
mkdirSync(srcDir);
|
|
43
|
+
const templatePath = join(dir, "manifest.yaml");
|
|
44
|
+
writeFileSync(templatePath, yaml);
|
|
45
|
+
const result = await importCommand({ templatePath, output: srcDir, ...(options.detect ? {} : { lexicon: "k8s" }) });
|
|
46
|
+
const files: Record<string, string> = {};
|
|
47
|
+
walk(srcDir, srcDir, files);
|
|
48
|
+
return { result, dir, srcDir, files };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function removeDir(dir: string): void {
|
|
52
|
+
rmSync(dir, { recursive: true, force: true });
|
|
53
|
+
}
|
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
apiVersion: v1
|
|
2
|
+
data:
|
|
3
|
+
alertmanager-overview.json: |-
|
|
4
|
+
{
|
|
5
|
+
"graphTooltip": 1,
|
|
6
|
+
"panels": [
|
|
7
|
+
{
|
|
8
|
+
"collapsed": false,
|
|
9
|
+
"gridPos": {
|
|
10
|
+
"h": 1,
|
|
11
|
+
"w": 24,
|
|
12
|
+
"x": 0,
|
|
13
|
+
"y": 0
|
|
14
|
+
},
|
|
15
|
+
"id": 1,
|
|
16
|
+
"panels": [
|
|
17
|
+
|
|
18
|
+
],
|
|
19
|
+
"title": "Alerts",
|
|
20
|
+
"type": "row"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"datasource": {
|
|
24
|
+
"type": "prometheus",
|
|
25
|
+
"uid": "$datasource"
|
|
26
|
+
},
|
|
27
|
+
"description": "current set of alerts stored in the Alertmanager",
|
|
28
|
+
"fieldConfig": {
|
|
29
|
+
"defaults": {
|
|
30
|
+
"custom": {
|
|
31
|
+
"fillOpacity": 10,
|
|
32
|
+
"showPoints": "never",
|
|
33
|
+
"stacking": {
|
|
34
|
+
"mode": "normal"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"unit": "none"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"gridPos": {
|
|
41
|
+
"h": 7,
|
|
42
|
+
"w": 12,
|
|
43
|
+
"x": 0,
|
|
44
|
+
"y": 1
|
|
45
|
+
},
|
|
46
|
+
"id": 2,
|
|
47
|
+
"options": {
|
|
48
|
+
"legend": {
|
|
49
|
+
"showLegend": false
|
|
50
|
+
},
|
|
51
|
+
"tooltip": {
|
|
52
|
+
"mode": "multi"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"pluginVersion": "v13.0.0",
|
|
56
|
+
"targets": [
|
|
57
|
+
{
|
|
58
|
+
"datasource": {
|
|
59
|
+
"type": "prometheus",
|
|
60
|
+
"uid": "$datasource"
|
|
61
|
+
},
|
|
62
|
+
"expr": "sum(alertmanager_alerts{namespace=~\"$namespace\",service=~\"$service\"}) by (namespace,service,instance)",
|
|
63
|
+
"intervalFactor": 2,
|
|
64
|
+
"legendFormat": "{{instance}}"
|
|
65
|
+
}
|
|
66
|
+
],
|
|
67
|
+
"title": "Alerts",
|
|
68
|
+
"type": "timeseries"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"datasource": {
|
|
72
|
+
"type": "prometheus",
|
|
73
|
+
"uid": "$datasource"
|
|
74
|
+
},
|
|
75
|
+
"description": "rate of successful and invalid alerts received by the Alertmanager",
|
|
76
|
+
"fieldConfig": {
|
|
77
|
+
"defaults": {
|
|
78
|
+
"custom": {
|
|
79
|
+
"fillOpacity": 10,
|
|
80
|
+
"showPoints": "never",
|
|
81
|
+
"stacking": {
|
|
82
|
+
"mode": "normal"
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"unit": "ops"
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
"gridPos": {
|
|
89
|
+
"h": 7,
|
|
90
|
+
"w": 12,
|
|
91
|
+
"x": 12,
|
|
92
|
+
"y": 1
|
|
93
|
+
},
|
|
94
|
+
"id": 3,
|
|
95
|
+
"options": {
|
|
96
|
+
"legend": {
|
|
97
|
+
"showLegend": false
|
|
98
|
+
},
|
|
99
|
+
"tooltip": {
|
|
100
|
+
"mode": "multi"
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
"pluginVersion": "v13.0.0",
|
|
104
|
+
"targets": [
|
|
105
|
+
{
|
|
106
|
+
"datasource": {
|
|
107
|
+
"type": "prometheus",
|
|
108
|
+
"uid": "$datasource"
|
|
109
|
+
},
|
|
110
|
+
"expr": "sum(rate(alertmanager_alerts_received_total{namespace=~\"$namespace\",service=~\"$service\"}[$__rate_interval])) by (namespace,service,instance)",
|
|
111
|
+
"intervalFactor": 2,
|
|
112
|
+
"legendFormat": "{{instance}} Received"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"datasource": {
|
|
116
|
+
"type": "prometheus",
|
|
117
|
+
"uid": "$datasource"
|
|
118
|
+
},
|
|
119
|
+
"expr": "sum(rate(alertmanager_alerts_invalid_total{namespace=~\"$namespace\",service=~\"$service\"}[$__rate_interval])) by (namespace,service,instance)",
|
|
120
|
+
"intervalFactor": 2,
|
|
121
|
+
"legendFormat": "{{instance}} Invalid"
|
|
122
|
+
}
|
|
123
|
+
],
|
|
124
|
+
"title": "Alerts receive rate",
|
|
125
|
+
"type": "timeseries"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"collapsed": false,
|
|
129
|
+
"gridPos": {
|
|
130
|
+
"h": 1,
|
|
131
|
+
"w": 24,
|
|
132
|
+
"x": 0,
|
|
133
|
+
"y": 8
|
|
134
|
+
},
|
|
135
|
+
"id": 4,
|
|
136
|
+
"panels": [
|
|
137
|
+
|
|
138
|
+
],
|
|
139
|
+
"title": "Notifications",
|
|
140
|
+
"type": "row"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"datasource": {
|
|
144
|
+
"type": "prometheus",
|
|
145
|
+
"uid": "$datasource"
|
|
146
|
+
},
|
|
147
|
+
"description": "rate of successful and invalid notifications sent by the Alertmanager",
|
|
148
|
+
"fieldConfig": {
|
|
149
|
+
"defaults": {
|
|
150
|
+
"custom": {
|
|
151
|
+
"fillOpacity": 10,
|
|
152
|
+
"showPoints": "never",
|
|
153
|
+
"stacking": {
|
|
154
|
+
"mode": "normal"
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
"unit": "ops"
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
"gridPos": {
|
|
161
|
+
"h": 7,
|
|
162
|
+
"w": 12,
|
|
163
|
+
"x": 0,
|
|
164
|
+
"y": 9
|
|
165
|
+
},
|
|
166
|
+
"id": 5,
|
|
167
|
+
"options": {
|
|
168
|
+
"legend": {
|
|
169
|
+
"showLegend": false
|
|
170
|
+
},
|
|
171
|
+
"tooltip": {
|
|
172
|
+
"mode": "multi"
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
"pluginVersion": "v13.0.0",
|
|
176
|
+
"repeat": "integration",
|
|
177
|
+
"targets": [
|
|
178
|
+
{
|
|
179
|
+
"datasource": {
|
|
180
|
+
"type": "prometheus",
|
|
181
|
+
"uid": "$datasource"
|
|
182
|
+
},
|
|
183
|
+
"expr": "sum(rate(alertmanager_notifications_total{namespace=~\"$namespace\",service=~\"$service\", integration=\"$integration\"}[$__rate_interval])) by (integration,namespace,service,instance)",
|
|
184
|
+
"intervalFactor": 2,
|
|
185
|
+
"legendFormat": "{{instance}} Total"
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
"datasource": {
|
|
189
|
+
"type": "prometheus",
|
|
190
|
+
"uid": "$datasource"
|
|
191
|
+
},
|
|
192
|
+
"expr": "sum(rate(alertmanager_notifications_failed_total{namespace=~\"$namespace\",service=~\"$service\", integration=\"$integration\"}[$__rate_interval])) by (integration,namespace,service,instance)",
|
|
193
|
+
"intervalFactor": 2,
|
|
194
|
+
"legendFormat": "{{instance}} Failed"
|
|
195
|
+
}
|
|
196
|
+
],
|
|
197
|
+
"title": "$integration: Notifications Send Rate",
|
|
198
|
+
"type": "timeseries"
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
"datasource": {
|
|
202
|
+
"type": "prometheus",
|
|
203
|
+
"uid": "$datasource"
|
|
204
|
+
},
|
|
205
|
+
"description": "latency of notifications sent by the Alertmanager",
|
|
206
|
+
"fieldConfig": {
|
|
207
|
+
"defaults": {
|
|
208
|
+
"custom": {
|
|
209
|
+
"fillOpacity": 10,
|
|
210
|
+
"showPoints": "never",
|
|
211
|
+
"stacking": {
|
|
212
|
+
"mode": "normal"
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
"unit": "s"
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
"gridPos": {
|
|
219
|
+
"h": 7,
|
|
220
|
+
"w": 12,
|
|
221
|
+
"x": 12,
|
|
222
|
+
"y": 9
|
|
223
|
+
},
|
|
224
|
+
"id": 6,
|
|
225
|
+
"options": {
|
|
226
|
+
"legend": {
|
|
227
|
+
"showLegend": false
|
|
228
|
+
},
|
|
229
|
+
"tooltip": {
|
|
230
|
+
"mode": "multi"
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
"pluginVersion": "v13.0.0",
|
|
234
|
+
"repeat": "integration",
|
|
235
|
+
"targets": [
|
|
236
|
+
{
|
|
237
|
+
"datasource": {
|
|
238
|
+
"type": "prometheus",
|
|
239
|
+
"uid": "$datasource"
|
|
240
|
+
},
|
|
241
|
+
"expr": "histogram_quantile(0.99,\n sum(rate(alertmanager_notification_latency_seconds_bucket{namespace=~\"$namespace\",service=~\"$service\", integration=\"$integration\"}[$__rate_interval])) by (le,namespace,service,instance)\n)\n",
|
|
242
|
+
"intervalFactor": 2,
|
|
243
|
+
"legendFormat": "{{instance}} 99th Percentile"
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
"datasource": {
|
|
247
|
+
"type": "prometheus",
|
|
248
|
+
"uid": "$datasource"
|
|
249
|
+
},
|
|
250
|
+
"expr": "histogram_quantile(0.50,\n sum(rate(alertmanager_notification_latency_seconds_bucket{namespace=~\"$namespace\",service=~\"$service\", integration=\"$integration\"}[$__rate_interval])) by (le,namespace,service,instance)\n)\n",
|
|
251
|
+
"intervalFactor": 2,
|
|
252
|
+
"legendFormat": "{{instance}} Median"
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
"datasource": {
|
|
256
|
+
"type": "prometheus",
|
|
257
|
+
"uid": "$datasource"
|
|
258
|
+
},
|
|
259
|
+
"expr": "sum(rate(alertmanager_notification_latency_seconds_sum{namespace=~\"$namespace\",service=~\"$service\", integration=\"$integration\"}[$__rate_interval])) by (namespace,service,instance)\n/\nsum(rate(alertmanager_notification_latency_seconds_count{namespace=~\"$namespace\",service=~\"$service\", integration=\"$integration\"}[$__rate_interval])) by (namespace,service,instance)\n",
|
|
260
|
+
"intervalFactor": 2,
|
|
261
|
+
"legendFormat": "{{instance}} Average"
|
|
262
|
+
}
|
|
263
|
+
],
|
|
264
|
+
"title": "$integration: Notification Duration",
|
|
265
|
+
"type": "timeseries"
|
|
266
|
+
}
|
|
267
|
+
],
|
|
268
|
+
"schemaVersion": 39,
|
|
269
|
+
"tags": [
|
|
270
|
+
"alertmanager-mixin"
|
|
271
|
+
],
|
|
272
|
+
"templating": {
|
|
273
|
+
"list": [
|
|
274
|
+
{
|
|
275
|
+
"current": {
|
|
276
|
+
"selected": false,
|
|
277
|
+
"text": "Prometheus",
|
|
278
|
+
"value": "Prometheus"
|
|
279
|
+
},
|
|
280
|
+
"hide": 0,
|
|
281
|
+
"label": "Data Source",
|
|
282
|
+
"name": "datasource",
|
|
283
|
+
"query": "prometheus",
|
|
284
|
+
"type": "datasource"
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
"current": {
|
|
288
|
+
"selected": false,
|
|
289
|
+
"text": "",
|
|
290
|
+
"value": ""
|
|
291
|
+
},
|
|
292
|
+
"datasource": {
|
|
293
|
+
"type": "prometheus",
|
|
294
|
+
"uid": "${datasource}"
|
|
295
|
+
},
|
|
296
|
+
"includeAll": false,
|
|
297
|
+
"label": "namespace",
|
|
298
|
+
"name": "namespace",
|
|
299
|
+
"query": "label_values(alertmanager_alerts, namespace)",
|
|
300
|
+
"refresh": 2,
|
|
301
|
+
"sort": 1,
|
|
302
|
+
"type": "query"
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
"current": {
|
|
306
|
+
"selected": false,
|
|
307
|
+
"text": "",
|
|
308
|
+
"value": ""
|
|
309
|
+
},
|
|
310
|
+
"datasource": {
|
|
311
|
+
"type": "prometheus",
|
|
312
|
+
"uid": "${datasource}"
|
|
313
|
+
},
|
|
314
|
+
"includeAll": false,
|
|
315
|
+
"label": "service",
|
|
316
|
+
"name": "service",
|
|
317
|
+
"query": "label_values(alertmanager_alerts, service)",
|
|
318
|
+
"refresh": 2,
|
|
319
|
+
"sort": 1,
|
|
320
|
+
"type": "query"
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
"current": {
|
|
324
|
+
"selected": false,
|
|
325
|
+
"text": "$__all",
|
|
326
|
+
"value": "$__all"
|
|
327
|
+
},
|
|
328
|
+
"datasource": {
|
|
329
|
+
"type": "prometheus",
|
|
330
|
+
"uid": "${datasource}"
|
|
331
|
+
},
|
|
332
|
+
"hide": 2,
|
|
333
|
+
"includeAll": true,
|
|
334
|
+
"name": "integration",
|
|
335
|
+
"query": "label_values(alertmanager_notifications_total{integration=~\".*\"}, integration)",
|
|
336
|
+
"refresh": 2,
|
|
337
|
+
"sort": 1,
|
|
338
|
+
"type": "query"
|
|
339
|
+
}
|
|
340
|
+
]
|
|
341
|
+
},
|
|
342
|
+
"time": {
|
|
343
|
+
"from": "now-1h",
|
|
344
|
+
"to": "now"
|
|
345
|
+
},
|
|
346
|
+
"timepicker": {
|
|
347
|
+
"refresh_intervals": [
|
|
348
|
+
"30s"
|
|
349
|
+
]
|
|
350
|
+
},
|
|
351
|
+
"timezone": "utc",
|
|
352
|
+
"title": "Alertmanager / Overview",
|
|
353
|
+
"uid": "alertmanager-overview"
|
|
354
|
+
}
|
|
355
|
+
kind: ConfigMap
|
|
356
|
+
metadata:
|
|
357
|
+
labels:
|
|
358
|
+
grafana_dashboard: '1'
|
|
359
|
+
app.kubernetes.io/component: grafana
|
|
360
|
+
app.kubernetes.io/name: grafana
|
|
361
|
+
app.kubernetes.io/part-of: kube-prometheus
|
|
362
|
+
app.kubernetes.io/version: 13.2.2
|
|
363
|
+
name: grafana-dashboard-alertmanager-overview
|
|
364
|
+
namespace: monitoring
|