Closed rudolf-repcin closed 5 months ago
@rudolf-repcin I think this is the section your'e looking for
grouping = {
aggregations = [
{
aggregation = {
type = "count"
}
name = "Count"
},
]
group_bys = [
{
keypath = ["ingressTimestamp"]
scope = "metadata"
},
]
}
@rudolf-repcin please let me know if it solved your issue, so I can close it.
Hello, the snippet you suggested is exactly what I already tried: It's in "coralogix_dashboard resource snippet 2" code snippet in the issue description
@rudolf-repcin I see what you say. I'll set the aggregation id to optional so you could set it as option 3. Look for next release.
Thank you very much.
Works like a charm now!! Thank you very much for resolving this frustrating issue we struggled with for a long time now.
Affected Resource(s)
Terraform Configuration Files
coralogix_dashboard resource snippet 1
Here I have used official Coralogix TF 1.13.4 documentation to build a data table - however not sure how to reference the Aggregation in the column so I used its name. I also tried just with "Aggregation". ```hcl resource "coralogix_dashboard" "test1" { layout = { sections = [ { rows = [ { height = 19 widgets = [ { definition = { data_table = { query = { logs = { filter = [ { logs = { field = "applicationname" operator = { type = "equals" selected_values = ["xxx"] } } }, { logs = { field = "subsystemname" operator = { type = "equals" selected_values = ["xxx"] } } } ] aggregation = { type = "count" } group_names_fields = [ { keypath = ["xxx", "xxx", "xxx"] scope = "label" } ] } } results_per_page = 10 row_style = "one_line" columns = [ { field = "GroupBy:coralogix.metadata.subsystemName" }, { field = "Aggregation:Count" } ] data_mode_type = "archive" order_by = { field = "Aggregation:Count" order_direction = "desc" } } } title = "New Data Table" } ] } ] } ] } name = "Dashboard TEST" } ```coralogix_dashboard resource snippet 2
Here I have used extracted code from tfstate after creating the dashboard manually in the UI and then using "data" source in Terraform to load it into tfstate. This one has a different structure than that provided in the documentation. Here I'm trying to use the aggregation name. ```hcl resource "coralogix_dashboard" "test2" { layout = { sections = [ { rows = [ { height = 19 widgets = [ { definition = { data_table = { columns = [ { field = "GroupBy:xxx" }, { field = "Aggregation:Count" width = 200 } ] data_mode_type = "archive" order_by = { field = "Aggregation:Count" order_direction = "desc" } query = { logs = { filters = [ { field = "applicationname" observation_field = { keypath = ["applicationname"] scope = "label" } operator = { selected_values = ["xxx"] type = "equals" } }, { field = "subsystemname" observation_field = { keypath = ["subsystemname"] scope = "label" } operator = { selected_values = ["xxx"] type = "equals" } } ], grouping = { aggregations = [ { aggregation = { type = "count" } is_visible = true name = "Count" } ] group_bys = [ { keypath = ["xxx", "xxx", "xxx"] scope = "user_data" } ] } } } results_per_page = 10 row_style = "one_line" } } title = "New Data Table" } ] } ] } ] } name = "Dashboard TEST" } ```coralogix_dashboard resource snippet 3
Here I'm also using the code from tfstate, however I tried to assign the "id" to the aggregation definition and referenced it in column and order by. ```hcl resource "coralogix_dashboard" "test3" { layout = { sections = [ { rows = [ { height = 19 widgets = [ { definition = { data_table = { columns = [ { field = "GroupBy:xxx" }, { field = "Aggregation:8e21cba0-070b-79f1-3c1c-05b50f72dacc" width = 200 } ] data_mode_type = "archive" order_by = { field = "Aggregation:8e21cba0-070b-79f1-3c1c-05b50f72dacc" order_direction = "desc" } query = { logs = { filters = [ { field = "applicationname" observation_field = { keypath = ["applicationname"] scope = "label" } operator = { selected_values = ["xxx"] type = "equals" } }, { field = "subsystemname" observation_field = { keypath = ["subsystemname"] scope = "label" } operator = { selected_values = ["xxx"] type = "equals" } } ], grouping = { aggregations = [ { aggregation = { type = "count" } id = "8e21cba0-070b-79f1-3c1c-05b50f72dacc" is_visible = true name = "Count" } ] group_bys = [ { keypath = ["xxx", "xxx", "xxx"] scope = "user_data" } ] } } } results_per_page = 10 row_style = "one_line" } } title = "New Data Table" } ] } ] } ] } name = "Dashboard TEST" } ```Debug Output
Dashboard 1: Terraform passed but created dashboard contains an Event type data table instead of Aggregation type Dashboard 2: Terraform passed but the dashboard fails to load in the UI. Browser console contains this error:
TypeError: column is undefined
Also:Dashboard 3: Terraform fails with:
Expected Behavior
It should be possible to create a dashboard containing data table widget with aggregations via Terraform.
Actual Behavior
It's not possible to create a dashboard containing data table widget with aggregations using latest Terraform provider.
Important Factoids
Terraform 1.6.6 Coralogix TF provider 1.13.4
Community Note