I am using Terraform to automate rule_group and dashboard generation. But I don’t think this solution is terraform specific. I currently have a 1 - 1 mapping between a rule in a group and a panel in a dashboard. Based on the exported config of rules, it looks like rules are linked to panels using __dashboardUid__
and __panelId__
. I was able to populate the __dashboardUid__
from the grafana_dashboard
tf resource. But I am not sure how I should populate __panelId__
.
Some of the approaches I tried:
- Specify
panelId
for each panel in grafana_dashboard. But looks like the panelId field in rules wants the value ofid
field. - Specify
id
for each panel in grafana_dashboard. But looks like this value is ignored when I runterraform apply
. - Using the index of panel and rule. Both the panels and rules are generated by iterating over a yaml file. It looks like this is working but I am not 100% if this will always work.