DataCollectionRule

class DataCollectionRule : KotlinCustomResource

Manages a Data Collection Rule.

Example Usage

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azure.core.ResourceGroup;
import com.pulumi.azure.core.ResourceGroupArgs;
import com.pulumi.azure.authorization.UserAssignedIdentity;
import com.pulumi.azure.authorization.UserAssignedIdentityArgs;
import com.pulumi.azure.operationalinsights.AnalyticsWorkspace;
import com.pulumi.azure.operationalinsights.AnalyticsWorkspaceArgs;
import com.pulumi.azure.operationalinsights.AnalyticsSolution;
import com.pulumi.azure.operationalinsights.AnalyticsSolutionArgs;
import com.pulumi.azure.operationalinsights.inputs.AnalyticsSolutionPlanArgs;
import com.pulumi.azure.eventhub.EventHubNamespace;
import com.pulumi.azure.eventhub.EventHubNamespaceArgs;
import com.pulumi.azure.eventhub.EventHub;
import com.pulumi.azure.eventhub.EventHubArgs;
import com.pulumi.azure.storage.Account;
import com.pulumi.azure.storage.AccountArgs;
import com.pulumi.azure.storage.Container;
import com.pulumi.azure.storage.ContainerArgs;
import com.pulumi.azure.monitoring.DataCollectionEndpoint;
import com.pulumi.azure.monitoring.DataCollectionEndpointArgs;
import com.pulumi.azure.monitoring.DataCollectionRule;
import com.pulumi.azure.monitoring.DataCollectionRuleArgs;
import com.pulumi.azure.monitoring.inputs.DataCollectionRuleDestinationsArgs;
import com.pulumi.azure.monitoring.inputs.DataCollectionRuleDestinationsEventHubArgs;
import com.pulumi.azure.monitoring.inputs.DataCollectionRuleDestinationsAzureMonitorMetricsArgs;
import com.pulumi.azure.monitoring.inputs.DataCollectionRuleDataFlowArgs;
import com.pulumi.azure.monitoring.inputs.DataCollectionRuleDataSourcesArgs;
import com.pulumi.azure.monitoring.inputs.DataCollectionRuleStreamDeclarationArgs;
import com.pulumi.azure.monitoring.inputs.DataCollectionRuleIdentityArgs;
import static com.pulumi.codegen.internal.Serialization.*;
import com.pulumi.resources.CustomResourceOptions;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var exampleResourceGroup = new ResourceGroup("exampleResourceGroup", ResourceGroupArgs.builder()
.location("West Europe")
.build());
var exampleUserAssignedIdentity = new UserAssignedIdentity("exampleUserAssignedIdentity", UserAssignedIdentityArgs.builder()
.resourceGroupName(exampleResourceGroup.name())
.location(exampleResourceGroup.location())
.build());
var exampleAnalyticsWorkspace = new AnalyticsWorkspace("exampleAnalyticsWorkspace", AnalyticsWorkspaceArgs.builder()
.resourceGroupName(exampleResourceGroup.name())
.location(exampleResourceGroup.location())
.build());
var exampleAnalyticsSolution = new AnalyticsSolution("exampleAnalyticsSolution", AnalyticsSolutionArgs.builder()
.solutionName("WindowsEventForwarding")
.location(exampleResourceGroup.location())
.resourceGroupName(exampleResourceGroup.name())
.workspaceResourceId(exampleAnalyticsWorkspace.id())
.workspaceName(exampleAnalyticsWorkspace.name())
.plan(AnalyticsSolutionPlanArgs.builder()
.publisher("Microsoft")
.product("OMSGallery/WindowsEventForwarding")
.build())
.build());
var exampleEventHubNamespace = new EventHubNamespace("exampleEventHubNamespace", EventHubNamespaceArgs.builder()
.location(exampleResourceGroup.location())
.resourceGroupName(exampleResourceGroup.name())
.sku("Standard")
.capacity(1)
.build());
var exampleEventHub = new EventHub("exampleEventHub", EventHubArgs.builder()
.namespaceName(exampleEventHubNamespace.name())
.resourceGroupName(exampleResourceGroup.name())
.partitionCount(2)
.messageRetention(1)
.build());
var exampleAccount = new Account("exampleAccount", AccountArgs.builder()
.resourceGroupName(exampleResourceGroup.name())
.location(exampleResourceGroup.location())
.accountTier("Standard")
.accountReplicationType("LRS")
.build());
var exampleContainer = new Container("exampleContainer", ContainerArgs.builder()
.storageAccountName(exampleAccount.name())
.containerAccessType("private")
.build());
var exampleDataCollectionEndpoint = new DataCollectionEndpoint("exampleDataCollectionEndpoint", DataCollectionEndpointArgs.builder()
.resourceGroupName(exampleResourceGroup.name())
.location(exampleResourceGroup.location())
.build());
var exampleDataCollectionRule = new DataCollectionRule("exampleDataCollectionRule", DataCollectionRuleArgs.builder()
.resourceGroupName(exampleResourceGroup.name())
.location(exampleResourceGroup.location())
.dataCollectionEndpointId(exampleDataCollectionEndpoint.id())
.destinations(DataCollectionRuleDestinationsArgs.builder()
.logAnalytics(DataCollectionRuleDestinationsLogAnalyticArgs.builder()
.workspaceResourceId(exampleAnalyticsWorkspace.id())
.name("example-destination-log")
.build())
.eventHub(DataCollectionRuleDestinationsEventHubArgs.builder()
.eventHubId(exampleEventHub.id())
.name("example-destination-eventhub")
.build())
.storageBlobs(DataCollectionRuleDestinationsStorageBlobArgs.builder()
.storageAccountId(exampleAccount.id())
.containerName(exampleContainer.name())
.name("example-destination-storage")
.build())
.azureMonitorMetrics(DataCollectionRuleDestinationsAzureMonitorMetricsArgs.builder()
.name("example-destination-metrics")
.build())
.build())
.dataFlows(
DataCollectionRuleDataFlowArgs.builder()
.streams("Microsoft-InsightsMetrics")
.destinations("example-destination-metrics")
.build(),
DataCollectionRuleDataFlowArgs.builder()
.streams(
"Microsoft-InsightsMetrics",
"Microsoft-Syslog",
"Microsoft-Perf")
.destinations("example-destination-log")
.build(),
DataCollectionRuleDataFlowArgs.builder()
.streams("Custom-MyTableRawData")
.destinations("example-destination-log")
.outputStream("Microsoft-Syslog")
.transformKql("source | project TimeGenerated = Time, Computer, Message = AdditionalContext")
.build())
.dataSources(DataCollectionRuleDataSourcesArgs.builder()
.syslogs(DataCollectionRuleDataSourcesSyslogArgs.builder()
.facilityNames("*")
.logLevels("*")
.name("example-datasource-syslog")
.streams("Microsoft-Syslog")
.build())
.iisLogs(DataCollectionRuleDataSourcesIisLogArgs.builder()
.streams("Microsoft-W3CIISLog")
.name("example-datasource-iis")
.logDirectories("C:\\Logs\\W3SVC1")
.build())
.logFiles(DataCollectionRuleDataSourcesLogFileArgs.builder()
.name("example-datasource-logfile")
.format("text")
.streams("Custom-MyTableRawData")
.filePatterns("C:\\JavaLogs\\*.log")
.settings(DataCollectionRuleDataSourcesLogFileSettingsArgs.builder()
.text(DataCollectionRuleDataSourcesLogFileSettingsTextArgs.builder()
.recordStartTimestampFormat("ISO 8601")
.build())
.build())
.build())
.performanceCounters(DataCollectionRuleDataSourcesPerformanceCounterArgs.builder()
.streams(
"Microsoft-Perf",
"Microsoft-InsightsMetrics")
.samplingFrequencyInSeconds(60)
.counterSpecifiers("Processor(*)\\% Processor Time")
.name("example-datasource-perfcounter")
.build())
.windowsEventLogs(DataCollectionRuleDataSourcesWindowsEventLogArgs.builder()
.streams("Microsoft-WindowsEvent")
.xPathQueries("*![System/Level=1]")
.name("example-datasource-wineventlog")
.build())
.extensions(DataCollectionRuleDataSourcesExtensionArgs.builder()
.streams("Microsoft-WindowsEvent")
.inputDataSources("example-datasource-wineventlog")
.extensionName("example-extension-name")
.extensionJson(serializeJson(
jsonObject(
jsonProperty("a", 1),
jsonProperty("b", "hello")
)))
.name("example-datasource-extension")
.build())
.build())
.streamDeclarations(DataCollectionRuleStreamDeclarationArgs.builder()
.streamName("Custom-MyTableRawData")
.columns(
DataCollectionRuleStreamDeclarationColumnArgs.builder()
.name("Time")
.type("datetime")
.build(),
DataCollectionRuleStreamDeclarationColumnArgs.builder()
.name("Computer")
.type("string")
.build(),
DataCollectionRuleStreamDeclarationColumnArgs.builder()
.name("AdditionalContext")
.type("string")
.build())
.build())
.identity(DataCollectionRuleIdentityArgs.builder()
.type("UserAssigned")
.identityIds(exampleUserAssignedIdentity.id())
.build())
.description("data collection rule example")
.tags(Map.of("foo", "bar"))
.build(), CustomResourceOptions.builder()
.dependsOn(exampleAnalyticsSolution)
.build());
}
}

Import

Data Collection Rules can be imported using the resource id, e.g.

$ pulumi import azure:monitoring/dataCollectionRule:DataCollectionRule example /subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.Insights/dataCollectionRules/rule1

Properties

Link copied to clipboard

The resource ID of the Data Collection Endpoint that this rule can be used with.

Link copied to clipboard

One or more data_flow blocks as defined below.

Link copied to clipboard

A data_sources block as defined below. This property is optional and can be omitted if the rule is meant to be used via direct calls to the provisioned endpoint.

Link copied to clipboard
val description: Output<String>?

The description of the Data Collection Rule.

Link copied to clipboard

A destinations block as defined below.

Link copied to clipboard
val id: Output<String>
Link copied to clipboard

An identity block as defined below.

Link copied to clipboard
val immutableId: Output<String>

The immutable ID of the Data Collection Rule.

Link copied to clipboard
val kind: Output<String>?

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.

Link copied to clipboard
val location: Output<String>

The Azure Region where the Data Collection Rule should exist. Changing this forces a new Data Collection Rule to be created.

Link copied to clipboard
val name: Output<String>

The name which should be used for this Data Collection Rule. Changing this forces a new Data Collection Rule to be created.

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

The name of the Resource Group where the Data Collection Rule should exist. Changing this forces a new Data Collection Rule to be created.

Link copied to clipboard

A stream_declaration block as defined below.

Link copied to clipboard
val tags: Output<Map<String, String>>?

A mapping of tags which should be assigned to the Data Collection Rule.

Link copied to clipboard
val urn: Output<String>