Skip to content
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

azurerm_monitor_data_collection_rule - support WorkspaceTransforms for kind #23873

Merged
merged 2 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,7 @@ func (r DataCollectionRuleResource) Arguments() map[string]*pluginsdk.Schema {
"Linux",
"Windows",
"AgentDirectToStore",
"WorkspaceTransforms",
},
false),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
Loading