Skip to content

Repository files navigation

monitor

This module manages the azurerm monitor resources, see https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs.

For more information about the module structure see https://telekom-mms.github.io/terraform-template.

<-- This file is autogenerated, please do not change. -->

Requirements

Name Version
terraform >= 1.5
azurerm >= 4.0, < 5.0

Providers

Name Version
azurerm >= 4.0, < 5.0

Resources

Name Type
azurerm_monitor_action_group.monitor_action_group resource
azurerm_monitor_activity_log_alert.monitor_activity_log_alert resource
azurerm_monitor_diagnostic_setting.monitor_diagnostic_setting resource
azurerm_monitor_scheduled_query_rules_alert.monitor_scheduled_query_rules_alert resource

Inputs

Name Description Type Default Required
monitor_action_group Resource definition, default settings are defined within locals and merged with var settings. For more information look at Outputs. any {} no
monitor_activity_log_alert Resource definition, default settings are defined within locals and merged with var settings. For more information look at Outputs. any {} no
monitor_diagnostic_setting Resource definition, default settings are defined within locals and merged with var settings. For more information look at Outputs. any {} no
monitor_scheduled_query_rules_alert Resource definition, default settings are defined within locals and merged with var settings. For more information look at Outputs. any {} no

Outputs

Name Description
monitor_action_group Outputs all attributes of azurerm_monitor_action_group.
monitor_activity_log_alert Outputs all attributes of azurerm_monitor_activity_log_alert.
monitor_diagnostic_setting Outputs all attributes of azurerm_monitor_diagnostic_setting.
monitor_scheduled_query_rules_alert Outputs all attributes of azurerm_monitor_scheduled_query_rules_alert.
variables Displays all configurable variables passed by the module. default = predefined values per module. merged = result of merging the default values and custom values passed to the module

Examples

Minimal configuration to install the desired resources with the module

data "azurerm_subscription" "current" {}

module "key_vault" {
  source = "registry.terraform.io/telekom-mms/key-vault/azurerm"
  key_vault = {
    kv-mms-github = {
      resource_group_name = "rg-mms-github"
      location            = "westeurope"
      tenant_id           = data.azurerm_subscription.current.tenant_id
      sku_name            = "standard"
    }
  }
}

module "log_analytics_workspace" {
  source = "registry.terraform.io/telekom-mms/log-analytics-workspace/azurerm"
  log_analytics_workspace = {
    law-mms-github = {
      resource_group_name = "rg-mms-github"
      location            = "westeurope"
    }
  }
}

module "monitor" {
  source = "registry.terraform.io/telekom-mms/monitor/azurerm"

  monitor_action_group = {
    ag-mms-github = {
      resource_group_name = "rg-mms-github"
      short_name          = "agmmsgithub"
    }
  }

  monitor_diagnostic_setting = {
    diag-mms-github = {
      target_resource_id = module.key_vault.key_vault["kv-mms-github"].id
    }
  }

  monitor_activity_log_alert = {
    ala-mms-github = {
      resource_group_name = "rg-mms-github"
      location            = "westeurope"
      scopes              = [data.azurerm_subscription.current.id]
      criteria = {
        category = "Recommendation"
      }
    }
  }

  monitor_scheduled_query_rules_alert = {
    sqra-mms-github = {
      resource_group_name = "rg-mms-github"
      location            = "westeurope"
      data_source_id      = module.log_analytics_workspace.log_analytics_workspace["law-mms-github"].id
      query               = "Perf | where ObjectName == \"Processor\" and CounterName == \"% Processor Time\" | summarize AggregatedValue = avg(CounterValue) by bin(TimeGenerated, 5m), Computer"
      trigger = {
        operator  = "GreaterThan"
        threshold = 3
      }
      action = {
        action_group = []
      }
    }
  }
}

Advanced configuration to install the desired resources with the module

data "azurerm_subscription" "current" {}

module "key_vault" {
  source = "registry.terraform.io/telekom-mms/key-vault/azurerm"
  key_vault = {
    kv-mms-github = {
      resource_group_name = "rg-mms-github"
      location            = "westeurope"
      tenant_id           = data.azurerm_subscription.current.tenant_id
      sku_name            = "standard"
    }
  }
}

module "log_analytics_workspace" {
  source = "registry.terraform.io/telekom-mms/log-analytics-workspace/azurerm"
  log_analytics_workspace = {
    law-mms-github = {
      resource_group_name = "rg-mms-github"
      location            = "westeurope"
    }
  }
}


module "monitor" {
  source = "registry.terraform.io/telekom-mms/monitor/azurerm"

  monitor_action_group = {
    ag-mms-github = {
      resource_group_name = "rg-mms-github"
      short_name          = "agmmsgithub"
      enabled             = true
      email_receiver = {
        sendtoadmin = {
          name                    = "sendtoadmin"
          email_address           = "admin@contoso.com"
          use_common_alert_schema = true
        }
      }
      tags = {
        project     = "mms-github"
        environment = "dev"
        managed-by  = "terraform"
      }
    }
  }

  monitor_diagnostic_setting = {
    diag-mms-github = {
      target_resource_id         = module.key_vault.key_vault["kv-mms-github"].id
      log_analytics_workspace_id = module.log_analytics_workspace.log_analytics_workspace["law-mms-github"].id
      enabled_log = {
        category = "AuditEvent"
      }
      enabled_metric = {
        category = "AllMetrics"
      }
    }
  }

  monitor_activity_log_alert = {
    ala-mms-github = {
      resource_group_name = "rg-mms-github"
      location            = "westeurope"
      scopes              = [data.azurerm_subscription.current.id]
      description         = "Alert for Service Health Recommendations"
      enabled             = true
      criteria = {
        category = "Recommendation"
        level    = "Informational"
      }
      action = {
        webhook_properties = {
          from = "terraform"
        }
      }
      tags = {
        project     = "mms-github"
        environment = "dev"
        managed-by  = "terraform"
      }
    }
  }

  monitor_scheduled_query_rules_alert = {
    sqra-mms-github = {
      resource_group_name     = "rg-mms-github"
      location                = "westeurope"
      data_source_id          = module.log_analytics_workspace.log_analytics_workspace["law-mms-github"].id
      query                   = "Perf | where ObjectName == \"Processor\" and CounterName == \"% Processor Time\" | summarize AggregatedValue = avg(CounterValue) by bin(TimeGenerated, 5m), Computer"
      description             = "Alert for High CPU Usage"
      enabled                 = true
      severity                = 2
      throttling              = 5
      frequency               = 5
      time_window             = 5
      auto_mitigation_enabled = true
      trigger = {
        operator  = "GreaterThan"
        threshold = 80
        metric_trigger = {
          metric_column       = "Computer"
          metric_trigger_type = "Consecutive"
          operator            = "GreaterThan"
          threshold           = 1
        }
      }
      action = {
        action_group           = []
        email_subject          = "High CPU Alert"
        custom_webhook_payload = "{ \"alert\": \"#alertrulename\", \"metric\": \"#metricvalue\" }"
      }
      tags = {
        project     = "mms-github"
        environment = "dev"
        managed-by  = "terraform"
      }
    }
  }
}

About

A Terraform module that manages the tpl_resources resources from the azurerm provider.

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages