-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.bicep
84 lines (76 loc) · 2.02 KB
/
main.bicep
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
@description('Enter response time threshold in seconds.')
@minValue(1)
@maxValue(10000)
param responseTimeThreshold int = 3
@description('Name of the workspace where the data will be stored.')
param workspaceName string = 'myWorkspace'
@description('Name of the application insights resource.')
param applicationInsightsName string = 'myApplicationInsights'
@description('Location for all resources.')
param location string = resourceGroup().location
var responseAlertName = 'ResponseTime-${toLower(applicationInsightsName)}'
resource workspace 'Microsoft.OperationalInsights/workspaces@2020-10-01' = {
name: workspaceName
location: location
properties: {
sku: {
name: 'Free'
}
}
}
resource applicationInsights 'Microsoft.Insights/components@2020-02-02-preview' = {
name: applicationInsightsName
location: location
kind: 'web'
properties: {
Application_Type: 'web'
WorkspaceResourceId: workspace.id
}
}
resource metricAlert 'Microsoft.Insights/metricAlerts@2018-03-01' = {
name: responseAlertName
location: 'global'
properties: {
description: 'Response time alert'
severity: 0
enabled: true
scopes: [
applicationInsights.id
]
evaluationFrequency: 'PT1M'
windowSize: 'PT5M'
criteria: {
'odata.type': 'Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria'
allOf: [
{
name: '1st criterion'
metricName: 'requests/duration'
operator: 'GreaterThan'
threshold: responseTimeThreshold
timeAggregation: 'Average'
criterionType: 'StaticThresholdCriterion'
}
]
}
actions: [
{
actionGroupId: emailActionGroup.id
}
]
}
}
resource emailActionGroup 'microsoft.insights/actionGroups@2019-06-01' = {
name: 'emailActionGroup'
location: 'global'
properties: {
groupShortName: 'string'
enabled: true
emailReceivers: [
{
name: 'Example'
emailAddress: '[email protected]'
useCommonAlertSchema: true
}
]
}
}