Skip to content

Commit 8b9d2c6

Browse files
Alerting: Add alert enrichment resource
1 parent a268948 commit 8b9d2c6

File tree

9 files changed

+1303
-113
lines changed

9 files changed

+1303
-113
lines changed
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "grafana_apps_alertenrichment_alertenrichment_v1beta1 Resource - terraform-provider-grafana"
4+
subcategory: "Grafana Apps"
5+
description: |-
6+
Manages Grafana Alert Enrichments.
7+
---
8+
9+
# grafana_apps_alertenrichment_alertenrichment_v1beta1 (Resource)
10+
11+
Manages Grafana Alert Enrichments.
12+
13+
## Example Usage
14+
15+
```terraform
16+
resource "grafana_apps_alertenrichment_alertenrichment_v1beta1" "example" {
17+
metadata = {
18+
uid = "alert-enrichment-example"
19+
}
20+
21+
spec {
22+
title = "Critical Alert Enrichment Pipeline"
23+
description = "Enriches critical production alerts with team information"
24+
25+
# Apply only to specific alert rules
26+
alert_rule_uids = ["high-cpu-alert", "disk-space-alert"]
27+
28+
# Apply only to specific receivers
29+
receivers = ["critical-alerts", "alerting-team"]
30+
31+
# Match alerts with specific labels
32+
label_matchers = [
33+
{
34+
type = "="
35+
name = "severity"
36+
value = "critical"
37+
},
38+
{
39+
type = "=~" # Regex match
40+
name = "environment"
41+
value = "prod.*"
42+
},
43+
{
44+
type = "!="
45+
name = "team"
46+
value = "test"
47+
}
48+
]
49+
50+
# Match alerts with specific annotations
51+
annotation_matchers = [
52+
{
53+
type = "!~" # Regex not match
54+
name = "runbook_url"
55+
value = "^http://grafana.com$"
56+
}
57+
]
58+
59+
assign_step {
60+
annotations = {
61+
enrichment_team = "alerting-team"
62+
runbook_url = "https://runbooks.grafana.com/critical-alerts"
63+
contact_slack = "#alerts-critical"
64+
incident_severity = "high"
65+
}
66+
timeout = "30s"
67+
}
68+
}
69+
}
70+
```
71+
72+
<!-- schema generated by tfplugindocs -->
73+
## Schema
74+
75+
### Optional
76+
77+
- `metadata` (Block, Optional) The metadata of the resource. (see [below for nested schema](#nestedblock--metadata))
78+
- `options` (Block, Optional) Options for applying the resource. (see [below for nested schema](#nestedblock--options))
79+
- `spec` (Block, Optional) The spec of the resource. (see [below for nested schema](#nestedblock--spec))
80+
81+
### Read-Only
82+
83+
- `id` (String) The ID of the resource derived from UUID.
84+
85+
<a id="nestedblock--metadata"></a>
86+
### Nested Schema for `metadata`
87+
88+
Required:
89+
90+
- `uid` (String) The unique identifier of the resource.
91+
92+
Optional:
93+
94+
- `folder_uid` (String) The UID of the folder to save the resource in.
95+
96+
Read-Only:
97+
98+
- `url` (String) The full URL of the resource.
99+
- `uuid` (String) The globally unique identifier of a resource, used by the API for tracking.
100+
- `version` (String) The version of the resource.
101+
102+
103+
<a id="nestedblock--options"></a>
104+
### Nested Schema for `options`
105+
106+
Optional:
107+
108+
- `overwrite` (Boolean) Set to true if you want to overwrite existing resource with newer version, same resource title in folder or same resource uid.
109+
110+
111+
<a id="nestedblock--spec"></a>
112+
### Nested Schema for `spec`
113+
114+
Required:
115+
116+
- `title` (String) The title of the alert enrichment.
117+
118+
Optional:
119+
120+
- `alert_rule_uids` (List of String) UIDs of alert rules this enrichment applies to. If empty, applies to all alert rules.
121+
- `annotation_matchers` (List of Object) Annotation matchers that an alert must satisfy for this enrichment to apply. Each matcher is an object with: 'type' (string, one of: =, !=, =~, !~), 'name' (string, annotation key to match), 'value' (string, annotation value to compare against, supports regex for =~/!~ operators). (see [below for nested schema](#nestedatt--spec--annotation_matchers))
122+
- `assign_step` (Block List) Assign enricher step that adds or modifies annotations on alerts. (see [below for nested schema](#nestedblock--spec--assign_step))
123+
- `description` (String) Description of the alert enrichment.
124+
- `label_matchers` (List of Object) Label matchers that an alert must satisfy for this enrichment to apply. Each matcher is an object with: 'type' (string, one of: =, !=, =~, !~), 'name' (string, label key to match), 'value' (string, label value to compare against, supports regex for =~/!~ operators). (see [below for nested schema](#nestedatt--spec--label_matchers))
125+
- `receivers` (List of String) Receiver names to match. If empty, applies to all receivers.
126+
127+
<a id="nestedatt--spec--annotation_matchers"></a>
128+
### Nested Schema for `spec.annotation_matchers`
129+
130+
Optional:
131+
132+
- `name` (String)
133+
- `type` (String)
134+
- `value` (String)
135+
136+
137+
<a id="nestedblock--spec--assign_step"></a>
138+
### Nested Schema for `spec.assign_step`
139+
140+
Required:
141+
142+
- `annotations` (Map of String) Map of annotation names to values to set on matching alerts. Values can use Go template syntax with access to $labels and $annotations.
143+
144+
Optional:
145+
146+
- `timeout` (String) Maximum execution time (e.g., '30s', '1m'). Defaults to 30s.
147+
148+
149+
<a id="nestedatt--spec--label_matchers"></a>
150+
### Nested Schema for `spec.label_matchers`
151+
152+
Optional:
153+
154+
- `name` (String)
155+
- `type` (String)
156+
- `value` (String)
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
resource "grafana_apps_alertenrichment_alertenrichment_v1beta1" "example" {
2+
metadata = {
3+
uid = "alert-enrichment-example"
4+
}
5+
6+
spec {
7+
title = "Critical Alert Enrichment Pipeline"
8+
description = "Enriches critical production alerts with team information"
9+
10+
# Apply only to specific alert rules
11+
alert_rule_uids = ["high-cpu-alert", "disk-space-alert"]
12+
13+
# Apply only to specific receivers
14+
receivers = ["critical-alerts", "alerting-team"]
15+
16+
# Match alerts with specific labels
17+
label_matchers = [
18+
{
19+
type = "="
20+
name = "severity"
21+
value = "critical"
22+
},
23+
{
24+
type = "=~" # Regex match
25+
name = "environment"
26+
value = "prod.*"
27+
},
28+
{
29+
type = "!="
30+
name = "team"
31+
value = "test"
32+
}
33+
]
34+
35+
# Match alerts with specific annotations
36+
annotation_matchers = [
37+
{
38+
type = "!~" # Regex not match
39+
name = "runbook_url"
40+
value = "^http://grafana.com$"
41+
}
42+
]
43+
44+
assign_step {
45+
annotations = {
46+
enrichment_team = "alerting-team"
47+
runbook_url = "https://runbooks.grafana.com/critical-alerts"
48+
contact_slack = "#alerts-critical"
49+
incident_severity = "high"
50+
}
51+
timeout = "30s"
52+
}
53+
}
54+
}

go.mod

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/grafana/terraform-provider-grafana/v4
22

3-
go 1.24.2
3+
go 1.24.6
44

55
require (
66
connectrpc.com/connect v1.18.1
@@ -11,12 +11,14 @@ require (
1111
github.com/grafana/amixr-api-go-client v0.0.25
1212
github.com/grafana/authlib/claims v0.0.0-20250120084028-e3328c576437
1313
github.com/grafana/fleet-management-api v1.0.0
14-
github.com/grafana/grafana-app-sdk v0.35.2-0.20250408075831-c2a87bde0849
14+
github.com/grafana/grafana-app-sdk v0.40.3
15+
github.com/grafana/grafana-asserts-public-clients/go/gcom v0.0.0-20250805165836-14e16b51b910
1516
github.com/grafana/grafana-com-public-clients/go/gcom v0.0.0-20250526074454-7ec66e02e4bb
1617
github.com/grafana/grafana-openapi-client-go v0.0.0-20250617151817-c0f8cbb88d5c
18+
github.com/grafana/grafana/apps/alerting/alertenrichment v0.0.0-20250904171753-3d6d6326866f
1719
github.com/grafana/grafana/apps/dashboard v0.0.0-20250424064802-2fbb2d6f5d27
1820
github.com/grafana/grafana/apps/playlist v0.0.0-20250424064802-2fbb2d6f5d27
19-
github.com/grafana/grafana/pkg/apimachinery v0.0.0-20250424064802-2fbb2d6f5d27
21+
github.com/grafana/grafana/pkg/apimachinery v0.0.0-20250901080157-a0280d701b28
2022
github.com/grafana/k6-cloud-openapi-client-go v0.0.0-20250715154343-32edc34ec1db
2123
github.com/grafana/machine-learning-go-client v0.8.2
2224
github.com/grafana/river v0.3.0
@@ -46,23 +48,20 @@ require (
4648
github.com/urfave/cli/v2 v2.27.7
4749
github.com/zclconf/go-cty v1.16.4
4850
golang.org/x/exp v0.0.0-20250718183923-645b1fa84792
49-
golang.org/x/text v0.27.0
51+
golang.org/x/text v0.28.0
5052
gopkg.in/yaml.v2 v2.4.0
51-
k8s.io/apimachinery v0.32.3
52-
k8s.io/client-go v0.32.3
53+
k8s.io/apimachinery v0.33.3
54+
k8s.io/client-go v0.33.3
5355
)
5456

55-
require github.com/grafana/grafana-asserts-public-clients/go/gcom v0.0.0-20250805165836-14e16b51b910
56-
5757
require (
5858
cuelang.org/go v0.11.1 // indirect
5959
dario.cat/mergo v1.0.1 // indirect
6060
github.com/BurntSushi/toml v1.5.0 // indirect
6161
github.com/Kunde21/markdownfmt/v3 v3.1.0 // indirect
6262
github.com/Masterminds/goutils v1.1.1 // indirect
6363
github.com/Masterminds/sprig/v3 v3.3.0 // indirect
64-
github.com/Microsoft/go-winio v0.6.2 // indirect
65-
github.com/ProtonMail/go-crypto v1.1.3 // indirect
64+
github.com/ProtonMail/go-crypto v1.1.6 // indirect
6665
github.com/agext/levenshtein v1.2.3 // indirect
6766
github.com/apache/arrow-go/v18 v18.2.0 // indirect
6867
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
@@ -71,18 +70,18 @@ require (
7170
github.com/beorn7/perks v1.0.1 // indirect
7271
github.com/bgentry/speakeasy v0.1.0 // indirect
7372
github.com/bmatcuk/doublestar/v4 v4.8.1 // indirect
74-
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
73+
github.com/cenkalti/backoff/v5 v5.0.2 // indirect
7574
github.com/cespare/xxhash/v2 v2.3.0 // indirect
7675
github.com/cheekybits/genny v1.0.0 // indirect
7776
github.com/chromedp/cdproto v0.0.0-20240810084448-b931b754e476 // indirect
78-
github.com/cloudflare/circl v1.3.7 // indirect
77+
github.com/cloudflare/circl v1.6.1 // indirect
7978
github.com/cockroachdb/apd/v3 v3.2.1 // indirect
8079
github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect
8180
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
8281
github.com/elazarl/goproxy v1.7.2 // indirect
83-
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
82+
github.com/emicklei/go-restful/v3 v3.12.1 // indirect
8483
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
85-
github.com/getkin/kin-openapi v0.131.0 // indirect
84+
github.com/getkin/kin-openapi v0.132.0 // indirect
8685
github.com/go-logr/logr v1.4.3 // indirect
8786
github.com/go-logr/stdr v1.2.2 // indirect
8887
github.com/go-openapi/analysis v0.23.0 // indirect
@@ -95,22 +94,20 @@ require (
9594
github.com/go-openapi/validate v0.24.0 // indirect
9695
github.com/goccy/go-json v0.10.5 // indirect
9796
github.com/gogo/protobuf v1.3.2 // indirect
98-
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
9997
github.com/golang/protobuf v1.5.4 // indirect
10098
github.com/google/flatbuffers v25.2.10+incompatible // indirect
10199
github.com/google/gnostic-models v0.6.9 // indirect
102100
github.com/google/go-cmp v0.7.0 // indirect
103101
github.com/google/go-querystring v1.1.0 // indirect
104-
github.com/google/gofuzz v1.2.0 // indirect
105102
github.com/google/uuid v1.6.0 // indirect
106103
github.com/gorilla/mux v1.8.1 // indirect
107-
github.com/grafana/grafana-app-sdk/logging v0.35.1 // indirect
104+
github.com/grafana/grafana-app-sdk/logging v0.40.2 // indirect
108105
github.com/grafana/grafana-plugin-sdk-go v0.275.0 // indirect
109106
github.com/grafana/otel-profiling-go v0.5.1 // indirect
110107
github.com/grafana/pyroscope-go/godeltaprof v0.1.8 // indirect
111108
github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.0.1 // indirect
112109
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.1 // indirect
113-
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 // indirect
110+
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.1 // indirect
114111
github.com/hashicorp/cli v1.1.7 // indirect
115112
github.com/hashicorp/errwrap v1.1.0 // indirect
116113
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
@@ -119,7 +116,7 @@ require (
119116
github.com/hashicorp/go-multierror v1.1.1 // indirect
120117
github.com/hashicorp/go-plugin v1.6.3 // indirect
121118
github.com/hashicorp/logutils v1.0.0 // indirect
122-
github.com/hashicorp/terraform-registry-address v0.2.4 // indirect
119+
github.com/hashicorp/terraform-registry-address v0.2.5 // indirect
123120
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
124121
github.com/hashicorp/yamux v0.1.1 // indirect
125122
github.com/huandu/xstrings v1.5.0 // indirect
@@ -154,14 +151,15 @@ require (
154151
github.com/pierrec/lz4/v4 v4.1.22 // indirect
155152
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
156153
github.com/posener/complete v1.2.3 // indirect
157-
github.com/prometheus/client_golang v1.22.0 // indirect
154+
github.com/prometheus/client_golang v1.23.0 // indirect
158155
github.com/prometheus/client_model v0.6.2 // indirect
159-
github.com/prometheus/procfs v0.15.1 // indirect
156+
github.com/prometheus/procfs v0.16.1 // indirect
160157
github.com/rivo/uniseg v0.4.7 // indirect
161158
github.com/rs/zerolog v1.34.0 // indirect
162159
github.com/russross/blackfriday/v2 v2.1.0 // indirect
163160
github.com/shopspring/decimal v1.4.0 // indirect
164161
github.com/spf13/cast v1.7.1 // indirect
162+
github.com/stretchr/objx v0.5.2 // indirect
165163
github.com/unknwon/bra v0.0.0-20200517080246-1e3013ecaff8 // indirect
166164
github.com/unknwon/com v1.0.1 // indirect
167165
github.com/unknwon/log v0.0.0-20200308114134-929b1006e34a // indirect
@@ -181,20 +179,21 @@ require (
181179
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.60.0 // indirect
182180
go.opentelemetry.io/contrib/propagators/jaeger v1.35.0 // indirect
183181
go.opentelemetry.io/contrib/samplers/jaegerremote v0.29.0 // indirect
184-
go.opentelemetry.io/otel v1.36.0 // indirect
185-
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.35.0 // indirect
186-
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.35.0 // indirect
187-
go.opentelemetry.io/otel/metric v1.36.0 // indirect
188-
go.opentelemetry.io/otel/sdk v1.36.0 // indirect
189-
go.opentelemetry.io/otel/trace v1.36.0 // indirect
190-
go.opentelemetry.io/proto/otlp v1.5.0 // indirect
191-
golang.org/x/crypto v0.40.0 // indirect
182+
go.opentelemetry.io/otel v1.37.0 // indirect
183+
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.37.0 // indirect
184+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.37.0 // indirect
185+
go.opentelemetry.io/otel/metric v1.37.0 // indirect
186+
go.opentelemetry.io/otel/sdk v1.37.0 // indirect
187+
go.opentelemetry.io/otel/trace v1.37.0 // indirect
188+
go.opentelemetry.io/proto/otlp v1.7.0 // indirect
189+
go.yaml.in/yaml/v2 v2.4.2 // indirect
190+
golang.org/x/crypto v0.41.0 // indirect
192191
golang.org/x/mod v0.26.0 // indirect
193-
golang.org/x/net v0.42.0 // indirect
192+
golang.org/x/net v0.43.0 // indirect
194193
golang.org/x/oauth2 v0.30.0 // indirect
195194
golang.org/x/sync v0.16.0 // indirect
196-
golang.org/x/sys v0.34.0 // indirect
197-
golang.org/x/term v0.33.0 // indirect
195+
golang.org/x/sys v0.35.0 // indirect
196+
golang.org/x/term v0.34.0 // indirect
198197
golang.org/x/time v0.11.0 // indirect
199198
golang.org/x/tools v0.35.0 // indirect
200199
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect
@@ -208,15 +207,15 @@ require (
208207
gopkg.in/inf.v0 v0.9.1 // indirect
209208
gopkg.in/validator.v2 v2.0.1 // indirect
210209
gopkg.in/yaml.v3 v3.0.1 // indirect
211-
k8s.io/api v0.32.3 // indirect
212-
k8s.io/apiextensions-apiserver v0.32.3 // indirect
210+
k8s.io/api v0.33.3 // indirect
211+
k8s.io/apiextensions-apiserver v0.33.3 // indirect
213212
k8s.io/klog/v2 v2.130.1 // indirect
214213
k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff // indirect
215-
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect
216-
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect
214+
k8s.io/utils v0.0.0-20241210054802-24370beab758 // indirect
215+
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
217216
sigs.k8s.io/randfill v1.0.0 // indirect
218-
sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect
219-
sigs.k8s.io/yaml v1.4.0 // indirect
217+
sigs.k8s.io/structured-merge-diff/v4 v4.7.0 // indirect
218+
sigs.k8s.io/yaml v1.5.0 // indirect
220219
)
221220

222221
// https://github.com/hashicorp/terraform-exec/issues/423

0 commit comments

Comments
 (0)