turbot/steampipe-mod-azure-compliance

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

  1. Go to Monitor.
  2. Click Alerts.
  3. Click + Create.
  4. Select Alert rule from the drop-down menu.
  5. Choose a subscription.
  6. Click Apply.
  7. Select the Condition tab.
  8. Click See all signals.
  9. Select Service health.
  10. Click Apply.
  11. Open the drop-down menu next to Event types.
  12. Check the box next to Select all.
  13. Select the Actions tab.
  14. Click Select action groups to select an existing action group, or Create action group to create a new action group.
  15. Follow the prompts to choose or create an action group.
  16. Select the Details tab.
  17. Select a Resource group, provide an Alert rule name and an optional Alert rule description.
  18. Click Review + create.
  19. Click Create.
  20. 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_11

Snapshot and share results via Turbot Pipes:

powerpipe login
powerpipe control run azure_compliance.control.cis_v400_7_1_2_11 --share

SQL

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 subscription
from
azure_subscription sub
left join alert_rule a on sub.subscription_id = a.subscription_id
group by
sub._ctx,
sub.subscription_id,
sub.display_name;

Tags