0

I am creating a dashboard that has different types of widgets. I want to make this dashboard as customizable as possible using the template variables. For this reason, I have a template variable that stores the env value.

In a service summary widget, it needs env value. Now, I am using the template variable to get the value there but it is not working.

widget {
    trace_service_definition {
        display_format     = "two_column"
    ==> env                = "$env.value"
        service            = "abcd"
        show_breakdown     = true
        show_distribution  = true
        show_errors        = true
        show_hits          = true
        show_latency       = true
        show_resource_list = false
        size_format        = "medium"
        span_name          = "metric.name.client"
        title              = "Service summary"
        }
        widget_layout {
        x      = 0
        y      = 2
        width  = 8
        height = 9
        }
}

Template variable

template_variable {
name    = "env"
prefix  = "env"
default = "dev"

}

Is there a way to use the template variable to get the value?

Ayush Ujjwal
  • 149
  • 9
  • 1
    You need to add curly brackets, i.e. `${env}`, or if the name of the variable really is `env.value` then `${env.value}` but I'm guessing there is some code missing, so it would be good to add the `templatefile` call as well to the question. – Marko E Jan 21 '22 at 14:48
  • @MarkoE If I am not wrong you are confusing the template variables with the variables from vars.tf file. The template variable is the variable we are using to create a custom dashboard using the variable. The code is """ template_variable { name = "region" prefix = "region" default = "us_west_1" } """ – Ayush Ujjwal Jan 27 '22 at 12:13
  • If I am confusing it, that's because I'm missing the code. :) Would you mind updating the question with the call to `templatefile` and variables file? – Marko E Jan 27 '22 at 12:19
  • @MarkoE I have updated the code with the template variable used in the terraform file. – Ayush Ujjwal Jan 27 '22 at 12:35
  • Still a lot of code is missing. Are you using the `templatefile` function to populate the values you want or you just want to use the `templatefile_variable` instead of `${env}`? – Marko E Jan 27 '22 at 13:03
  • Hey @MarkoE, sorry for replying later due to some inconveniences. I was trying to use a template variable just like you get on the dashboards on datadog to use in the widgets. I was able to achieve the same using the `.value` property. Hence, it is working now. The issue is I don't know if we can use this value to compare with other values as such. – Ayush Ujjwal Feb 18 '22 at 07:56

0 Answers0