Azure Monitor Log Profile
This page shows how to write Terraform and Azure Resource Manager for Monitor Log Profile and write them securely.
azurerm_monitor_log_profile (Terraform)
The Log Profile in Monitor can be configured in Terraform with the resource name azurerm_monitor_log_profile
. The following sections describe 2 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "azurerm_monitor_log_profile" "allowed" {
categories = [
"Action",
"Delete",
"Write"
]
resource "azurerm_monitor_log_profile" "allowed" {
retention_policy {
enabled = true
days = 365
}
}
Security Best Practices for azurerm_monitor_log_profile
There are 2 settings in azurerm_monitor_log_profile that should be taken care of for security reasons. The following section explain an overview and example code.
Ensure to enable the activity retention log
It is better to enable the activity retention log to ensure that all the information required for an effective investigation is still available.
Ensure to configure log profile to capture all activities
It is better to configure a log profile to capture all activities to ensure that all relevant information possible is available for the investigation.
Parameters
-
categories
required - set of string -
id
optional computed - string -
locations
required - set of string -
name
required - string -
servicebus_rule_id
optional - string -
storage_account_id
optional - string -
retention_policy
list block -
timeouts
single block
Explanation in Terraform Registry
Manages a Log Profile. A Log Profile configures how Activity Logs are exported. -> NOTE: It's only possible to configure one Log Profile per Subscription. If you are trying to create more than one Log Profile, an error with
StatusCode=409
will occur.
Microsoft.Insights/logProfiles (Azure Resource Manager)
The logProfiles in Microsoft.Insights can be configured in Azure Resource Manager with the resource name Microsoft.Insights/logProfiles
. The following sections describe how to use the resource and its parameters.
Example Usage from GitHub
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"storageAccountId": {
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"storageAccountId": {
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"resources": [
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"name": {
"type": "Microsoft.Insights/logProfiles",
"name": "default",
"existenceScope": "subscription",
"existenceCondition": {
"allOf": [
{
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"eventHubSubscription" : {
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"variables": {},
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"variables": {},
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"variables": {},
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"variables": {},
Frequently asked questions
What is Azure Monitor Log Profile?
Azure Monitor Log Profile is a resource for Monitor of Microsoft Azure. Settings can be wrote in Terraform.
Where can I find the example code for the Azure Monitor Log Profile?
For Terraform, the snyk-labs/infrastructure-as-code-goof and snyk-labs/infrastructure-as-code-goof source code examples are useful. See the Terraform Example section for further details.
For Azure Resource Manager, the fugue/regula, fugue/regula and fugue/regula source code examples are useful. See the Azure Resource Manager Example section for further details.