https://github.com/timtorchen/terraform-module-grafana-rule-groups
Terraform helper module to create grafana alerts from json/yaml document
https://github.com/timtorchen/terraform-module-grafana-rule-groups
Last synced: 5 months ago
JSON representation
Terraform helper module to create grafana alerts from json/yaml document
- Host: GitHub
- URL: https://github.com/timtorchen/terraform-module-grafana-rule-groups
- Owner: timtorChen
- License: mit
- Created: 2024-10-04T05:44:46.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-09T02:27:11.000Z (over 1 year ago)
- Last Synced: 2025-04-01T18:03:35.420Z (about 1 year ago)
- Language: HCL
- Homepage: https://registry.terraform.io/modules/timtorChen/grafana-rule-groups/module/latest
- Size: 18.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Terraform grafana rule groups module
⚠️ This project is still under development; use it with caution.
The helper module to create grafana alerts from document following rule-groups [schema](./schema.json).
## Usage
Load rule groups document with `static_rule_groups` and customize fine-grained control on each rule with `rule_groups` dynamic variable.
```tf
# main.tf
resource "grafana_data_source" "prometheus" {
}
module "alert" {
source = "timtorChen/grafana-rule-groups/module"
version = "0.1.0"
folder_name = "node"
datasource_uid = grafana_data_source.prometheus.uid
static_rule_groups = yamldecode(templatefile("${path.module}/node-exporter-rules.yaml", {}))
rule_groups = {}
}
```
```yaml
# node-exporter-rules.yaml
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/timtorChen/terraform-module-grafana-rule-groups/refs/heads/main/schema.json
- name: metrics-check
interval_seconds: 300
rules:
- name: node-no-data
annotations:
summary: "Node-exporter metrics return NoData"
description: >-
Node-exporter metrics has been no data for 5 minutes.
Please check if node-exporter or Prometheus is working.
condition: "Z"
datas:
- ref_id: "Z"
model:
expr: "absent(node_uname_info) or vector(0)"
instant: true
no_data_state: "Alerting"
exec_err_state: "Error"
for: "5m"
labels:
severity: "critical"
```
## Requirements
| Name | Version |
| ------------------------------------------------------------------ | ------- |
| [grafana](#requirement_grafana) | 3.7.0 |
## Providers
| Name | Version |
| ------------------------------------------------------------ | ------- |
| [grafana](#provider_grafana) | 3.7.0 |
## Modules
No modules.
## Resources
| Name | Type |
| ------------------------------------------------------------------------------------------------------------------ | -------- |
| [grafana_folder.this](https://registry.terraform.io/providers/grafana/grafana/3.7.0/docs/resources/folder) | resource |
| [grafana_rule_group.this](https://registry.terraform.io/providers/grafana/grafana/3.7.0/docs/resources/rule_group) | resource |
## Inputs
| Name | Description | Type | Default | Required |
| --------------------------------------------------------------------------------------- | ----------- | ------------- | ------- | :------: |
| [folder_name](#input_folder_name) | n/a | `string` | n/a | yes |
| [labels](#input_labels) | n/a | `map(string)` | `{}` | no |
| [annotations](#input_annotations) | n/a | `map(string)` | `{}` | no |
| [datasource_uid](#input_datasource_uid) | n/a | `string` | `""` | no |
| [static_rule_groups](#input_static_rule_groups) | n/a | `any` | n/a | yes |
| [rule_groups](#input_rule_groups) | n/a | `any` | n/a | yes |
## Outputs
No outputs.