{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "workspace": {
      "type": "String"
    }
  },
  "resources": [
    {
      "apiVersion": "2024-01-01-preview",
      "id": "[concat(resourceId('Microsoft.OperationalInsights/workspaces/providers', parameters('workspace'), 'Microsoft.SecurityInsights'),'/alertRules/4be5b645-1d08-49e4-b58d-07294ff19223')]",
      "kind": "Scheduled",
      "name": "[concat(parameters('workspace'),'/Microsoft.SecurityInsights/4be5b645-1d08-49e4-b58d-07294ff19223')]",
      "properties": {
        "alertRuleTemplateName": "4be5b645-1d08-49e4-b58d-07294ff19223",
        "customDetails": null,
        "description": "'This alert is designed to monitor assets within the Maturity Model for Event Log Management (M-21-31) standard. The alert triggers when a monitored asset fails to provide a heartbeat within 24 hours.'\n",
        "displayName": "M2131_AssetStoppedLogging",
        "enabled": true,
        "entityMappings": [
          {
            "entityType": "AzureResource",
            "fieldMappings": [
              {
                "columnName": "ResourceId",
                "identifier": "ResourceId"
              }
            ]
          }
        ],
        "OriginalUri": "https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/MaturityModelForEventLogManagementM2131/Analytic%20Rules/M2131AssetStoppedLogging.yaml",
        "query": "let LastHeartbeatTime = Heartbeat\n| summarize LastHeartbeat_Time = arg_max(TimeGenerated, *) by ResourceId;\nHeartbeat\n| where TimeGenerated > ago(14d)\n| summarize LastHeartbeat_Hours = datetime_diff(\"hour\",now(), max(TimeGenerated)) by ResourceId\n| where ResourceId <> \"\"\n| where ResourceId <> \"None\"\n| join kind=inner (LastHeartbeatTime) on ResourceId\n| where LastHeartbeat_Hours > 24\n| project LastHeartbeat_Hours, LastHeartbeat_Time, Computer, ComputerIP, Category, OSType, OSName, ResourceId, SubscriptionId, ResourceGroup, RemoteIPCountry \n| sort by LastHeartbeat_Hours desc\n",
        "queryFrequency": "P1D",
        "queryPeriod": "P14D",
        "severity": "Medium",
        "status": "Available",
        "subTechniques": [],
        "suppressionDuration": "PT1H",
        "suppressionEnabled": false,
        "tactics": [
          "Discovery"
        ],
        "techniques": [
          "T1082"
        ],
        "templateVersion": "1.0.0",
        "triggerOperator": "GreaterThan",
        "triggerThreshold": 0
      },
      "type": "Microsoft.OperationalInsights/workspaces/providers/alertRules"
    }
  ]
}
