Implement Data Collection Rule for Container Insights#623
Conversation
6d4a17e to
74b27bc
Compare
|
@lonegunmanb this PR was implemented looking at the documentation example available here: Cc: @ganga1980 and @wanlonghenry in case they have review comments. Thanks |
74b27bc to
9c5f699
Compare
9c5f699 to
95da31f
Compare
lonegunmanb
left a comment
There was a problem hiding this comment.
@zioproto We've got the following error:
TestExamplesForV4/application_gateway_ingress_v4 2024-12-20T16:01:45Z retry.go:99: Returning due to fatal error: FatalError{Underlying: error while running command: exit status 1; ╷
│ Error: Attempt to get attribute from null value
│
│ on ../../v4/log_analytics.tf line 86, in locals:
│ 86: dcr_location = coalesce(local.log_analytics_workspace.location, try(data.azurerm_log_analytics_workspace.main[0].location, null))
│ ├────────────────
│ │ local.log_analytics_workspace is null
│
│ This value is null, so it does not have any attributes.
╵}
apply.go:34:
Error Trace: /src/test/vendor/github.com/gruntwork-io/terratest/modules/terraform/apply.go:34
/src/test/vendor/github.com/Azure/terraform-module-test-helper/e2etest.go:107
/src/test/vendor/github.com/Azure/terraform-module-test-helper/e2etest.go:87
/src/test/vendor/github.com/Azure/terraform-module-test-helper/e2etest.go:55
/src/test/e2e/terraform_aks_test.go:211
Error: Received unexpected error:
FatalError{Underlying: error while running command: exit status 1; ╷
│ Error: Attempt to get attribute from null value
│
│ on ../../v4/log_analytics.tf line 86, in locals:
│ 86: dcr_location = coalesce(local.log_analytics_workspace.location, try(data.azurerm_log_analytics_workspace.main[0].location, null))
│ ├────────────────
│ │ local.log_analytics_workspace is null
│
│ This value is null, so it does not have any attributes.
╵}
Test: TestExamplesForV4/application_gateway_ingress_v4
Need further investigation.
| } | ||
|
|
||
| locals { | ||
| dcr_location = coalesce(local.log_analytics_workspace.location, try(data.azurerm_log_analytics_workspace.main[0].location, null)) |
There was a problem hiding this comment.
Could we try coalesce(try(local.log_analytics_workspace.location, null), try(data.azurerm_log_analytics_workspace.main[0].location, null)) here?
95da31f to
6e4c7a6
Compare
6e4c7a6 to
d7fcda5
Compare
d7fcda5 to
b70b241
Compare
b70b241 to
5af1c80
Compare
5af1c80 to
e40655b
Compare
e40655b to
6b92981
Compare
|
@lonegunmanb I managed to find the correct expression, the E2E tests are now passing. Please have a look. Thanks |
lonegunmanb
left a comment
There was a problem hiding this comment.
Thanks @zioproto , some comments
| data_sources { | ||
| syslog { | ||
| streams = ["Microsoft-Syslog"] | ||
| facility_names = var.syslog_facilities |
There was a problem hiding this comment.
Could we rename this new variable to monitor_data_collection_rule_data_sources_syslog_facilities?
| syslog { | ||
| streams = ["Microsoft-Syslog"] | ||
| facility_names = var.syslog_facilities | ||
| log_levels = var.syslog_levels |
There was a problem hiding this comment.
Could we rename this new variable to monitor_data_collection_rule_data_sources_syslog_levels?
| } | ||
|
|
||
| extension { | ||
| streams = var.streams |
There was a problem hiding this comment.
Could we rename this new variable to monitor_data_collection_rule_extensions_streams?
| "namespaces" : var.data_collection_settings.namespaces_for_data_collection, | ||
| "enableContainerLogV2" : var.data_collection_settings.container_log_v2_enabled, | ||
| } | ||
| }) |
There was a problem hiding this comment.
We could use HCL syntax here:
{
dataCollectionSettings = {
interval = var.data_collection_settings.data_collection_interval
namespaceFilteringMode = var.data_collection_settings.namespace_filtering_mode_for_data_collection
namespaces = var.data_collection_settings.namespaces_for_data_collection
enableContainerLogV2 = var.data_collection_settings.container_log_v2_enabled
}
}| } | ||
|
|
||
| resource "azurerm_monitor_data_collection_rule" "dcr" { | ||
| count = (var.log_analytics_workspace_enabled && var.oms_agent_enabled) ? 1 : 0 |
There was a problem hiding this comment.
Would count = (local.create_analytics_workspace && var.oms_agent_enabled) ? 1 : 0 be better?
| } | ||
|
|
||
| resource "azurerm_monitor_data_collection_rule_association" "dcra" { | ||
| count = (var.log_analytics_workspace_enabled && var.oms_agent_enabled) ? 1 : 0 |
There was a problem hiding this comment.
Would count = (local.create_analytics_workspace && var.oms_agent_enabled) ? 1 : 0 be better?
6b92981 to
8c6fd61
Compare
Describe your changes
Implement Data Collection Rule for Container Insights. This completes the work started in PR #446
Issue number
#607
Checklist before requesting a review
CHANGELOG.mdfile