diff --git a/internal/services/monitor/monitor_data_collection_rule_resource.go b/internal/services/monitor/monitor_data_collection_rule_resource.go index 230e83f1b0ea..0dce4ced7aaa 100644 --- a/internal/services/monitor/monitor_data_collection_rule_resource.go +++ b/internal/services/monitor/monitor_data_collection_rule_resource.go @@ -865,6 +865,7 @@ func (r DataCollectionRuleResource) Arguments() map[string]*pluginsdk.Schema { "Linux", "Windows", "AgentDirectToStore", + "WorkspaceTransforms", }, false), }, diff --git a/internal/services/monitor/monitor_data_collection_rule_resource_test.go b/internal/services/monitor/monitor_data_collection_rule_resource_test.go index 79936ac4b4a9..39a65a01dae4 100644 --- a/internal/services/monitor/monitor_data_collection_rule_resource_test.go +++ b/internal/services/monitor/monitor_data_collection_rule_resource_test.go @@ -65,6 +65,21 @@ func TestAccMonitorDataCollectionRule_kindDirectToStore(t *testing.T) { }) } +func TestAccMonitorDataCollectionRule_kindWorkspaceTransforms(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_monitor_data_collection_rule", "test") + r := MonitorDataCollectionRuleResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.kindWorkspaceTransforms(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + func TestAccMonitorDataCollectionRule_identity(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_monitor_data_collection_rule", "test") r := MonitorDataCollectionRuleResource{} @@ -270,6 +285,39 @@ resource "azurerm_monitor_data_collection_rule" "test" { `, r.template(data), data.RandomInteger, data.RandomString) } +func (r MonitorDataCollectionRuleResource) kindWorkspaceTransforms(data acceptance.TestData) string { + return fmt.Sprintf(` +%[1]s + +resource "azurerm_log_analytics_workspace" "test" { + name = "acctest-law-%[2]d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + sku = "PerGB2018" + retention_in_days = 30 +} + +resource "azurerm_monitor_data_collection_rule" "test" { + name = "acctestmdcr-%[2]d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + kind = "WorkspaceTransforms" + destinations { + log_analytics { + workspace_resource_id = azurerm_log_analytics_workspace.test.id + name = "test-destination-log" + } + } + + data_flow { + streams = ["Microsoft-Table-LAQueryLogs"] + destinations = ["test-destination-log"] + transform_kql = "source | where QueryText !contains 'LAQueryLogs' | extend Context = parse_json(RequestContext) | extend Resources_CF = tostring(Context['workspaces'])" + } +} +`, r.template(data), data.RandomInteger, data.RandomString) +} + func (r MonitorDataCollectionRuleResource) systemAssigned(data acceptance.TestData) string { return fmt.Sprintf(` %[1]s diff --git a/website/docs/r/monitor_data_collection_rule.html.markdown b/website/docs/r/monitor_data_collection_rule.html.markdown index 01b4e320bb71..ccd02fc2cced 100644 --- a/website/docs/r/monitor_data_collection_rule.html.markdown +++ b/website/docs/r/monitor_data_collection_rule.html.markdown @@ -233,7 +233,7 @@ The following arguments are supported: * `identity` - (Optional) An `identity` block as defined below. -* `kind` - (Optional) The kind of the Data Collection Rule. Possible values are `Linux`, `Windows`,and `AgentDirectToStore`. A rule of kind `Linux` does not allow for `windows_event_log` data sources. And a rule of kind `Windows` does not allow for `syslog` data sources. If kind is not specified, all kinds of data sources are allowed. +* `kind` - (Optional) The kind of the Data Collection Rule. Possible values are `Linux`, `Windows`, `AgentDirectToStore` and `WorkspaceTransforms`. A rule of kind `Linux` does not allow for `windows_event_log` data sources. And a rule of kind `Windows` does not allow for `syslog` data sources. If kind is not specified, all kinds of data sources are allowed. ~> **NOTE** Once `kind` has been set, changing it forces a new Data Collection Rule to be created.