DiagnosticSettingArgs

data class DiagnosticSettingArgs(val enabledLogs: Output<List<DiagnosticSettingEnabledLogArgs>>? = null, val eventhubAuthorizationRuleId: Output<String>? = null, val eventhubName: Output<String>? = null, val logAnalyticsDestinationType: Output<String>? = null, val logAnalyticsWorkspaceId: Output<String>? = null, val metrics: Output<List<DiagnosticSettingMetricArgs>>? = null, val name: Output<String>? = null, val partnerSolutionId: Output<String>? = null, val storageAccountId: Output<String>? = null, val targetResourceId: Output<String>? = null) : ConvertibleToJava<DiagnosticSettingArgs>

Manages a Diagnostic Setting for an existing Resource.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
const example = new azure.core.ResourceGroup("example", {
name: "example-resources",
location: "West Europe",
});
const exampleAccount = new azure.storage.Account("example", {
name: "storageaccountname",
resourceGroupName: example.name,
location: example.location,
accountTier: "Standard",
accountReplicationType: "LRS",
});
const current = azure.core.getClientConfig({});
const exampleKeyVault = new azure.keyvault.KeyVault("example", {
name: "examplekeyvault",
location: example.location,
resourceGroupName: example.name,
tenantId: current.then(current => current.tenantId),
softDeleteRetentionDays: 7,
purgeProtectionEnabled: false,
skuName: "standard",
});
const exampleDiagnosticSetting = new azure.monitoring.DiagnosticSetting("example", {
name: "example",
targetResourceId: exampleKeyVault.id,
storageAccountId: exampleAccount.id,
enabledLogs: [{
category: "AuditEvent",
}],
metrics: [{
category: "AllMetrics",
}],
});
import pulumi
import pulumi_azure as azure
example = azure.core.ResourceGroup("example",
name="example-resources",
location="West Europe")
example_account = azure.storage.Account("example",
name="storageaccountname",
resource_group_name=example.name,
location=example.location,
account_tier="Standard",
account_replication_type="LRS")
current = azure.core.get_client_config()
example_key_vault = azure.keyvault.KeyVault("example",
name="examplekeyvault",
location=example.location,
resource_group_name=example.name,
tenant_id=current.tenant_id,
soft_delete_retention_days=7,
purge_protection_enabled=False,
sku_name="standard")
example_diagnostic_setting = azure.monitoring.DiagnosticSetting("example",
name="example",
target_resource_id=example_key_vault.id,
storage_account_id=example_account.id,
enabled_logs=[{
"category": "AuditEvent",
}],
metrics=[{
"category": "AllMetrics",
}])
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Azure = Pulumi.Azure;
return await Deployment.RunAsync(() =>
{
var example = new Azure.Core.ResourceGroup("example", new()
{
Name = "example-resources",
Location = "West Europe",
});
var exampleAccount = new Azure.Storage.Account("example", new()
{
Name = "storageaccountname",
ResourceGroupName = example.Name,
Location = example.Location,
AccountTier = "Standard",
AccountReplicationType = "LRS",
});
var current = Azure.Core.GetClientConfig.Invoke();
var exampleKeyVault = new Azure.KeyVault.KeyVault("example", new()
{
Name = "examplekeyvault",
Location = example.Location,
ResourceGroupName = example.Name,
TenantId = current.Apply(getClientConfigResult => getClientConfigResult.TenantId),
SoftDeleteRetentionDays = 7,
PurgeProtectionEnabled = false,
SkuName = "standard",
});
var exampleDiagnosticSetting = new Azure.Monitoring.DiagnosticSetting("example", new()
{
Name = "example",
TargetResourceId = exampleKeyVault.Id,
StorageAccountId = exampleAccount.Id,
EnabledLogs = new[]
{
new Azure.Monitoring.Inputs.DiagnosticSettingEnabledLogArgs
{
Category = "AuditEvent",
},
},
Metrics = new[]
{
new Azure.Monitoring.Inputs.DiagnosticSettingMetricArgs
{
Category = "AllMetrics",
},
},
});
});
package main
import (
"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/core"
"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/keyvault"
"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/monitoring"
"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/storage"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := core.NewResourceGroup(ctx, "example", &core.ResourceGroupArgs{
Name: pulumi.String("example-resources"),
Location: pulumi.String("West Europe"),
})
if err != nil {
return err
}
exampleAccount, err := storage.NewAccount(ctx, "example", &storage.AccountArgs{
Name: pulumi.String("storageaccountname"),
ResourceGroupName: example.Name,
Location: example.Location,
AccountTier: pulumi.String("Standard"),
AccountReplicationType: pulumi.String("LRS"),
})
if err != nil {
return err
}
current, err := core.GetClientConfig(ctx, map[string]interface{}{}, nil)
if err != nil {
return err
}
exampleKeyVault, err := keyvault.NewKeyVault(ctx, "example", &keyvault.KeyVaultArgs{
Name: pulumi.String("examplekeyvault"),
Location: example.Location,
ResourceGroupName: example.Name,
TenantId: pulumi.String(current.TenantId),
SoftDeleteRetentionDays: pulumi.Int(7),
PurgeProtectionEnabled: pulumi.Bool(false),
SkuName: pulumi.String("standard"),
})
if err != nil {
return err
}
_, err = monitoring.NewDiagnosticSetting(ctx, "example", &monitoring.DiagnosticSettingArgs{
Name: pulumi.String("example"),
TargetResourceId: exampleKeyVault.ID(),
StorageAccountId: exampleAccount.ID(),
EnabledLogs: monitoring.DiagnosticSettingEnabledLogArray{
&monitoring.DiagnosticSettingEnabledLogArgs{
Category: pulumi.String("AuditEvent"),
},
},
Metrics: monitoring.DiagnosticSettingMetricArray{
&monitoring.DiagnosticSettingMetricArgs{
Category: pulumi.String("AllMetrics"),
},
},
})
if err != nil {
return err
}
return nil
})
}
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.storage.Account;
import com.pulumi.azure.storage.AccountArgs;
import com.pulumi.azure.core.CoreFunctions;
import com.pulumi.azure.keyvault.KeyVault;
import com.pulumi.azure.keyvault.KeyVaultArgs;
import com.pulumi.azure.monitoring.DiagnosticSetting;
import com.pulumi.azure.monitoring.DiagnosticSettingArgs;
import com.pulumi.azure.monitoring.inputs.DiagnosticSettingEnabledLogArgs;
import com.pulumi.azure.monitoring.inputs.DiagnosticSettingMetricArgs;
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 example = new ResourceGroup("example", ResourceGroupArgs.builder()
.name("example-resources")
.location("West Europe")
.build());
var exampleAccount = new Account("exampleAccount", AccountArgs.builder()
.name("storageaccountname")
.resourceGroupName(example.name())
.location(example.location())
.accountTier("Standard")
.accountReplicationType("LRS")
.build());
final var current = CoreFunctions.getClientConfig(%!v(PANIC=Format method: runtime error: invalid memory address or nil pointer dereference);
var exampleKeyVault = new KeyVault("exampleKeyVault", KeyVaultArgs.builder()
.name("examplekeyvault")
.location(example.location())
.resourceGroupName(example.name())
.tenantId(current.tenantId())
.softDeleteRetentionDays(7)
.purgeProtectionEnabled(false)
.skuName("standard")
.build());
var exampleDiagnosticSetting = new DiagnosticSetting("exampleDiagnosticSetting", DiagnosticSettingArgs.builder()
.name("example")
.targetResourceId(exampleKeyVault.id())
.storageAccountId(exampleAccount.id())
.enabledLogs(DiagnosticSettingEnabledLogArgs.builder()
.category("AuditEvent")
.build())
.metrics(DiagnosticSettingMetricArgs.builder()
.category("AllMetrics")
.build())
.build());
}
}
resources:
example:
type: azure:core:ResourceGroup
properties:
name: example-resources
location: West Europe
exampleAccount:
type: azure:storage:Account
name: example
properties:
name: storageaccountname
resourceGroupName: ${example.name}
location: ${example.location}
accountTier: Standard
accountReplicationType: LRS
exampleKeyVault:
type: azure:keyvault:KeyVault
name: example
properties:
name: examplekeyvault
location: ${example.location}
resourceGroupName: ${example.name}
tenantId: ${current.tenantId}
softDeleteRetentionDays: 7
purgeProtectionEnabled: false
skuName: standard
exampleDiagnosticSetting:
type: azure:monitoring:DiagnosticSetting
name: example
properties:
name: example
targetResourceId: ${exampleKeyVault.id}
storageAccountId: ${exampleAccount.id}
enabledLogs:
- category: AuditEvent
metrics:
- category: AllMetrics
variables:
current:
fn::invoke:
function: azure:core:getClientConfig
arguments: {}

Import

Diagnostic Settings can be imported using the resource id, e.g.

$ pulumi import azure:monitoring/diagnosticSetting:DiagnosticSetting example "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.KeyVault/vaults/vault1|logMonitoring1"

Constructors

Link copied to clipboard
constructor(enabledLogs: Output<List<DiagnosticSettingEnabledLogArgs>>? = null, eventhubAuthorizationRuleId: Output<String>? = null, eventhubName: Output<String>? = null, logAnalyticsDestinationType: Output<String>? = null, logAnalyticsWorkspaceId: Output<String>? = null, metrics: Output<List<DiagnosticSettingMetricArgs>>? = null, name: Output<String>? = null, partnerSolutionId: Output<String>? = null, storageAccountId: Output<String>? = null, targetResourceId: Output<String>? = null)

Properties

Link copied to clipboard

One or more enabled_log blocks as defined below.

Link copied to clipboard
val eventhubAuthorizationRuleId: Output<String>? = null

Specifies the ID of an Event Hub Namespace Authorization Rule used to send Diagnostics Data.

Link copied to clipboard
val eventhubName: Output<String>? = null

Specifies the name of the Event Hub where Diagnostics Data should be sent.

Link copied to clipboard
val logAnalyticsDestinationType: Output<String>? = null

Possible values are AzureDiagnostics and Dedicated. When set to Dedicated, logs sent to a Log Analytics workspace will go into resource specific tables, instead of the legacy AzureDiagnostics table.

Link copied to clipboard
val logAnalyticsWorkspaceId: Output<String>? = null

Specifies the ID of a Log Analytics Workspace where Diagnostics Data should be sent.

Link copied to clipboard

One or more metric blocks as defined below.

Link copied to clipboard
val name: Output<String>? = null

Specifies the name of the Diagnostic Setting. Changing this forces a new resource to be created.

Link copied to clipboard
val partnerSolutionId: Output<String>? = null

The ID of the market partner solution where Diagnostics Data should be sent. For potential partner integrations, click to learn more about partner integration.

Link copied to clipboard
val storageAccountId: Output<String>? = null

The ID of the Storage Account where logs should be sent.

Link copied to clipboard
val targetResourceId: Output<String>? = null

The ID of an existing Resource on which to configure Diagnostic Settings. Changing this forces a new resource to be created.

Functions

Link copied to clipboard
open override fun toJava(): DiagnosticSettingArgs