{
  "$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/a6d51bc1-bf51-47d1-9885-b81762cd6306')]",
      "kind": "Scheduled",
      "name": "[concat(parameters('workspace'),'/Microsoft.SecurityInsights/a6d51bc1-bf51-47d1-9885-b81762cd6306')]",
      "properties": {
        "alertRuleTemplateName": "a6d51bc1-bf51-47d1-9885-b81762cd6306",
        "customDetails": null,
        "description": "A device is still marked active in the Devices table but has not sent a heartbeat in 30+ days. Emitted once per device by the daily tenant health-check job (api/src/functions/tenantHealthChecks.js); clears automatically if the device checks in again, so it can re-fire after a later gap.\n",
        "displayName": "CTE - Stale Device (No Heartbeat in 30 Days)",
        "enabled": true,
        "entityMappings": [
          {
            "entityType": "Host",
            "fieldMappings": [
              {
                "columnName": "HostName",
                "identifier": "HostName"
              }
            ]
          }
        ],
        "OriginalUri": "https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/Cybereinforce/Analytic%20Rules/StaleDeviceNoHeartbeatIn30Days.yaml",
        "query": "CybereinforceCTE_CL\n| where EventType == \"device.stale_heartbeat\"\n| extend d = parse_json(Details)\n| extend\n    DeviceId = tostring(d.deviceId),\n    HostName = iff(isnotempty(tostring(d.hostname)), tostring(d.hostname), strcat(\"cte-device-\", substring(EntityId, 0, 8))),\n    LastSeen = tostring(d.lastSeen)\n| project TimeGenerated, TenantId, DeviceId, HostName, LastSeen, Severity, Category, Source\n",
        "queryFrequency": "PT24H",
        "queryPeriod": "P2D",
        "severity": "Medium",
        "subTechniques": [],
        "suppressionDuration": "PT1H",
        "suppressionEnabled": false,
        "tactics": [
          "DefenseEvasion"
        ],
        "techniques": [
          "T1562"
        ],
        "templateVersion": "1.0.0",
        "triggerOperator": "GreaterThan",
        "triggerThreshold": 0
      },
      "type": "Microsoft.OperationalInsights/workspaces/providers/alertRules"
    }
  ]
}
