Bir metrik uyarı tanımı oluşturun veya güncelleyin.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}?api-version=2024-03-01-preview
URI Parametreleri
| Name |
İçinde |
Gerekli |
Tür |
Description |
|
resourceGroupName
|
path |
True
|
string
minLength: 1 maxLength: 90
|
Kaynak grubunun adı. Ad büyük/küçük harfe duyarsız.
|
|
ruleName
|
path |
True
|
string
|
Kuralın adı.
|
|
subscriptionId
|
path |
True
|
string
minLength: 1
|
Hedef aboneliğin kimliği.
|
|
api-version
|
query |
True
|
string
minLength: 1
|
Bu işlem için kullanılacak API sürümü.
|
İstek Gövdesi
| Name |
Gerekli |
Tür |
Description |
|
location
|
True
|
string
|
Kaynağın bulunduğu coğrafi konum
|
|
properties.criteria
|
True
|
MetricAlertCriteria:
|
Belirli uyarı ölçütü bilgilerini tanımlar.
|
|
properties.enabled
|
True
|
boolean
|
Ölçüm uyarısının etkinleştirilip etkinleştirilmediğini gösteren bayrak.
|
|
properties.evaluationFrequency
|
True
|
string
(duration)
|
Ölçüm uyarısının ne sıklıkta değerlendirildiği ISO 8601 süre biçiminde gösterilir.
|
|
properties.scopes
|
True
|
string[]
|
Bu ölçüm uyarısının kapsamının belirlendiği kaynak kimliklerinin listesi. Günlükleri temel alan bir ölçüm kuralının kapsamını değiştiremezsiniz.
|
|
properties.severity
|
True
|
integer
(int32)
|
Uyarı önem derecesi {0, 1, 2, 3, 4}
|
|
identity
|
|
Microsoft.Common.Identity
|
Kaynağın kimliği.
|
|
properties.actionProperties
|
|
object
|
Eylem özelliklerinin özellikleri.
|
|
properties.actions
|
|
MetricAlertAction[]
|
Uyarı kuralı etkin olduğunda ve bir uyarı koşulu çözümlendiğinde gerçekleştirilen eylemler dizisi.
|
|
properties.autoMitigate
|
|
boolean
|
Uyarının otomatik olarak çözümlenmesi gerekip gerekmediğini gösteren bayrak. Varsayılan değer true'dur.
|
|
properties.customProperties
|
|
object
|
Uyarı yükünün özellikleri.
|
|
properties.description
|
|
string
|
Uyarı e-postasına eklenecek ölçüm uyarısının açıklaması.
|
|
properties.resolveConfiguration
|
|
ResolveConfiguration
|
Uyarının nasıl çözümlendiğine ilişkin yapılandırma. PromQLCriteria için geçerlidir.
|
|
properties.targetResourceRegion
|
|
string
|
Uyarının oluşturulduğu/güncelleştirildiği hedef kaynakların bölgesi. Kapsam bir abonelik, kaynak grubu veya birden fazla kaynak içeriyorsa zorunlu.
|
|
properties.targetResourceType
|
|
string
|
Uyarının oluşturulduğu/güncelleştirildiği hedef kaynakların kaynak türü. Kapsam bir abonelik, kaynak grubu veya birden fazla kaynak içeriyorsa zorunlu.
|
|
properties.windowSize
|
|
string
(duration)
|
Eşiğe göre uyarı etkinliğini izlemek için kullanılan süre (ISO 8601 süre biçiminde).
|
|
tags
|
|
object
|
Kaynak etiketleri.
|
Yanıtlar
Güvenlik
azure_auth
Azure Active Directory OAuth2 Flow.
Tür:
oauth2
Akış:
implicit
Yetkilendirme URL’si:
https://login.microsoftonline.com/common/oauth2/authorize
Kapsamlar
| Name |
Description |
|
user_impersonation
|
kullanıcı hesabınızın kimliğine bürünme
|
Örnekler
Create or update a dynamic alert rule for Multiple Resources
Örnek isteği
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
Örnek yanıt
{
"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
Örnek isteği
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
Örnek yanıt
{
"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
Örnek isteği
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
Örnek yanıt
{
"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
Örnek isteği
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
Örnek yanıt
{
"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
Örnek isteği
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
Örnek yanıt
{
"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
Örnek isteği
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
Örnek yanıt
{
"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
Örnek isteği
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
Örnek yanıt
{
"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
Örnek isteği
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
Örnek yanıt
{
"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
Örnek isteği
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
Örnek yanıt
{
"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)
Örnek isteği
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
Örnek yanıt
{
"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
Örnek isteği
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
Örnek yanıt
{
"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
Örnek isteği
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
Örnek yanıt
{
"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"
}
}
Tanımlar
AggregationTypeEnum
Numaralandırma
Ölçüt zaman toplama türleri. Daha önce belgelenmemiş değerler döndürülebilir
| Değer |
Description |
|
Average
|
Average
|
|
Count
|
Count
|
|
Minimum
|
En Küçük
|
|
Maximum
|
Maximum
|
|
Total
|
Total
|
createdByType
Numaralandırma
Kaynağı oluşturan kimliğin türü.
| Değer |
Description |
|
User
|
|
|
Application
|
|
|
ManagedIdentity
|
|
|
Key
|
|
DynamicMetricCriteria
Nesne
Dinamik eşik için kriter.
| Name |
Tür |
Description |
|
alertSensitivity
|
DynamicThresholdSensitivity
|
Uyarı tetikleme için gereken sapma kapsamı. Bu, eşiğin ölçüm serisi düzenine ne kadar sıkı olduğunu etkiler. Daha önce belgelenmemiş değerler döndürülebilir
|
|
criterionType
|
string:
DynamicThresholdCriterion
|
Eşik ölçütlerinin türünü belirtir. Daha önce belgelenmemiş değerler döndürülebilir
|
|
dimensions
|
MetricDimension[]
|
Boyut koşullarının listesi.
|
|
failingPeriods
|
DynamicThresholdFailingPeriods
|
Uyarı göndermek için gereken, seçilen geri arama zaman penceresinde gereken en düşük ihlal sayısı.
|
|
ignoreDataBefore
|
string
(date-time)
|
Ölçüm geçmiş verilerini öğrenmeye başlayacağınız tarihi ayarlamak ve dinamik eşikleri hesaplamak için bu seçeneği kullanın (ISO8601 biçimde)
|
|
metricName
|
string
|
Ölçümün adı.
|
|
metricNamespace
|
string
|
Ölçümün ad alanı.
|
|
name
|
string
|
Ölçüt adı.
|
|
operator
|
DynamicThresholdOperator
|
Ölçüm değerini eşikle karşılaştırmak için kullanılan işleç. Daha önce belgelenmemiş değerler döndürülebilir
|
|
skipMetricValidation
|
boolean
|
Uyarı kuralı oluşturmanın, henüz üretilmemiş bir özel ölçüm üzerinde, ölçüm doğrulamasını atlayarak yapılmasına izin verir.
|
|
timeAggregation
|
AggregationTypeEnum
|
Ölçüt zaman toplama türleri. Daha önce belgelenmemiş değerler döndürülebilir
|
DynamicPromQLCriteria
Nesne
Dinamik mezuniyet dili sorgusu için kriter.
| Name |
Tür |
Description |
|
alertSensitivity
|
DynamicThresholdSensitivity
|
Uyarı tetikleme için gereken sapma kapsamı. Bu, eşiğin ölçüm serisi düzenine ne kadar sıkı olduğunu etkiler. Daha önce belgelenmemiş değerler döndürülebilir
|
|
criterionType
|
string:
DynamicThresholdCriterion
|
Eşik ölçütlerinin türünü belirtir. Daha önce belgelenmemiş değerler döndürülebilir
|
|
ignoreDataBefore
|
string
(date-time)
|
Ölçüm geçmiş verilerini öğrenmeye başlayacağınız tarihi ayarlamak ve dinamik eşikleri hesaplamak için bu seçeneği kullanın (ISO8601 biçimde)
|
|
name
|
string
|
Ölçüt adı.
|
|
operator
|
DynamicThresholdOperator
|
Ölçüm değerini eşikle karşılaştırmak için kullanılan işleç. Daha önce belgelenmemiş değerler döndürülebilir
|
|
query
|
string
|
Uyarı kuralını değerlendirmek için kullanılan sorgu
|
DynamicThresholdFailingPeriods
Nesne
Uyarı göndermek için gereken, seçilen geri arama zaman penceresinde gereken en düşük ihlal sayısı.
| Name |
Tür |
Description |
|
minFailingPeriodsToAlert
|
number
(float)
|
Uyarı tetikleme ihlallerinin sayısı. NumberOfEvaluationPeriods değerine eşit veya daha küçük olmalıdır.
|
|
numberOfEvaluationPeriods
|
number
(float)
|
Toplanan geri arama noktalarının sayısı. Geri arama zamanı penceresi toplama ayrıntı düzeyi (windowSize) ve seçili toplanan nokta sayısına göre hesaplanır.
|
DynamicThresholdOperator
Numaralandırma
Ölçüm değerini eşikle karşılaştırmak için kullanılan işleç. Daha önce belgelenmemiş değerler döndürülebilir
| Değer |
Description |
|
GreaterThan
|
GreaterThan
|
|
LessThan
|
LessThan
|
|
GreaterOrLessThan
|
BüyükYa KüçükOlur
|
DynamicThresholdSensitivity
Numaralandırma
Uyarı tetikleme için gereken sapma kapsamı. Bu, eşiğin ölçüm serisi düzenine ne kadar sıkı olduğunu etkiler. Daha önce belgelenmemiş değerler döndürülebilir
| Değer |
Description |
|
Low
|
Low
|
|
Medium
|
Medium
|
|
High
|
Yüksek
|
IdentityType
Numaralandırma
Yönetilen hizmet kimliği türü.
| Değer |
Description |
|
SystemAssigned
|
Sistem Ataması
|
|
UserAssigned
|
UserAssigned
|
|
None
|
Hiçbiri
|
MetricAlertAction
Nesne
Bir uyarı eylemi.
| Name |
Tür |
Description |
|
actionGroupId
|
string
|
Kullanılacak eylem grubunun kimliği.
|
|
webHookProperties
|
object
|
Bu alan, web kancasına giriş olarak gönderilen uyarı yüküne eklenecek özel özelliklerin belirtilmesine olanak tanır.
|
MetricAlertErrorResponse
Nesne
Hata yanıtının biçimini açıklar.
MetricAlertMultipleResourceMultipleMetricCriteria
Nesne
Birden fazla metrik kriterine sahip birden fazla kaynak için metrik uyarı kriterlerini belirtir.
| Name |
Tür |
Description |
|
allOf
|
MultiMetricCriteria[]:
|
Bu 'tümü' işlemi için birden çok ölçüm ölçütünün listesi.
|
|
odata.type
|
string:
Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria
|
Uyarı ölçütlerinin türünü belirtir. Daha önce belgelenmemiş değerler döndürülebilir
|
MetricAlertResource
Nesne
Metrik uyarı kaynağı.
| Name |
Tür |
Description |
|
id
|
string
|
Kaynağın tam kaynak kimliği. Örn - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
|
identity
|
Microsoft.Common.Identity
|
Kaynağın kimliği.
|
|
location
|
string
|
Kaynağın bulunduğu coğrafi konum
|
|
name
|
string
|
Kaynağın adı
|
|
properties.actionProperties
|
object
|
Eylem özelliklerinin özellikleri.
|
|
properties.actions
|
MetricAlertAction[]
|
Uyarı kuralı etkin olduğunda ve bir uyarı koşulu çözümlendiğinde gerçekleştirilen eylemler dizisi.
|
|
properties.autoMitigate
|
boolean
|
Uyarının otomatik olarak çözümlenmesi gerekip gerekmediğini gösteren bayrak. Varsayılan değer true'dur.
|
|
properties.criteria
|
MetricAlertCriteria:
|
Belirli uyarı ölçütü bilgilerini tanımlar.
|
|
properties.customProperties
|
object
|
Uyarı yükünün özellikleri.
|
|
properties.description
|
string
|
Uyarı e-postasına eklenecek ölçüm uyarısının açıklaması.
|
|
properties.enabled
|
boolean
|
Ölçüm uyarısının etkinleştirilip etkinleştirilmediğini gösteren bayrak.
|
|
properties.evaluationFrequency
|
string
(duration)
|
Ölçüm uyarısının ne sıklıkta değerlendirildiği ISO 8601 süre biçiminde gösterilir.
|
|
properties.isMigrated
|
boolean
|
Bu uyarı kuralının taşınıp taşınmadığını gösteren değer.
|
|
properties.lastUpdatedTime
|
string
(date-time)
|
Kural en son ISO8601 formatta güncellenmişti.
|
|
properties.resolveConfiguration
|
ResolveConfiguration
|
Uyarının nasıl çözümlendiğine ilişkin yapılandırma. PromQLCriteria için geçerlidir.
|
|
properties.scopes
|
string[]
|
Bu ölçüm uyarısının kapsamının belirlendiği kaynak kimliklerinin listesi. Günlükleri temel alan bir ölçüm kuralının kapsamını değiştiremezsiniz.
|
|
properties.severity
|
integer
(int32)
|
Uyarı önem derecesi {0, 1, 2, 3, 4}
|
|
properties.targetResourceRegion
|
string
|
Uyarının oluşturulduğu/güncelleştirildiği hedef kaynakların bölgesi. Kapsam bir abonelik, kaynak grubu veya birden fazla kaynak içeriyorsa zorunlu.
|
|
properties.targetResourceType
|
string
|
Uyarının oluşturulduğu/güncelleştirildiği hedef kaynakların kaynak türü. Kapsam bir abonelik, kaynak grubu veya birden fazla kaynak içeriyorsa zorunlu.
|
|
properties.windowSize
|
string
(duration)
|
Eşiğe göre uyarı etkinliğini izlemek için kullanılan süre (ISO 8601 süre biçiminde).
|
|
systemData
|
systemData
|
createdBy ve modifiedBy bilgilerini içeren Azure Resource Manager meta verileri.
|
|
tags
|
object
|
Kaynak etiketleri.
|
|
type
|
string
|
Kaynağın türü. Örneğin "Microsoft. Compute/virtualMachines" veya "Microsoft. Depo/Depolama Hesapları"
|
MetricAlertSingleResourceMultipleMetricCriteria
Nesne
Birden fazla metrik kriterine sahip tek bir kaynak için metrik uyarı kriterlerini belirtir.
| Name |
Tür |
Description |
|
allOf
|
MetricCriteria[]
|
Bu 'tümü' işlemi için ölçüm ölçütlerinin listesi.
|
|
odata.type
|
string:
Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria
|
Uyarı ölçütlerinin türünü belirtir. Daha önce belgelenmemiş değerler döndürülebilir
|
MetricCriteria
Nesne
Ölçütleri filtrelemek için kriterler.
| Name |
Tür |
Description |
|
criterionType
|
string:
StaticThresholdCriterion
|
Eşik ölçütlerinin türünü belirtir. Daha önce belgelenmemiş değerler döndürülebilir
|
|
dimensions
|
MetricDimension[]
|
Boyut koşullarının listesi.
|
|
metricName
|
string
|
Ölçümün adı.
|
|
metricNamespace
|
string
|
Ölçümün ad alanı.
|
|
name
|
string
|
Ölçüt adı.
|
|
operator
|
Operator
|
Ölçüt işleci. Daha önce belgelenmemiş değerler döndürülebilir
|
|
skipMetricValidation
|
boolean
|
Uyarı kuralı oluşturmanın, henüz üretilmemiş bir özel ölçüm üzerinde, ölçüm doğrulamasını atlayarak yapılmasına izin verir.
|
|
threshold
|
number
(double)
|
Uyarıyı etkinleştiren ölçüt eşik değeri.
|
|
timeAggregation
|
AggregationTypeEnum
|
Ölçüt zaman toplama türleri. Daha önce belgelenmemiş değerler döndürülebilir
|
MetricDimension
Nesne
Bir metrik boyut belirtir.
| Name |
Tür |
Description |
|
name
|
string
|
Boyutun adı.
|
|
operator
|
string
|
Boyut işleci. Yalnızca 'Dahil Et' ve 'Dışla' desteklenir
|
|
values
|
string[]
|
Boyut değerlerinin listesi.
|
Microsoft.Common.ErrorDetail
Nesne
Hata yanıtının detaylarını açıklar.
| Name |
Tür |
Description |
|
additionalInfo
|
Microsoft.Common.ErrorDetailAdditionalInfoItem[]
|
'Type' ve 'info' özelliklerine sahip bir nesne dizisi. 'Bilgi' şeması servise özgüdür ve 'type' dizisine bağlıdır.
|
|
code
|
string
|
Hatayı programatik olarak tanımlamak için kullanılabilen lokalize edilmemiş dizidir.
|
|
message
|
string
|
Hatayı ayrıntılı olarak tanımlar ve hata ayıklama bilgisi sağlar.
|
|
target
|
string
|
Belirli bir hatanın hedefi (örneğin, hatalı özelliğin adı).
|
Microsoft.Common.ErrorDetailAdditionalInfoItem
Nesne
| Name |
Tür |
Description |
|
info
|
|
Tipe özgü ek bilgiler.
|
|
type
|
string
|
Ek bilgi türü.
|
Microsoft.Common.ErrorResponseError
Nesne
| Name |
Tür |
Description |
|
additionalInfo
|
Microsoft.Common.ErrorResponseErrorAdditionalInfoItem[]
|
'Type' ve 'info' özelliklerine sahip bir nesne dizisi. 'Bilgi' şeması servise özgüdür ve 'type' dizisine bağlıdır.
|
|
code
|
string
|
Hatayı programatik olarak tanımlamak için kullanılabilen lokalize edilmemiş dizidir.
|
|
details
|
Microsoft.Common.ErrorDetail[]
|
Bu sözleşmede açıklandığı gibi ek iç içe hata yanıtı bilgi nesneleri dizisi.
|
|
message
|
string
|
Hatayı ayrıntılı olarak tanımlar ve hata ayıklama bilgisi sağlar. Eğer Accept-Language istekte ayarlanmışsa, o dile yerelleştirilmelidir.
|
|
target
|
string
|
Belirli bir hatanın hedefi (örneğin, hatalı özelliğin adı).
|
Microsoft.Common.ErrorResponseErrorAdditionalInfoItem
Nesne
| Name |
Tür |
Description |
|
info
|
|
Tipe özgü ek bilgiler.
|
|
type
|
string
|
Ek bilgi türü.
|
Microsoft.Common.Identity
Nesne
Kaynağın kimliği.
| Name |
Tür |
Description |
|
principalId
|
string
|
Kaynak kimliğinin asıl kimliği.
|
|
tenantId
|
string
|
Kaynağın kiracı kimliği.
|
|
type
|
IdentityType
|
Yönetilen hizmet kimliği türü.
|
|
userAssignedIdentities
|
<string,
Microsoft.Common.UserIdentityProperties>
|
Kaynakla ilişkilendirilmiş kullanıcı kimliklerinin listesi. Kullanıcı kimliği sözlük anahtarı başvuruları şu biçimde ARM kaynak kimlikleri olacaktır: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.
|
Microsoft.Common.UserIdentityProperties
Nesne
Kullanıcı tarafından atanan kimliğin özellikleri.
| Name |
Tür |
Description |
|
clientId
|
string
|
Kaynak kimliğinin istemci kimliği.
|
|
principalId
|
string
|
Kaynak kimliğinin asıl kimliği.
|
Odatatype
Numaralandırma
Uyarı ölçütlerinin türünü belirtir. Daha önce belgelenmemiş değerler döndürülebilir
| Değer |
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
Numaralandırma
Ölçüt işleci. Daha önce belgelenmemiş değerler döndürülebilir
| Değer |
Description |
|
Equals
|
Eşittir
|
|
GreaterThan
|
GreaterThan
|
|
GreaterThanOrEqual
|
GreaterThanOrEqual
|
|
LessThan
|
LessThan
|
|
LessThanOrEqual
|
LessThanOrEqual
|
PromQLCriteria
Nesne
Metrik uyarı kaynağı için PromQL kriterlerini belirtir.
| Name |
Tür |
Description |
|
allOf
|
MultiPromQLCriteria[]:
|
PromQL kriterlerinin listesi. Tüm koşullar karşılandığında uyarı verilecektir.
|
|
failingPeriods
|
QueryFailingPeriods
|
Sorgu tabanlı uyarılarda başarısız dönemler için yapılandırma.
|
|
odata.type
|
string:
Microsoft.Azure.Monitor.PromQLCriteria
|
Uyarı ölçütlerinin türünü belirtir. Daha önce belgelenmemiş değerler döndürülebilir
|
QueryFailingPeriods
Nesne
Sorgu tabanlı uyarılarda başarısız dönemler için yapılandırma.
| Name |
Tür |
Description |
|
for
|
string
(duration)
|
Tetiklemeden önce süre (ISO 8601 süre biçiminde) uyarısının etkin olması gerekir.
|
ResolveConfiguration
Nesne
| Name |
Tür |
Description |
|
autoResolved
|
boolean
|
Uyarının otomatik olarak çözümlenmesi gerekip gerekmediğini gösterir
|
|
timeToResolve
|
string
(duration)
|
Uyarının otomatik olarak çözümlenmesi gereken süre (ISO 8601 süre biçiminde)
|
StaticPromQLCriteria
Nesne
Statik balo sorgusu için kriter.
| Name |
Tür |
Description |
|
criterionType
|
string:
StaticThresholdCriterion
|
Eşik ölçütlerinin türünü belirtir. Daha önce belgelenmemiş değerler döndürülebilir
|
|
name
|
string
|
Ölçüt adı.
|
|
query
|
string
|
Uyarı kuralını değerlendirmek için kullanılan sorgu
|
systemData
Nesne
Kaynağın oluşturulması ve son değiştirilmesiyle ilgili meta veriler.
| Name |
Tür |
Description |
|
createdAt
|
string
(date-time)
|
Kaynak oluşturma (UTC) zaman damgası.
|
|
createdBy
|
string
|
Kaynağı oluşturan kimlik.
|
|
createdByType
|
createdByType
|
Kaynağı oluşturan kimliğin türü.
|
|
lastModifiedAt
|
string
(date-time)
|
Kaynağın son değişikliğinin zaman damgası (UTC)
|
|
lastModifiedBy
|
string
|
Kaynağı en son değiştiren kimlik.
|
|
lastModifiedByType
|
createdByType
|
Kaynağı en son değiştiren kimlik türü.
|
WebtestLocationAvailabilityCriteria
Nesne
Bir web test kaynağı için metrik uyarı kuralı kriterlerini belirler.
| Name |
Tür |
Description |
|
componentId
|
string
|
Application Insights kaynak kimliği.
|
|
failedLocationCount
|
number
(float)
|
Başarısız konumların sayısı.
|
|
odata.type
|
string:
Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria
|
Uyarı ölçütlerinin türünü belirtir. Daha önce belgelenmemiş değerler döndürülebilir
|
|
webTestId
|
string
|
Application Insights web testi kimliği.
|