terraform-provider-grafana icon indicating copy to clipboard operation
terraform-provider-grafana copied to clipboard

[Feature Request]: Add a way to increment __panelId__ parameter dynamically

Open RorFis opened this issue 8 months ago • 2 comments

Feature Request

I create alert rules dynamically and I link alerts to a dashboard panel dynamically as well. I use a system of inventory which is a file in json containing a list of each instance of an alert (for example a list of multiple servers with their name, disk, ram and cpu threshold). As of today, I only have 3 possibilities to make this work :

  • Create a dashboard with panels side by side and incrementing the panelid by 1 each time ( when I only have one rule block in grafana_rule_group resource that I instantiate by looping over the list)
  • Create a dashboard with rows that have exactly the same number of panel. In that case I can increment the panelId in each of the rule block (1 by panel in the row) by using a modulo to always find the right paneIld (basically it's list Index * number of panels in row + place in row)
  • Create a dashboard that use the panelId parameter in the list (which is not really practical when I need to do changes)

The problem comes when I have a dashboard with multiple rows that are not exactly the same. For example if I have a dashboard with disk, cpu and ram and I want 1 of the servers to have an alert on its network traffic, it breaks the modulo and I can't set the PanelId dynamicaly anymore.

What I need is a way to set PanelId dynamically when using multiple rule blocks and each instance of an alert should have the knowledge of the previous value of panelId.

RorFis avatar Jun 12 '24 09:06 RorFis