Maak of werk een metrische waarschuwingsdefinitie aan.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}?api-version=2024-03-01-preview
URI-parameters
| Name |
In |
Vereist |
Type |
Description |
|
resourceGroupName
|
path |
True
|
string
minLength: 1 maxLength: 90
|
De naam van de resourcegroep. De naam is hoofdletterongevoelig.
|
|
ruleName
|
path |
True
|
string
|
De naam van de regel.
|
|
subscriptionId
|
path |
True
|
string
minLength: 1
|
De id van het doelabonnement.
|
|
api-version
|
query |
True
|
string
minLength: 1
|
De API-versie die voor deze bewerking moet worden gebruikt.
|
Aanvraagbody
| Name |
Vereist |
Type |
Description |
|
location
|
True
|
string
|
De geografische locatie waar de resource zich bevindt
|
|
properties.criteria
|
True
|
MetricAlertCriteria:
|
Definieert de specifieke informatie over de alarmcriteria.
|
|
properties.enabled
|
True
|
boolean
|
De vlag die aangeeft of de metrische waarschuwing is ingeschakeld.
|
|
properties.evaluationFrequency
|
True
|
string
(duration)
|
Hoe vaak de metrische waarschuwing wordt geëvalueerd, weergegeven in de ISO 8601-duurindeling.
|
|
properties.scopes
|
True
|
string[]
|
De lijst met resource-id's waarop deze metrische waarschuwing is gericht. U kunt het bereik van een metrische regel niet wijzigen op basis van logboeken.
|
|
properties.severity
|
True
|
integer
(int32)
|
Ernst van waarschuwing {0, 1, 2, 3, 4}
|
|
identity
|
|
Microsoft.Common.Identity
|
De identiteit van de resource.
|
|
properties.actionProperties
|
|
object
|
De eigenschappen van een actie-eigenschappen.
|
|
properties.actions
|
|
MetricAlertAction[]
|
De matrix met acties die worden uitgevoerd wanneer de waarschuwingsregel actief wordt en wanneer een waarschuwingsvoorwaarde wordt opgelost.
|
|
properties.autoMitigate
|
|
boolean
|
De vlag die aangeeft of de waarschuwing automatisch moet worden opgelost of niet. De standaardwaarde is waar.
|
|
properties.customProperties
|
|
object
|
De eigenschappen van een nettolading van een waarschuwing.
|
|
properties.description
|
|
string
|
De beschrijving van de metrische waarschuwing die wordt opgenomen in de waarschuwingsmail.
|
|
properties.resolveConfiguration
|
|
ResolveConfiguration
|
De configuratie voor de manier waarop de waarschuwing wordt opgelost. Van toepassing op PromQLCriteria.
|
|
properties.targetResourceRegion
|
|
string
|
De regio van de doelbron(nen) waarop de waarschuwing is gemaakt/bijgewerkt. Verplicht als het bereik een abonnement, resourcegroep of meer dan één resource bevat.
|
|
properties.targetResourceType
|
|
string
|
Het resourcetype van de doelresource(s) waarop de waarschuwing is gemaakt/bijgewerkt. Verplicht als het bereik een abonnement, resourcegroep of meer dan één resource bevat.
|
|
properties.windowSize
|
|
string
(duration)
|
De periode (in ISO 8601-duurformaat) die wordt gebruikt om waarschuwingsactiviteit te bewaken op basis van de drempelwaarde.
|
|
tags
|
|
object
|
Resourcetags.
|
Antwoorden
Beveiliging
azure_auth
Azure Active Directory OAuth2 Flow.
Type:
oauth2
Stroom:
implicit
Autorisatie-URL:
https://login.microsoftonline.com/common/oauth2/authorize
Bereiken
| Name |
Description |
|
user_impersonation
|
Uw gebruikersaccount imiteren
|
Voorbeelden
Create or update a dynamic alert rule for Multiple Resources
Voorbeeldaanvraag
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/Microsoft.Insights/metricAlerts/MetricAlertOnMultipleResources?api-version=2024-03-01-preview
{
"location": "global",
"properties": {
"description": "This is the description of the rule1",
"actions": [
{
"actionGroupId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
"webHookProperties": {
"key11": "value11",
"key12": "value12"
}
}
],
"autoMitigate": true,
"criteria": {
"allOf": [
{
"name": "High_CPU_80",
"alertSensitivity": "Medium",
"criterionType": "DynamicThresholdCriterion",
"dimensions": [],
"failingPeriods": {
"minFailingPeriodsToAlert": 4,
"numberOfEvaluationPeriods": 4
},
"metricName": "Percentage CPU",
"metricNamespace": "microsoft.compute/virtualmachines",
"operator": "GreaterOrLessThan",
"timeAggregation": "Average"
}
],
"odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria"
},
"enabled": true,
"evaluationFrequency": "PT1M",
"scopes": [
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme1",
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme2"
],
"severity": 3,
"targetResourceRegion": "southcentralus",
"targetResourceType": "Microsoft.Compute/virtualMachines",
"windowSize": "PT15M"
},
"tags": {}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.monitor import MonitorManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-monitor
# USAGE
python create_or_update_dynamic_metric_alert_multiple_resource.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = MonitorManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.metric_alerts.create_or_update(
resource_group_name="gigtest",
rule_name="MetricAlertOnMultipleResources",
parameters={
"location": "global",
"properties": {
"actions": [
{
"actionGroupId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
"webHookProperties": {"key11": "value11", "key12": "value12"},
}
],
"autoMitigate": True,
"criteria": {
"allOf": [
{
"alertSensitivity": "Medium",
"criterionType": "DynamicThresholdCriterion",
"dimensions": [],
"failingPeriods": {"minFailingPeriodsToAlert": 4, "numberOfEvaluationPeriods": 4},
"metricName": "Percentage CPU",
"metricNamespace": "microsoft.compute/virtualmachines",
"name": "High_CPU_80",
"operator": "GreaterOrLessThan",
"timeAggregation": "Average",
}
],
"odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria",
},
"description": "This is the description of the rule1",
"enabled": True,
"evaluationFrequency": "PT1M",
"scopes": [
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme1",
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme2",
],
"severity": 3,
"targetResourceRegion": "southcentralus",
"targetResourceType": "Microsoft.Compute/virtualMachines",
"windowSize": "PT15M",
},
"tags": {},
},
)
print(response)
# x-ms-original-file: 2024-03-01-preview/createOrUpdateDynamicMetricAlertMultipleResource.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armmonitor_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/monitor/armmonitor"
)
// Generated from example definition: 2024-03-01-preview/createOrUpdateDynamicMetricAlertMultipleResource.json
func ExampleMetricAlertsClient_CreateOrUpdate_createOrUpdateADynamicAlertRuleForMultipleResources() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armmonitor.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewMetricAlertsClient().CreateOrUpdate(ctx, "gigtest", "MetricAlertOnMultipleResources", armmonitor.MetricAlertResource{
Location: to.Ptr("global"),
Properties: &armmonitor.MetricAlertProperties{
Description: to.Ptr("This is the description of the rule1"),
Actions: []*armmonitor.MetricAlertAction{
{
ActionGroupID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"),
WebHookProperties: map[string]*string{
"key11": to.Ptr("value11"),
"key12": to.Ptr("value12"),
},
},
},
AutoMitigate: to.Ptr(true),
Criteria: &armmonitor.MetricAlertMultipleResourceMultipleMetricCriteria{
AllOf: []armmonitor.MultiMetricCriteriaClassification{
&armmonitor.DynamicMetricCriteria{
Name: to.Ptr("High_CPU_80"),
AlertSensitivity: to.Ptr(armmonitor.DynamicThresholdSensitivityMedium),
CriterionType: to.Ptr(armmonitor.CriterionTypeDynamicThresholdCriterion),
Dimensions: []*armmonitor.MetricDimension{},
FailingPeriods: &armmonitor.DynamicThresholdFailingPeriods{
MinFailingPeriodsToAlert: to.Ptr[float32](4),
NumberOfEvaluationPeriods: to.Ptr[float32](4),
},
MetricName: to.Ptr("Percentage CPU"),
MetricNamespace: to.Ptr("microsoft.compute/virtualmachines"),
Operator: to.Ptr(armmonitor.DynamicThresholdOperatorGreaterOrLessThan),
TimeAggregation: to.Ptr(armmonitor.AggregationTypeEnumAverage),
},
},
ODataType: to.Ptr(armmonitor.OdatatypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria),
},
Enabled: to.Ptr(true),
EvaluationFrequency: to.Ptr("PT1M"),
Scopes: []*string{
to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme1"),
to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme2"),
},
Severity: to.Ptr[int32](3),
TargetResourceRegion: to.Ptr("southcentralus"),
TargetResourceType: to.Ptr("Microsoft.Compute/virtualMachines"),
WindowSize: to.Ptr("PT15M"),
},
Tags: map[string]*string{},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res = armmonitor.MetricAlertsClientCreateOrUpdateResponse{
// MetricAlertResource: armmonitor.MetricAlertResource{
// Type: to.Ptr("Microsoft.Insights/metricAlerts"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/providers/microsoft.insights/metricalerts/MetricAlertOnMultipleResources"),
// Location: to.Ptr("global"),
// Properties: &armmonitor.MetricAlertProperties{
// Description: to.Ptr("This is the description of the rule1"),
// Actions: []*armmonitor.MetricAlertAction{
// {
// ActionGroupID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"),
// WebHookProperties: map[string]*string{
// "key11": to.Ptr("value11"),
// "key12": to.Ptr("value12"),
// },
// },
// },
// AutoMitigate: to.Ptr(true),
// Criteria: &armmonitor.MetricAlertMultipleResourceMultipleMetricCriteria{
// AllOf: []armmonitor.MultiMetricCriteriaClassification{
// &armmonitor.DynamicMetricCriteria{
// Name: to.Ptr("High_CPU_80"),
// AlertSensitivity: to.Ptr(armmonitor.DynamicThresholdSensitivityMedium),
// CriterionType: to.Ptr(armmonitor.CriterionTypeDynamicThresholdCriterion),
// Dimensions: []*armmonitor.MetricDimension{
// },
// FailingPeriods: &armmonitor.DynamicThresholdFailingPeriods{
// MinFailingPeriodsToAlert: to.Ptr[float32](4),
// NumberOfEvaluationPeriods: to.Ptr[float32](4),
// },
// MetricName: to.Ptr("Percentage CPU"),
// MetricNamespace: to.Ptr("microsoft.compute/virtualmachines"),
// Operator: to.Ptr(armmonitor.DynamicThresholdOperatorGreaterOrLessThan),
// TimeAggregation: to.Ptr(armmonitor.AggregationTypeEnumAverage),
// },
// },
// ODataType: to.Ptr(armmonitor.OdatatypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria),
// },
// Enabled: to.Ptr(true),
// EvaluationFrequency: to.Ptr("PT1M"),
// Scopes: []*string{
// to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme1"),
// to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme2"),
// },
// Severity: to.Ptr[int32](3),
// TargetResourceRegion: to.Ptr("southcentralus"),
// TargetResourceType: to.Ptr("Microsoft.Compute/virtualMachines"),
// WindowSize: to.Ptr("PT15M"),
// },
// Tags: map[string]*string{
// "hidden-link:/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/Microsoft.Web/sites/leoalerttest": to.Ptr("Resource"),
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { MonitorClient } = require("@azure/arm-monitor");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to create or update an metric alert definition.
*
* @summary create or update an metric alert definition.
* x-ms-original-file: 2024-03-01-preview/createOrUpdateDynamicMetricAlertMultipleResource.json
*/
async function createOrUpdateADynamicAlertRuleForMultipleResources() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new MonitorClient(credential, subscriptionId);
const result = await client.metricAlerts.createOrUpdate(
"gigtest",
"MetricAlertOnMultipleResources",
{
location: "global",
description: "This is the description of the rule1",
actions: [
{
actionGroupId:
"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
webHookProperties: { key11: "value11", key12: "value12" },
},
],
autoMitigate: true,
criteria: {
allOf: [
{
name: "High_CPU_80",
alertSensitivity: "Medium",
criterionType: "DynamicThresholdCriterion",
dimensions: [],
failingPeriods: { minFailingPeriodsToAlert: 4, numberOfEvaluationPeriods: 4 },
metricName: "Percentage CPU",
metricNamespace: "microsoft.compute/virtualmachines",
operator: "GreaterOrLessThan",
timeAggregation: "Average",
},
],
odataType: "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria",
},
enabled: true,
evaluationFrequency: "PT1M",
scopes: [
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme1",
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme2",
],
severity: 3,
targetResourceRegion: "southcentralus",
targetResourceType: "Microsoft.Compute/virtualMachines",
windowSize: "PT15M",
tags: {},
},
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Voorbeeldrespons
{
"type": "Microsoft.Insights/metricAlerts",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/providers/microsoft.insights/metricalerts/MetricAlertOnMultipleResources",
"location": "global",
"properties": {
"description": "This is the description of the rule1",
"actions": [
{
"actionGroupId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
"webHookProperties": {
"key11": "value11",
"key12": "value12"
}
}
],
"autoMitigate": true,
"criteria": {
"allOf": [
{
"name": "High_CPU_80",
"alertSensitivity": "Medium",
"criterionType": "DynamicThresholdCriterion",
"dimensions": [],
"failingPeriods": {
"minFailingPeriodsToAlert": 4,
"numberOfEvaluationPeriods": 4
},
"metricName": "Percentage CPU",
"metricNamespace": "microsoft.compute/virtualmachines",
"operator": "GreaterOrLessThan",
"timeAggregation": "Average"
}
],
"odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria"
},
"enabled": true,
"evaluationFrequency": "PT1M",
"scopes": [
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme1",
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme2"
],
"severity": 3,
"targetResourceRegion": "southcentralus",
"targetResourceType": "Microsoft.Compute/virtualMachines",
"windowSize": "PT15M"
},
"tags": {
"hidden-link:/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/Microsoft.Web/sites/leoalerttest": "Resource"
}
}
Create or update a dynamic alert rule for Single Resource
Voorbeeldaanvraag
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/Microsoft.Insights/metricAlerts/chiricutin?api-version=2024-03-01-preview
{
"location": "global",
"properties": {
"description": "This is the description of the rule1",
"actions": [
{
"actionGroupId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
"webHookProperties": {
"key11": "value11",
"key12": "value12"
}
}
],
"autoMitigate": true,
"criteria": {
"allOf": [
{
"name": "High_CPU_80",
"alertSensitivity": "Medium",
"criterionType": "DynamicThresholdCriterion",
"dimensions": [],
"failingPeriods": {
"minFailingPeriodsToAlert": 4,
"numberOfEvaluationPeriods": 4
},
"ignoreDataBefore": "2019-04-04T21:00:00.000Z",
"metricName": "Percentage CPU",
"metricNamespace": "microsoft.compute/virtualmachines",
"operator": "GreaterOrLessThan",
"timeAggregation": "Average"
}
],
"odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria"
},
"enabled": true,
"evaluationFrequency": "PT1M",
"scopes": [
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme"
],
"severity": 3,
"windowSize": "PT15M"
},
"tags": {}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.monitor import MonitorManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-monitor
# USAGE
python create_or_update_dynamic_metric_alert_single_resource.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = MonitorManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.metric_alerts.create_or_update(
resource_group_name="gigtest",
rule_name="chiricutin",
parameters={
"location": "global",
"properties": {
"actions": [
{
"actionGroupId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
"webHookProperties": {"key11": "value11", "key12": "value12"},
}
],
"autoMitigate": True,
"criteria": {
"allOf": [
{
"alertSensitivity": "Medium",
"criterionType": "DynamicThresholdCriterion",
"dimensions": [],
"failingPeriods": {"minFailingPeriodsToAlert": 4, "numberOfEvaluationPeriods": 4},
"ignoreDataBefore": "2019-04-04T21:00:00.000Z",
"metricName": "Percentage CPU",
"metricNamespace": "microsoft.compute/virtualmachines",
"name": "High_CPU_80",
"operator": "GreaterOrLessThan",
"timeAggregation": "Average",
}
],
"odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria",
},
"description": "This is the description of the rule1",
"enabled": True,
"evaluationFrequency": "PT1M",
"scopes": [
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme"
],
"severity": 3,
"windowSize": "PT15M",
},
"tags": {},
},
)
print(response)
# x-ms-original-file: 2024-03-01-preview/createOrUpdateDynamicMetricAlertSingleResource.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armmonitor_test
import (
"context"
"log"
"time"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/monitor/armmonitor"
)
// Generated from example definition: 2024-03-01-preview/createOrUpdateDynamicMetricAlertSingleResource.json
func ExampleMetricAlertsClient_CreateOrUpdate_createOrUpdateADynamicAlertRuleForSingleResource() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armmonitor.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewMetricAlertsClient().CreateOrUpdate(ctx, "gigtest", "chiricutin", armmonitor.MetricAlertResource{
Location: to.Ptr("global"),
Properties: &armmonitor.MetricAlertProperties{
Description: to.Ptr("This is the description of the rule1"),
Actions: []*armmonitor.MetricAlertAction{
{
ActionGroupID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"),
WebHookProperties: map[string]*string{
"key11": to.Ptr("value11"),
"key12": to.Ptr("value12"),
},
},
},
AutoMitigate: to.Ptr(true),
Criteria: &armmonitor.MetricAlertMultipleResourceMultipleMetricCriteria{
AllOf: []armmonitor.MultiMetricCriteriaClassification{
&armmonitor.DynamicMetricCriteria{
Name: to.Ptr("High_CPU_80"),
AlertSensitivity: to.Ptr(armmonitor.DynamicThresholdSensitivityMedium),
CriterionType: to.Ptr(armmonitor.CriterionTypeDynamicThresholdCriterion),
Dimensions: []*armmonitor.MetricDimension{},
FailingPeriods: &armmonitor.DynamicThresholdFailingPeriods{
MinFailingPeriodsToAlert: to.Ptr[float32](4),
NumberOfEvaluationPeriods: to.Ptr[float32](4),
},
IgnoreDataBefore: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-04T21:00:00.000Z"); return t }()),
MetricName: to.Ptr("Percentage CPU"),
MetricNamespace: to.Ptr("microsoft.compute/virtualmachines"),
Operator: to.Ptr(armmonitor.DynamicThresholdOperatorGreaterOrLessThan),
TimeAggregation: to.Ptr(armmonitor.AggregationTypeEnumAverage),
},
},
ODataType: to.Ptr(armmonitor.OdatatypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria),
},
Enabled: to.Ptr(true),
EvaluationFrequency: to.Ptr("PT1M"),
Scopes: []*string{
to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme"),
},
Severity: to.Ptr[int32](3),
WindowSize: to.Ptr("PT15M"),
},
Tags: map[string]*string{},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res = armmonitor.MetricAlertsClientCreateOrUpdateResponse{
// MetricAlertResource: armmonitor.MetricAlertResource{
// Type: to.Ptr("Microsoft.Insights/metricAlerts"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/providers/microsoft.insights/metricalerts/chiricutin"),
// Location: to.Ptr("global"),
// Properties: &armmonitor.MetricAlertProperties{
// Description: to.Ptr("This is the description of the rule1"),
// Actions: []*armmonitor.MetricAlertAction{
// {
// ActionGroupID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"),
// WebHookProperties: map[string]*string{
// "key11": to.Ptr("value11"),
// "key12": to.Ptr("value12"),
// },
// },
// },
// AutoMitigate: to.Ptr(true),
// Criteria: &armmonitor.MetricAlertMultipleResourceMultipleMetricCriteria{
// AllOf: []armmonitor.MultiMetricCriteriaClassification{
// &armmonitor.DynamicMetricCriteria{
// Name: to.Ptr("High_CPU_80"),
// AlertSensitivity: to.Ptr(armmonitor.DynamicThresholdSensitivityMedium),
// CriterionType: to.Ptr(armmonitor.CriterionTypeDynamicThresholdCriterion),
// Dimensions: []*armmonitor.MetricDimension{
// },
// FailingPeriods: &armmonitor.DynamicThresholdFailingPeriods{
// MinFailingPeriodsToAlert: to.Ptr[float32](4),
// NumberOfEvaluationPeriods: to.Ptr[float32](4),
// },
// IgnoreDataBefore: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-04T21:00:00.000Z"); return t}()),
// MetricName: to.Ptr("Percentage CPU"),
// MetricNamespace: to.Ptr("microsoft.compute/virtualmachines"),
// Operator: to.Ptr(armmonitor.DynamicThresholdOperatorGreaterOrLessThan),
// TimeAggregation: to.Ptr(armmonitor.AggregationTypeEnumAverage),
// },
// },
// ODataType: to.Ptr(armmonitor.OdatatypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria),
// },
// Enabled: to.Ptr(true),
// EvaluationFrequency: to.Ptr("PT1M"),
// Scopes: []*string{
// to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme"),
// },
// Severity: to.Ptr[int32](3),
// TargetResourceRegion: to.Ptr("southcentralus"),
// TargetResourceType: to.Ptr("Microsoft.Compute/virtualMachines"),
// WindowSize: to.Ptr("PT15M"),
// },
// Tags: map[string]*string{
// "hidden-link:/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/Microsoft.Web/sites/leoalerttest": to.Ptr("Resource"),
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { MonitorClient } = require("@azure/arm-monitor");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to create or update an metric alert definition.
*
* @summary create or update an metric alert definition.
* x-ms-original-file: 2024-03-01-preview/createOrUpdateDynamicMetricAlertSingleResource.json
*/
async function createOrUpdateADynamicAlertRuleForSingleResource() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new MonitorClient(credential, subscriptionId);
const result = await client.metricAlerts.createOrUpdate("gigtest", "chiricutin", {
location: "global",
description: "This is the description of the rule1",
actions: [
{
actionGroupId:
"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
webHookProperties: { key11: "value11", key12: "value12" },
},
],
autoMitigate: true,
criteria: {
allOf: [
{
name: "High_CPU_80",
alertSensitivity: "Medium",
criterionType: "DynamicThresholdCriterion",
dimensions: [],
failingPeriods: { minFailingPeriodsToAlert: 4, numberOfEvaluationPeriods: 4 },
ignoreDataBefore: new Date("2019-04-04T21:00:00.000Z"),
metricName: "Percentage CPU",
metricNamespace: "microsoft.compute/virtualmachines",
operator: "GreaterOrLessThan",
timeAggregation: "Average",
},
],
odataType: "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria",
},
enabled: true,
evaluationFrequency: "PT1M",
scopes: [
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme",
],
severity: 3,
windowSize: "PT15M",
tags: {},
});
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Voorbeeldrespons
{
"type": "Microsoft.Insights/metricAlerts",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/providers/microsoft.insights/metricalerts/chiricutin",
"location": "global",
"properties": {
"description": "This is the description of the rule1",
"actions": [
{
"actionGroupId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
"webHookProperties": {
"key11": "value11",
"key12": "value12"
}
}
],
"autoMitigate": true,
"criteria": {
"allOf": [
{
"name": "High_CPU_80",
"alertSensitivity": "Medium",
"criterionType": "DynamicThresholdCriterion",
"dimensions": [],
"failingPeriods": {
"minFailingPeriodsToAlert": 4,
"numberOfEvaluationPeriods": 4
},
"ignoreDataBefore": "2019-04-04T21:00:00.000Z",
"metricName": "Percentage CPU",
"metricNamespace": "microsoft.compute/virtualmachines",
"operator": "GreaterOrLessThan",
"timeAggregation": "Average"
}
],
"odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria"
},
"enabled": true,
"evaluationFrequency": "PT1M",
"scopes": [
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme"
],
"severity": 3,
"targetResourceRegion": "southcentralus",
"targetResourceType": "Microsoft.Compute/virtualMachines",
"windowSize": "PT15M"
},
"tags": {
"hidden-link:/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/Microsoft.Web/sites/leoalerttest": "Resource"
}
}
Create or update a query based alert rule
Voorbeeldaanvraag
PUT https://management.azure.com/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Insights/metricAlerts/chiricutin?api-version=2024-03-01-preview
{
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/2f1a501a-6e1d-4f37-a445-462d7f8a563d/resourceGroups/AdisTest/providers/Microsoft.ManagedIdentity/userAssignedIdentities/msi-test-euap": {}
}
},
"location": "eastus",
"properties": {
"description": "This is the description of the rule1",
"actionProperties": {
"Email.Sujbect": "my custom email subject"
},
"actions": [
{
"actionGroupId": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"
}
],
"criteria": {
"allOf": [
{
"name": "Metric1",
"criterionType": "StaticThresholdCriterion",
"query": "avg({\"system.cpu.utilization\"}) > 90"
}
],
"failingPeriods": {
"for": "PT5M"
},
"odata.type": "Microsoft.Azure.Monitor.PromQLCriteria"
},
"customProperties": {
"key11": "value11",
"key12": "value12"
},
"enabled": true,
"evaluationFrequency": "PT1M",
"resolveConfiguration": {
"autoResolved": true,
"timeToResolve": "PT10M"
},
"scopes": [
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/microsoft.monitor/accounts/gigwadme"
],
"severity": 3
},
"tags": {}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.monitor import MonitorManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-monitor
# USAGE
python create_or_update_metric_alert_query.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = MonitorManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.metric_alerts.create_or_update(
resource_group_name="gigtest",
rule_name="chiricutin",
parameters={
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/2f1a501a-6e1d-4f37-a445-462d7f8a563d/resourceGroups/AdisTest/providers/Microsoft.ManagedIdentity/userAssignedIdentities/msi-test-euap": {}
},
},
"location": "eastus",
"properties": {
"actionProperties": {"Email.Sujbect": "my custom email subject"},
"actions": [
{
"actionGroupId": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"
}
],
"criteria": {
"allOf": [
{
"criterionType": "StaticThresholdCriterion",
"name": "Metric1",
"query": 'avg({"system.cpu.utilization"}) > 90',
}
],
"failingPeriods": {"for": "PT5M"},
"odata.type": "Microsoft.Azure.Monitor.PromQLCriteria",
},
"customProperties": {"key11": "value11", "key12": "value12"},
"description": "This is the description of the rule1",
"enabled": True,
"evaluationFrequency": "PT1M",
"resolveConfiguration": {"autoResolved": True, "timeToResolve": "PT10M"},
"scopes": [
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/microsoft.monitor/accounts/gigwadme"
],
"severity": 3,
},
"tags": {},
},
)
print(response)
# x-ms-original-file: 2024-03-01-preview/createOrUpdateMetricAlertQuery.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armmonitor_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/monitor/armmonitor"
)
// Generated from example definition: 2024-03-01-preview/createOrUpdateMetricAlertQuery.json
func ExampleMetricAlertsClient_CreateOrUpdate_createOrUpdateAQueryBasedAlertRule() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armmonitor.NewClientFactory("14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewMetricAlertsClient().CreateOrUpdate(ctx, "gigtest", "chiricutin", armmonitor.MetricAlertResource{
Identity: &armmonitor.Identity{
Type: to.Ptr(armmonitor.IdentityTypeUserAssigned),
UserAssignedIdentities: map[string]*armmonitor.UserIdentityProperties{
"/subscriptions/2f1a501a-6e1d-4f37-a445-462d7f8a563d/resourceGroups/AdisTest/providers/Microsoft.ManagedIdentity/userAssignedIdentities/msi-test-euap": {},
},
},
Location: to.Ptr("eastus"),
Properties: &armmonitor.MetricAlertProperties{
Description: to.Ptr("This is the description of the rule1"),
ActionProperties: map[string]*string{
"Email.Sujbect": to.Ptr("my custom email subject"),
},
Actions: []*armmonitor.MetricAlertAction{
{
ActionGroupID: to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"),
},
},
Criteria: &armmonitor.PromQLCriteria{
AllOf: []armmonitor.MultiPromQLCriteriaClassification{
&armmonitor.StaticPromQLCriteria{
Name: to.Ptr("Metric1"),
CriterionType: to.Ptr(armmonitor.CriterionTypeStaticThresholdCriterion),
Query: to.Ptr("avg({\"system.cpu.utilization\"}) > 90"),
},
},
FailingPeriods: &armmonitor.QueryFailingPeriods{
For: to.Ptr("PT5M"),
},
ODataType: to.Ptr(armmonitor.OdatatypeMicrosoftAzureMonitorPromQLCriteria),
},
CustomProperties: map[string]*string{
"key11": to.Ptr("value11"),
"key12": to.Ptr("value12"),
},
Enabled: to.Ptr(true),
EvaluationFrequency: to.Ptr("PT1M"),
ResolveConfiguration: &armmonitor.ResolveConfiguration{
AutoResolved: to.Ptr(true),
TimeToResolve: to.Ptr("PT10M"),
},
Scopes: []*string{
to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/microsoft.monitor/accounts/gigwadme"),
},
Severity: to.Ptr[int32](3),
},
Tags: map[string]*string{},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res = armmonitor.MetricAlertsClientCreateOrUpdateResponse{
// MetricAlertResource: armmonitor.MetricAlertResource{
// Type: to.Ptr("Microsoft.Insights/metricAlerts"),
// ID: to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/providers/microsoft.insights/metricalerts/chiricutin"),
// Identity: &armmonitor.Identity{
// Type: to.Ptr(armmonitor.IdentityTypeUserAssigned),
// TenantID: to.Ptr("72f988bf-86f1-41af-91ab-2d7cd011db47"),
// UserAssignedIdentities: map[string]*armmonitor.UserIdentityProperties{
// "/subscriptions/2f1a501a-6e1d-4f37-a445-462d7f8a563d/resourceGroups/AdisTest/providers/Microsoft.ManagedIdentity/userAssignedIdentities/msi-test-euap": &armmonitor.UserIdentityProperties{
// ClientID: to.Ptr("778f4d04-3c60-4622-a839-5cf05866c983"),
// PrincipalID: to.Ptr("669dd76d-cde8-4dc3-b882-1de566b0c628"),
// },
// },
// },
// Location: to.Ptr("eastus"),
// Properties: &armmonitor.MetricAlertProperties{
// Description: to.Ptr("This is the description of the rule1"),
// ActionProperties: map[string]*string{
// "Email.Sujbect": to.Ptr("my custom email subject"),
// },
// Actions: []*armmonitor.MetricAlertAction{
// {
// ActionGroupID: to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"),
// },
// },
// Criteria: &armmonitor.PromQLCriteria{
// AllOf: []armmonitor.MultiPromQLCriteriaClassification{
// &armmonitor.StaticPromQLCriteria{
// Name: to.Ptr("Metric1"),
// CriterionType: to.Ptr(armmonitor.CriterionTypeStaticThresholdCriterion),
// Query: to.Ptr("avg({\"system.cpu.utilization\"}) > 90"),
// },
// },
// FailingPeriods: &armmonitor.QueryFailingPeriods{
// For: to.Ptr("PT2M"),
// },
// ODataType: to.Ptr(armmonitor.OdatatypeMicrosoftAzureMonitorPromQLCriteria),
// },
// CustomProperties: map[string]*string{
// "key11": to.Ptr("value11"),
// "key12": to.Ptr("value12"),
// },
// Enabled: to.Ptr(true),
// EvaluationFrequency: to.Ptr("PT1M"),
// ResolveConfiguration: &armmonitor.ResolveConfiguration{
// AutoResolved: to.Ptr(true),
// TimeToResolve: to.Ptr("PT10M"),
// },
// Scopes: []*string{
// to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/microsoft.monitor/accounts/gigwadme"),
// },
// Severity: to.Ptr[int32](3),
// },
// Tags: map[string]*string{
// "hidden-link:/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/Microsoft.Web/sites/leoalerttest": to.Ptr("Resource"),
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { MonitorClient } = require("@azure/arm-monitor");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to create or update an metric alert definition.
*
* @summary create or update an metric alert definition.
* x-ms-original-file: 2024-03-01-preview/createOrUpdateMetricAlertQuery.json
*/
async function createOrUpdateAQueryBasedAlertRule() {
const credential = new DefaultAzureCredential();
const subscriptionId = "14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7";
const client = new MonitorClient(credential, subscriptionId);
const result = await client.metricAlerts.createOrUpdate("gigtest", "chiricutin", {
identity: {
type: "UserAssigned",
userAssignedIdentities: {
"/subscriptions/2f1a501a-6e1d-4f37-a445-462d7f8a563d/resourceGroups/AdisTest/providers/Microsoft.ManagedIdentity/userAssignedIdentities/msi-test-euap":
{},
},
},
location: "eastus",
description: "This is the description of the rule1",
actionProperties: { "Email.Sujbect": "my custom email subject" },
actions: [
{
actionGroupId:
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
},
],
criteria: {
allOf: [
{
name: "Metric1",
criterionType: "StaticThresholdCriterion",
query: 'avg({"system.cpu.utilization"}) > 90',
},
],
failingPeriods: { for: "PT5M" },
odataType: "Microsoft.Azure.Monitor.PromQLCriteria",
},
customProperties: { key11: "value11", key12: "value12" },
enabled: true,
evaluationFrequency: "PT1M",
resolveConfiguration: { autoResolved: true, timeToResolve: "PT10M" },
scopes: [
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/microsoft.monitor/accounts/gigwadme",
],
severity: 3,
tags: {},
});
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Voorbeeldrespons
{
"type": "Microsoft.Insights/metricAlerts",
"id": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/providers/microsoft.insights/metricalerts/chiricutin",
"identity": {
"type": "UserAssigned",
"tenantId": "72f988bf-86f1-41af-91ab-2d7cd011db47",
"userAssignedIdentities": {
"/subscriptions/2f1a501a-6e1d-4f37-a445-462d7f8a563d/resourceGroups/AdisTest/providers/Microsoft.ManagedIdentity/userAssignedIdentities/msi-test-euap": {
"clientId": "778f4d04-3c60-4622-a839-5cf05866c983",
"principalId": "669dd76d-cde8-4dc3-b882-1de566b0c628"
}
}
},
"location": "eastus",
"properties": {
"description": "This is the description of the rule1",
"actionProperties": {
"Email.Sujbect": "my custom email subject"
},
"actions": [
{
"actionGroupId": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"
}
],
"criteria": {
"allOf": [
{
"name": "Metric1",
"criterionType": "StaticThresholdCriterion",
"query": "avg({\"system.cpu.utilization\"}) > 90"
}
],
"failingPeriods": {
"for": "PT2M"
},
"odata.type": "Microsoft.Azure.Monitor.PromQLCriteria"
},
"customProperties": {
"key11": "value11",
"key12": "value12"
},
"enabled": true,
"evaluationFrequency": "PT1M",
"resolveConfiguration": {
"autoResolved": true,
"timeToResolve": "PT10M"
},
"scopes": [
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/microsoft.monitor/accounts/gigwadme"
],
"severity": 3
},
"tags": {
"hidden-link:/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/Microsoft.Web/sites/leoalerttest": "Resource"
}
}
Create or update a query based alert rule with dynamic threshold
Voorbeeldaanvraag
PUT https://management.azure.com/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Insights/metricAlerts/chiricutin?api-version=2024-03-01-preview
{
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/2f1a501a-6e1d-4f37-a445-462d7f8a563d/resourceGroups/AdisTest/providers/Microsoft.ManagedIdentity/userAssignedIdentities/msi-test-euap": {}
}
},
"location": "eastus",
"properties": {
"description": "This is the description of the rule1",
"actionProperties": {
"Email.Sujbect": "my custom email subject"
},
"actions": [
{
"actionGroupId": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"
}
],
"criteria": {
"allOf": [
{
"name": "Metric1",
"alertSensitivity": "Medium",
"criterionType": "DynamicThresholdCriterion",
"ignoreDataBefore": "2019-04-04T21:00:00.000Z",
"operator": "LessThan",
"query": "avg({\"system.cpu.utilization\"})"
}
],
"failingPeriods": {
"for": "PT5M"
},
"odata.type": "Microsoft.Azure.Monitor.PromQLCriteria"
},
"customProperties": {
"key11": "value11",
"key12": "value12"
},
"enabled": true,
"evaluationFrequency": "PT1M",
"resolveConfiguration": {
"autoResolved": true,
"timeToResolve": "PT10M"
},
"scopes": [
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/microsoft.monitor/accounts/gigwadme"
],
"severity": 3
},
"tags": {}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.monitor import MonitorManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-monitor
# USAGE
python create_or_update_metric_alert_query_dt.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = MonitorManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.metric_alerts.create_or_update(
resource_group_name="gigtest",
rule_name="chiricutin",
parameters={
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/2f1a501a-6e1d-4f37-a445-462d7f8a563d/resourceGroups/AdisTest/providers/Microsoft.ManagedIdentity/userAssignedIdentities/msi-test-euap": {}
},
},
"location": "eastus",
"properties": {
"actionProperties": {"Email.Sujbect": "my custom email subject"},
"actions": [
{
"actionGroupId": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"
}
],
"criteria": {
"allOf": [
{
"alertSensitivity": "Medium",
"criterionType": "DynamicThresholdCriterion",
"ignoreDataBefore": "2019-04-04T21:00:00.000Z",
"name": "Metric1",
"operator": "LessThan",
"query": 'avg({"system.cpu.utilization"})',
}
],
"failingPeriods": {"for": "PT5M"},
"odata.type": "Microsoft.Azure.Monitor.PromQLCriteria",
},
"customProperties": {"key11": "value11", "key12": "value12"},
"description": "This is the description of the rule1",
"enabled": True,
"evaluationFrequency": "PT1M",
"resolveConfiguration": {"autoResolved": True, "timeToResolve": "PT10M"},
"scopes": [
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/microsoft.monitor/accounts/gigwadme"
],
"severity": 3,
},
"tags": {},
},
)
print(response)
# x-ms-original-file: 2024-03-01-preview/createOrUpdateMetricAlertQueryDT.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armmonitor_test
import (
"context"
"log"
"time"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/monitor/armmonitor"
)
// Generated from example definition: 2024-03-01-preview/createOrUpdateMetricAlertQueryDT.json
func ExampleMetricAlertsClient_CreateOrUpdate_createOrUpdateAQueryBasedAlertRuleWithDynamicThreshold() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armmonitor.NewClientFactory("14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewMetricAlertsClient().CreateOrUpdate(ctx, "gigtest", "chiricutin", armmonitor.MetricAlertResource{
Identity: &armmonitor.Identity{
Type: to.Ptr(armmonitor.IdentityTypeUserAssigned),
UserAssignedIdentities: map[string]*armmonitor.UserIdentityProperties{
"/subscriptions/2f1a501a-6e1d-4f37-a445-462d7f8a563d/resourceGroups/AdisTest/providers/Microsoft.ManagedIdentity/userAssignedIdentities/msi-test-euap": {},
},
},
Location: to.Ptr("eastus"),
Properties: &armmonitor.MetricAlertProperties{
Description: to.Ptr("This is the description of the rule1"),
ActionProperties: map[string]*string{
"Email.Sujbect": to.Ptr("my custom email subject"),
},
Actions: []*armmonitor.MetricAlertAction{
{
ActionGroupID: to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"),
},
},
Criteria: &armmonitor.PromQLCriteria{
AllOf: []armmonitor.MultiPromQLCriteriaClassification{
&armmonitor.DynamicPromQLCriteria{
Name: to.Ptr("Metric1"),
AlertSensitivity: to.Ptr(armmonitor.DynamicThresholdSensitivityMedium),
CriterionType: to.Ptr(armmonitor.CriterionTypeDynamicThresholdCriterion),
IgnoreDataBefore: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-04T21:00:00.000Z"); return t }()),
Operator: to.Ptr(armmonitor.DynamicThresholdOperatorLessThan),
Query: to.Ptr("avg({\"system.cpu.utilization\"})"),
},
},
FailingPeriods: &armmonitor.QueryFailingPeriods{
For: to.Ptr("PT5M"),
},
ODataType: to.Ptr(armmonitor.OdatatypeMicrosoftAzureMonitorPromQLCriteria),
},
CustomProperties: map[string]*string{
"key11": to.Ptr("value11"),
"key12": to.Ptr("value12"),
},
Enabled: to.Ptr(true),
EvaluationFrequency: to.Ptr("PT1M"),
ResolveConfiguration: &armmonitor.ResolveConfiguration{
AutoResolved: to.Ptr(true),
TimeToResolve: to.Ptr("PT10M"),
},
Scopes: []*string{
to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/microsoft.monitor/accounts/gigwadme"),
},
Severity: to.Ptr[int32](3),
},
Tags: map[string]*string{},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res = armmonitor.MetricAlertsClientCreateOrUpdateResponse{
// MetricAlertResource: armmonitor.MetricAlertResource{
// Type: to.Ptr("Microsoft.Insights/metricAlerts"),
// ID: to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/providers/microsoft.insights/metricalerts/chiricutin"),
// Identity: &armmonitor.Identity{
// Type: to.Ptr(armmonitor.IdentityTypeUserAssigned),
// TenantID: to.Ptr("72f988bf-86f1-41af-91ab-2d7cd011db47"),
// UserAssignedIdentities: map[string]*armmonitor.UserIdentityProperties{
// "/subscriptions/2f1a501a-6e1d-4f37-a445-462d7f8a563d/resourceGroups/AdisTest/providers/Microsoft.ManagedIdentity/userAssignedIdentities/msi-test-euap": &armmonitor.UserIdentityProperties{
// ClientID: to.Ptr("778f4d04-3c60-4622-a839-5cf05866c983"),
// PrincipalID: to.Ptr("669dd76d-cde8-4dc3-b882-1de566b0c628"),
// },
// },
// },
// Location: to.Ptr("eastus"),
// Properties: &armmonitor.MetricAlertProperties{
// Description: to.Ptr("This is the description of the rule1"),
// ActionProperties: map[string]*string{
// "Email.Sujbect": to.Ptr("my custom email subject"),
// },
// Actions: []*armmonitor.MetricAlertAction{
// {
// ActionGroupID: to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"),
// },
// },
// Criteria: &armmonitor.PromQLCriteria{
// AllOf: []armmonitor.MultiPromQLCriteriaClassification{
// &armmonitor.DynamicPromQLCriteria{
// Name: to.Ptr("Metric1"),
// AlertSensitivity: to.Ptr(armmonitor.DynamicThresholdSensitivityMedium),
// CriterionType: to.Ptr(armmonitor.CriterionTypeDynamicThresholdCriterion),
// IgnoreDataBefore: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-04T21:00:00.000Z"); return t}()),
// Operator: to.Ptr(armmonitor.DynamicThresholdOperatorLessThan),
// Query: to.Ptr("avg({\"system.cpu.utilization\"})"),
// },
// },
// FailingPeriods: &armmonitor.QueryFailingPeriods{
// For: to.Ptr("PT2M"),
// },
// ODataType: to.Ptr(armmonitor.OdatatypeMicrosoftAzureMonitorPromQLCriteria),
// },
// CustomProperties: map[string]*string{
// "key11": to.Ptr("value11"),
// "key12": to.Ptr("value12"),
// },
// Enabled: to.Ptr(true),
// EvaluationFrequency: to.Ptr("PT1M"),
// ResolveConfiguration: &armmonitor.ResolveConfiguration{
// AutoResolved: to.Ptr(true),
// TimeToResolve: to.Ptr("PT10M"),
// },
// Scopes: []*string{
// to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/microsoft.monitor/accounts/gigwadme"),
// },
// Severity: to.Ptr[int32](3),
// },
// Tags: map[string]*string{
// "hidden-link:/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/Microsoft.Web/sites/leoalerttest": to.Ptr("Resource"),
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { MonitorClient } = require("@azure/arm-monitor");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to create or update an metric alert definition.
*
* @summary create or update an metric alert definition.
* x-ms-original-file: 2024-03-01-preview/createOrUpdateMetricAlertQueryDT.json
*/
async function createOrUpdateAQueryBasedAlertRuleWithDynamicThreshold() {
const credential = new DefaultAzureCredential();
const subscriptionId = "14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7";
const client = new MonitorClient(credential, subscriptionId);
const result = await client.metricAlerts.createOrUpdate("gigtest", "chiricutin", {
identity: {
type: "UserAssigned",
userAssignedIdentities: {
"/subscriptions/2f1a501a-6e1d-4f37-a445-462d7f8a563d/resourceGroups/AdisTest/providers/Microsoft.ManagedIdentity/userAssignedIdentities/msi-test-euap":
{},
},
},
location: "eastus",
description: "This is the description of the rule1",
actionProperties: { "Email.Sujbect": "my custom email subject" },
actions: [
{
actionGroupId:
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
},
],
criteria: {
allOf: [
{
name: "Metric1",
alertSensitivity: "Medium",
criterionType: "DynamicThresholdCriterion",
ignoreDataBefore: new Date("2019-04-04T21:00:00.000Z"),
operator: "LessThan",
query: 'avg({"system.cpu.utilization"})',
},
],
failingPeriods: { for: "PT5M" },
odataType: "Microsoft.Azure.Monitor.PromQLCriteria",
},
customProperties: { key11: "value11", key12: "value12" },
enabled: true,
evaluationFrequency: "PT1M",
resolveConfiguration: { autoResolved: true, timeToResolve: "PT10M" },
scopes: [
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/microsoft.monitor/accounts/gigwadme",
],
severity: 3,
tags: {},
});
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Voorbeeldrespons
{
"type": "Microsoft.Insights/metricAlerts",
"id": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/providers/microsoft.insights/metricalerts/chiricutin",
"identity": {
"type": "UserAssigned",
"tenantId": "72f988bf-86f1-41af-91ab-2d7cd011db47",
"userAssignedIdentities": {
"/subscriptions/2f1a501a-6e1d-4f37-a445-462d7f8a563d/resourceGroups/AdisTest/providers/Microsoft.ManagedIdentity/userAssignedIdentities/msi-test-euap": {
"clientId": "778f4d04-3c60-4622-a839-5cf05866c983",
"principalId": "669dd76d-cde8-4dc3-b882-1de566b0c628"
}
}
},
"location": "eastus",
"properties": {
"description": "This is the description of the rule1",
"actionProperties": {
"Email.Sujbect": "my custom email subject"
},
"actions": [
{
"actionGroupId": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"
}
],
"criteria": {
"allOf": [
{
"name": "Metric1",
"alertSensitivity": "Medium",
"criterionType": "DynamicThresholdCriterion",
"ignoreDataBefore": "2019-04-04T21:00:00.000Z",
"operator": "LessThan",
"query": "avg({\"system.cpu.utilization\"})"
}
],
"failingPeriods": {
"for": "PT2M"
},
"odata.type": "Microsoft.Azure.Monitor.PromQLCriteria"
},
"customProperties": {
"key11": "value11",
"key12": "value12"
},
"enabled": true,
"evaluationFrequency": "PT1M",
"resolveConfiguration": {
"autoResolved": true,
"timeToResolve": "PT10M"
},
"scopes": [
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/microsoft.monitor/accounts/gigwadme"
],
"severity": 3
},
"tags": {
"hidden-link:/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/Microsoft.Web/sites/leoalerttest": "Resource"
}
}
Create or update a resource centric query based alert rule
Voorbeeldaanvraag
PUT https://management.azure.com/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Insights/metricAlerts/chiricutin?api-version=2024-03-01-preview
{
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/2f1a501a-6e1d-4f37-a445-462d7f8a563d/resourceGroups/AdisTest/providers/Microsoft.ManagedIdentity/userAssignedIdentities/msi-test-euap": {}
}
},
"location": "eastus",
"properties": {
"description": "This is the description of the rule1",
"actionProperties": {
"Email.Sujbect": "my custom email subject"
},
"actions": [
{
"actionGroupId": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"
}
],
"criteria": {
"allOf": [
{
"name": "Metric1",
"criterionType": "StaticThresholdCriterion",
"query": "avg({\"system.cpu.utilization\"}) > 90"
}
],
"failingPeriods": {
"for": "PT5M"
},
"odata.type": "Microsoft.Azure.Monitor.PromQLCriteria"
},
"customProperties": {
"key11": "value11",
"key12": "value12"
},
"enabled": true,
"evaluationFrequency": "PT1M",
"resolveConfiguration": {
"autoResolved": true,
"timeToResolve": "PT10M"
},
"scopes": [
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/microsoft.compute/virtualMachines/myVmName"
],
"severity": 3
},
"tags": {}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.monitor import MonitorManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-monitor
# USAGE
python create_or_update_metric_alert_query_resource_centric.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = MonitorManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.metric_alerts.create_or_update(
resource_group_name="gigtest",
rule_name="chiricutin",
parameters={
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/2f1a501a-6e1d-4f37-a445-462d7f8a563d/resourceGroups/AdisTest/providers/Microsoft.ManagedIdentity/userAssignedIdentities/msi-test-euap": {}
},
},
"location": "eastus",
"properties": {
"actionProperties": {"Email.Sujbect": "my custom email subject"},
"actions": [
{
"actionGroupId": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"
}
],
"criteria": {
"allOf": [
{
"criterionType": "StaticThresholdCriterion",
"name": "Metric1",
"query": 'avg({"system.cpu.utilization"}) > 90',
}
],
"failingPeriods": {"for": "PT5M"},
"odata.type": "Microsoft.Azure.Monitor.PromQLCriteria",
},
"customProperties": {"key11": "value11", "key12": "value12"},
"description": "This is the description of the rule1",
"enabled": True,
"evaluationFrequency": "PT1M",
"resolveConfiguration": {"autoResolved": True, "timeToResolve": "PT10M"},
"scopes": [
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/microsoft.compute/virtualMachines/myVmName"
],
"severity": 3,
},
"tags": {},
},
)
print(response)
# x-ms-original-file: 2024-03-01-preview/createOrUpdateMetricAlertQueryResourceCentric.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armmonitor_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/monitor/armmonitor"
)
// Generated from example definition: 2024-03-01-preview/createOrUpdateMetricAlertQueryResourceCentric.json
func ExampleMetricAlertsClient_CreateOrUpdate_createOrUpdateAResourceCentricQueryBasedAlertRule() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armmonitor.NewClientFactory("14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewMetricAlertsClient().CreateOrUpdate(ctx, "gigtest", "chiricutin", armmonitor.MetricAlertResource{
Identity: &armmonitor.Identity{
Type: to.Ptr(armmonitor.IdentityTypeUserAssigned),
UserAssignedIdentities: map[string]*armmonitor.UserIdentityProperties{
"/subscriptions/2f1a501a-6e1d-4f37-a445-462d7f8a563d/resourceGroups/AdisTest/providers/Microsoft.ManagedIdentity/userAssignedIdentities/msi-test-euap": {},
},
},
Location: to.Ptr("eastus"),
Properties: &armmonitor.MetricAlertProperties{
Description: to.Ptr("This is the description of the rule1"),
ActionProperties: map[string]*string{
"Email.Sujbect": to.Ptr("my custom email subject"),
},
Actions: []*armmonitor.MetricAlertAction{
{
ActionGroupID: to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"),
},
},
Criteria: &armmonitor.PromQLCriteria{
AllOf: []armmonitor.MultiPromQLCriteriaClassification{
&armmonitor.StaticPromQLCriteria{
Name: to.Ptr("Metric1"),
CriterionType: to.Ptr(armmonitor.CriterionTypeStaticThresholdCriterion),
Query: to.Ptr("avg({\"system.cpu.utilization\"}) > 90"),
},
},
FailingPeriods: &armmonitor.QueryFailingPeriods{
For: to.Ptr("PT5M"),
},
ODataType: to.Ptr(armmonitor.OdatatypeMicrosoftAzureMonitorPromQLCriteria),
},
CustomProperties: map[string]*string{
"key11": to.Ptr("value11"),
"key12": to.Ptr("value12"),
},
Enabled: to.Ptr(true),
EvaluationFrequency: to.Ptr("PT1M"),
ResolveConfiguration: &armmonitor.ResolveConfiguration{
AutoResolved: to.Ptr(true),
TimeToResolve: to.Ptr("PT10M"),
},
Scopes: []*string{
to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/microsoft.compute/virtualMachines/myVmName"),
},
Severity: to.Ptr[int32](3),
},
Tags: map[string]*string{},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res = armmonitor.MetricAlertsClientCreateOrUpdateResponse{
// MetricAlertResource: armmonitor.MetricAlertResource{
// Type: to.Ptr("Microsoft.Insights/metricAlerts"),
// ID: to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/providers/microsoft.insights/metricalerts/chiricutin"),
// Identity: &armmonitor.Identity{
// Type: to.Ptr(armmonitor.IdentityTypeUserAssigned),
// TenantID: to.Ptr("72f988bf-86f1-41af-91ab-2d7cd011db47"),
// UserAssignedIdentities: map[string]*armmonitor.UserIdentityProperties{
// "/subscriptions/2f1a501a-6e1d-4f37-a445-462d7f8a563d/resourceGroups/AdisTest/providers/Microsoft.ManagedIdentity/userAssignedIdentities/msi-test-euap": &armmonitor.UserIdentityProperties{
// ClientID: to.Ptr("778f4d04-3c60-4622-a839-5cf05866c983"),
// PrincipalID: to.Ptr("669dd76d-cde8-4dc3-b882-1de566b0c628"),
// },
// },
// },
// Location: to.Ptr("eastus"),
// Properties: &armmonitor.MetricAlertProperties{
// Description: to.Ptr("This is the description of the rule1"),
// ActionProperties: map[string]*string{
// "Email.Sujbect": to.Ptr("my custom email subject"),
// },
// Actions: []*armmonitor.MetricAlertAction{
// {
// ActionGroupID: to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"),
// },
// },
// Criteria: &armmonitor.PromQLCriteria{
// AllOf: []armmonitor.MultiPromQLCriteriaClassification{
// &armmonitor.StaticPromQLCriteria{
// Name: to.Ptr("Metric1"),
// CriterionType: to.Ptr(armmonitor.CriterionTypeStaticThresholdCriterion),
// Query: to.Ptr("avg({\"system.cpu.utilization\"}) > 90"),
// },
// },
// FailingPeriods: &armmonitor.QueryFailingPeriods{
// For: to.Ptr("PT2M"),
// },
// ODataType: to.Ptr(armmonitor.OdatatypeMicrosoftAzureMonitorPromQLCriteria),
// },
// CustomProperties: map[string]*string{
// "key11": to.Ptr("value11"),
// "key12": to.Ptr("value12"),
// },
// Enabled: to.Ptr(true),
// EvaluationFrequency: to.Ptr("PT1M"),
// ResolveConfiguration: &armmonitor.ResolveConfiguration{
// AutoResolved: to.Ptr(true),
// TimeToResolve: to.Ptr("PT10M"),
// },
// Scopes: []*string{
// to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/microsoft.compute/virtualMachines/myVmName"),
// },
// Severity: to.Ptr[int32](3),
// },
// Tags: map[string]*string{
// "hidden-link:/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/Microsoft.Web/sites/leoalerttest": to.Ptr("Resource"),
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { MonitorClient } = require("@azure/arm-monitor");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to create or update an metric alert definition.
*
* @summary create or update an metric alert definition.
* x-ms-original-file: 2024-03-01-preview/createOrUpdateMetricAlertQueryResourceCentric.json
*/
async function createOrUpdateAResourceCentricQueryBasedAlertRule() {
const credential = new DefaultAzureCredential();
const subscriptionId = "14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7";
const client = new MonitorClient(credential, subscriptionId);
const result = await client.metricAlerts.createOrUpdate("gigtest", "chiricutin", {
identity: {
type: "UserAssigned",
userAssignedIdentities: {
"/subscriptions/2f1a501a-6e1d-4f37-a445-462d7f8a563d/resourceGroups/AdisTest/providers/Microsoft.ManagedIdentity/userAssignedIdentities/msi-test-euap":
{},
},
},
location: "eastus",
description: "This is the description of the rule1",
actionProperties: { "Email.Sujbect": "my custom email subject" },
actions: [
{
actionGroupId:
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
},
],
criteria: {
allOf: [
{
name: "Metric1",
criterionType: "StaticThresholdCriterion",
query: 'avg({"system.cpu.utilization"}) > 90',
},
],
failingPeriods: { for: "PT5M" },
odataType: "Microsoft.Azure.Monitor.PromQLCriteria",
},
customProperties: { key11: "value11", key12: "value12" },
enabled: true,
evaluationFrequency: "PT1M",
resolveConfiguration: { autoResolved: true, timeToResolve: "PT10M" },
scopes: [
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/microsoft.compute/virtualMachines/myVmName",
],
severity: 3,
tags: {},
});
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Voorbeeldrespons
{
"type": "Microsoft.Insights/metricAlerts",
"id": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/providers/microsoft.insights/metricalerts/chiricutin",
"identity": {
"type": "UserAssigned",
"tenantId": "72f988bf-86f1-41af-91ab-2d7cd011db47",
"userAssignedIdentities": {
"/subscriptions/2f1a501a-6e1d-4f37-a445-462d7f8a563d/resourceGroups/AdisTest/providers/Microsoft.ManagedIdentity/userAssignedIdentities/msi-test-euap": {
"clientId": "778f4d04-3c60-4622-a839-5cf05866c983",
"principalId": "669dd76d-cde8-4dc3-b882-1de566b0c628"
}
}
},
"location": "eastus",
"properties": {
"description": "This is the description of the rule1",
"actionProperties": {
"Email.Sujbect": "my custom email subject"
},
"actions": [
{
"actionGroupId": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"
}
],
"criteria": {
"allOf": [
{
"name": "Metric1",
"criterionType": "StaticThresholdCriterion",
"query": "avg({\"system.cpu.utilization\"}) > 90"
}
],
"failingPeriods": {
"for": "PT2M"
},
"odata.type": "Microsoft.Azure.Monitor.PromQLCriteria"
},
"customProperties": {
"key11": "value11",
"key12": "value12"
},
"enabled": true,
"evaluationFrequency": "PT1M",
"resolveConfiguration": {
"autoResolved": true,
"timeToResolve": "PT10M"
},
"scopes": [
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/microsoft.compute/virtualMachines/myVmName"
],
"severity": 3
},
"tags": {
"hidden-link:/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/Microsoft.Web/sites/leoalerttest": "Resource"
}
}
Create or update a resource centric query based alert rule for Multiple Resources
Voorbeeldaanvraag
PUT https://management.azure.com/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Insights/metricAlerts/chiricutin?api-version=2024-03-01-preview
{
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/2f1a501a-6e1d-4f37-a445-462d7f8a563d/resourceGroups/AdisTest/providers/Microsoft.ManagedIdentity/userAssignedIdentities/msi-test-euap": {}
}
},
"location": "eastus",
"properties": {
"description": "This is the description of the rule1",
"actionProperties": {
"Email.Sujbect": "my custom email subject"
},
"actions": [
{
"actionGroupId": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"
}
],
"criteria": {
"allOf": [
{
"name": "Metric1",
"criterionType": "StaticThresholdCriterion",
"query": "avg({\"system.cpu.utilization\"}) by (\"microsoft.resourceid\") > 90"
}
],
"failingPeriods": {
"for": "PT5M"
},
"odata.type": "Microsoft.Azure.Monitor.PromQLCriteria"
},
"customProperties": {
"key11": "value11",
"key12": "value12"
},
"enabled": true,
"evaluationFrequency": "PT1M",
"resolveConfiguration": {
"autoResolved": true,
"timeToResolve": "PT10M"
},
"scopes": [
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7"
],
"severity": 3
},
"tags": {}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.monitor import MonitorManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-monitor
# USAGE
python create_or_update_metric_alert_query_multi_resource.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = MonitorManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.metric_alerts.create_or_update(
resource_group_name="gigtest",
rule_name="chiricutin",
parameters={
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/2f1a501a-6e1d-4f37-a445-462d7f8a563d/resourceGroups/AdisTest/providers/Microsoft.ManagedIdentity/userAssignedIdentities/msi-test-euap": {}
},
},
"location": "eastus",
"properties": {
"actionProperties": {"Email.Sujbect": "my custom email subject"},
"actions": [
{
"actionGroupId": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"
}
],
"criteria": {
"allOf": [
{
"criterionType": "StaticThresholdCriterion",
"name": "Metric1",
"query": 'avg({"system.cpu.utilization"}) by ("microsoft.resourceid") > 90',
}
],
"failingPeriods": {"for": "PT5M"},
"odata.type": "Microsoft.Azure.Monitor.PromQLCriteria",
},
"customProperties": {"key11": "value11", "key12": "value12"},
"description": "This is the description of the rule1",
"enabled": True,
"evaluationFrequency": "PT1M",
"resolveConfiguration": {"autoResolved": True, "timeToResolve": "PT10M"},
"scopes": ["/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7"],
"severity": 3,
},
"tags": {},
},
)
print(response)
# x-ms-original-file: 2024-03-01-preview/createOrUpdateMetricAlertQueryMultiResource.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armmonitor_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/monitor/armmonitor"
)
// Generated from example definition: 2024-03-01-preview/createOrUpdateMetricAlertQueryMultiResource.json
func ExampleMetricAlertsClient_CreateOrUpdate_createOrUpdateAResourceCentricQueryBasedAlertRuleForMultipleResources() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armmonitor.NewClientFactory("14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewMetricAlertsClient().CreateOrUpdate(ctx, "gigtest", "chiricutin", armmonitor.MetricAlertResource{
Identity: &armmonitor.Identity{
Type: to.Ptr(armmonitor.IdentityTypeUserAssigned),
UserAssignedIdentities: map[string]*armmonitor.UserIdentityProperties{
"/subscriptions/2f1a501a-6e1d-4f37-a445-462d7f8a563d/resourceGroups/AdisTest/providers/Microsoft.ManagedIdentity/userAssignedIdentities/msi-test-euap": {},
},
},
Location: to.Ptr("eastus"),
Properties: &armmonitor.MetricAlertProperties{
Description: to.Ptr("This is the description of the rule1"),
ActionProperties: map[string]*string{
"Email.Sujbect": to.Ptr("my custom email subject"),
},
Actions: []*armmonitor.MetricAlertAction{
{
ActionGroupID: to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"),
},
},
Criteria: &armmonitor.PromQLCriteria{
AllOf: []armmonitor.MultiPromQLCriteriaClassification{
&armmonitor.StaticPromQLCriteria{
Name: to.Ptr("Metric1"),
CriterionType: to.Ptr(armmonitor.CriterionTypeStaticThresholdCriterion),
Query: to.Ptr("avg({\"system.cpu.utilization\"}) by (\"microsoft.resourceid\") > 90"),
},
},
FailingPeriods: &armmonitor.QueryFailingPeriods{
For: to.Ptr("PT5M"),
},
ODataType: to.Ptr(armmonitor.OdatatypeMicrosoftAzureMonitorPromQLCriteria),
},
CustomProperties: map[string]*string{
"key11": to.Ptr("value11"),
"key12": to.Ptr("value12"),
},
Enabled: to.Ptr(true),
EvaluationFrequency: to.Ptr("PT1M"),
ResolveConfiguration: &armmonitor.ResolveConfiguration{
AutoResolved: to.Ptr(true),
TimeToResolve: to.Ptr("PT10M"),
},
Scopes: []*string{
to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7"),
},
Severity: to.Ptr[int32](3),
},
Tags: map[string]*string{},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res = armmonitor.MetricAlertsClientCreateOrUpdateResponse{
// MetricAlertResource: armmonitor.MetricAlertResource{
// Type: to.Ptr("Microsoft.Insights/metricAlerts"),
// ID: to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/providers/microsoft.insights/metricalerts/chiricutin"),
// Identity: &armmonitor.Identity{
// Type: to.Ptr(armmonitor.IdentityTypeUserAssigned),
// TenantID: to.Ptr("72f988bf-86f1-41af-91ab-2d7cd011db47"),
// UserAssignedIdentities: map[string]*armmonitor.UserIdentityProperties{
// "/subscriptions/2f1a501a-6e1d-4f37-a445-462d7f8a563d/resourceGroups/AdisTest/providers/Microsoft.ManagedIdentity/userAssignedIdentities/msi-test-euap": &armmonitor.UserIdentityProperties{
// ClientID: to.Ptr("778f4d04-3c60-4622-a839-5cf05866c983"),
// PrincipalID: to.Ptr("669dd76d-cde8-4dc3-b882-1de566b0c628"),
// },
// },
// },
// Location: to.Ptr("eastus"),
// Properties: &armmonitor.MetricAlertProperties{
// Description: to.Ptr("This is the description of the rule1"),
// ActionProperties: map[string]*string{
// "Email.Sujbect": to.Ptr("my custom email subject"),
// },
// Actions: []*armmonitor.MetricAlertAction{
// {
// ActionGroupID: to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"),
// },
// },
// Criteria: &armmonitor.PromQLCriteria{
// AllOf: []armmonitor.MultiPromQLCriteriaClassification{
// &armmonitor.StaticPromQLCriteria{
// Name: to.Ptr("Metric1"),
// CriterionType: to.Ptr(armmonitor.CriterionTypeStaticThresholdCriterion),
// Query: to.Ptr("avg({\"system.cpu.utilization\"}) by (\"microsoft.resourceid\") > 90"),
// },
// },
// FailingPeriods: &armmonitor.QueryFailingPeriods{
// For: to.Ptr("PT2M"),
// },
// ODataType: to.Ptr(armmonitor.OdatatypeMicrosoftAzureMonitorPromQLCriteria),
// },
// CustomProperties: map[string]*string{
// "key11": to.Ptr("value11"),
// "key12": to.Ptr("value12"),
// },
// Enabled: to.Ptr(true),
// EvaluationFrequency: to.Ptr("PT1M"),
// ResolveConfiguration: &armmonitor.ResolveConfiguration{
// AutoResolved: to.Ptr(true),
// TimeToResolve: to.Ptr("PT10M"),
// },
// Scopes: []*string{
// to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7"),
// },
// Severity: to.Ptr[int32](3),
// },
// Tags: map[string]*string{
// "hidden-link:/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/Microsoft.Web/sites/leoalerttest": to.Ptr("Resource"),
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { MonitorClient } = require("@azure/arm-monitor");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to create or update an metric alert definition.
*
* @summary create or update an metric alert definition.
* x-ms-original-file: 2024-03-01-preview/createOrUpdateMetricAlertQueryMultiResource.json
*/
async function createOrUpdateAResourceCentricQueryBasedAlertRuleForMultipleResources() {
const credential = new DefaultAzureCredential();
const subscriptionId = "14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7";
const client = new MonitorClient(credential, subscriptionId);
const result = await client.metricAlerts.createOrUpdate("gigtest", "chiricutin", {
identity: {
type: "UserAssigned",
userAssignedIdentities: {
"/subscriptions/2f1a501a-6e1d-4f37-a445-462d7f8a563d/resourceGroups/AdisTest/providers/Microsoft.ManagedIdentity/userAssignedIdentities/msi-test-euap":
{},
},
},
location: "eastus",
description: "This is the description of the rule1",
actionProperties: { "Email.Sujbect": "my custom email subject" },
actions: [
{
actionGroupId:
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
},
],
criteria: {
allOf: [
{
name: "Metric1",
criterionType: "StaticThresholdCriterion",
query: 'avg({"system.cpu.utilization"}) by ("microsoft.resourceid") > 90',
},
],
failingPeriods: { for: "PT5M" },
odataType: "Microsoft.Azure.Monitor.PromQLCriteria",
},
customProperties: { key11: "value11", key12: "value12" },
enabled: true,
evaluationFrequency: "PT1M",
resolveConfiguration: { autoResolved: true, timeToResolve: "PT10M" },
scopes: ["/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7"],
severity: 3,
tags: {},
});
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Voorbeeldrespons
{
"type": "Microsoft.Insights/metricAlerts",
"id": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/providers/microsoft.insights/metricalerts/chiricutin",
"identity": {
"type": "UserAssigned",
"tenantId": "72f988bf-86f1-41af-91ab-2d7cd011db47",
"userAssignedIdentities": {
"/subscriptions/2f1a501a-6e1d-4f37-a445-462d7f8a563d/resourceGroups/AdisTest/providers/Microsoft.ManagedIdentity/userAssignedIdentities/msi-test-euap": {
"clientId": "778f4d04-3c60-4622-a839-5cf05866c983",
"principalId": "669dd76d-cde8-4dc3-b882-1de566b0c628"
}
}
},
"location": "eastus",
"properties": {
"description": "This is the description of the rule1",
"actionProperties": {
"Email.Sujbect": "my custom email subject"
},
"actions": [
{
"actionGroupId": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"
}
],
"criteria": {
"allOf": [
{
"name": "Metric1",
"criterionType": "StaticThresholdCriterion",
"query": "avg({\"system.cpu.utilization\"}) by (\"microsoft.resourceid\") > 90"
}
],
"failingPeriods": {
"for": "PT2M"
},
"odata.type": "Microsoft.Azure.Monitor.PromQLCriteria"
},
"customProperties": {
"key11": "value11",
"key12": "value12"
},
"enabled": true,
"evaluationFrequency": "PT1M",
"resolveConfiguration": {
"autoResolved": true,
"timeToResolve": "PT10M"
},
"scopes": [
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7"
],
"severity": 3
},
"tags": {
"hidden-link:/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/Microsoft.Web/sites/leoalerttest": "Resource"
}
}
Create or update a web test alert rule
Voorbeeldaanvraag
PUT https://management.azure.com/subscriptions/12345678-1234-1234-1234-123456789101/resourceGroups/rg-example/providers/Microsoft.Insights/metricAlerts/webtest-name-example?api-version=2024-03-01-preview
{
"location": "global",
"properties": {
"description": "Automatically created alert rule for availability test \"component-example\" a",
"actions": [],
"criteria": {
"componentId": "/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/components/webtest-name-example",
"failedLocationCount": 2,
"odata.type": "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria",
"webTestId": "/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/webtests/component-example"
},
"enabled": true,
"evaluationFrequency": "PT1M",
"scopes": [
"/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/webtests/component-example",
"/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/components/webtest-name-example"
],
"severity": 4,
"windowSize": "PT15M"
},
"tags": {
"hidden-link:/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/components/webtest-name-example": "Resource",
"hidden-link:/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/webtests/component-example": "Resource"
}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.monitor import MonitorManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-monitor
# USAGE
python create_or_update_web_test_metric_alert.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = MonitorManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.metric_alerts.create_or_update(
resource_group_name="rg-example",
rule_name="webtest-name-example",
parameters={
"location": "global",
"properties": {
"actions": [],
"criteria": {
"componentId": "/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/components/webtest-name-example",
"failedLocationCount": 2,
"odata.type": "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria",
"webTestId": "/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/webtests/component-example",
},
"description": 'Automatically created alert rule for availability test "component-example" a',
"enabled": True,
"evaluationFrequency": "PT1M",
"scopes": [
"/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/webtests/component-example",
"/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/components/webtest-name-example",
],
"severity": 4,
"windowSize": "PT15M",
},
"tags": {
"hidden-link:/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/components/webtest-name-example": "Resource",
"hidden-link:/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/webtests/component-example": "Resource",
},
},
)
print(response)
# x-ms-original-file: 2024-03-01-preview/createOrUpdateWebTestMetricAlert.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armmonitor_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/monitor/armmonitor"
)
// Generated from example definition: 2024-03-01-preview/createOrUpdateWebTestMetricAlert.json
func ExampleMetricAlertsClient_CreateOrUpdate_createOrUpdateAWebTestAlertRule() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armmonitor.NewClientFactory("12345678-1234-1234-1234-123456789101", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewMetricAlertsClient().CreateOrUpdate(ctx, "rg-example", "webtest-name-example", armmonitor.MetricAlertResource{
Location: to.Ptr("global"),
Properties: &armmonitor.MetricAlertProperties{
Description: to.Ptr("Automatically created alert rule for availability test \"component-example\" a"),
Actions: []*armmonitor.MetricAlertAction{},
Criteria: &armmonitor.WebtestLocationAvailabilityCriteria{
ComponentID: to.Ptr("/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/components/webtest-name-example"),
FailedLocationCount: to.Ptr[float32](2),
ODataType: to.Ptr(armmonitor.OdatatypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria),
WebTestID: to.Ptr("/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/webtests/component-example"),
},
Enabled: to.Ptr(true),
EvaluationFrequency: to.Ptr("PT1M"),
Scopes: []*string{
to.Ptr("/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/webtests/component-example"),
to.Ptr("/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/components/webtest-name-example"),
},
Severity: to.Ptr[int32](4),
WindowSize: to.Ptr("PT15M"),
},
Tags: map[string]*string{
"hidden-link:/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/components/webtest-name-example": to.Ptr("Resource"),
"hidden-link:/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/webtests/component-example": to.Ptr("Resource"),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res = armmonitor.MetricAlertsClientCreateOrUpdateResponse{
// MetricAlertResource: armmonitor.MetricAlertResource{
// Name: to.Ptr("webtest-name-example"),
// Type: to.Ptr("Microsoft.Insights/metricAlerts"),
// ID: to.Ptr("/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/metricalerts/webtest-name-example"),
// Location: to.Ptr("global"),
// Properties: &armmonitor.MetricAlertProperties{
// Description: to.Ptr("Automatically created alert rule for availability test \"webtest-name-example\" a"),
// Actions: []*armmonitor.MetricAlertAction{
// },
// Criteria: &armmonitor.WebtestLocationAvailabilityCriteria{
// ComponentID: to.Ptr("/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/components/component-example"),
// FailedLocationCount: to.Ptr[float32](2),
// ODataType: to.Ptr(armmonitor.OdatatypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria),
// WebTestID: to.Ptr("/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/webtests/webtest-name-example"),
// },
// Enabled: to.Ptr(true),
// EvaluationFrequency: to.Ptr("PT1M"),
// Scopes: []*string{
// to.Ptr("/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/webtests/webtest-name-example"),
// to.Ptr("/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/components/component-example"),
// },
// Severity: to.Ptr[int32](4),
// WindowSize: to.Ptr("PT15M"),
// },
// Tags: map[string]*string{
// "hidden-link:/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/components/component-example": to.Ptr("Resource"),
// "hidden-link:/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/webtests/webtest-name-example": to.Ptr("Resource"),
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { MonitorClient } = require("@azure/arm-monitor");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to create or update an metric alert definition.
*
* @summary create or update an metric alert definition.
* x-ms-original-file: 2024-03-01-preview/createOrUpdateWebTestMetricAlert.json
*/
async function createOrUpdateAWebTestAlertRule() {
const credential = new DefaultAzureCredential();
const subscriptionId = "12345678-1234-1234-1234-123456789101";
const client = new MonitorClient(credential, subscriptionId);
const result = await client.metricAlerts.createOrUpdate("rg-example", "webtest-name-example", {
location: "global",
description: 'Automatically created alert rule for availability test "component-example" a',
actions: [],
criteria: {
componentId:
"/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/components/webtest-name-example",
failedLocationCount: 2,
odataType: "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria",
webTestId:
"/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/webtests/component-example",
},
enabled: true,
evaluationFrequency: "PT1M",
scopes: [
"/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/webtests/component-example",
"/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/components/webtest-name-example",
],
severity: 4,
windowSize: "PT15M",
tags: {
"hidden-link:/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/components/webtest-name-example":
"Resource",
"hidden-link:/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/webtests/component-example":
"Resource",
},
});
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Voorbeeldrespons
{
"name": "webtest-name-example",
"type": "Microsoft.Insights/metricAlerts",
"id": "/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/metricalerts/webtest-name-example",
"location": "global",
"properties": {
"description": "Automatically created alert rule for availability test \"webtest-name-example\" a",
"actions": [],
"criteria": {
"componentId": "/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/components/component-example",
"failedLocationCount": 2,
"odata.type": "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria",
"webTestId": "/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/webtests/webtest-name-example"
},
"enabled": true,
"evaluationFrequency": "PT1M",
"scopes": [
"/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/webtests/webtest-name-example",
"/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/components/component-example"
],
"severity": 4,
"windowSize": "PT15M"
},
"tags": {
"hidden-link:/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/components/component-example": "Resource",
"hidden-link:/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/webtests/webtest-name-example": "Resource"
}
}
Create or update an alert rule for Multiple Resource
Voorbeeldaanvraag
PUT https://management.azure.com/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Insights/metricAlerts/MetricAlertOnMultipleResources?api-version=2024-03-01-preview
{
"location": "global",
"properties": {
"description": "This is the description of the rule1",
"actions": [
{
"actionGroupId": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
"webHookProperties": {
"key11": "value11",
"key12": "value12"
}
}
],
"autoMitigate": true,
"criteria": {
"allOf": [
{
"name": "High_CPU_80",
"criterionType": "StaticThresholdCriterion",
"dimensions": [],
"metricName": "Percentage CPU",
"metricNamespace": "microsoft.compute/virtualmachines",
"operator": "GreaterThan",
"threshold": 80.5,
"timeAggregation": "Average"
}
],
"odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria"
},
"enabled": true,
"evaluationFrequency": "PT1M",
"scopes": [
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme1",
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme2"
],
"severity": 3,
"targetResourceRegion": "southcentralus",
"targetResourceType": "Microsoft.Compute/virtualMachines",
"windowSize": "PT15M"
},
"tags": {}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.monitor import MonitorManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-monitor
# USAGE
python create_or_update_metric_alert_multiple_resource.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = MonitorManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.metric_alerts.create_or_update(
resource_group_name="gigtest",
rule_name="MetricAlertOnMultipleResources",
parameters={
"location": "global",
"properties": {
"actions": [
{
"actionGroupId": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
"webHookProperties": {"key11": "value11", "key12": "value12"},
}
],
"autoMitigate": True,
"criteria": {
"allOf": [
{
"criterionType": "StaticThresholdCriterion",
"dimensions": [],
"metricName": "Percentage CPU",
"metricNamespace": "microsoft.compute/virtualmachines",
"name": "High_CPU_80",
"operator": "GreaterThan",
"threshold": 80.5,
"timeAggregation": "Average",
}
],
"odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria",
},
"description": "This is the description of the rule1",
"enabled": True,
"evaluationFrequency": "PT1M",
"scopes": [
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme1",
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme2",
],
"severity": 3,
"targetResourceRegion": "southcentralus",
"targetResourceType": "Microsoft.Compute/virtualMachines",
"windowSize": "PT15M",
},
"tags": {},
},
)
print(response)
# x-ms-original-file: 2024-03-01-preview/createOrUpdateMetricAlertMultipleResource.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armmonitor_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/monitor/armmonitor"
)
// Generated from example definition: 2024-03-01-preview/createOrUpdateMetricAlertMultipleResource.json
func ExampleMetricAlertsClient_CreateOrUpdate_createOrUpdateAnAlertRuleForMultipleResource() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armmonitor.NewClientFactory("14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewMetricAlertsClient().CreateOrUpdate(ctx, "gigtest", "MetricAlertOnMultipleResources", armmonitor.MetricAlertResource{
Location: to.Ptr("global"),
Properties: &armmonitor.MetricAlertProperties{
Description: to.Ptr("This is the description of the rule1"),
Actions: []*armmonitor.MetricAlertAction{
{
ActionGroupID: to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"),
WebHookProperties: map[string]*string{
"key11": to.Ptr("value11"),
"key12": to.Ptr("value12"),
},
},
},
AutoMitigate: to.Ptr(true),
Criteria: &armmonitor.MetricAlertMultipleResourceMultipleMetricCriteria{
AllOf: []armmonitor.MultiMetricCriteriaClassification{
&armmonitor.MetricCriteria{
Name: to.Ptr("High_CPU_80"),
CriterionType: to.Ptr(armmonitor.CriterionTypeStaticThresholdCriterion),
Dimensions: []*armmonitor.MetricDimension{},
MetricName: to.Ptr("Percentage CPU"),
MetricNamespace: to.Ptr("microsoft.compute/virtualmachines"),
Operator: to.Ptr(armmonitor.OperatorGreaterThan),
Threshold: to.Ptr[float64](80.5),
TimeAggregation: to.Ptr(armmonitor.AggregationTypeEnumAverage),
},
},
ODataType: to.Ptr(armmonitor.OdatatypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria),
},
Enabled: to.Ptr(true),
EvaluationFrequency: to.Ptr("PT1M"),
Scopes: []*string{
to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme1"),
to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme2"),
},
Severity: to.Ptr[int32](3),
TargetResourceRegion: to.Ptr("southcentralus"),
TargetResourceType: to.Ptr("Microsoft.Compute/virtualMachines"),
WindowSize: to.Ptr("PT15M"),
},
Tags: map[string]*string{},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res = armmonitor.MetricAlertsClientCreateOrUpdateResponse{
// MetricAlertResource: armmonitor.MetricAlertResource{
// Type: to.Ptr("Microsoft.Insights/metricAlerts"),
// ID: to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/providers/microsoft.insights/metricalerts/MetricAlertOnMultipleResources"),
// Location: to.Ptr("global"),
// Properties: &armmonitor.MetricAlertProperties{
// Description: to.Ptr("This is the description of the rule1"),
// Actions: []*armmonitor.MetricAlertAction{
// {
// ActionGroupID: to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"),
// WebHookProperties: map[string]*string{
// "key11": to.Ptr("value11"),
// "key12": to.Ptr("value12"),
// },
// },
// },
// AutoMitigate: to.Ptr(true),
// Criteria: &armmonitor.MetricAlertMultipleResourceMultipleMetricCriteria{
// AllOf: []armmonitor.MultiMetricCriteriaClassification{
// &armmonitor.MetricCriteria{
// Name: to.Ptr("High_CPU_80"),
// CriterionType: to.Ptr(armmonitor.CriterionTypeStaticThresholdCriterion),
// Dimensions: []*armmonitor.MetricDimension{
// },
// MetricName: to.Ptr("Percentage CPU"),
// MetricNamespace: to.Ptr("microsoft.compute/virtualmachines"),
// Operator: to.Ptr(armmonitor.OperatorGreaterThan),
// Threshold: to.Ptr[float64](80.5),
// TimeAggregation: to.Ptr(armmonitor.AggregationTypeEnumAverage),
// },
// },
// ODataType: to.Ptr(armmonitor.OdatatypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria),
// },
// Enabled: to.Ptr(true),
// EvaluationFrequency: to.Ptr("PT1M"),
// Scopes: []*string{
// to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme1"),
// to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme2"),
// },
// Severity: to.Ptr[int32](3),
// TargetResourceRegion: to.Ptr("southcentralus"),
// TargetResourceType: to.Ptr("Microsoft.Compute/virtualMachines"),
// WindowSize: to.Ptr("PT15M"),
// },
// Tags: map[string]*string{
// "hidden-link:/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/Microsoft.Web/sites/leoalerttest": to.Ptr("Resource"),
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { MonitorClient } = require("@azure/arm-monitor");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to create or update an metric alert definition.
*
* @summary create or update an metric alert definition.
* x-ms-original-file: 2024-03-01-preview/createOrUpdateMetricAlertMultipleResource.json
*/
async function createOrUpdateAnAlertRuleForMultipleResource() {
const credential = new DefaultAzureCredential();
const subscriptionId = "14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7";
const client = new MonitorClient(credential, subscriptionId);
const result = await client.metricAlerts.createOrUpdate(
"gigtest",
"MetricAlertOnMultipleResources",
{
location: "global",
description: "This is the description of the rule1",
actions: [
{
actionGroupId:
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
webHookProperties: { key11: "value11", key12: "value12" },
},
],
autoMitigate: true,
criteria: {
allOf: [
{
name: "High_CPU_80",
criterionType: "StaticThresholdCriterion",
dimensions: [],
metricName: "Percentage CPU",
metricNamespace: "microsoft.compute/virtualmachines",
operator: "GreaterThan",
threshold: 80.5,
timeAggregation: "Average",
},
],
odataType: "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria",
},
enabled: true,
evaluationFrequency: "PT1M",
scopes: [
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme1",
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme2",
],
severity: 3,
targetResourceRegion: "southcentralus",
targetResourceType: "Microsoft.Compute/virtualMachines",
windowSize: "PT15M",
tags: {},
},
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Voorbeeldrespons
{
"type": "Microsoft.Insights/metricAlerts",
"id": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/providers/microsoft.insights/metricalerts/MetricAlertOnMultipleResources",
"location": "global",
"properties": {
"description": "This is the description of the rule1",
"actions": [
{
"actionGroupId": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
"webHookProperties": {
"key11": "value11",
"key12": "value12"
}
}
],
"autoMitigate": true,
"criteria": {
"allOf": [
{
"name": "High_CPU_80",
"criterionType": "StaticThresholdCriterion",
"dimensions": [],
"metricName": "Percentage CPU",
"metricNamespace": "microsoft.compute/virtualmachines",
"operator": "GreaterThan",
"threshold": 80.5,
"timeAggregation": "Average"
}
],
"odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria"
},
"enabled": true,
"evaluationFrequency": "PT1M",
"scopes": [
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme1",
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme2"
],
"severity": 3,
"targetResourceRegion": "southcentralus",
"targetResourceType": "Microsoft.Compute/virtualMachines",
"windowSize": "PT15M"
},
"tags": {
"hidden-link:/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/Microsoft.Web/sites/leoalerttest": "Resource"
}
}
Create or update an alert rule for Single Resource
Voorbeeldaanvraag
PUT https://management.azure.com/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Insights/metricAlerts/chiricutin?api-version=2024-03-01-preview
{
"location": "global",
"properties": {
"description": "This is the description of the rule1",
"actions": [
{
"actionGroupId": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
"webHookProperties": {
"key11": "value11",
"key12": "value12"
}
}
],
"autoMitigate": true,
"criteria": {
"allOf": [
{
"name": "High_CPU_80",
"criterionType": "StaticThresholdCriterion",
"dimensions": [],
"metricName": "\\Processor(_Total)\\% Processor Time",
"operator": "GreaterThan",
"threshold": 80.5,
"timeAggregation": "Average"
}
],
"odata.type": "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria"
},
"enabled": true,
"evaluationFrequency": "PT1M",
"scopes": [
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme"
],
"severity": 3,
"windowSize": "PT15M"
},
"tags": {}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.monitor import MonitorManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-monitor
# USAGE
python create_or_update_metric_alert_single_resource.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = MonitorManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.metric_alerts.create_or_update(
resource_group_name="gigtest",
rule_name="chiricutin",
parameters={
"location": "global",
"properties": {
"actions": [
{
"actionGroupId": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
"webHookProperties": {"key11": "value11", "key12": "value12"},
}
],
"autoMitigate": True,
"criteria": {
"allOf": [
{
"criterionType": "StaticThresholdCriterion",
"dimensions": [],
"metricName": "\\Processor(_Total)\\% Processor Time",
"name": "High_CPU_80",
"operator": "GreaterThan",
"threshold": 80.5,
"timeAggregation": "Average",
}
],
"odata.type": "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria",
},
"description": "This is the description of the rule1",
"enabled": True,
"evaluationFrequency": "PT1M",
"scopes": [
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme"
],
"severity": 3,
"windowSize": "PT15M",
},
"tags": {},
},
)
print(response)
# x-ms-original-file: 2024-03-01-preview/createOrUpdateMetricAlertSingleResource.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armmonitor_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/monitor/armmonitor"
)
// Generated from example definition: 2024-03-01-preview/createOrUpdateMetricAlertSingleResource.json
func ExampleMetricAlertsClient_CreateOrUpdate_createOrUpdateAnAlertRuleForSingleResource() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armmonitor.NewClientFactory("14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewMetricAlertsClient().CreateOrUpdate(ctx, "gigtest", "chiricutin", armmonitor.MetricAlertResource{
Location: to.Ptr("global"),
Properties: &armmonitor.MetricAlertProperties{
Description: to.Ptr("This is the description of the rule1"),
Actions: []*armmonitor.MetricAlertAction{
{
ActionGroupID: to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"),
WebHookProperties: map[string]*string{
"key11": to.Ptr("value11"),
"key12": to.Ptr("value12"),
},
},
},
AutoMitigate: to.Ptr(true),
Criteria: &armmonitor.MetricAlertSingleResourceMultipleMetricCriteria{
AllOf: []*armmonitor.MetricCriteria{
{
Name: to.Ptr("High_CPU_80"),
CriterionType: to.Ptr(armmonitor.CriterionTypeStaticThresholdCriterion),
Dimensions: []*armmonitor.MetricDimension{},
MetricName: to.Ptr("\\Processor(_Total)\\% Processor Time"),
Operator: to.Ptr(armmonitor.OperatorGreaterThan),
Threshold: to.Ptr[float64](80.5),
TimeAggregation: to.Ptr(armmonitor.AggregationTypeEnumAverage),
},
},
ODataType: to.Ptr(armmonitor.OdatatypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria),
},
Enabled: to.Ptr(true),
EvaluationFrequency: to.Ptr("PT1M"),
Scopes: []*string{
to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme"),
},
Severity: to.Ptr[int32](3),
WindowSize: to.Ptr("PT15M"),
},
Tags: map[string]*string{},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res = armmonitor.MetricAlertsClientCreateOrUpdateResponse{
// MetricAlertResource: armmonitor.MetricAlertResource{
// Type: to.Ptr("Microsoft.Insights/metricAlerts"),
// ID: to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/providers/microsoft.insights/metricalerts/chiricutin"),
// Location: to.Ptr("global"),
// Properties: &armmonitor.MetricAlertProperties{
// Description: to.Ptr("This is the description of the rule1"),
// Actions: []*armmonitor.MetricAlertAction{
// {
// ActionGroupID: to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"),
// WebHookProperties: map[string]*string{
// "key11": to.Ptr("value11"),
// "key12": to.Ptr("value12"),
// },
// },
// },
// AutoMitigate: to.Ptr(true),
// Criteria: &armmonitor.MetricAlertSingleResourceMultipleMetricCriteria{
// AllOf: []*armmonitor.MetricCriteria{
// {
// Name: to.Ptr("High_CPU_80"),
// CriterionType: to.Ptr(armmonitor.CriterionTypeStaticThresholdCriterion),
// Dimensions: []*armmonitor.MetricDimension{
// },
// MetricName: to.Ptr("\\Processor(_Total)\\% Processor Time"),
// Operator: to.Ptr(armmonitor.OperatorGreaterThan),
// Threshold: to.Ptr[float64](80.5),
// TimeAggregation: to.Ptr(armmonitor.AggregationTypeEnumAverage),
// },
// },
// ODataType: to.Ptr(armmonitor.OdatatypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria),
// },
// Enabled: to.Ptr(true),
// EvaluationFrequency: to.Ptr("PT1M"),
// Scopes: []*string{
// to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme"),
// },
// Severity: to.Ptr[int32](3),
// WindowSize: to.Ptr("PT15M"),
// },
// Tags: map[string]*string{
// "hidden-link:/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/Microsoft.Web/sites/leoalerttest": to.Ptr("Resource"),
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { MonitorClient } = require("@azure/arm-monitor");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to create or update an metric alert definition.
*
* @summary create or update an metric alert definition.
* x-ms-original-file: 2024-03-01-preview/createOrUpdateMetricAlertSingleResource.json
*/
async function createOrUpdateAnAlertRuleForSingleResource() {
const credential = new DefaultAzureCredential();
const subscriptionId = "14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7";
const client = new MonitorClient(credential, subscriptionId);
const result = await client.metricAlerts.createOrUpdate("gigtest", "chiricutin", {
location: "global",
description: "This is the description of the rule1",
actions: [
{
actionGroupId:
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
webHookProperties: { key11: "value11", key12: "value12" },
},
],
autoMitigate: true,
criteria: {
allOf: [
{
name: "High_CPU_80",
criterionType: "StaticThresholdCriterion",
dimensions: [],
metricName: "\\Processor(_Total)\\% Processor Time",
operator: "GreaterThan",
threshold: 80.5,
timeAggregation: "Average",
},
],
odataType: "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria",
},
enabled: true,
evaluationFrequency: "PT1M",
scopes: [
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme",
],
severity: 3,
windowSize: "PT15M",
tags: {},
});
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Voorbeeldrespons
{
"type": "Microsoft.Insights/metricAlerts",
"id": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/providers/microsoft.insights/metricalerts/chiricutin",
"location": "global",
"properties": {
"description": "This is the description of the rule1",
"actions": [
{
"actionGroupId": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
"webHookProperties": {
"key11": "value11",
"key12": "value12"
}
}
],
"autoMitigate": true,
"criteria": {
"allOf": [
{
"name": "High_CPU_80",
"criterionType": "StaticThresholdCriterion",
"dimensions": [],
"metricName": "\\Processor(_Total)\\% Processor Time",
"operator": "GreaterThan",
"threshold": 80.5,
"timeAggregation": "Average"
}
],
"odata.type": "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria"
},
"enabled": true,
"evaluationFrequency": "PT1M",
"scopes": [
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme"
],
"severity": 3,
"windowSize": "PT15M"
},
"tags": {
"hidden-link:/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/Microsoft.Web/sites/leoalerttest": "Resource"
}
}
Create or update an alert rule on Resource group(s)
Voorbeeldaanvraag
PUT https://management.azure.com/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest1/providers/Microsoft.Insights/metricAlerts/MetricAlertAtResourceGroupLevel?api-version=2024-03-01-preview
{
"location": "global",
"properties": {
"description": "This is the description of the rule1",
"actions": [
{
"actionGroupId": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
"webHookProperties": {
"key11": "value11",
"key12": "value12"
}
}
],
"autoMitigate": true,
"criteria": {
"allOf": [
{
"name": "High_CPU_80",
"criterionType": "StaticThresholdCriterion",
"dimensions": [],
"metricName": "Percentage CPU",
"metricNamespace": "microsoft.compute/virtualmachines",
"operator": "GreaterThan",
"threshold": 80.5,
"timeAggregation": "Average"
}
],
"odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria"
},
"enabled": true,
"evaluationFrequency": "PT1M",
"scopes": [
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest1",
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest2"
],
"severity": 3,
"targetResourceRegion": "southcentralus",
"targetResourceType": "Microsoft.Compute/virtualMachines",
"windowSize": "PT15M"
},
"tags": {}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.monitor import MonitorManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-monitor
# USAGE
python create_or_update_metric_alert_resource_group.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = MonitorManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.metric_alerts.create_or_update(
resource_group_name="gigtest1",
rule_name="MetricAlertAtResourceGroupLevel",
parameters={
"location": "global",
"properties": {
"actions": [
{
"actionGroupId": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
"webHookProperties": {"key11": "value11", "key12": "value12"},
}
],
"autoMitigate": True,
"criteria": {
"allOf": [
{
"criterionType": "StaticThresholdCriterion",
"dimensions": [],
"metricName": "Percentage CPU",
"metricNamespace": "microsoft.compute/virtualmachines",
"name": "High_CPU_80",
"operator": "GreaterThan",
"threshold": 80.5,
"timeAggregation": "Average",
}
],
"odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria",
},
"description": "This is the description of the rule1",
"enabled": True,
"evaluationFrequency": "PT1M",
"scopes": [
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest1",
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest2",
],
"severity": 3,
"targetResourceRegion": "southcentralus",
"targetResourceType": "Microsoft.Compute/virtualMachines",
"windowSize": "PT15M",
},
"tags": {},
},
)
print(response)
# x-ms-original-file: 2024-03-01-preview/createOrUpdateMetricAlertResourceGroup.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armmonitor_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/monitor/armmonitor"
)
// Generated from example definition: 2024-03-01-preview/createOrUpdateMetricAlertResourceGroup.json
func ExampleMetricAlertsClient_CreateOrUpdate_createOrUpdateAnAlertRuleOnResourceGroupS() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armmonitor.NewClientFactory("14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewMetricAlertsClient().CreateOrUpdate(ctx, "gigtest1", "MetricAlertAtResourceGroupLevel", armmonitor.MetricAlertResource{
Location: to.Ptr("global"),
Properties: &armmonitor.MetricAlertProperties{
Description: to.Ptr("This is the description of the rule1"),
Actions: []*armmonitor.MetricAlertAction{
{
ActionGroupID: to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"),
WebHookProperties: map[string]*string{
"key11": to.Ptr("value11"),
"key12": to.Ptr("value12"),
},
},
},
AutoMitigate: to.Ptr(true),
Criteria: &armmonitor.MetricAlertMultipleResourceMultipleMetricCriteria{
AllOf: []armmonitor.MultiMetricCriteriaClassification{
&armmonitor.MetricCriteria{
Name: to.Ptr("High_CPU_80"),
CriterionType: to.Ptr(armmonitor.CriterionTypeStaticThresholdCriterion),
Dimensions: []*armmonitor.MetricDimension{},
MetricName: to.Ptr("Percentage CPU"),
MetricNamespace: to.Ptr("microsoft.compute/virtualmachines"),
Operator: to.Ptr(armmonitor.OperatorGreaterThan),
Threshold: to.Ptr[float64](80.5),
TimeAggregation: to.Ptr(armmonitor.AggregationTypeEnumAverage),
},
},
ODataType: to.Ptr(armmonitor.OdatatypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria),
},
Enabled: to.Ptr(true),
EvaluationFrequency: to.Ptr("PT1M"),
Scopes: []*string{
to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest1"),
to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest2"),
},
Severity: to.Ptr[int32](3),
TargetResourceRegion: to.Ptr("southcentralus"),
TargetResourceType: to.Ptr("Microsoft.Compute/virtualMachines"),
WindowSize: to.Ptr("PT15M"),
},
Tags: map[string]*string{},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res = armmonitor.MetricAlertsClientCreateOrUpdateResponse{
// MetricAlertResource: armmonitor.MetricAlertResource{
// Type: to.Ptr("Microsoft.Insights/metricAlerts"),
// ID: to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest1/providers/providers/microsoft.insights/metricalerts/MetricAlertAtResourceGroupLevel"),
// Location: to.Ptr("global"),
// Properties: &armmonitor.MetricAlertProperties{
// Description: to.Ptr("This is the description of the rule1"),
// Actions: []*armmonitor.MetricAlertAction{
// {
// ActionGroupID: to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"),
// WebHookProperties: map[string]*string{
// "key11": to.Ptr("value11"),
// "key12": to.Ptr("value12"),
// },
// },
// },
// AutoMitigate: to.Ptr(true),
// Criteria: &armmonitor.MetricAlertMultipleResourceMultipleMetricCriteria{
// AllOf: []armmonitor.MultiMetricCriteriaClassification{
// &armmonitor.MetricCriteria{
// Name: to.Ptr("High_CPU_80"),
// CriterionType: to.Ptr(armmonitor.CriterionTypeStaticThresholdCriterion),
// Dimensions: []*armmonitor.MetricDimension{
// },
// MetricName: to.Ptr("Percentage CPU"),
// MetricNamespace: to.Ptr("microsoft.compute/virtualmachines"),
// Operator: to.Ptr(armmonitor.OperatorGreaterThan),
// Threshold: to.Ptr[float64](80.5),
// TimeAggregation: to.Ptr(armmonitor.AggregationTypeEnumAverage),
// },
// },
// ODataType: to.Ptr(armmonitor.OdatatypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria),
// },
// Enabled: to.Ptr(true),
// EvaluationFrequency: to.Ptr("PT1M"),
// Scopes: []*string{
// to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest1"),
// to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest2"),
// },
// Severity: to.Ptr[int32](3),
// TargetResourceRegion: to.Ptr("southcentralus"),
// TargetResourceType: to.Ptr("Microsoft.Compute/virtualMachines"),
// WindowSize: to.Ptr("PT15M"),
// },
// Tags: map[string]*string{
// "hidden-link:/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/Microsoft.Web/sites/leoalerttest": to.Ptr("Resource"),
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { MonitorClient } = require("@azure/arm-monitor");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to create or update an metric alert definition.
*
* @summary create or update an metric alert definition.
* x-ms-original-file: 2024-03-01-preview/createOrUpdateMetricAlertResourceGroup.json
*/
async function createOrUpdateAnAlertRuleOnResourceGroupS() {
const credential = new DefaultAzureCredential();
const subscriptionId = "14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7";
const client = new MonitorClient(credential, subscriptionId);
const result = await client.metricAlerts.createOrUpdate(
"gigtest1",
"MetricAlertAtResourceGroupLevel",
{
location: "global",
description: "This is the description of the rule1",
actions: [
{
actionGroupId:
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
webHookProperties: { key11: "value11", key12: "value12" },
},
],
autoMitigate: true,
criteria: {
allOf: [
{
name: "High_CPU_80",
criterionType: "StaticThresholdCriterion",
dimensions: [],
metricName: "Percentage CPU",
metricNamespace: "microsoft.compute/virtualmachines",
operator: "GreaterThan",
threshold: 80.5,
timeAggregation: "Average",
},
],
odataType: "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria",
},
enabled: true,
evaluationFrequency: "PT1M",
scopes: [
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest1",
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest2",
],
severity: 3,
targetResourceRegion: "southcentralus",
targetResourceType: "Microsoft.Compute/virtualMachines",
windowSize: "PT15M",
tags: {},
},
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Voorbeeldrespons
{
"type": "Microsoft.Insights/metricAlerts",
"id": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest1/providers/providers/microsoft.insights/metricalerts/MetricAlertAtResourceGroupLevel",
"location": "global",
"properties": {
"description": "This is the description of the rule1",
"actions": [
{
"actionGroupId": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
"webHookProperties": {
"key11": "value11",
"key12": "value12"
}
}
],
"autoMitigate": true,
"criteria": {
"allOf": [
{
"name": "High_CPU_80",
"criterionType": "StaticThresholdCriterion",
"dimensions": [],
"metricName": "Percentage CPU",
"metricNamespace": "microsoft.compute/virtualmachines",
"operator": "GreaterThan",
"threshold": 80.5,
"timeAggregation": "Average"
}
],
"odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria"
},
"enabled": true,
"evaluationFrequency": "PT1M",
"scopes": [
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest1",
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest2"
],
"severity": 3,
"targetResourceRegion": "southcentralus",
"targetResourceType": "Microsoft.Compute/virtualMachines",
"windowSize": "PT15M"
},
"tags": {
"hidden-link:/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/Microsoft.Web/sites/leoalerttest": "Resource"
}
}
Create or update an alert rule on Subscription
Voorbeeldaanvraag
PUT https://management.azure.com/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Insights/metricAlerts/MetricAlertAtSubscriptionLevel?api-version=2024-03-01-preview
{
"location": "global",
"properties": {
"description": "This is the description of the rule1",
"actions": [
{
"actionGroupId": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
"webHookProperties": {
"key11": "value11",
"key12": "value12"
}
}
],
"autoMitigate": true,
"criteria": {
"allOf": [
{
"name": "High_CPU_80",
"criterionType": "StaticThresholdCriterion",
"dimensions": [],
"metricName": "Percentage CPU",
"metricNamespace": "microsoft.compute/virtualmachines",
"operator": "GreaterThan",
"threshold": 80.5,
"timeAggregation": "Average"
}
],
"odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria"
},
"enabled": true,
"evaluationFrequency": "PT1M",
"scopes": [
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7"
],
"severity": 3,
"targetResourceRegion": "southcentralus",
"targetResourceType": "Microsoft.Compute/virtualMachines",
"windowSize": "PT15M"
},
"tags": {}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.monitor import MonitorManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-monitor
# USAGE
python create_or_update_metric_alert_subscription.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = MonitorManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.metric_alerts.create_or_update(
resource_group_name="gigtest",
rule_name="MetricAlertAtSubscriptionLevel",
parameters={
"location": "global",
"properties": {
"actions": [
{
"actionGroupId": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
"webHookProperties": {"key11": "value11", "key12": "value12"},
}
],
"autoMitigate": True,
"criteria": {
"allOf": [
{
"criterionType": "StaticThresholdCriterion",
"dimensions": [],
"metricName": "Percentage CPU",
"metricNamespace": "microsoft.compute/virtualmachines",
"name": "High_CPU_80",
"operator": "GreaterThan",
"threshold": 80.5,
"timeAggregation": "Average",
}
],
"odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria",
},
"description": "This is the description of the rule1",
"enabled": True,
"evaluationFrequency": "PT1M",
"scopes": ["/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7"],
"severity": 3,
"targetResourceRegion": "southcentralus",
"targetResourceType": "Microsoft.Compute/virtualMachines",
"windowSize": "PT15M",
},
"tags": {},
},
)
print(response)
# x-ms-original-file: 2024-03-01-preview/createOrUpdateMetricAlertSubscription.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armmonitor_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/monitor/armmonitor"
)
// Generated from example definition: 2024-03-01-preview/createOrUpdateMetricAlertSubscription.json
func ExampleMetricAlertsClient_CreateOrUpdate_createOrUpdateAnAlertRuleOnSubscription() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armmonitor.NewClientFactory("14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewMetricAlertsClient().CreateOrUpdate(ctx, "gigtest", "MetricAlertAtSubscriptionLevel", armmonitor.MetricAlertResource{
Location: to.Ptr("global"),
Properties: &armmonitor.MetricAlertProperties{
Description: to.Ptr("This is the description of the rule1"),
Actions: []*armmonitor.MetricAlertAction{
{
ActionGroupID: to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"),
WebHookProperties: map[string]*string{
"key11": to.Ptr("value11"),
"key12": to.Ptr("value12"),
},
},
},
AutoMitigate: to.Ptr(true),
Criteria: &armmonitor.MetricAlertMultipleResourceMultipleMetricCriteria{
AllOf: []armmonitor.MultiMetricCriteriaClassification{
&armmonitor.MetricCriteria{
Name: to.Ptr("High_CPU_80"),
CriterionType: to.Ptr(armmonitor.CriterionTypeStaticThresholdCriterion),
Dimensions: []*armmonitor.MetricDimension{},
MetricName: to.Ptr("Percentage CPU"),
MetricNamespace: to.Ptr("microsoft.compute/virtualmachines"),
Operator: to.Ptr(armmonitor.OperatorGreaterThan),
Threshold: to.Ptr[float64](80.5),
TimeAggregation: to.Ptr(armmonitor.AggregationTypeEnumAverage),
},
},
ODataType: to.Ptr(armmonitor.OdatatypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria),
},
Enabled: to.Ptr(true),
EvaluationFrequency: to.Ptr("PT1M"),
Scopes: []*string{
to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7"),
},
Severity: to.Ptr[int32](3),
TargetResourceRegion: to.Ptr("southcentralus"),
TargetResourceType: to.Ptr("Microsoft.Compute/virtualMachines"),
WindowSize: to.Ptr("PT15M"),
},
Tags: map[string]*string{},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res = armmonitor.MetricAlertsClientCreateOrUpdateResponse{
// MetricAlertResource: armmonitor.MetricAlertResource{
// Type: to.Ptr("Microsoft.Insights/metricAlerts"),
// ID: to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/providers/microsoft.insights/metricalerts/MetricAlertAtSubscriptionLevel"),
// Location: to.Ptr("global"),
// Properties: &armmonitor.MetricAlertProperties{
// Description: to.Ptr("This is the description of the rule1"),
// Actions: []*armmonitor.MetricAlertAction{
// {
// ActionGroupID: to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"),
// WebHookProperties: map[string]*string{
// "key11": to.Ptr("value11"),
// "key12": to.Ptr("value12"),
// },
// },
// },
// AutoMitigate: to.Ptr(true),
// Criteria: &armmonitor.MetricAlertMultipleResourceMultipleMetricCriteria{
// AllOf: []armmonitor.MultiMetricCriteriaClassification{
// &armmonitor.MetricCriteria{
// Name: to.Ptr("High_CPU_80"),
// CriterionType: to.Ptr(armmonitor.CriterionTypeStaticThresholdCriterion),
// Dimensions: []*armmonitor.MetricDimension{
// },
// MetricName: to.Ptr("Percentage CPU"),
// MetricNamespace: to.Ptr("microsoft.compute/virtualmachines"),
// Operator: to.Ptr(armmonitor.OperatorGreaterThan),
// Threshold: to.Ptr[float64](80.5),
// TimeAggregation: to.Ptr(armmonitor.AggregationTypeEnumAverage),
// },
// },
// ODataType: to.Ptr(armmonitor.OdatatypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria),
// },
// Enabled: to.Ptr(true),
// EvaluationFrequency: to.Ptr("PT1M"),
// Scopes: []*string{
// to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7"),
// },
// Severity: to.Ptr[int32](3),
// TargetResourceRegion: to.Ptr("southcentralus"),
// TargetResourceType: to.Ptr("Microsoft.Compute/virtualMachines"),
// WindowSize: to.Ptr("PT15M"),
// },
// Tags: map[string]*string{
// "hidden-link:/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/Microsoft.Web/sites/leoalerttest": to.Ptr("Resource"),
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { MonitorClient } = require("@azure/arm-monitor");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to create or update an metric alert definition.
*
* @summary create or update an metric alert definition.
* x-ms-original-file: 2024-03-01-preview/createOrUpdateMetricAlertSubscription.json
*/
async function createOrUpdateAnAlertRuleOnSubscription() {
const credential = new DefaultAzureCredential();
const subscriptionId = "14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7";
const client = new MonitorClient(credential, subscriptionId);
const result = await client.metricAlerts.createOrUpdate(
"gigtest",
"MetricAlertAtSubscriptionLevel",
{
location: "global",
description: "This is the description of the rule1",
actions: [
{
actionGroupId:
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
webHookProperties: { key11: "value11", key12: "value12" },
},
],
autoMitigate: true,
criteria: {
allOf: [
{
name: "High_CPU_80",
criterionType: "StaticThresholdCriterion",
dimensions: [],
metricName: "Percentage CPU",
metricNamespace: "microsoft.compute/virtualmachines",
operator: "GreaterThan",
threshold: 80.5,
timeAggregation: "Average",
},
],
odataType: "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria",
},
enabled: true,
evaluationFrequency: "PT1M",
scopes: ["/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7"],
severity: 3,
targetResourceRegion: "southcentralus",
targetResourceType: "Microsoft.Compute/virtualMachines",
windowSize: "PT15M",
tags: {},
},
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Voorbeeldrespons
{
"type": "Microsoft.Insights/metricAlerts",
"id": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/providers/microsoft.insights/metricalerts/MetricAlertAtSubscriptionLevel",
"location": "global",
"properties": {
"description": "This is the description of the rule1",
"actions": [
{
"actionGroupId": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
"webHookProperties": {
"key11": "value11",
"key12": "value12"
}
}
],
"autoMitigate": true,
"criteria": {
"allOf": [
{
"name": "High_CPU_80",
"criterionType": "StaticThresholdCriterion",
"dimensions": [],
"metricName": "Percentage CPU",
"metricNamespace": "microsoft.compute/virtualmachines",
"operator": "GreaterThan",
"threshold": 80.5,
"timeAggregation": "Average"
}
],
"odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria"
},
"enabled": true,
"evaluationFrequency": "PT1M",
"scopes": [
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7"
],
"severity": 3,
"targetResourceRegion": "southcentralus",
"targetResourceType": "Microsoft.Compute/virtualMachines",
"windowSize": "PT15M"
},
"tags": {
"hidden-link:/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/Microsoft.Web/sites/leoalerttest": "Resource"
}
}
Create or update an alert rules with dimensions
Voorbeeldaanvraag
PUT https://management.azure.com/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Insights/metricAlerts/MetricAlertOnMultipleDimensions?api-version=2024-03-01-preview
{
"location": "global",
"properties": {
"description": "This is the description of the rule1",
"actions": [
{
"actionGroupId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
"webHookProperties": {
"key11": "value11",
"key12": "value12"
}
}
],
"autoMitigate": true,
"criteria": {
"allOf": [
{
"name": "Metric1",
"criterionType": "StaticThresholdCriterion",
"dimensions": [
{
"name": "ActivityName",
"operator": "Include",
"values": [
"*"
]
},
{
"name": "StatusCode",
"operator": "Include",
"values": [
"200"
]
}
],
"metricName": "Availability",
"metricNamespace": "Microsoft.KeyVault/vaults",
"operator": "GreaterThan",
"threshold": 55,
"timeAggregation": "Average"
}
],
"odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria"
},
"enabled": true,
"evaluationFrequency": "PT1H",
"scopes": [
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.KeyVault/vaults/keyVaultResource"
],
"severity": 3,
"windowSize": "P1D"
},
"tags": {}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.monitor import MonitorManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-monitor
# USAGE
python create_or_update_metric_alert_with_dimensions.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = MonitorManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.metric_alerts.create_or_update(
resource_group_name="gigtest",
rule_name="MetricAlertOnMultipleDimensions",
parameters={
"location": "global",
"properties": {
"actions": [
{
"actionGroupId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
"webHookProperties": {"key11": "value11", "key12": "value12"},
}
],
"autoMitigate": True,
"criteria": {
"allOf": [
{
"criterionType": "StaticThresholdCriterion",
"dimensions": [
{"name": "ActivityName", "operator": "Include", "values": ["*"]},
{"name": "StatusCode", "operator": "Include", "values": ["200"]},
],
"metricName": "Availability",
"metricNamespace": "Microsoft.KeyVault/vaults",
"name": "Metric1",
"operator": "GreaterThan",
"threshold": 55,
"timeAggregation": "Average",
}
],
"odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria",
},
"description": "This is the description of the rule1",
"enabled": True,
"evaluationFrequency": "PT1H",
"scopes": [
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.KeyVault/vaults/keyVaultResource"
],
"severity": 3,
"windowSize": "P1D",
},
"tags": {},
},
)
print(response)
# x-ms-original-file: 2024-03-01-preview/createOrUpdateMetricAlertWithDimensions.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armmonitor_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/monitor/armmonitor"
)
// Generated from example definition: 2024-03-01-preview/createOrUpdateMetricAlertWithDimensions.json
func ExampleMetricAlertsClient_CreateOrUpdate_createOrUpdateAnAlertRulesWithDimensions() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armmonitor.NewClientFactory("14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewMetricAlertsClient().CreateOrUpdate(ctx, "gigtest", "MetricAlertOnMultipleDimensions", armmonitor.MetricAlertResource{
Location: to.Ptr("global"),
Properties: &armmonitor.MetricAlertProperties{
Description: to.Ptr("This is the description of the rule1"),
Actions: []*armmonitor.MetricAlertAction{
{
ActionGroupID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"),
WebHookProperties: map[string]*string{
"key11": to.Ptr("value11"),
"key12": to.Ptr("value12"),
},
},
},
AutoMitigate: to.Ptr(true),
Criteria: &armmonitor.MetricAlertMultipleResourceMultipleMetricCriteria{
AllOf: []armmonitor.MultiMetricCriteriaClassification{
&armmonitor.MetricCriteria{
Name: to.Ptr("Metric1"),
CriterionType: to.Ptr(armmonitor.CriterionTypeStaticThresholdCriterion),
Dimensions: []*armmonitor.MetricDimension{
{
Name: to.Ptr("ActivityName"),
Operator: to.Ptr("Include"),
Values: []*string{
to.Ptr("*"),
},
},
{
Name: to.Ptr("StatusCode"),
Operator: to.Ptr("Include"),
Values: []*string{
to.Ptr("200"),
},
},
},
MetricName: to.Ptr("Availability"),
MetricNamespace: to.Ptr("Microsoft.KeyVault/vaults"),
Operator: to.Ptr(armmonitor.OperatorGreaterThan),
Threshold: to.Ptr[float64](55),
TimeAggregation: to.Ptr(armmonitor.AggregationTypeEnumAverage),
},
},
ODataType: to.Ptr(armmonitor.OdatatypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria),
},
Enabled: to.Ptr(true),
EvaluationFrequency: to.Ptr("PT1H"),
Scopes: []*string{
to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.KeyVault/vaults/keyVaultResource"),
},
Severity: to.Ptr[int32](3),
WindowSize: to.Ptr("P1D"),
},
Tags: map[string]*string{},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res = armmonitor.MetricAlertsClientCreateOrUpdateResponse{
// MetricAlertResource: armmonitor.MetricAlertResource{
// Type: to.Ptr("Microsoft.Insights/metricAlerts"),
// ID: to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/providers/microsoft.insights/metricalerts/MetricAlertWithDimensions"),
// Location: to.Ptr("global"),
// Properties: &armmonitor.MetricAlertProperties{
// Description: to.Ptr("This is the description of the rule1"),
// Actions: []*armmonitor.MetricAlertAction{
// {
// ActionGroupID: to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"),
// WebHookProperties: map[string]*string{
// "key11": to.Ptr("value11"),
// "key12": to.Ptr("value12"),
// },
// },
// },
// AutoMitigate: to.Ptr(true),
// Criteria: &armmonitor.MetricAlertMultipleResourceMultipleMetricCriteria{
// AllOf: []armmonitor.MultiMetricCriteriaClassification{
// &armmonitor.MetricCriteria{
// Name: to.Ptr("Metric1"),
// CriterionType: to.Ptr(armmonitor.CriterionTypeStaticThresholdCriterion),
// Dimensions: []*armmonitor.MetricDimension{
// {
// Name: to.Ptr("ActivityName"),
// Operator: to.Ptr("Include"),
// Values: []*string{
// to.Ptr("*"),
// },
// },
// {
// Name: to.Ptr("StatusCode"),
// Operator: to.Ptr("Include"),
// Values: []*string{
// to.Ptr("200"),
// },
// },
// },
// MetricName: to.Ptr("Availability"),
// MetricNamespace: to.Ptr("Microsoft.KeyVault/vaults"),
// Operator: to.Ptr(armmonitor.OperatorGreaterThan),
// Threshold: to.Ptr[float64](55),
// TimeAggregation: to.Ptr(armmonitor.AggregationTypeEnumAverage),
// },
// },
// ODataType: to.Ptr(armmonitor.OdatatypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria),
// },
// Enabled: to.Ptr(true),
// EvaluationFrequency: to.Ptr("PT1H"),
// Scopes: []*string{
// to.Ptr("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.KeyVault/vaults/keyVaultResource"),
// },
// Severity: to.Ptr[int32](3),
// TargetResourceRegion: to.Ptr("southcentralus"),
// TargetResourceType: to.Ptr("Microsoft.KeyVault/vaults"),
// WindowSize: to.Ptr("P1D"),
// },
// Tags: map[string]*string{
// "hidden-link:/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/Microsoft.Web/sites/leoalerttest": to.Ptr("Resource"),
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { MonitorClient } = require("@azure/arm-monitor");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to create or update an metric alert definition.
*
* @summary create or update an metric alert definition.
* x-ms-original-file: 2024-03-01-preview/createOrUpdateMetricAlertWithDimensions.json
*/
async function createOrUpdateAnAlertRulesWithDimensions() {
const credential = new DefaultAzureCredential();
const subscriptionId = "14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7";
const client = new MonitorClient(credential, subscriptionId);
const result = await client.metricAlerts.createOrUpdate(
"gigtest",
"MetricAlertOnMultipleDimensions",
{
location: "global",
description: "This is the description of the rule1",
actions: [
{
actionGroupId:
"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
webHookProperties: { key11: "value11", key12: "value12" },
},
],
autoMitigate: true,
criteria: {
allOf: [
{
name: "Metric1",
criterionType: "StaticThresholdCriterion",
dimensions: [
{ name: "ActivityName", operator: "Include", values: ["*"] },
{ name: "StatusCode", operator: "Include", values: ["200"] },
],
metricName: "Availability",
metricNamespace: "Microsoft.KeyVault/vaults",
operator: "GreaterThan",
threshold: 55,
timeAggregation: "Average",
},
],
odataType: "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria",
},
enabled: true,
evaluationFrequency: "PT1H",
scopes: [
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.KeyVault/vaults/keyVaultResource",
],
severity: 3,
windowSize: "P1D",
tags: {},
},
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Voorbeeldrespons
{
"type": "Microsoft.Insights/metricAlerts",
"id": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/providers/microsoft.insights/metricalerts/MetricAlertWithDimensions",
"location": "global",
"properties": {
"description": "This is the description of the rule1",
"actions": [
{
"actionGroupId": "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2",
"webHookProperties": {
"key11": "value11",
"key12": "value12"
}
}
],
"autoMitigate": true,
"criteria": {
"allOf": [
{
"name": "Metric1",
"criterionType": "StaticThresholdCriterion",
"dimensions": [
{
"name": "ActivityName",
"operator": "Include",
"values": [
"*"
]
},
{
"name": "StatusCode",
"operator": "Include",
"values": [
"200"
]
}
],
"metricName": "Availability",
"metricNamespace": "Microsoft.KeyVault/vaults",
"operator": "GreaterThan",
"threshold": 55,
"timeAggregation": "Average"
}
],
"odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria"
},
"enabled": true,
"evaluationFrequency": "PT1H",
"scopes": [
"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.KeyVault/vaults/keyVaultResource"
],
"severity": 3,
"targetResourceRegion": "southcentralus",
"targetResourceType": "Microsoft.KeyVault/vaults",
"windowSize": "P1D"
},
"tags": {
"hidden-link:/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/Microsoft.Web/sites/leoalerttest": "Resource"
}
}
Definities
AggregationTypeEnum
Opsomming
De criteria voor tijdaggregatietypen. Eerder ongedocumenteerde waarden kunnen worden geretourneerd
| Waarde |
Description |
|
Average
|
Gemiddeld
|
|
Count
|
Aantal
|
|
Minimum
|
Minimaal
|
|
Maximum
|
Maximum
|
|
Total
|
Total
|
createdByType
Opsomming
Het type identiteit waarmee de resource is gemaakt.
| Waarde |
Description |
|
User
|
|
|
Application
|
|
|
ManagedIdentity
|
|
|
Key
|
|
DynamicMetricCriteria
Object
Criterium voor dynamische drempel.
| Name |
Type |
Description |
|
alertSensitivity
|
DynamicThresholdSensitivity
|
De mate van afwijking die is vereist voor het activeren van een waarschuwing. Dit is van invloed op hoe strak de drempelwaarde is voor het patroon van de metrische reeks. Eerder ongedocumenteerde waarden kunnen worden geretourneerd
|
|
criterionType
|
string:
DynamicThresholdCriterion
|
Hiermee geeft u het type drempelcriteria op. Eerder ongedocumenteerde waarden kunnen worden geretourneerd
|
|
dimensions
|
MetricDimension[]
|
Lijst met dimensievoorwaarden.
|
|
failingPeriods
|
DynamicThresholdFailingPeriods
|
Het minimale aantal schendingen dat is vereist in het geselecteerde tijdvenster voor terugkijken dat is vereist om een waarschuwing te genereren.
|
|
ignoreDataBefore
|
string
(date-time)
|
Gebruik deze optie om de datum in te stellen van waaruit u de historische metrische gegevens wilt leren en de dynamische drempelwaarden (in ISO8601 notatie) wilt berekenen
|
|
metricName
|
string
|
Naam van de metrische waarde.
|
|
metricNamespace
|
string
|
Naamruimte van de metrische waarde.
|
|
name
|
string
|
Naam van de criteria.
|
|
operator
|
DynamicThresholdOperator
|
De operator die wordt gebruikt om de metrische waarde te vergelijken met de drempelwaarde. Eerder ongedocumenteerde waarden kunnen worden geretourneerd
|
|
skipMetricValidation
|
boolean
|
Hiermee kunt u een waarschuwingsregel maken voor een aangepaste metrische waarde die nog niet is verzonden, door ervoor te zorgen dat de metrische validatie wordt overgeslagen.
|
|
timeAggregation
|
AggregationTypeEnum
|
De criteria voor tijdaggregatietypen. Eerder ongedocumenteerde waarden kunnen worden geretourneerd
|
DynamicPromQLCriteria
Object
Het criterium voor een dynamische prom-query.
| Name |
Type |
Description |
|
alertSensitivity
|
DynamicThresholdSensitivity
|
De mate van afwijking die is vereist voor het activeren van een waarschuwing. Dit is van invloed op hoe strak de drempelwaarde is voor het patroon van de metrische reeks. Eerder ongedocumenteerde waarden kunnen worden geretourneerd
|
|
criterionType
|
string:
DynamicThresholdCriterion
|
Hiermee geeft u het type drempelcriteria op. Eerder ongedocumenteerde waarden kunnen worden geretourneerd
|
|
ignoreDataBefore
|
string
(date-time)
|
Gebruik deze optie om de datum in te stellen van waaruit u de historische metrische gegevens wilt leren en de dynamische drempelwaarden (in ISO8601 notatie) wilt berekenen
|
|
name
|
string
|
Naam van de criteria.
|
|
operator
|
DynamicThresholdOperator
|
De operator die wordt gebruikt om de metrische waarde te vergelijken met de drempelwaarde. Eerder ongedocumenteerde waarden kunnen worden geretourneerd
|
|
query
|
string
|
De query die wordt gebruikt om de waarschuwingsregel te evalueren
|
DynamicThresholdFailingPeriods
Object
Het minimale aantal schendingen dat is vereist in het geselecteerde tijdvenster voor terugkijken dat is vereist om een waarschuwing te genereren.
| Name |
Type |
Description |
|
minFailingPeriodsToAlert
|
number
(float)
|
Het aantal schendingen dat een waarschuwing activeert. Moet kleiner of gelijk zijn aan numberOfEvaluationPeriods.
|
|
numberOfEvaluationPeriods
|
number
(float)
|
Het aantal geaggregeerde lookbackpunten. Het tijdvenster voor lookback wordt berekend op basis van de aggregatiegranulariteit (windowSize) en het geselecteerde aantal geaggregeerde punten.
|
DynamicThresholdOperator
Opsomming
De operator die wordt gebruikt om de metrische waarde te vergelijken met de drempelwaarde. Eerder ongedocumenteerde waarden kunnen worden geretourneerd
| Waarde |
Description |
|
GreaterThan
|
GreaterThan
|
|
LessThan
|
LessThan
|
|
GreaterOrLessThan
|
GreaterOrLessThan
|
DynamicThresholdSensitivity
Opsomming
De mate van afwijking die is vereist voor het activeren van een waarschuwing. Dit is van invloed op hoe strak de drempelwaarde is voor het patroon van de metrische reeks. Eerder ongedocumenteerde waarden kunnen worden geretourneerd
| Waarde |
Description |
|
Low
|
Low
|
|
Medium
|
Medium
|
|
High
|
Hoog
|
IdentityType
Opsomming
Type beheerde service-identiteit.
| Waarde |
Description |
|
SystemAssigned
|
SysteemToegewezen
|
|
UserAssigned
|
UserAssigned
|
|
None
|
Geen
|
MetricAlertAction
Object
Een alarmactie.
| Name |
Type |
Description |
|
actionGroupId
|
string
|
De id van de actiegroep die je moet gebruiken.
|
|
webHookProperties
|
object
|
Met dit veld kunt u aangepaste eigenschappen opgeven, die worden toegevoegd aan de nettolading van de waarschuwing die als invoer naar de webhook wordt verzonden.
|
MetricAlertErrorResponse
Object
Beschrijft de indeling van foutreactie.
MetricAlertMultipleResourceMultipleMetricCriteria
Object
Specificeert de criteria voor metrische waarschuwingen voor meerdere bronnen die meerdere metriekcriteria hebben.
| Name |
Type |
Description |
|
allOf
|
MultiMetricCriteria[]:
|
De lijst met meerdere metrische criteria voor deze 'alle' operatie.
|
|
odata.type
|
string:
Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria
|
Hiermee geeft u het type waarschuwingscriteria op. Eerder ongedocumenteerde waarden kunnen worden geretourneerd
|
MetricAlertResource
Object
De bron voor metriekwaarschuwingen.
| Name |
Type |
Description |
|
id
|
string
|
Volledig gekwalificeerde resource-id voor de resource. Vb.: - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
|
identity
|
Microsoft.Common.Identity
|
De identiteit van de resource.
|
|
location
|
string
|
De geografische locatie waar de resource zich bevindt
|
|
name
|
string
|
De naam van de resource
|
|
properties.actionProperties
|
object
|
De eigenschappen van een actie-eigenschappen.
|
|
properties.actions
|
MetricAlertAction[]
|
De matrix met acties die worden uitgevoerd wanneer de waarschuwingsregel actief wordt en wanneer een waarschuwingsvoorwaarde wordt opgelost.
|
|
properties.autoMitigate
|
boolean
|
De vlag die aangeeft of de waarschuwing automatisch moet worden opgelost of niet. De standaardwaarde is waar.
|
|
properties.criteria
|
MetricAlertCriteria:
|
Definieert de specifieke informatie over de alarmcriteria.
|
|
properties.customProperties
|
object
|
De eigenschappen van een nettolading van een waarschuwing.
|
|
properties.description
|
string
|
De beschrijving van de metrische waarschuwing die wordt opgenomen in de waarschuwingsmail.
|
|
properties.enabled
|
boolean
|
De vlag die aangeeft of de metrische waarschuwing is ingeschakeld.
|
|
properties.evaluationFrequency
|
string
(duration)
|
Hoe vaak de metrische waarschuwing wordt geëvalueerd, weergegeven in de ISO 8601-duurindeling.
|
|
properties.isMigrated
|
boolean
|
De waarde geeft aan of deze waarschuwingsregel is gemigreerd.
|
|
properties.lastUpdatedTime
|
string
(date-time)
|
De vorige keer werd de regel in ISO8601 formaat bijgewerkt.
|
|
properties.resolveConfiguration
|
ResolveConfiguration
|
De configuratie voor de manier waarop de waarschuwing wordt opgelost. Van toepassing op PromQLCriteria.
|
|
properties.scopes
|
string[]
|
De lijst met resource-id's waarop deze metrische waarschuwing is gericht. U kunt het bereik van een metrische regel niet wijzigen op basis van logboeken.
|
|
properties.severity
|
integer
(int32)
|
Ernst van waarschuwing {0, 1, 2, 3, 4}
|
|
properties.targetResourceRegion
|
string
|
De regio van de doelbron(nen) waarop de waarschuwing is gemaakt/bijgewerkt. Verplicht als het bereik een abonnement, resourcegroep of meer dan één resource bevat.
|
|
properties.targetResourceType
|
string
|
Het resourcetype van de doelresource(s) waarop de waarschuwing is gemaakt/bijgewerkt. Verplicht als het bereik een abonnement, resourcegroep of meer dan één resource bevat.
|
|
properties.windowSize
|
string
(duration)
|
De periode (in ISO 8601-duurformaat) die wordt gebruikt om waarschuwingsactiviteit te bewaken op basis van de drempelwaarde.
|
|
systemData
|
systemData
|
Azure Resource Manager-metagegevens met createdBy- en modifiedBy-gegevens.
|
|
tags
|
object
|
Resourcetags.
|
|
type
|
string
|
Het type bron. Bijvoorbeeld 'Microsoft.Compute/virtualMachines' of 'Microsoft.Storage/storageAccounts'
|
MetricAlertSingleResourceMultipleMetricCriteria
Object
Specificeert de criteria voor metrische waarschuwingen voor een enkele bron die meerdere metriekcriteria heeft.
| Name |
Type |
Description |
|
allOf
|
MetricCriteria[]
|
De lijst met metrische criteria voor deze 'all'-bewerking.
|
|
odata.type
|
string:
Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria
|
Hiermee geeft u het type waarschuwingscriteria op. Eerder ongedocumenteerde waarden kunnen worden geretourneerd
|
MetricCriteria
Object
Criterium om metrieken te filteren.
| Name |
Type |
Description |
|
criterionType
|
string:
StaticThresholdCriterion
|
Hiermee geeft u het type drempelcriteria op. Eerder ongedocumenteerde waarden kunnen worden geretourneerd
|
|
dimensions
|
MetricDimension[]
|
Lijst met dimensievoorwaarden.
|
|
metricName
|
string
|
Naam van de metrische waarde.
|
|
metricNamespace
|
string
|
Naamruimte van de metrische waarde.
|
|
name
|
string
|
Naam van de criteria.
|
|
operator
|
Operator
|
De criteriumoperator. Eerder ongedocumenteerde waarden kunnen worden geretourneerd
|
|
skipMetricValidation
|
boolean
|
Hiermee kunt u een waarschuwingsregel maken voor een aangepaste metrische waarde die nog niet is verzonden, door ervoor te zorgen dat de metrische validatie wordt overgeslagen.
|
|
threshold
|
number
(double)
|
De drempelwaarde voor het criterium waarmee de waarschuwing wordt geactiveerd.
|
|
timeAggregation
|
AggregationTypeEnum
|
De criteria voor tijdaggregatietypen. Eerder ongedocumenteerde waarden kunnen worden geretourneerd
|
MetricDimension
Object
Specificeert een metrische dimensie.
| Name |
Type |
Description |
|
name
|
string
|
Naam van de dimensie.
|
|
operator
|
string
|
De dimensieoperator. Alleen Opnemen en Uitsluiten worden ondersteund
|
|
values
|
string[]
|
Lijst met dimensiewaarden.
|
Microsoft.Common.ErrorDetail
Object
Beschrijft details van een foutrespons.
| Name |
Type |
Description |
|
additionalInfo
|
Microsoft.Common.ErrorDetailAdditionalInfoItem[]
|
Een array van objecten met eigenschappen 'type' en 'info'. Het schema van 'info' is service-specifiek en afhankelijk van de 'type'-string.
|
|
code
|
string
|
Niet-gelokaliseerde string die kan worden gebruikt om de fout programmatisch te identificeren.
|
|
message
|
string
|
Beschrijft de fout in detail en geeft informatie over debugging.
|
|
target
|
string
|
Het doel van de specifieke fout (bijvoorbeeld de naam van de eigenschap in fout).
|
Microsoft.Common.ErrorDetailAdditionalInfoItem
Object
| Name |
Type |
Description |
|
info
|
|
De aanvullende informatie die specifiek is voor het type.
|
|
type
|
string
|
Het soort extra informatie.
|
Microsoft.Common.ErrorResponseError
Object
| Name |
Type |
Description |
|
additionalInfo
|
Microsoft.Common.ErrorResponseErrorAdditionalInfoItem[]
|
Een array van objecten met eigenschappen 'type' en 'info'. Het schema van 'info' is service-specifiek en afhankelijk van de 'type'-string.
|
|
code
|
string
|
Niet-gelokaliseerde string die kan worden gebruikt om de fout programmatisch te identificeren.
|
|
details
|
Microsoft.Common.ErrorDetail[]
|
Een matrix met aanvullende geneste informatieobjecten voor foutreacties, zoals beschreven in dit contract.
|
|
message
|
string
|
Beschrijft de fout in detail en geeft informatie over debugging. Als Accept-Language in het verzoek is ingesteld, moet het gelokaliseerd zijn naar die taal.
|
|
target
|
string
|
Het doel van de specifieke fout (bijvoorbeeld de naam van de eigenschap in fout).
|
Microsoft.Common.ErrorResponseErrorAdditionalInfoItem
Object
| Name |
Type |
Description |
|
info
|
|
De aanvullende informatie die specifiek is voor het type.
|
|
type
|
string
|
Het soort extra informatie.
|
Microsoft.Common.Identity
Object
Identiteit voor de resource.
| Name |
Type |
Description |
|
principalId
|
string
|
De principal-id van de resource-id.
|
|
tenantId
|
string
|
De tenant-id van de resource.
|
|
type
|
IdentityType
|
Type beheerde service-identiteit.
|
|
userAssignedIdentities
|
<string,
Microsoft.Common.UserIdentityProperties>
|
De lijst met gebruikersidentiteiten die zijn gekoppeld aan de resource. De sleutelverwijzingen voor de gebruikersidentiteitswoordenlijst zijn ARM-resource-id's in de vorm: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}.
|
Microsoft.Common.UserIdentityProperties
Object
Eigenschappen van de door de gebruiker toegewezen identiteit.
| Name |
Type |
Description |
|
clientId
|
string
|
De client-ID van resource-identiteit.
|
|
principalId
|
string
|
De principal-id van de resource-id.
|
Odatatype
Opsomming
Hiermee geeft u het type waarschuwingscriteria op. Eerder ongedocumenteerde waarden kunnen worden geretourneerd
| Waarde |
Description |
|
Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria
|
Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria
|
|
Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria
|
Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria
|
|
Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria
|
Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria
|
|
Microsoft.Azure.Monitor.PromQLCriteria
|
Microsoft.Azure.Monitor.PromQLCriteria
|
Operator
Opsomming
De criteriumoperator. Eerder ongedocumenteerde waarden kunnen worden geretourneerd
| Waarde |
Description |
|
Equals
|
Gelijk aan
|
|
GreaterThan
|
GreaterThan
|
|
GreaterThanOrEqual
|
GreaterThanOrEqual (GroterDanOfGelijkAan)
|
|
LessThan
|
LessThan
|
|
LessThanOrEqual
|
LessThanOrEqual
|
PromQLCriteria
Object
Specificeert de PromQL-criteria voor de metric alert-resource.
| Name |
Type |
Description |
|
allOf
|
MultiPromQLCriteria[]:
|
De lijst met promQL-criteria. Er wordt alarm geslagen wanneer aan alle voorwaarden is voldaan.
|
|
failingPeriods
|
QueryFailingPeriods
|
Configuratie voor foutperioden in waarschuwingen op basis van query's.
|
|
odata.type
|
string:
Microsoft.Azure.Monitor.PromQLCriteria
|
Hiermee geeft u het type waarschuwingscriteria op. Eerder ongedocumenteerde waarden kunnen worden geretourneerd
|
QueryFailingPeriods
Object
Configuratie voor foutperioden in waarschuwingen op basis van query's.
| Name |
Type |
Description |
|
for
|
string
(duration)
|
De tijdsduur (in ISO 8601-duurformaat) alert moet actief zijn voordat er wordt afgevuurd.
|
ResolveConfiguration
Object
| Name |
Type |
Description |
|
autoResolved
|
boolean
|
Geeft aan of de waarschuwing automatisch moet worden opgelost
|
|
timeToResolve
|
string
(duration)
|
De tijd (in ISO 8601-duurformaat) waarna de waarschuwing automatisch moet worden opgelost
|
StaticPromQLCriteria
Object
Het criterium voor een statische prom-query.
| Name |
Type |
Description |
|
criterionType
|
string:
StaticThresholdCriterion
|
Hiermee geeft u het type drempelcriteria op. Eerder ongedocumenteerde waarden kunnen worden geretourneerd
|
|
name
|
string
|
Naam van de criteria.
|
|
query
|
string
|
De query die wordt gebruikt om de waarschuwingsregel te evalueren
|
systemData
Object
Metagegevens met betrekking tot het maken en de laatste wijziging van de resource.
| Name |
Type |
Description |
|
createdAt
|
string
(date-time)
|
De tijdstempel van het maken van resources (UTC).
|
|
createdBy
|
string
|
De identiteit waarmee de resource is gemaakt.
|
|
createdByType
|
createdByType
|
Het type identiteit waarmee de resource is gemaakt.
|
|
lastModifiedAt
|
string
(date-time)
|
De tijdstempel van de laatste wijziging van de resource (UTC)
|
|
lastModifiedBy
|
string
|
De identiteit die de resource voor het laatst heeft gewijzigd.
|
|
lastModifiedByType
|
createdByType
|
Het type identiteit dat de resource voor het laatst heeft gewijzigd.
|
WebtestLocationAvailabilityCriteria
Object
Specificeert de criteria voor de metrische waarschuwingsregel voor een webtestbron.
| Name |
Type |
Description |
|
componentId
|
string
|
De Application Insights-resource-id.
|
|
failedLocationCount
|
number
(float)
|
Het aantal mislukte locaties.
|
|
odata.type
|
string:
Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria
|
Hiermee geeft u het type waarschuwingscriteria op. Eerder ongedocumenteerde waarden kunnen worden geretourneerd
|
|
webTestId
|
string
|
De Application Insights-webtest-id.
|