exec.azurerm.monitor.diagnostic_setting

Azure Resource Manager (ARM) Diagnostic Setting Execution Module

New in version 1.0.0.

Changed in version 4.0.0.

maintainer:

<devops@eitr.tech>

configuration:

This module requires Azure Resource Manager credentials to be passed as keyword arguments to every function or via acct in order to work properly.

Required provider parameters:

if using username and password:
  • subscription_id
  • username
  • password
if using a service principal:
  • subscription_id
  • tenant
  • client_id
  • secret

Optional provider parameters:

cloud_environment: Used to point the cloud driver to different API endpoints, such as Azure GovCloud. Possible values:

  • AZURE_PUBLIC_CLOUD (default)
  • AZURE_CHINA_CLOUD
  • AZURE_US_GOV_CLOUD
  • AZURE_GERMAN_CLOUD
idem_azurerm.exec.azurerm.monitor.diagnostic_setting.create_or_update(hub, ctx, name, resource_uri, metrics, logs, workspace_id=None, log_analytics_destination_type=None, storage_account_id=None, event_hub_name=None, event_hub_authorization_rule_id=None, **kwargs)

New in version 1.0.0.

Changed in version 4.0.0.

Create or update diagnostic settings for the specified resource. At least one destination for the diagnostic setting logs is required. Any combination of the following destinations is acceptable:

  1. Archive the diagnostic settings to a storage account. This would require the storage_account_id paramater.
  2. Stream the diagnostic settings to an event hub. This would require the event_hub_name and
event_hub_authorization_rule_id parameters.
  1. Send the diagnostic settings to a Log Analytics Workspace. This would require the workspace_id parameter.
Parameters:
  • name – The name of the diagnostic setting.
  • resource_uri – The identifier of the resource.
  • metrics

    A list of dictionaries representing valid MetricSettings objects. If this list is empty, then the list passed as the logs parameter must have at least one element. Valid parameters are:

    • category: Name of a diagnostic metric category for the resource type this setting is applied to. To obtain the list of diagnostic metric categories for a resource, first perform a GET diagnostic setting operation. This is a required parameter.
    • enabled: A value indicating whether this category is enabled. This is a required parameter.
    • time_grain: An optional timegrain of the metric in ISO-8601 format.
    • retention_policy: An optional dictionary representing a RetentionPolicy object for the specified category. The default retention policy for a diagnostic setting is {‘enabled’: False, ‘days’: 0}. Required parameters include:
      • days: The number of days for the retention in days. A value of 0 will retain the events indefinitely.
      • enabled: A value indicating whether the retention policy is enabled.
  • logs

    A list of dictionaries representing valid LogSettings objects. If this list is empty, then the list passed as the metrics parameter must have at least one element. Valid parameters are:

    • category: Name of a diagnostic log category for the resource type this setting is applied to. To obtain the list of diagnostic log categories for a resource, first perform a GET diagnostic setting operation. This is a required parameter.
    • enabled: A value indicating whether this category is enabled. This is a required parameter.
    • retention_policy: An optional dictionary representing a RetentionPolicy object for the specified category. The default retention policy for a diagnostic setting is {‘enabled’: False, ‘days’: 0}. Required parameters include:
      • days: The number of days for the retention in days. A value of 0 will retain the events indefinitely.
      • enabled: A value indicating whether the retention policy is enabled.
  • workspace_id – The resource ID of the Log Analytics workspace to which you would like to send Diagnostic Logs. Required if you want to send the diagnostic settings data to Log Analytics.
  • log_analytics_destination_type – A string indicating whether the export to the Log Analytics Workspace should store the logs within the legacy default destination type, the AzureDiagnostics table, or a dedicated, resource specific table. Optional, used with the workspace_id parameter. Possible values include: “Dedicated” and “AzureDiagnostics”.
  • storage_account_id – The resource ID of the storage account to which you would like to send Diagnostic Logs. Required if you want to archive the diagnostic settings data to a storage account.
  • event_hub_name – The name of the event hub. If none is specified, the default event hub will be selected. Required to stream the diagnostic settings data to an event hub.
  • event_hub_authorization_rule_id – The resource ID for the event hub authorization rule. Required with the event_hub_name parameter.

CLI Example:

azurerm.monitor.diagnostic_setting.create_or_update test_name test_uri test_metrics test_logs test_destination
idem_azurerm.exec.azurerm.monitor.diagnostic_setting.delete(hub, ctx, name, resource_uri, **kwargs)

New in version 1.0.0.

Deletes existing diagnostic settings for the specified resource.

Parameters:
  • name – The name of the diagnostic setting.
  • resource_uri – The identifier of the resource.

CLI Example:

azurerm.monitor.diagnostic_setting.delete test_name test_uri
idem_azurerm.exec.azurerm.monitor.diagnostic_setting.get(hub, ctx, name, resource_uri, **kwargs)

New in version 1.0.0.

Gets the active diagnostic settings for the specified resource.

Parameters:
  • name – The name of the diagnostic setting.
  • resource_uri – The identifier of the resource.

CLI Example:

azurerm.monitor.diagnostic_setting.get test_name test_uri
idem_azurerm.exec.azurerm.monitor.diagnostic_setting.list_(hub, ctx, resource_uri, **kwargs)

New in version 1.0.0.

Gets the active diagnostic settings list for the specified resource.

Parameters:resource_uri – The identifier of the resource.

CLI Example:

azurerm.monitor.diagnostic_setting.list test_uri