Control: 7.1.2.11 Ensure that an Activity Log Alert exists for Service Health
Description
Create an activity log alert for Service Health.
Monitoring for Service Health events provides insight into service issues, planned maintenance, security advisories, and other changes that may affect the Azure services and regions in use.
Remediation
From Azure Portal
- Go to 
Monitor. - Click 
Alerts. - Click 
+ Create. - Select 
Alert rulefrom the drop-down menu. - Choose a subscription.
 - Click 
Apply. - Select the 
Conditiontab. - Click 
See all signals. - Select 
Service health. - Click 
Apply. - Open the drop-down menu next to 
Event types. - Check the box next to 
Select all. - Select the 
Actionstab. - Click 
Select action groupsto select an existing action group, orCreate action groupto create a new action group. - Follow the prompts to choose or create an action group.
 - Select the 
Detailstab. - Select a 
Resource group, provide anAlert rule nameand an optionalAlert rule description. - Click 
Review + create. - Click 
Create. - Repeat steps 1-19 for each subscription requiring remediation.
 
From Azure CLI
For each subscription requiring remediation, run the following command to create a ServiceHealth alert rule for a subscription:
az monitor activity-log alert create --subscription <subscription-id> --resource-group <resource-group> --name <alert-rule> --condition category=ServiceHealth and properties.incidentType=Incident --scope /subscriptions/<subscription-id> --action-group <action-group>
From PowerShell
Create the Conditions object:
$conditions = @()$conditions += New-AzActivityLogAlertAlertRuleAnyOfOrLeafConditionObject -Field category -Equal ServiceHealth$conditions += New-AzActivityLogAlertAlertRuleAnyOfOrLeafConditionObject -Field properties.incidentType -Equal Incident
Retrieve the Action Group information and store in a variable:
$actionGroup = Get-AzActionGroup -ResourceGroupName <resource-group> -Name <action-group>
Create the Actions object:
$actionObject = New-AzActivityLogAlertActionGroupObject -Id $actionGroup.Id
Create the Scope object:
$scope = "/subscriptions/<subscription-id>"
Create the activity log alert rule:
New-AzActivityLogAlert -Name <alert-rule> -ResourceGroupName <resource-group> -Condition $conditions -Scope $scope -Location global -Action $actionObject -Subscription <subscription-id> -Enabled $true
Repeat for each subscription requiring remediation.
Default Value
By default, no monitoring alerts are created.
Usage
Run the control in your terminal:
powerpipe control run azure_compliance.control.cis_v400_7_1_2_11Snapshot and share results via Turbot Pipes:
powerpipe loginpowerpipe control run azure_compliance.control.cis_v400_7_1_2_11 --shareSQL
This control uses a named query:
with alert_rule as (  select    alert.id as alert_id,    alert.name as alert_name,    alert.enabled,    alert.location,    alert.subscription_id  from    azure_log_alert as alert,    jsonb_array_elements_text(scopes) as sc  where    alert.location = 'global'    and alert.enabled    and sc = '/subscriptions/' || alert.subscription_id    and (      (        alert.condition -> 'allOf' @> '[{"field":"category", "equals":"ServiceHealth"}]'      )      or      (        alert.condition -> 'allOf' @> '[{"field":"category", "equals":"ResourceHealth"}]'      )    ))select  sub.subscription_id as resource,  case    when count(a.subscription_id) > 0 then 'ok'    else 'alarm'  end as status,  case    when count(a.subscription_id) > 0 then 'Activity log alert exists for Service Health events.'    else 'Activity log alert does not exist for Service Health events.'  end as reason    , sub.display_name as subscriptionfrom  azure_subscription sub  left join alert_rule a on sub.subscription_id = a.subscription_idgroup by  sub._ctx,  sub.subscription_id,  sub.display_name;