|
| 1 | +resource "grafana_apps_alertenrichment_alertenrichment_v1beta1" "enrichment" { |
| 2 | + metadata { |
| 3 | + uid = "test_enrichment" |
| 4 | + } |
| 5 | + |
| 6 | + spec { |
| 7 | + title = "Comprehensive alert enrichment" |
| 8 | + description = "Demonstrates many enrichment steps and configurations" |
| 9 | + |
| 10 | + # Target specific alert rules by UIDs |
| 11 | + alert_rule_uids = ["alert-rule-1", "alert-rule-2"] |
| 12 | + |
| 13 | + # Target specific receiver names |
| 14 | + receivers = ["webhook", "slack-critical"] |
| 15 | + |
| 16 | + # Label matchers - supports =, !=, =~, !~ operators |
| 17 | + label_matchers = [ |
| 18 | + { |
| 19 | + type = "=" |
| 20 | + name = "severity" |
| 21 | + value = "critical" |
| 22 | + }, |
| 23 | + { |
| 24 | + type = "=~" |
| 25 | + name = "team" |
| 26 | + value = "alerting|alerting-team" |
| 27 | + } |
| 28 | + ] |
| 29 | + |
| 30 | + # Annotation matchers |
| 31 | + annotation_matchers = [ |
| 32 | + { |
| 33 | + type = "!=" |
| 34 | + name = "runbook_url" |
| 35 | + value = "" |
| 36 | + } |
| 37 | + ] |
| 38 | + |
| 39 | + # Adds annotations to alerts with the assign step |
| 40 | + step { |
| 41 | + assign { |
| 42 | + timeout = "30s" |
| 43 | + annotations = { |
| 44 | + "priority" = "high" |
| 45 | + "runbook_url" = "https://runbooks.grafana.com/alert-handling" |
| 46 | + } |
| 47 | + } |
| 48 | + } |
| 49 | + |
| 50 | + # Calls external service |
| 51 | + step { |
| 52 | + external { |
| 53 | + url = "https://some-api.grafana.com/alert-enrichment" |
| 54 | + } |
| 55 | + } |
| 56 | + |
| 57 | + # Data source step with logs query |
| 58 | + step { |
| 59 | + data_source { |
| 60 | + timeout = "30s" |
| 61 | + |
| 62 | + logs_query { |
| 63 | + data_source_type = "loki" |
| 64 | + data_source_uid = "loki-uid-123" |
| 65 | + expr = "{job=\"my-app\"} |= \"error\"" |
| 66 | + max_lines = 5 |
| 67 | + } |
| 68 | + } |
| 69 | + } |
| 70 | + |
| 71 | + # Data source step with raw query |
| 72 | + step { |
| 73 | + data_source { |
| 74 | + timeout = "30s" |
| 75 | + |
| 76 | + raw_query { |
| 77 | + ref_id = "A" |
| 78 | + request = jsonencode({ |
| 79 | + datasource = { |
| 80 | + type = "prometheus" |
| 81 | + uid = "prometheus-uid-456" |
| 82 | + } |
| 83 | + expr = "rate(http_requests_total[5m])" |
| 84 | + refId = "A" |
| 85 | + intervalMs = 1000 |
| 86 | + maxDataPoints = 43200 |
| 87 | + }) |
| 88 | + } |
| 89 | + } |
| 90 | + } |
| 91 | + |
| 92 | + # Triggers a new Sift investigation |
| 93 | + step { |
| 94 | + sift {} |
| 95 | + } |
| 96 | + |
| 97 | + # Generates AI explanation of the alert using Grafana LLM plugin |
| 98 | + step { |
| 99 | + explain { |
| 100 | + annotation = "ai_explanation" |
| 101 | + } |
| 102 | + } |
| 103 | + |
| 104 | + |
| 105 | + # Trigger a new Assistant Investigation |
| 106 | + step { |
| 107 | + assistant_investigations {} |
| 108 | + } |
| 109 | + } |
| 110 | +} |
0 commit comments