Azure Monitor Smart Detector Alert Rule

This page shows how to write Terraform and Azure Resource Manager for Monitor Smart Detector Alert Rule and write them securely.

azurerm_monitor_smart_detector_alert_rule (Terraform)

The Smart Detector Alert Rule in Monitor can be configured in Terraform with the resource name azurerm_monitor_smart_detector_alert_rule. The following sections describe 2 examples of how to use the resource and its parameters.

Example Usage from GitHub

smartDetectorAlertRules.tf#L4
resource "azurerm_monitor_smart_detector_alert_rule" "alert_rule" {
    name = ""
    resource_group_name = ""
    severity = "Sev0"
    scope_resource_ids = "App Insights ids eg. [azurerm_application_insights.example.id]"
    frequency = "PT1M"
main.tf#L1
resource "azurerm_monitor_smart_detector_alert_rule" "example" {
  name                = var.name
  resource_group_name = module.resource_group.azurerm_resource_group.example.name
  severity            = var.severity
  scope_resource_ids  = [module.insight.azurerm_application_insights.example.id]
  frequency           = var.frequency

Review your Terraform file for Azure best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

Explanation in Terraform Registry

Manages an Monitor Smart Detector Alert Rule.

Tips: Best Practices for The Other Azure Monitor Resources

In addition to the azurerm_monitor_log_profile, Azure Monitor has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.

risk-label

azurerm_monitor_log_profile

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.

Review your Azure Monitor settings

In addition to the above, there are other security points you should be aware of making sure that your .tf files are protected in Shisho Cloud.

Microsoft.AlertsManagement/smartdetectoralertrules (Azure Resource Manager)

The smartdetectoralertrules in Microsoft.AlertsManagement can be configured in Azure Resource Manager with the resource name Microsoft.AlertsManagement/smartdetectoralertrules. The following sections describe how to use the resource and its parameters.

Example Usage from GitHub

app.template.json
{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "actionGroups_Application_Insights_Smart_Detection_name": {
failure-anomalies-alert.json
{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "appInsightsName": {
failure-anomalies.json
{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "applicationInsights": {
infra-monitoring.json
{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "infra": {
application-insights-failure-anomalies.json
{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "appInsightsName": {
AppInsightsIncludingSmartAlertsAndFailureAnomaliesActionGroup.json
{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "applicationInsightsName": {
AppInsightsIncludingSmartAlertsAndFailureAnomaliesActionGroup.json
{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "applicationInsightsName": {
9-Deploy_SmartDetectorAlertRules.json
{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "appinsightsname": {
9-Deploy_SmartDetectorAlertRules.json
{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "appinsightsname": {
azuredeploy.json
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "metadata": {
    "author": "Anton Shcherbyna",

Frequently asked questions

What is Azure Monitor Smart Detector Alert Rule?

Azure Monitor Smart Detector Alert Rule 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 Smart Detector Alert Rule?

For Terraform, the dmaxim/wimc-net and VentsislavDinev/en_sample source code examples are useful. See the Terraform Example section for further details.

For Azure Resource Manager, the Jakobaby/Arm-Maya, SkillsFundingAgency/das-platform-building-blocks and scoutzfiction/arm-templates source code examples are useful. See the Azure Resource Manager Example section for further details.