Skip to main content

azure_monitor_log_profile resource

Use the azure_monitor_log_profile InSpec audit resource to test the properties and configuration of an Azure Log profile.

Azure REST API version, endpoint, and HTTP client parameters

This resource interacts with API versions supported by the resource provider. You can specify the api_version as a resource parameter to use a specific version of the Azure REST API. If you don’t specify an API version, this resource uses the latest version available. For more information about API versioning, see the azure_generic_resource.

By default, this resource uses the azure_cloud global endpoint and default HTTP client settings. You can override these settings if you need to connect to a different Azure environment (such as Azure Government or Azure China). For more information about configuration options, see the resource pack README.

Syntax

name or the resource_id are required parameters.

describe azure_monitor_log_profile(name: 'LOG_PROFILE') do
  it { should exist }
end
describe azure_monitor_log_profile(resource_id: '/subscriptions/{subscriptionId}/providers/microsoft.insights/logprofiles/{logProfileName}') do
  it { should exist }
end

Parameters

name
Name of the log profile to test.
resource_id
The unique resource ID.

Properties

retention_policy
The retention policy for the events in the log with these properties.
retention_days
The number of days for the log retention in days. A value of 0 means that the events will be retained indefinitely.
storage_account
A hash containing the name and the resouce_group of the storage account in which the activity logs are kept.

For properties applicable to all resources, such as type, name, id, and properties, refer to azure_generic_resource.

Also, see the Azure documentation for other available properties.

You can access any attribute in the response with the key names separated by dots (.). For example, properties.<attribute>.

Examples

Test if a Log profile is referenced with a valid name:

describe azure_monitor_log_profile(name: 'LOG_PROFILE') do
  it { should exist }
end

Test if a Log profile is referenced with an invalid name:

describe azure_monitor_log_profile(name: 'i-dont-exist') do
  it { should_not exist }
end

Test the retention days of a Log profile:

describe azure_monitor_log_profile(name: 'LOG_PROFILE') do
  its('retention_days') { should be 90 }
end

Test the storage account of a Log profile:

describe azure_monitor_log_profile(resource_id: '/subscriptions/{subscriptionId}/providers/microsoft.insights/logprofiles/{logProfileName}') do
  its('storage_account') { should eql(resource_group: 'RESOURCE_GROUP', name: 'STORAGE_ACCOUNT') }
end

Matchers

For a full list of available matchers, see our Universal Matchers page.

This resource has the following special matchers.

have_log_retention_enabled

Test whether the log retention is enabled.

describe azure_monitor_log_profile(name: 'LOG_PROFILE') do
  it { should have_log_retention_enabled }
end

exists

# If we expect a resource to always exist.

describe azure_monitor_log_profile(name: 'LOG_PROFILE') do
  it { should exist }
end

not_exists

# If we expect a resource to never exist.

describe azure_monitor_log_profile(name: 'LOG_PROFILE') do
  it { should_not exist }
end

Azure permissions

Your Service Principal must be set up with at least a contributor role on the subscription you wish to test.

Thank you for your feedback!

×