-
Notifications
You must be signed in to change notification settings - Fork 500
Implement Data Collection Rule for Container Insights #623
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
log_analytics.tf
Outdated
| } | ||
|
|
||
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @zioproto , some comments
log_analytics.tf
Outdated
| data_sources { | ||
| syslog { | ||
| streams = ["Microsoft-Syslog"] | ||
| facility_names = var.syslog_facilities |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we rename this new variable to monitor_data_collection_rule_data_sources_syslog_facilities?
log_analytics.tf
Outdated
| syslog { | ||
| streams = ["Microsoft-Syslog"] | ||
| facility_names = var.syslog_facilities | ||
| log_levels = var.syslog_levels |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we rename this new variable to monitor_data_collection_rule_data_sources_syslog_levels?
log_analytics.tf
Outdated
| } | ||
|
|
||
| extension { | ||
| streams = var.streams |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
}
}
log_analytics.tf
Outdated
| } | ||
|
|
||
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would count = (local.create_analytics_workspace && var.oms_agent_enabled) ? 1 : 0 be better?
log_analytics.tf
Outdated
| } | ||
|
|
||
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would count = (local.create_analytics_workspace && var.oms_agent_enabled) ? 1 : 0 be better?
6b92981 to
8c6fd61
Compare
lonegunmanb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @zioproto, LGTM!
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