@intentius/chant-lexicon-prometheus 0.100.0 → 0.101.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 +4 -1
- package/dist/codegen/docs.d.ts.map +1 -1
- package/dist/composites/catalog.d.ts.map +1 -1
- package/dist/composites/genai.d.ts +224 -0
- package/dist/composites/genai.d.ts.map +1 -0
- package/dist/composites/index.d.ts +2 -0
- package/dist/composites/index.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/init-templates.d.ts +11 -2
- package/dist/init-templates.d.ts.map +1 -1
- package/dist/integrity.json +3 -3
- package/dist/manifest.json +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/rule-eval.d.ts +10 -4
- package/dist/rule-eval.d.ts.map +1 -1
- package/dist/skills/chant-prometheus.md +22 -0
- package/package.json +3 -2
- package/src/codegen/docs.ts +5 -0
- package/src/composites/catalog.test.ts +1 -1
- package/src/composites/catalog.ts +70 -0
- package/src/composites/genai.test.ts +307 -0
- package/src/composites/genai.ts +678 -0
- package/src/composites/index.ts +15 -0
- package/src/composites/slo-burn.test.ts +25 -1
- package/src/index.ts +14 -0
- package/src/init-templates.test.ts +37 -11
- package/src/init-templates.ts +75 -6
- package/src/plugin.ts +6 -2
- package/src/rule-eval.ts +72 -7
- package/src/skills/chant-prometheus.md +22 -0
- package/src/typecheck.test.ts +88 -0
package/README.md
CHANGED
|
@@ -27,6 +27,7 @@ export { api, oncall, fallback, root };
|
|
|
27
27
|
|---|---|
|
|
28
28
|
| `RuleGroup` | rule file |
|
|
29
29
|
| `Slo` (composite) | rule file: SLI recording rules, error budget and multiwindow burn-rate alerts |
|
|
30
|
+
| `GenAiRules` (composite) | rule file: request, error, latency, token and cost rules and opt-in alerts for the otel GenAI preset |
|
|
30
31
|
| `Route`, `Receiver` (every Alertmanager integration), `InhibitRule`, `TimeInterval`, `AlertmanagerSettings` | `alertmanager.yml` |
|
|
31
32
|
|
|
32
33
|
Types follow Prometheus `v3.15.0` and Alertmanager `v0.34.1` (`PROMETHEUS_PIN`).
|
|
@@ -47,6 +48,7 @@ PromQL is parsed with `@prometheus-io/lezer-promql`, the Prometheus project's ow
|
|
|
47
48
|
- `validateRuleFile`, `validateAlertmanagerConfig`, `validateSeverityRouting` run the checks without a build.
|
|
48
49
|
- `checkPromql`, `parseMatchers`, `isValidDuration` are the pieces underneath.
|
|
49
50
|
- `sloMetrics(slo)` names the series an `Slo` records and its burn-rate thresholds, for dashboards.
|
|
51
|
+
- `genAiRuleMetrics(rules)` names the series a `GenAiRules` records and the alerts it builds.
|
|
50
52
|
|
|
51
53
|
## Project structure
|
|
52
54
|
|
|
@@ -54,10 +56,11 @@ PromQL is parsed with `@prometheus-io/lezer-promql`, the Prometheus project's ow
|
|
|
54
56
|
- `src/rules.ts`: `RuleGroup`
|
|
55
57
|
- `src/alertmanager.ts`: the Alertmanager entities
|
|
56
58
|
- `src/composites/slo.ts`: `Slo` and `sloMetrics`
|
|
59
|
+
- `src/composites/genai.ts`: `GenAiRules` and `genAiRuleMetrics`
|
|
57
60
|
- `src/build.ts`: entities to config to YAML
|
|
58
61
|
- `src/promql.ts`, `src/matchers.ts`, `src/duration.ts`: parsing
|
|
59
62
|
- `src/validate-config.ts`, `src/lint/`: checks
|
|
60
63
|
- `src/tools.ts`: promtool and amtool
|
|
61
64
|
- `src/import/`: `chant import` for rule files and `alertmanager.yml` (parser, generator, `Slo` recognition, round-trip tests and fixtures)
|
|
62
|
-
- `src/rule-eval.ts`: a small rule evaluator the SLO tests run over synthetic series
|
|
65
|
+
- `src/rule-eval.ts`: a small rule evaluator the SLO and GenAI tests run over synthetic series
|
|
63
66
|
- `examples/`: getting-started, alerting, rules-from-data, slo, k3d-stack
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../src/codegen/docs.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../src/codegen/docs.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAqFH,wBAAsB,YAAY,CAAC,IAAI,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAuB9E"}
|
|
@@ -1 +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,
|
|
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,EAiI5C,CAAC"}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `GenAiRules`: recording rules and opt-in alerts for the otel lexicon's
|
|
3
|
+
* GenAI collector preset, and spend from a price table the project declares.
|
|
4
|
+
*
|
|
5
|
+
* Every metric and label name comes from the `GenAiMetrics` the collector was
|
|
6
|
+
* built with (`genAiMetrics(options)` or `genAiComponents(options).metrics`)
|
|
7
|
+
* and from the otel lexicon's attribute keys, so a collector with another
|
|
8
|
+
* namespace, or with the conventions' client metrics switched on, moves every
|
|
9
|
+
* expression here with it.
|
|
10
|
+
*
|
|
11
|
+
* Two sources describe model calls:
|
|
12
|
+
*
|
|
13
|
+
* - `client`: the conventions' `gen_ai.client.operation.duration` and
|
|
14
|
+
* `gen_ai.client.token.usage` (#3041). Requests are the duration
|
|
15
|
+
* histogram's `_count`, errors the ones with an `error.type`, tokens the
|
|
16
|
+
* token histogram's `_sum` split by `gen_ai.token.type`.
|
|
17
|
+
* - `spans`: the preset's own `genai.calls`, `genai.duration` and token sums.
|
|
18
|
+
* Errors are spans with `status.code` `STATUS_CODE_ERROR`. The token sums
|
|
19
|
+
* carry the model only, so cost series take the provider from the price
|
|
20
|
+
* table.
|
|
21
|
+
*
|
|
22
|
+
* The default is `client` when the metrics have it. Per-tool rules always
|
|
23
|
+
* read the span metrics: the conventions' client metrics carry no tool name.
|
|
24
|
+
*
|
|
25
|
+
* Everything is in one group, recording rules first, because Prometheus
|
|
26
|
+
* evaluates a group's rules in order and the later rules and the alerts read
|
|
27
|
+
* the series the earlier ones record in the same evaluation.
|
|
28
|
+
*
|
|
29
|
+
* Cost is a rate in the price's currency per second, one series per priced
|
|
30
|
+
* model and token type, labelled with the currency. A model the table does
|
|
31
|
+
* not price gets no cost series, never a cost of zero. The lexicon ships no
|
|
32
|
+
* prices. `currency` and `source` are required on every price, the same two
|
|
33
|
+
* fields a workspace run's cost record carries (#3033), so the two can be
|
|
34
|
+
* compared; chant converts no currency.
|
|
35
|
+
*/
|
|
36
|
+
import { type CompositeInstance } from "@intentius/chant/composite";
|
|
37
|
+
import { type GenAiMetrics } from "@intentius/chant-lexicon-otel/genai";
|
|
38
|
+
import { type RuleGroupEntity } from "../rules.js";
|
|
39
|
+
import type { LabelSet } from "../model.js";
|
|
40
|
+
/** One model's price, as the provider publishes it, per million tokens. */
|
|
41
|
+
export interface GenAiPrice {
|
|
42
|
+
/** The `gen_ai.provider.name` value, e.g. `anthropic` or `openai`. */
|
|
43
|
+
provider: string;
|
|
44
|
+
/** The `gen_ai.request.model` value the price applies to, exactly as spans report it. */
|
|
45
|
+
model: string;
|
|
46
|
+
/** Price of one million input tokens. */
|
|
47
|
+
inputPerMTok: number;
|
|
48
|
+
/** Price of one million output tokens. */
|
|
49
|
+
outputPerMTok: number;
|
|
50
|
+
/** The currency the prices are in, e.g. `USD`. Required: chant converts nothing. */
|
|
51
|
+
currency: string;
|
|
52
|
+
/** Where the prices come from, e.g. the provider's pricing page URL. Required. */
|
|
53
|
+
source: string;
|
|
54
|
+
/** The date the prices were read, `YYYY-MM-DD`. */
|
|
55
|
+
asOf?: string;
|
|
56
|
+
}
|
|
57
|
+
/** The fields every alert takes. */
|
|
58
|
+
export interface GenAiAlertOptions {
|
|
59
|
+
/** How long the condition must hold (default `10m`). */
|
|
60
|
+
for?: string;
|
|
61
|
+
/** The `severity` label, which Alertmanager routes on (default `warning`). */
|
|
62
|
+
severity?: string;
|
|
63
|
+
/** More labels on the alert. */
|
|
64
|
+
labels?: LabelSet;
|
|
65
|
+
/** More annotations on the alert, e.g. `runbook_url`. */
|
|
66
|
+
annotations?: LabelSet;
|
|
67
|
+
}
|
|
68
|
+
export interface GenAiRatioAlert extends GenAiAlertOptions {
|
|
69
|
+
/** The error ratio the alert fires above, between 0 and 1. */
|
|
70
|
+
threshold?: number;
|
|
71
|
+
}
|
|
72
|
+
export interface GenAiLatencyAlert extends GenAiAlertOptions {
|
|
73
|
+
/** The p95 operation latency, in seconds, the alert fires above (default 30). */
|
|
74
|
+
thresholdSeconds?: number;
|
|
75
|
+
}
|
|
76
|
+
/** A spending limit over the last hour or day, in one currency. */
|
|
77
|
+
export interface GenAiBudget extends GenAiAlertOptions {
|
|
78
|
+
/** The most the window may cost, e.g. `50`. */
|
|
79
|
+
amount: number;
|
|
80
|
+
/** The currency of `amount`; it must be the currency of at least one price. */
|
|
81
|
+
currency: string;
|
|
82
|
+
/** `hour` (spend over the last hour) or `day` (the last 24 hours). */
|
|
83
|
+
per: "hour" | "day";
|
|
84
|
+
}
|
|
85
|
+
/** Opt-in alerts. None is built unless it is set here. */
|
|
86
|
+
export interface GenAiAlerting {
|
|
87
|
+
/** Error ratio per provider, model and operation (default threshold 0.05). */
|
|
88
|
+
errorRatio?: true | GenAiRatioAlert;
|
|
89
|
+
/** p95 operation latency per provider, model and operation (default 30s). */
|
|
90
|
+
latency?: true | GenAiLatencyAlert;
|
|
91
|
+
/** Error ratio per tool, from the span metrics (default threshold 0.1). */
|
|
92
|
+
toolErrorRatio?: true | GenAiRatioAlert;
|
|
93
|
+
/** Spend over a budget per hour or per day, from the cost rules. Needs `prices`. */
|
|
94
|
+
budgets?: GenAiBudget[];
|
|
95
|
+
}
|
|
96
|
+
export interface GenAiRulesProps {
|
|
97
|
+
/** The preset's metrics: `genAiMetrics(options)` with the options the collector was built with, or `genAiComponents(options)`. */
|
|
98
|
+
genAi: GenAiMetrics | {
|
|
99
|
+
metrics: GenAiMetrics;
|
|
100
|
+
};
|
|
101
|
+
/** Which metrics the model rules read (default `client` when the metrics include the conventions' client metrics, else `spans`). */
|
|
102
|
+
source?: "client" | "spans";
|
|
103
|
+
/** Prices per provider and model. A model missing here gets no cost series. */
|
|
104
|
+
prices?: GenAiPrice[];
|
|
105
|
+
/** Opt-in alerts (default: none). */
|
|
106
|
+
alerts?: GenAiAlerting;
|
|
107
|
+
/** The rule group's name (default `genai`). */
|
|
108
|
+
name?: string;
|
|
109
|
+
/** The first part of every recorded series name (default `gen_ai`). */
|
|
110
|
+
prefix?: string;
|
|
111
|
+
/** The range every `rate` reads (default `5m`). */
|
|
112
|
+
rateWindow?: string;
|
|
113
|
+
/** More Prometheus labels every rule keeps, e.g. `job` or `service_name`. */
|
|
114
|
+
groupBy?: string[];
|
|
115
|
+
/** Labels added to every rule, e.g. `team`. */
|
|
116
|
+
labels?: LabelSet;
|
|
117
|
+
/** Evaluation interval of the group (default: Prometheus's `evaluation_interval`). */
|
|
118
|
+
interval?: string;
|
|
119
|
+
}
|
|
120
|
+
export type GenAiRulesMembers = {
|
|
121
|
+
/** The recording rules, then the alerts. */
|
|
122
|
+
rules: RuleGroupEntity;
|
|
123
|
+
};
|
|
124
|
+
/** What `GenAiRules(...)` returns: its rule group, as `rules`. */
|
|
125
|
+
export type GenAiRulesInstance = CompositeInstance<GenAiRulesMembers> & GenAiRulesMembers;
|
|
126
|
+
/** A recorded latency series and the quantiles it holds, one per `quantile` label value. */
|
|
127
|
+
export interface GenAiQuantileSeries {
|
|
128
|
+
record: string;
|
|
129
|
+
/** The values of the `quantile` label, e.g. `0.95`. */
|
|
130
|
+
quantiles: string[];
|
|
131
|
+
}
|
|
132
|
+
/** One alert as built. */
|
|
133
|
+
export interface GenAiAlertInfo {
|
|
134
|
+
alert: string;
|
|
135
|
+
kind: "errorRatio" | "latency" | "toolErrorRatio" | "budget";
|
|
136
|
+
severity: string;
|
|
137
|
+
/** The value the alert fires above: a ratio, seconds, or an amount of money. */
|
|
138
|
+
threshold: number;
|
|
139
|
+
/** For a budget: its currency and window. */
|
|
140
|
+
currency?: string;
|
|
141
|
+
per?: "hour" | "day";
|
|
142
|
+
}
|
|
143
|
+
/** The series a `GenAiRules` records, read by dashboards instead of repeating names. */
|
|
144
|
+
export interface GenAiRuleMetrics {
|
|
145
|
+
/** The rule group's name. */
|
|
146
|
+
group: string;
|
|
147
|
+
/** Which metrics the model rules read. */
|
|
148
|
+
source: "client" | "spans";
|
|
149
|
+
rateWindow: string;
|
|
150
|
+
/** Prometheus label names the series are split by. */
|
|
151
|
+
labels: {
|
|
152
|
+
/** Absent when the source metrics have no provider (span metrics without `providerDimensions`). */
|
|
153
|
+
provider?: string;
|
|
154
|
+
model: string;
|
|
155
|
+
operation: string;
|
|
156
|
+
errorType: string;
|
|
157
|
+
tokenType: string;
|
|
158
|
+
/** Absent when the span metrics have no tool dimension. */
|
|
159
|
+
tool?: string;
|
|
160
|
+
currency: string;
|
|
161
|
+
quantile: string;
|
|
162
|
+
};
|
|
163
|
+
/** The labels the model series (requests, errors, latency) are split by, `groupBy` last. */
|
|
164
|
+
modelLabels: string[];
|
|
165
|
+
/** The labels token and cost series are split by, besides the token type (and currency on cost). */
|
|
166
|
+
tokenLabels: string[];
|
|
167
|
+
/** Requests per second. */
|
|
168
|
+
requests: string;
|
|
169
|
+
/** Errors per second, also by `error.type`. */
|
|
170
|
+
errors: string;
|
|
171
|
+
/** Errors over requests, 0 when there are none. */
|
|
172
|
+
errorRatio: string;
|
|
173
|
+
/** Errors of each `error.type` over all requests. */
|
|
174
|
+
errorRatioByType: string;
|
|
175
|
+
/** Operation latency in seconds, at p50, p95 and p99. */
|
|
176
|
+
latency: GenAiQuantileSeries;
|
|
177
|
+
/** Tokens per second, by `gen_ai.token.type` (`input`, `output`). */
|
|
178
|
+
tokens: string;
|
|
179
|
+
/** Spend per second in each price's currency, by token type. Absent without prices. */
|
|
180
|
+
cost?: string;
|
|
181
|
+
/** Per-tool series, from the span metrics. Absent when they carry no tool name. */
|
|
182
|
+
tool?: {
|
|
183
|
+
calls: string;
|
|
184
|
+
errors: string;
|
|
185
|
+
errorRatio: string;
|
|
186
|
+
latency: GenAiQuantileSeries;
|
|
187
|
+
};
|
|
188
|
+
/** The price table as declared, without the prices. */
|
|
189
|
+
prices: Array<{
|
|
190
|
+
provider: string;
|
|
191
|
+
model: string;
|
|
192
|
+
currency: string;
|
|
193
|
+
source: string;
|
|
194
|
+
asOf?: string;
|
|
195
|
+
}>;
|
|
196
|
+
/** Every currency in the price table. */
|
|
197
|
+
currencies: string[];
|
|
198
|
+
/** The alerts built, in rule order. Empty unless asked for. */
|
|
199
|
+
alerts: GenAiAlertInfo[];
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Recording rules and opt-in alerts for GenAI calls, from the otel preset's metrics.
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* ```ts
|
|
206
|
+
* import { genAiMetrics } from "@intentius/chant-lexicon-otel";
|
|
207
|
+
* import { GenAiRules } from "@intentius/chant-lexicon-prometheus";
|
|
208
|
+
*
|
|
209
|
+
* export const genai = GenAiRules({
|
|
210
|
+
* genAi: genAiMetrics({ clientMetrics: "derive" }),
|
|
211
|
+
* prices: [{ provider: "anthropic", model: "claude-x", inputPerMTok: 3, outputPerMTok: 15, currency: "USD", source: "https://example.com/pricing", asOf: "2026-09-29" }],
|
|
212
|
+
* alerts: { errorRatio: true, budgets: [{ amount: 50, currency: "USD", per: "day" }] },
|
|
213
|
+
* });
|
|
214
|
+
* // genai.rules is a RuleGroup; genAiRuleMetrics(genai) names its series.
|
|
215
|
+
* ```
|
|
216
|
+
*/
|
|
217
|
+
export declare const GenAiRules: import("@intentius/chant/composite").CompositeDefinition<GenAiRulesProps, GenAiRulesMembers>;
|
|
218
|
+
/**
|
|
219
|
+
* The series a `GenAiRules` records and the alerts it builds. Pass the
|
|
220
|
+
* `GenAiRules(...)` result, its rule group, or the props it was built from;
|
|
221
|
+
* a dashboard reads names from here instead of repeating them.
|
|
222
|
+
*/
|
|
223
|
+
export declare function genAiRuleMetrics(rules: GenAiRulesInstance | RuleGroupEntity | GenAiRulesProps): GenAiRuleMetrics;
|
|
224
|
+
//# sourceMappingURL=genai.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"genai.d.ts","sourceRoot":"","sources":["../../src/composites/genai.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EAAa,KAAK,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,EAAyD,KAAK,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAE/H,OAAO,EAAoD,KAAK,eAAe,EAAE,MAAM,UAAU,CAAC;AAClG,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGzC,2EAA2E;AAC3E,MAAM,WAAW,UAAU;IACzB,sEAAsE;IACtE,QAAQ,EAAE,MAAM,CAAC;IACjB,yFAAyF;IACzF,KAAK,EAAE,MAAM,CAAC;IACd,yCAAyC;IACzC,YAAY,EAAE,MAAM,CAAC;IACrB,0CAA0C;IAC1C,aAAa,EAAE,MAAM,CAAC;IACtB,oFAAoF;IACpF,QAAQ,EAAE,MAAM,CAAC;IACjB,kFAAkF;IAClF,MAAM,EAAE,MAAM,CAAC;IACf,mDAAmD;IACnD,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,oCAAoC;AACpC,MAAM,WAAW,iBAAiB;IAChC,wDAAwD;IACxD,GAAG,CAAC,E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AG,eAAe,GAAG,gBAAgB,CAOhH"}
|
|
@@ -3,4 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export { Slo, sloMetrics, sloPropsProblem, sliExprProblem, DEFAULT_BURN_RATES, SLO_WINDOW_PLACEHOLDER, } from "./slo.js";
|
|
5
5
|
export type { SloProps, SloSli, SloAlerting, SloAlertTier, BurnRateWindow, SloMembers, SloInstance, SloMetrics, SloBurnRate, } from "./slo.js";
|
|
6
|
+
export { GenAiRules, genAiRuleMetrics } from "./genai.js";
|
|
7
|
+
export type { GenAiRulesProps, GenAiRulesMembers, GenAiRulesInstance, GenAiRuleMetrics, GenAiPrice, GenAiAlerting, GenAiAlertOptions, GenAiRatioAlert, GenAiLatencyAlert, GenAiBudget, GenAiAlertInfo, GenAiQuantileSeries, } from "./genai.js";
|
|
6
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/composites/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,GAAG,EACH,UAAU,EACV,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,OAAO,CAAC;AACf,YAAY,EACV,QAAQ,EACR,MAAM,EACN,WAAW,EACX,YAAY,EACZ,cAAc,EACd,UAAU,EACV,WAAW,EACX,UAAU,EACV,WAAW,GACZ,MAAM,OAAO,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/composites/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,GAAG,EACH,UAAU,EACV,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,OAAO,CAAC;AACf,YAAY,EACV,QAAQ,EACR,MAAM,EACN,WAAW,EACX,YAAY,EACZ,cAAc,EACd,UAAU,EACV,WAAW,EACX,UAAU,EACV,WAAW,GACZ,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACvD,YAAY,EACV,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,cAAc,EACd,mBAAmB,GACpB,MAAM,SAAS,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -10,5 +10,5 @@ export { checkPromql, PROMQL_GRAMMAR, type PromqlCheck } from "./promql.js";
|
|
|
10
10
|
export { validateRuleFile, validateAlertmanagerConfig, validateSeverityRouting, alertSeverities, type PrometheusIssue, type PrometheusIssueCode, } from "./validate-config.js";
|
|
11
11
|
export { PROMETHEUS_PIN } from "./pin.js";
|
|
12
12
|
export { promtoolCheckRules, promtoolTestRules, amtoolCheckConfig, hasTool, type ToolResult } from "./tools.js";
|
|
13
|
-
export { Slo, sloMetrics, sloPropsProblem, sliExprProblem, DEFAULT_BURN_RATES, SLO_WINDOW_PLACEHOLDER, type SloProps, type SloSli, type SloAlerting, type SloAlertTier, type BurnRateWindow, type SloMembers, type SloInstance, type SloMetrics, type SloBurnRate, } from "./composites/index.js";
|
|
13
|
+
export { Slo, sloMetrics, sloPropsProblem, sliExprProblem, DEFAULT_BURN_RATES, SLO_WINDOW_PLACEHOLDER, type SloProps, type SloSli, type SloAlerting, type SloAlertTier, type BurnRateWindow, type SloMembers, type SloInstance, type SloMetrics, type SloBurnRate, GenAiRules, genAiRuleMetrics, type GenAiRulesProps, type GenAiRulesMembers, type GenAiRulesInstance, type GenAiRuleMetrics, type GenAiPrice, type GenAiAlerting, type GenAiAlertOptions, type GenAiRatioAlert, type GenAiLatencyAlert, type GenAiBudget, type GenAiAlertInfo, type GenAiQuantileSeries, } from "./composites/index.js";
|
|
14
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":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AM,UAAU,CAAC;AACzE,OAAO,EACL,gBAAgB,EAChB,0BAA0B,EAC1B,uBAAuB,EACvB,eAAe,EACf,KAAK,eAAe,EACpB,KAAK,mBAAmB,GACzB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;AAG7G,OAAO,EACL,GAAG,EACH,UAAU,EACV,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,sBAAsB,EACtB,KAAK,QAAQ,EACb,KAAK,MAAM,EACX,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,WAAW,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGvE,OAAO,EACL,SAAS,EACT,eAAe,EACf,WAAW,EACX,eAAe,EACf,UAAU,EACV,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,IAAI,EACT,KAAK,aAAa,EAClB,KAAK,YAAY,GAClB,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,KAAK,EACL,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,oBAAoB,EACpB,UAAU,EACV,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,OAAO,EACP,UAAU,EACV,aAAa,EACb,cAAc,EACd,sBAAsB,EACtB,oBAAoB,EACpB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,gBAAg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B,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,mBAAmB,GACzB,MAAM,cAAc,CAAC"}
|
package/dist/init-templates.d.ts
CHANGED
|
@@ -6,8 +6,17 @@
|
|
|
6
6
|
* - `rules`: rule groups only, for a setup whose Alertmanager config lives
|
|
7
7
|
* elsewhere.
|
|
8
8
|
* - `slo-style`: a recording rule per window and alerts on two severities,
|
|
9
|
-
* the shape SLO burn-rate rules take.
|
|
9
|
+
* the shape SLO burn-rate rules take, written out as plain rules.
|
|
10
|
+
* - `slo`: an SLO declared with the `Slo` composite, which builds its error
|
|
11
|
+
* ratios, error budget and multiwindow burn-rate alerts, and the
|
|
12
|
+
* Alertmanager routing for the page and ticket severities those alerts
|
|
13
|
+
* carry, with a page muting the same SLO's ticket.
|
|
10
14
|
*/
|
|
11
15
|
import type { InitTemplateSet } from "@intentius/chant/lexicon";
|
|
12
|
-
export declare
|
|
16
|
+
export declare const DEFAULT_TEMPLATE: InitTemplateSet;
|
|
17
|
+
export declare const RULES_TEMPLATE: InitTemplateSet;
|
|
18
|
+
export declare const SLO_STYLE_TEMPLATE: InitTemplateSet;
|
|
19
|
+
export declare const SLO_TEMPLATE: InitTemplateSet;
|
|
20
|
+
/** The template names `chant init --lexicon prometheus --template <name>` takes, besides the default. */
|
|
21
|
+
export declare const TEMPLATE_NAMES: readonly ["rules", "slo-style", "slo"];
|
|
13
22
|
//# sourceMappingURL=init-templates.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-templates.d.ts","sourceRoot":"","sources":["../src/init-templates.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"init-templates.d.ts","sourceRoot":"","sources":["../src/init-templates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAyHhE,eAAO,MAAM,gBAAgB,EAAE,eAAiF,CAAC;AAEjH,eAAO,MAAM,cAAc,EAAE,eAAgD,CAAC;AAE9E,eAAO,MAAM,kBAAkB,EAAE,eAAoD,CAAC;AAEtF,eAAO,MAAM,YAAY,EAAE,eAA6F,CAAC;AAEzH,yGAAyG;AACzG,eAAO,MAAM,cAAc,wCAAyC,CAAC"}
|
package/dist/integrity.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"algorithm": "sha256",
|
|
3
3
|
"artifacts": {
|
|
4
|
-
"manifest.json": "
|
|
4
|
+
"manifest.json": "65f130bfb1121c22b92f960f4f742b25b7fecc737e4ca2b2f1737cd580d7b65e",
|
|
5
5
|
"meta.json": "6aeeb24f8a09f61582620870021cdb0d781690d4a9d0efebc729d054df3eaebb",
|
|
6
6
|
"types/index.d.ts": "150d72287453a24a40cdeffb8cf3e9dc6e77ab58b342b48d01902dc58fb5f85d",
|
|
7
7
|
"rules/literal-credential.ts": "384c500ab33d9608b545b0743ed4a382c76f645175eda9b1628e00e24b87fbb7",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"rules/prom207.ts": "60b9fb8017da191f43d174ac6173c31abfb151d536b9994408f104fc6e25cdb4",
|
|
26
26
|
"rules/prom208.ts": "692b4ae103b762199a51ab9fb64b1d6686dfbc0356676f6cf6afb393a89ef83a",
|
|
27
27
|
"rules/prom209.ts": "5c4fe651e51e1eea7fa5f03a7f6331d98399629c7c7d53f4ea8620982d419bbd",
|
|
28
|
-
"skills/chant-prometheus.md": "
|
|
28
|
+
"skills/chant-prometheus.md": "842db9fa6329b486b95987aa93e1542af52436aa326c02275854e64b51946edb",
|
|
29
29
|
"skills/chant-prometheus-alertmanager.md": "c5e63edb67cf70dc2abfcc4af648e20d495e9226f440327f05c397f3b655f25c",
|
|
30
30
|
"skills/chant-prometheus-kubernetes.md": "cca016857891f4cabf1feb6f9db83c220a2e6ece200cd89e635851079f8070a8"
|
|
31
31
|
},
|
|
32
|
-
"composite": "
|
|
32
|
+
"composite": "9bd4294e4364dd80fb88e37b9c99fee8ff39c64e4e349f1120e9507de9469e7d"
|
|
33
33
|
}
|
package/dist/manifest.json
CHANGED
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AA+B9D;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AA+B9D;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,EAAE,aA6G9B,CAAC"}
|
package/dist/rule-eval.d.ts
CHANGED
|
@@ -7,10 +7,15 @@
|
|
|
7
7
|
* The PromQL it understands is the subset the lexicon's generated rules use:
|
|
8
8
|
* number literals, vector and range selectors with `=`, `!=`, `=~` and `!~`
|
|
9
9
|
* matchers, `rate`, `increase`, `avg_over_time`, `sum_over_time`,
|
|
10
|
-
* `count_over_time`, `vector`, `sum` (with `by` or
|
|
11
|
-
* arithmetic and comparison operators
|
|
12
|
-
*
|
|
13
|
-
*
|
|
10
|
+
* `count_over_time`, `vector`, `histogram_quantile`, `sum` (with `by` or
|
|
11
|
+
* `without`), the arithmetic and comparison operators (one-to-one, or
|
|
12
|
+
* many-to-one with `group_left` and no extra labels) and `and`, `or` and
|
|
13
|
+
* `unless` (with `on` or `ignoring`). Anything else throws, so a test never
|
|
14
|
+
* passes by silently evaluating something it does not understand.
|
|
15
|
+
*
|
|
16
|
+
* `histogram_quantile` interpolates linearly inside the bucket the rank
|
|
17
|
+
* falls in, as Prometheus does for classic buckets, and returns the upper
|
|
18
|
+
* bound of the highest finite bucket when the rank falls in `+Inf`.
|
|
14
19
|
*
|
|
15
20
|
* `rate` is the increase between the first and last sample in the range
|
|
16
21
|
* over the time between them, without Prometheus's extrapolation to the
|
|
@@ -61,6 +66,7 @@ export declare class RuleEvaluator {
|
|
|
61
66
|
private node;
|
|
62
67
|
private args;
|
|
63
68
|
private call;
|
|
69
|
+
private histogramQuantile;
|
|
64
70
|
private aggregate;
|
|
65
71
|
private binary;
|
|
66
72
|
}
|
package/dist/rule-eval.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rule-eval.d.ts","sourceRoot":"","sources":["../src/rule-eval.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"rule-eval.d.ts","sourceRoot":"","sources":["../src/rule-eval.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAIH,OAAO,EAA8D,KAAK,eAAe,EAAE,MAAM,SAAS,CAAC;AAI3G,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC5C,MAAM,WAAW,MAAM;IACrB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AACD,MAAM,WAAW,MAAM;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AACD,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAGD,0CAA0C;AAC1C,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAkCD,8DAA8D;AAC9D,qBAAa,aAAa;IAKZ,OAAO,CAAC,QAAQ,CAAC,MAAM;IAJnC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA6B;IACpD,yDAAyD;IACzD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA0C;gBAErC,MAAM,EAAE,eAAe,EAAE;IAEtD,wEAAwE;IACxE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI;IAU/C,yFAAyF;IACzF,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,WAAW,EAAE;IA8B9B,yFAAyF;IACzF,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,aAAa,EAAE;IAK/C,OAAO,CAAC,IAAI;IAOZ,OAAO,CAAC,IAAI;IAIZ,OAAO,CAAC,QAAQ;IAiBhB,OAAO,CAAC,MAAM;IAId,iCAAiC;IACjC,OAAO,CAAC,MAAM;IAcd,OAAO,CAAC,IAAI;IAyBZ,OAAO,CAAC,IAAI;IAQZ,OAAO,CAAC,IAAI;IA0CZ,OAAO,CAAC,iBAAiB;IAuCzB,OAAO,CAAC,SAAS;IA4BjB,OAAO,CAAC,MAAM;CA2Hf"}
|
|
@@ -100,3 +100,25 @@ sloMetrics(checkout).errorRatio["1h"]; // "slo:sli_error:ratio_rate1h"
|
|
|
100
100
|
- Write the objective as a fraction strictly between 0 and 1, and put `{{window}}` where each SLI expression's range goes (PROM003).
|
|
101
101
|
- Alerts carry `severity` `page` or `ticket`; route both (PROM202).
|
|
102
102
|
- Read series names from `sloMetrics()` in dashboards instead of repeating them.
|
|
103
|
+
|
|
104
|
+
## GenAI rules
|
|
105
|
+
|
|
106
|
+
`GenAiRules` builds rules for the otel lexicon's GenAI collector preset from the same `genAiMetrics(options)` the collector was built with: request rate, error ratio (also by `error.type`) and p50/p95/p99 latency per provider, model and operation, token rates, spend per second from a price table the project declares, and per-tool call rate, error ratio and p95 latency. Alerts are off unless `alerts` names them.
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
import { genAiMetrics } from "@intentius/chant-lexicon-otel";
|
|
110
|
+
import { GenAiRules, genAiRuleMetrics } from "@intentius/chant-lexicon-prometheus";
|
|
111
|
+
|
|
112
|
+
export const genai = GenAiRules({
|
|
113
|
+
genAi: genAiMetrics({ clientMetrics: "derive" }),
|
|
114
|
+
prices: [{ provider: "anthropic", model: "claude-x", inputPerMTok: 3, outputPerMTok: 15, currency: "USD", source: "https://example.com/pricing", asOf: "2026-09-29" }],
|
|
115
|
+
alerts: { errorRatio: true, latency: { thresholdSeconds: 20 }, budgets: [{ amount: 50, currency: "USD", per: "day" }] },
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
genAiRuleMetrics(genai).cost; // "gen_ai:cost:rate5m"
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
- Pass the collector's own options to `genAiMetrics()`; never write a metric name by hand.
|
|
122
|
+
- Ship no prices in a lexicon or template. The project declares them, with `currency` and `source` on each.
|
|
123
|
+
- A model missing from `prices` gets no cost series, so a sum of the cost series covers priced models only.
|
|
124
|
+
- Read series names from `genAiRuleMetrics()` in dashboards.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intentius/chant-lexicon-prometheus",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.101.0",
|
|
4
4
|
"description": "Prometheus lexicon for chant — typed recording and alerting rule groups and Alertmanager routing, serialized to a rule file and alertmanager.yml",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://intentius.io/chant",
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json && find dist -type f \\( -name \"*.js\" -o -name \"*.js.map\" \\) -delete"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
+
"@intentius/chant-lexicon-otel": "*",
|
|
62
63
|
"@lezer/highlight": "^1.2.4",
|
|
63
64
|
"@lezer/lr": "^1.4.10",
|
|
64
65
|
"@prometheus-io/lezer-promql": "0.315.0",
|
|
@@ -71,7 +72,7 @@
|
|
|
71
72
|
"typescript": "^5.9.3"
|
|
72
73
|
},
|
|
73
74
|
"peerDependencies": {
|
|
74
|
-
"@intentius/chant": "^0.
|
|
75
|
+
"@intentius/chant": "^0.101.0",
|
|
75
76
|
"typescript": "^5.9.3"
|
|
76
77
|
}
|
|
77
78
|
}
|
package/src/codegen/docs.ts
CHANGED
|
@@ -42,6 +42,11 @@ The \`Slo\` composite builds a service level objective to a \`RuleGroup\`:
|
|
|
42
42
|
error ratios per window, the error budget left, and the SRE Workbook's
|
|
43
43
|
multiwindow multi-burn-rate alerts. See [SLOs](./slos/).
|
|
44
44
|
|
|
45
|
+
The \`GenAiRules\` composite builds recording rules, opt-in alerts and spend
|
|
46
|
+
from a declared price table for the otel lexicon's GenAI collector preset,
|
|
47
|
+
reading every metric name from its \`GenAiMetrics\`. See
|
|
48
|
+
[GenAI Rules](./genai-rules/).
|
|
49
|
+
|
|
45
50
|
Checks run at build time: PromQL syntax in every \`expr\` (PROM104), unique
|
|
46
51
|
group names (PROM101), valid durations (PROM103), routes that name
|
|
47
52
|
declared receivers (PROM201), and every alert severity routed by some route
|
|
@@ -19,7 +19,7 @@ const catalogued = compositeCatalog.map((entry) => entry.name).sort();
|
|
|
19
19
|
|
|
20
20
|
describe("the prometheus composite catalog", () => {
|
|
21
21
|
test("every exported composite has an entry, and every entry names an exported composite", () => {
|
|
22
|
-
expect(exported).toEqual(["Slo"]);
|
|
22
|
+
expect(exported).toEqual(["GenAiRules", "Slo"]);
|
|
23
23
|
expect(catalogued, "regenerate with `npm run generate:composite-catalogs -- prometheus`").toEqual(exported);
|
|
24
24
|
});
|
|
25
25
|
|
|
@@ -4,6 +4,76 @@
|
|
|
4
4
|
import type { CompositeEntry } from "@intentius/chant/lexicon";
|
|
5
5
|
|
|
6
6
|
export const compositeCatalog: CompositeEntry[] = [
|
|
7
|
+
{
|
|
8
|
+
"name": "GenAiRules",
|
|
9
|
+
"lexicon": "prometheus",
|
|
10
|
+
"description": "Recording rules and opt-in alerts for GenAI calls, from the otel preset's metrics.",
|
|
11
|
+
"bundles": [
|
|
12
|
+
"RuleGroup"
|
|
13
|
+
],
|
|
14
|
+
"params": [
|
|
15
|
+
{
|
|
16
|
+
"name": "genAi",
|
|
17
|
+
"type": "GenAiMetrics | { metrics: GenAiMetrics }",
|
|
18
|
+
"required": true,
|
|
19
|
+
"description": "The preset's metrics: `genAiMetrics(options)` with the options the collector was built with, or `genAiComponents(options)`."
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"name": "source",
|
|
23
|
+
"type": "\"client\" | \"spans\"",
|
|
24
|
+
"required": false,
|
|
25
|
+
"description": "Which metrics the model rules read (default `client` when the metrics include the conventions' client metrics, else `spans`)."
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"name": "prices",
|
|
29
|
+
"type": "GenAiPrice[]",
|
|
30
|
+
"required": false,
|
|
31
|
+
"description": "Prices per provider and model."
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"name": "alerts",
|
|
35
|
+
"type": "GenAiAlerting",
|
|
36
|
+
"required": false,
|
|
37
|
+
"description": "Opt-in alerts (default: none)."
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"name": "name",
|
|
41
|
+
"type": "string",
|
|
42
|
+
"required": false,
|
|
43
|
+
"description": "The rule group's name (default `genai`)."
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"name": "prefix",
|
|
47
|
+
"type": "string",
|
|
48
|
+
"required": false,
|
|
49
|
+
"description": "The first part of every recorded series name (default `gen_ai`)."
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"name": "rateWindow",
|
|
53
|
+
"type": "string",
|
|
54
|
+
"required": false,
|
|
55
|
+
"description": "The range every `rate` reads (default `5m`)."
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"name": "groupBy",
|
|
59
|
+
"type": "string[]",
|
|
60
|
+
"required": false,
|
|
61
|
+
"description": "More Prometheus labels every rule keeps, e.g. `job` or `service_name`."
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"name": "labels",
|
|
65
|
+
"type": "LabelSet",
|
|
66
|
+
"required": false,
|
|
67
|
+
"description": "Labels added to every rule, e.g. `team`."
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"name": "interval",
|
|
71
|
+
"type": "string",
|
|
72
|
+
"required": false,
|
|
73
|
+
"description": "Evaluation interval of the group (default: Prometheus's `evaluation_interval`)."
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
},
|
|
7
77
|
{
|
|
8
78
|
"name": "Slo",
|
|
9
79
|
"lexicon": "prometheus",
|