Skip to content

Commit 41bba16

Browse files
authored
Merge pull request #97615 from harelbr/patch-10
Update alerts-metric-create-templates.md
2 parents 8b0861d + 75c559e commit 41bba16

File tree

2 files changed

+232
-10
lines changed

2 files changed

+232
-10
lines changed

articles/azure-monitor/platform/alerts-metric-create-templates.md

Lines changed: 231 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -545,9 +545,11 @@ az group deployment create \
545545
>
546546
> While the metric alert could be created in a different resource group to the target resource, we recommend using the same resource group as your target resource.
547547
548-
## Template for a more advanced static threshold metric alert
548+
## Template for a static threshold metric alert that monitors multiple criteria
549549

550-
Newer metric alerts support alerting on multi-dimensional metrics as well as supporting multiple criteria. You can use the following template to create a more advanced metric alert on dimensional metrics and specify multiple criteria.
550+
Newer metric alerts support alerting on multi-dimensional metrics as well as supporting multiple criteria. You can use the following template to create a more advanced metric alert rule on dimensional metrics and specify multiple criteria.
551+
552+
Please note that when the alert rule contains multiple criteria, the use of dimensions is limited to one value per dimension within each criterion.
551553

552554
Save the json below as advancedstaticmetricalert.json for the purpose of this walkthrough.
553555

@@ -751,7 +753,7 @@ Save and modify the json below as advancedstaticmetricalert.parameters.json for
751753
```
752754

753755

754-
You can create the metric alert using the template and parameters file using PowerShell or Azure CLI from your current working directory
756+
You can create the metric alert using the template and parameters file using PowerShell or Azure CLI from your current working directory.
755757

756758
Using Azure PowerShell
757759
```powershell
@@ -778,17 +780,237 @@ az group deployment create \
778780

779781
>[!NOTE]
780782
>
781-
> While the metric alert could be created in a different resource group to the target resource, we recommend using the same resource group as your target resource.
783+
> When an alert rule contains multiple criteria, the use of dimensions is limited to one value per dimension within each criterion.
784+
785+
## Template for a static metric alert that monitors multiple dimensions
786+
787+
You can use the following template to create a static metric alert rule on dimensional metrics.
788+
789+
A single alert rule can monitor multiple metric time series at a time, which results in fewer alert rules to manage.
790+
791+
In the example below, the alert rule will monitor the dimensions value combinations of the **ResponseType** and **ApiName** dimensions for the **Transactions** metric:
792+
1. **ResponsType** - The use of the "\*" wildcard means that for each value of the **ResponseType** dimension, including future values, a different time series will be monitored individually.
793+
2. **ApiName** - A different time series will be monitored only for the **GetBlob** and **PutBlob** dimension values.
794+
795+
For example, a few of the potential time series that will be monitored by this alert rule are:
796+
- Metric = *Transactions*, ResponseType = *Success*, ApiName = *GetBlob*
797+
- Metric = *Transactions*, ResponseType = *Success*, ApiName = *PutBlob*
798+
- Metric = *Transactions*, ResponseType = *Server Timeout*, ApiName = *GetBlob*
799+
- Metric = *Transactions*, ResponseType = *Server Timeout*, ApiName = *PutBlob*
800+
801+
Save the json below as multidimensionalstaticmetricalert.json for the purpose of this walkthrough.
802+
803+
```json
804+
{
805+
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
806+
"contentVersion": "1.0.0.0",
807+
"parameters": {
808+
"alertName": {
809+
"type": "string",
810+
"metadata": {
811+
"description": "Name of the alert"
812+
}
813+
},
814+
"alertDescription": {
815+
"type": "string",
816+
"defaultValue": "This is a metric alert",
817+
"metadata": {
818+
"description": "Description of alert"
819+
}
820+
},
821+
"alertSeverity": {
822+
"type": "int",
823+
"defaultValue": 3,
824+
"allowedValues": [
825+
0,
826+
1,
827+
2,
828+
3,
829+
4
830+
],
831+
"metadata": {
832+
"description": "Severity of alert {0,1,2,3,4}"
833+
}
834+
},
835+
"isEnabled": {
836+
"type": "bool",
837+
"defaultValue": true,
838+
"metadata": {
839+
"description": "Specifies whether the alert is enabled"
840+
}
841+
},
842+
"resourceId": {
843+
"type": "string",
844+
"defaultValue": "",
845+
"metadata": {
846+
"description": "Resource ID of the resource emitting the metric that will be used for the comparison."
847+
}
848+
},
849+
"criterion":{
850+
"type": "object",
851+
"metadata": {
852+
"description": "Criterion includes metric name, dimension values, threshold and an operator. The alert rule fires when ALL criteria are met"
853+
}
854+
},
855+
"windowSize": {
856+
"type": "string",
857+
"defaultValue": "PT5M",
858+
"allowedValues": [
859+
"PT1M",
860+
"PT5M",
861+
"PT15M",
862+
"PT30M",
863+
"PT1H",
864+
"PT6H",
865+
"PT12H",
866+
"PT24H"
867+
],
868+
"metadata": {
869+
"description": "Period of time used to monitor alert activity based on the threshold. Must be between one minute and one day. ISO 8601 duration format."
870+
}
871+
},
872+
"evaluationFrequency": {
873+
"type": "string",
874+
"defaultValue": "PT1M",
875+
"allowedValues": [
876+
"PT1M",
877+
"PT5M",
878+
"PT15M",
879+
"PT30M",
880+
"PT1H"
881+
],
882+
"metadata": {
883+
"description": "how often the metric alert is evaluated represented in ISO 8601 duration format"
884+
}
885+
},
886+
"actionGroupId": {
887+
"type": "string",
888+
"defaultValue": "",
889+
"metadata": {
890+
"description": "The ID of the action group that is triggered when the alert is activated or deactivated"
891+
}
892+
}
893+
},
894+
"variables": {
895+
"criteria": "[array(parameters('criterion'))]"
896+
},
897+
"resources": [
898+
{
899+
"name": "[parameters('alertName')]",
900+
"type": "Microsoft.Insights/metricAlerts",
901+
"location": "global",
902+
"apiVersion": "2018-03-01",
903+
"tags": {},
904+
"properties": {
905+
"description": "[parameters('alertDescription')]",
906+
"severity": "[parameters('alertSeverity')]",
907+
"enabled": "[parameters('isEnabled')]",
908+
"scopes": ["[parameters('resourceId')]"],
909+
"evaluationFrequency":"[parameters('evaluationFrequency')]",
910+
"windowSize": "[parameters('windowSize')]",
911+
"criteria": {
912+
"odata.type": "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria",
913+
"allOf": "[variables('criteria')]"
914+
},
915+
"actions": [
916+
{
917+
"actionGroupId": "[parameters('actionGroupId')]"
918+
}
919+
]
920+
}
921+
}
922+
]
923+
}
924+
```
925+
926+
You can use the above template along with the parameter file provided below.
927+
928+
Save and modify the json below as multidimensionalstaticmetricalert.parameters.json for the purpose of this walkthrough.
929+
930+
```json
931+
{
932+
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
933+
"contentVersion": "1.0.0.0",
934+
"parameters": {
935+
"alertName": {
936+
"value": "New multi-dimensional metric alert rule (replace with your alert name)"
937+
},
938+
"alertDescription": {
939+
"value": "New multi-dimensional metric alert rule created via template (replace with your alert description)"
940+
},
941+
"alertSeverity": {
942+
"value":3
943+
},
944+
"isEnabled": {
945+
"value": true
946+
},
947+
"resourceId": {
948+
"value": "/subscriptions/replace-with-subscription-id/resourceGroups/replace-with-resourcegroup-name/providers/Microsoft.Storage/storageAccounts/replace-with-storage-account"
949+
},
950+
"criterion": {
951+
"value": {
952+
"name": "Criterion",
953+
"metricName": "Transactions",
954+
"dimensions": [
955+
{
956+
"name":"ResponseType",
957+
"operator": "Include",
958+
"values": ["*"]
959+
},
960+
{
961+
"name":"ApiName",
962+
"operator": "Include",
963+
"values": ["GetBlob", "PutBlob"]
964+
}
965+
],
966+
"operator": "GreaterThan",
967+
"threshold": "5",
968+
"timeAggregation": "Total"
969+
}
970+
},
971+
"actionGroupId": {
972+
"value": "/subscriptions/replace-with-subscription-id/resourceGroups/replace-with-resource-group-name/providers/Microsoft.Insights/actionGroups/replace-with-actiongroup-name"
973+
}
974+
}
975+
}
976+
```
977+
978+
979+
You can create the metric alert using the template and parameters file using PowerShell or Azure CLI from your current working directory.
980+
981+
Using Azure PowerShell
982+
```powershell
983+
Connect-AzAccount
984+
985+
Select-AzSubscription -SubscriptionName <yourSubscriptionName>
986+
987+
New-AzResourceGroupDeployment -Name AlertDeployment -ResourceGroupName ResourceGroupofTargetResource `
988+
-TemplateFile multidimensionalstaticmetricalert.json -TemplateParameterFile multidimensionalstaticmetricalert.parameters.json
989+
```
782990

783-
## Template for a more advanced Dynamic Thresholds metric alert
991+
992+
993+
Using Azure CLI
994+
```azurecli
995+
az login
996+
997+
az group deployment create \
998+
--name AlertDeployment \
999+
--resource-group ResourceGroupofTargetResource \
1000+
--template-file multidimensionalstaticmetricalert.json \
1001+
--parameters @multidimensionalstaticmetricalert.parameters.json
1002+
```
1003+
1004+
1005+
## Template for a Dynamic Thresholds metric alert that monitors multiple dimensions
7841006

7851007
You can use the following template to create a more advanced Dynamic Thresholds metric alert rule on dimensional metrics.
7861008

7871009
A single Dynamic Thresholds alert rule can create tailored thresholds for hundreds of metric time series (even different types) at a time, which results in fewer alert rules to manage.
7881010

7891011
In the example below, the alert rule will monitor the dimensions value combinations of the **ResponseType** and **ApiName** dimensions for the **Transactions** metric:
790-
1. ResponsType - For each value of the **ResponseType** dimension, including future values, a different time series will be monitored individually.
791-
2. ApiName - A different time series will be monitored only for the **GetBlob** and **PutBlob** dimension values.
1012+
1. **ResponsType** - For each value of the **ResponseType** dimension, including future values, a different time series will be monitored individually.
1013+
2. **ApiName** - A different time series will be monitored only for the **GetBlob** and **PutBlob** dimension values.
7921014

7931015
For example, a few of the potential time series that will be monitored by this alert rule are:
7941016
- Metric = *Transactions*, ResponseType = *Success*, ApiName = *GetBlob*
@@ -974,7 +1196,7 @@ Save and modify the json below as advanceddynamicmetricalert.parameters.json for
9741196
```
9751197

9761198

977-
You can create the metric alert using the template and parameters file using PowerShell or Azure CLI from your current working directory
1199+
You can create the metric alert using the template and parameters file using PowerShell or Azure CLI from your current working directory.
9781200

9791201
Using Azure PowerShell
9801202
```powershell
@@ -1003,7 +1225,7 @@ az group deployment create \
10031225
>
10041226
> Multiple criteria are not currently supported for metric alert rules that use Dynamic Thresholds.
10051227
1006-
## Template for metric alert that monitors multiple resources
1228+
## Template for a metric alert that monitors multiple resources
10071229

10081230
The previous sections described sample Azure Resource Manager templates to create metric alerts that monitor a single resource. Azure Monitor now supports monitoring multiple resources with a single metric alert rule. This feature is currently only supported in Azure public cloud and only for virtual Machines and Databox Edge Devices.
10091231

articles/azure-monitor/platform/alerts-metric-overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ You can specify the scope of monitoring by a single metric alert in one of three
130130
- all virtual machines (in one Azure region) in one or more resource groups in a subscription
131131
- all virtual machines (in one Azure region) in one subscription
132132

133-
Creating metric alert rules that monitor multiple resources is like [creating any other metric alert](alerts-metric.md) that monitors a single resource. Only difference is that you would select all the resources you want to monitor. You can also create these rules through [Azure Resource Manager templates](../../azure-monitor/platform/alerts-metric-create-templates.md#template-for-metric-alert-that-monitors-multiple-resources). You will receive individual notifications for each virtual machine.
133+
Creating metric alert rules that monitor multiple resources is like [creating any other metric alert](alerts-metric.md) that monitors a single resource. Only difference is that you would select all the resources you want to monitor. You can also create these rules through [Azure Resource Manager templates](../../azure-monitor/platform/alerts-metric-create-templates.md#template-for-a-metric-alert-that-monitors-multiple-resources). You will receive individual notifications for each virtual machine.
134134

135135
## Typical latency
136136

0 commit comments

Comments
 (0)