-
Notifications
You must be signed in to change notification settings - Fork 16
/
availability_tests.json
127 lines (127 loc) · 6.51 KB
/
availability_tests.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"appInsightsName": {
"type": "string",
"metadata": {
"description": "Name of the application insights resource"
}
},
"availabilityTests": {
"defaultValue": [],
"type": "array",
"metadata": {
"description": "Array of test objects to configure URLs to perform availability tests for."
}
},
"alertEmailAddress": {
"type": "string",
"metadata": {
"description": "Email to send alerts to"
}
},
"webTestLocations": {
"type": "array",
"metadata": {
"description": "The locations to conduct webtests from"
}
},
"enableWebTestAlerts": {
"type": "bool"
}
},
"variables": {
"actionGroupName": "[concat(parameters('appInsightsName'), '-ag-down-alert')]"
},
"resources": [
{
"type": "Microsoft.Insights/actionGroups",
"apiVersion": "2019-06-01",
"name": "[variables('actionGroupName')]",
"location": "global",
"tags": {},
"properties": {
"groupShortName": "[concat(split(parameters('appInsightsName'), '-')[0], '-ops')]",
"enabled": "[parameters('enableWebTestAlerts')]",
"useCommonAlertSchema": true,
"emailReceivers": [
{
"name": "email",
"emailAddress": "[parameters('alertEmailAddress')]"
}
]
}
},
{
"type": "Microsoft.Insights/webtests",
"apiVersion": "2015-05-01",
"name": "[if(greater(length(parameters('availabilityTests')), 0), concat(parameters('appInsightsName'), '-at-', parameters('availabilityTests')[copyIndex('webTestsCopy')].nameSuffix), 'UNUSED_WEBTEST')]",
"condition": "[greater(length(parameters('availabilityTests')), 0)]",
"location": "[resourceGroup().location]",
"copy": {
"name": "webTestsCopy",
"count": "[if(greater(length(parameters('availabilityTests')), 0), length(parameters('availabilityTests')), 1)]"
},
"tags": {
"[concat('hidden-link:', resourceId('Microsoft.Insights/components', parameters('appInsightsName')))]": "Resource"
},
"properties": {
"SyntheticMonitorId": "[concat(parameters('appInsightsName'), '-at-', parameters('availabilityTests')[copyIndex('webTestsCopy')].nameSuffix)]",
"Name": "[concat(parameters('appInsightsName'), '-at-', parameters('availabilityTests')[copyIndex('webTestsCopy')].nameSuffix)]",
"Enabled": "[parameters('enableWebTestAlerts')]",
"Frequency": 300,
"Timeout": 120,
"RetryEnabled": true,
"Locations": "[parameters('webTestLocations')]",
"Kind": "ping",
"Configuration": {
"WebTest": "[concat('<WebTest Name=\"', parameters('appInsightsName'), '-at-', parameters('availabilityTests')[copyIndex('webTestsCopy')].nameSuffix, '\"', ' Id=\"', parameters('availabilityTests')[copyIndex('webTestsCopy')].guid,'\" Enabled=\"True\" CssProjectStructure=\"\" CssIteration=\"\" Timeout=\"0\" WorkItemIds=\"\" xmlns=\"http://microsoft.com/schemas/VisualStudio/TeamTest/2010\" Description=\"\" CredentialUserName=\"\" CredentialPassword=\"\" PreAuthenticate=\"True\" Proxy=\"default\" StopOnError=\"False\" RecordedResultFile=\"\" ResultsLocale=\"\"> <Items> <Request Method=\"GET\" Guid=\"a5f10126-e4cd-570d-961c-cea43999a200\" Version=\"1.1\" Url=\"', replace(parameters('availabilityTests')[copyIndex('webTestsCopy')].url, '&', '&'),'\" ThinkTime=\"0\" Timeout=\"300\" ParseDependentRequests=\"True\" FollowRedirects=\"True\" RecordResult=\"True\" Cache=\"False\" ResponseTimeGoal=\"0\" Encoding=\"utf-8\" ExpectedHttpStatusCode=\"200\" ExpectedResponseUrl=\"\" ReportingName=\"\" IgnoreHttpStatusCode=\"False\" /></Items></WebTest>')]"
}
}
},
{
"type": "Microsoft.Insights/metricAlerts",
"apiVersion": "2018-03-01",
"name": "[if(greater(length(parameters('availabilityTests')), 0), concat(parameters('appInsightsName'), '-at-', parameters('availabilityTests')[copyIndex('metricAlertsCopy')].nameSuffix, '-alert'), 'UNUSED_ALERT')]",
"condition": "[greater(length(parameters('availabilityTests')), 0)]",
"dependsOn": [
"[resourceId('Microsoft.Insights/actionGroups', variables('actionGroupName'))]",
"[resourceId('Microsoft.Insights/webtests', concat(parameters('appInsightsName'), '-at-', parameters('availabilityTests')[copyIndex('metricAlertsCopy')].nameSuffix))]"
],
"tags": {
"[concat('hidden-link:', resourceId('microsoft.insights/components', parameters('appInsightsName')))]": "Resource",
"[concat('hidden-link:', resourceId('Microsoft.Insights/webtests', concat(parameters('appInsightsName'), '-at-', parameters('availabilityTests')[copyIndex('metricAlertsCopy')].nameSuffix)))]": "Resource"
},
"location": "global",
"copy": {
"name": "metricAlertsCopy",
"count": "[if(greater(length(parameters('availabilityTests')), 0), length(parameters('availabilityTests')), 1)]"
},
"properties": {
"name": "[concat(parameters('appInsightsName'), '-at-', parameters('availabilityTests')[copyIndex('metricAlertsCopy')].nameSuffix, '-alert')]",
"description": "[concat('Returns when availability of ', parameters('availabilityTests')[copyIndex('metricAlertsCopy')].nameSuffix ,' is less than 100%')]",
"severity": 1,
"enabled": "[parameters('enableWebTestAlerts')]",
"scopes": [
"[resourceId('Microsoft.Insights/webtests', concat(parameters('appInsightsName'), '-at-', parameters('availabilityTests')[copyIndex('metricAlertsCopy')].nameSuffix))]",
"[resourceId('microsoft.insights/components', parameters('appInsightsName'))]"
],
"evaluationFrequency": "PT1M",
"windowSize": "PT1M",
"criteria": {
"odata.type": "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria",
"webTestId": "[resourceId('Microsoft.Insights/webtests', concat(parameters('appInsightsName'), '-at-', parameters('availabilityTests')[copyIndex('metricAlertsCopy')].nameSuffix))]",
"componentId": "[resourceId('Microsoft.Insights/components', parameters('appInsightsName'))]",
"failedLocationCount": 1
},
"actions": [
{
"actionGroupId": "[resourceId('Microsoft.Insights/actionGroups', variables('actionGroupName'))]",
"webHookProperties": {}
}
]
}
}
]
}