إنشاء تنبيه قياسي في سجلات Azure Monitor

نظرة عامة

إشعار

نوصي باستخدام الوحدة النمطية Azure Az PowerShell للتفاعل مع Azure. راجع تثبيت Azure PowerShell للبدء. لمعرفة كيفية الترحيل إلى الوحدة النمطية Az PowerShell، راجع ترحيل Azure PowerShell من AzureRM إلى Az.

تتيح لك التنبيهات القياسية للسجلات الاستفادة من قدرات التنبيهات القياسية على مجموعة محددة مسبقا من السجلات في سجلات Azure Monitor. يتم تحويل سجلات المراقبة، والتي يمكن جمعها من أجهزة الكمبيوتر Azure، أو أجهزة الكمبيوتر المحلية، إلى مقاييس، ثم يتم مراقبتها بقواعد التنبيه القياسية تمامًا مثل أي مقياس آخر. سجلات تحليلات السجل المعتمدة هي التالية:

هناك العديد من الفوائد لاستخدام التنبيهات القياسية للسجلات عبر تنبيهات البحث في السجل المستندة إلى الاستعلام في Azure؛ بعضها مدرج أدناه:

  • توفر التنبيهات القياسية إمكانية مراقبة في الوقت الفعلي تقريبًا، وبيانات تنبيهات قياسية للسجلات من مصدر السجل لضمان نفس الشيء.
  • التنبيهات القياسية ذات حالة - يتم الإعلام مرة واحدة فقط عند إطلاق التنبيه ومرة واحدة عند حل التنبيه؛ بدلا من تسجيل تنبيهات البحث، والتي هي عديمة الحالة والحفاظ على إطلاق النار في كل فاصل زمني إذا تم استيفاء شرط التنبيه.
  • توفر التنبيهات القياسية للسجل أبعادًا متعددة، مما يسمح بالتصفية لقيم محددة؛ مثل: أجهزة الكمبيوتر، ونوع نظام التشغيل، وما إلى ذلك بشكل أبسط، دون الحاجة إلى تعريف استعلام معقد في سجل التحليلات.

إشعار

ولن يتم عرض المقياس و/ أو البعد المحدد إلا إذا كانت البيانات الخاصة به موجودة في الفترة المختارة. تتوفر هذه المقاييس للعملاء الذين لديهم مساحات عمل Azure Log Analytics.

مقاييس وأبعاد معتمدة للسجلات

تدعم تنبيهات القياس التنبيه للمقاييس التي تستخدم الأبعاد. يمكنك استخدام الأبعاد لتصفية المقياس إلى المستوى الصحيح. القائمة الكاملة للمقاييس المدعومة للسجلات تعادل قائمة مقياس مساحة عمل Log Analytics.

إشعار

لعرض مقياس مدعوم مستخرج من مساحة عمل Log Analytics عبر Azure Monitor - Metrics، يجب إنشاء تنبيه قياسي للسجل على هذا المقياس المحدد. الأبعاد التي تم اختيارها في التنبيه القياسي للسجلات - ستظهر فقط للاستكشاف عبر Azure Monitor - المقاييس.

إنشاء تنبيه قياسي Log Analytics

يتم نقل البيانات القياسية من السجلات الشائعة قبل معالجتها في Log Analytics، إلى Azure Monitor - المقاييس. وهذا يسمح للمستخدمين بالاستفادة من قدرات النظام الأساسي القياسي وكذلك التنبيه القياسي - بما في ذلك وجود تنبيهات بتردد منخفض يصل إلى دقيقة واحدة. المدرجة أدناه هي وسيلة لصياغة تنبيه قياسي للسجلات.

المتطلبات الأساسية للتنبيه القياسي للسجلات

قبل أن يعمل Metric for Logs الذي تم تجميعه على بيانات Log Analytics، يجب إعداد ما يلي وإتاحته:

  1. مساحة عمل تحليلات السجل النشطة: يجب أن تكون مساحة عمل Log Analytics صالحة ونشطة موجودة. لمزيد من المعلومات، راجع إنشاء مساحة عمل Log Analytics في مدخل Microsoft Azure.
  2. تم تكوين العامل لمساحة عمل Log Analytics: يجب تكوين العامل لأجهزة Azure الظاهرية (و/أو) الأجهزة الظاهرية المحلية لإرسال البيانات إلى مساحة عمل Log Analytics المستخدمة في الخطوة السابقة. لمزيد من المعلومات، راجع تحليلات السجل - نظرة عامة على العامل.
  3. تم تثبيت حل Log Analytics المدعوم: يجب تكوين حل Log Analytics وإرسال البيانات إلى مساحة عمل Log Analytics - الحلول المدعومة هي عدادات الأداء ل Windows وLinux وسجلات Heartbeat لصحة العامل وإدارة التحديث وبيانات الأحداث.
  4. حلول Log Analytics المكونة لإرسال السجلات: يجب أن يحتوي حل Log Analytics على السجلات/البيانات المطلوبة المقابلة للمقاييس المدعومة لمساحات عمل Log Analytics الممكنة . على سبيل المثال، بالنسبة إلى عداد الذاكرة المتوفرة بالنسبة ل ٪ يجب تكوينه في حل عدادات الأداء أولا.

تكوين تنبيه قياسي للسجلات

يمكن إنشاء التنبيهات القياسية وإدارتها باستخدام مدخل Azure، وقوالب إدارة الموارد وAPI REST وPowerShell و Azure CLI. منذ تنبيهات قياسي للسجلات، هو البديل من التنبيهات قياسي - بمجرد الانتهاء من المتطلبات الأساسية، يمكن إنشاء تنبيه قياسي للسجلات لمساحة عمل محددة Log Analytics. ستكون جميع خصائص ووظائف التنبيهات القياسية قابلة للتطبيق على التنبيهات القياسية للسجلات، أيضا؛ بما في ذلك مخطط الحمولة وحدود الحصة النسبية القابلة للتطبيق والسعر المفوتر.

للحصول على تفاصيل ونماذج خطوة بخطوة - راجع إنشاء التنبيهات القياسية وإدارتها. على وجه التحديد، بالنسبة للتنبيهات القياسية للسجلات - اتبع الإرشادات الخاصة بإدارة التنبيهات القياسية، وتأكد مما يلي:

  • الهدف للتنبيه القياسي هو مساحة عمل Log Analytics صالحة
  • الإشارة المختارة للتنبيه القياسي لمساحة عمل Log Analytics المحددة هي من النوع Metric
  • تصفية شروط أو موارد محددة باستخدام عوامل تصفية الأبعاد، مقاييس للسجلات متعددة الأبعاد
  • عند تكوين Signal Logic، يمكن إنشاء تنبيه واحد لامتداد قيم متعددة للبعد (مثل الكمبيوتر)
  • إذا لم تكن تستخدم مدخل Microsoft Azure لإنشاء تنبيه قياسي لمساحة عمل Log Analytics المحددة؛ فيجب على المستخدم أولا إنشاء قاعدة صريحة لتحويل بيانات السجل إلى مقياس باستخدام Azure Monitor - قواعد الاستعلام المجدولة.

إشعار

عند إنشاء تنبيه قياسي للسجل عبر مدخل Microsoft Azure - قاعدة مقابلة لتحويل بيانات السجل إلى مقياس عبر Azure Monitor - يتم إنشاء قواعد الاستعلام المجدولة تلقائيا في الخلفية، دون الحاجة إلى أي تدخل أو إجراء من قبل المستخدم. للحصول على تنبيه قياسي للسجلات التي تم إنشاؤها باستخدام وسائل أخرى غير مدخل Microsoft Azure، راجع قسم قالب الموارد للتنبيهات القياسية للسجلات على نموذج وسائل إنشاء سجل يستند إلى ScheduledQueryRule إلى قاعدة تحويل القياس قبل إنشاء التنبيه القياسي - وإلا فلن تكون هناك بيانات للتنبيه القياسي على السجلات التي تم إنشاؤها.

قالب المورد للتنبيهات القياسية للسجلات

كما ذكر سابقًا، عملية إنشاء تنبيهات قياسية للسجلات تكون مزدوجة :

  1. إنشاء قاعدة لاستخراج المقاييس من السجلات المعتمدة باستخدام scheduledQueryRule API
  2. إنشاء تنبيه قياسي للمقياس المستخرج من السجل (في الخطوة 1)، ومساحة عمل Log Analytics كمورد مستهدف

تنبيهات قياسية للسجلات ذات العتبة الثابتة

لتحقيق نفس الشيء، يمكن للمرء استخدام نموذج Azure Resource Manager Template أدناه - حيث يعتمد إنشاء تنبيه قياس عتبة ثابت على الإنشاء الناجح للقاعدة لاستخراج المقاييس من السجلات عبر scheduledQueryRule.

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "convertRuleName": {
            "type": "string",
            "minLength": 1,
            "metadata": {
                "description": "Name of the rule to convert log to metric"
            }
        },
        "convertRuleDescription": {
            "type": "string",
            "minLength": 1,
            "metadata": {
                "description": "Description for log converted to metric"
            }
        },
        "convertRuleRegion": {
            "type": "string",
            "minLength": 1,
            "metadata": {
                "description": "Name of the region used by workspace"
            }
        },
        "convertRuleStatus": {
            "type": "string",
            "defaultValue": "true",
            "metadata": {
                "description": "Specifies whether the log conversion rule is enabled"
            }
        },
        "convertRuleMetric": {
            "type": "string",
            "minLength": 1,
            "metadata": {
                "description": "Name of the metric once extraction done from logs."
            }
        },
        "alertName": {
            "type": "string",
            "minLength": 1,
            "metadata": {
                "description": "Name of the alert"
            }
        },
        "alertDescription": {
            "type": "string",
            "defaultValue": "This is a metric alert",
            "metadata": {
                "description": "Description of alert"
            }
        },
        "alertSeverity": {
            "type": "int",
            "defaultValue": 3,
            "allowedValues": [
                0,
                1,
                2,
                3,
                4
            ],
            "metadata": {
                "description": "Severity of alert {0,1,2,3,4}"
            }
        },
        "isEnabled": {
            "type": "bool",
            "defaultValue": true,
            "metadata": {
                "description": "Specifies whether the alert is enabled"
            }
        },
        "resourceId": {
            "type": "string",
            "minLength": 1,
            "metadata": {
                "description": "Full Resource ID of the resource emitting the metric that will be used for the comparison. For example: /subscriptions/00000000-0000-0000-0000-0000-00000000/resourceGroups/ResourceGroupName/providers/Microsoft.OperationalInsights/workspaces/workspaceName"
            }
        },
        "metricName": {
            "type": "string",
            "minLength": 1,
            "metadata": {
                "description": "Name of the metric used in the comparison to activate the alert."
            }
        },
        "operator": {
            "type": "string",
            "defaultValue": "GreaterThan",
            "allowedValues": [
                "Equals",
                "NotEquals",
                "GreaterThan",
                "GreaterThanOrEqual",
                "LessThan",
                "LessThanOrEqual"
            ],
            "metadata": {
                "description": "Operator comparing the current value with the threshold value."
            }
        },
        "threshold": {
            "type": "string",
            "defaultValue": "0",
            "metadata": {
                "description": "The threshold value at which the alert is activated."
            }
        },
        "timeAggregation": {
            "type": "string",
            "defaultValue": "Average",
            "allowedValues": [
                "Average",
                "Minimum",
                "Maximum",
                "Total"
            ],
            "metadata": {
                "description": "How the data that is collected should be combined over time."
            }
        },
        "windowSize": {
            "type": "string",
            "defaultValue": "PT5M",
            "metadata": {
                "description": "Period of time used to monitor alert activity based on the threshold. Must be between five minutes and one day. ISO 8601 duration format."
            }
        },
        "evaluationFrequency": {
            "type": "string",
            "defaultValue": "PT1M",
            "metadata": {
                "description": "how often the metric alert is evaluated represented in ISO 8601 duration format"
            }
        },
        "actionGroupId": {
            "type": "string",
            "defaultValue": "",
            "metadata": {
                "description": "The ID of the action group that is triggered when the alert is activated or deactivated"
            }
        }
    },
    "variables": {
        "convertRuleSourceWorkspace": {
            "SourceId": "/subscriptions/1234-56789-1234-567a/resourceGroups/resourceGroupName/providers/Microsoft.OperationalInsights/workspaces/workspaceName"
        }
    },
    "resources": [
        {
            "name": "[parameters('convertRuleName')]",
            "type": "Microsoft.Insights/scheduledQueryRules",
            "apiVersion": "2018-04-16",
            "location": "[parameters('convertRuleRegion')]",
            "properties": {
                "description": "[parameters('convertRuleDescription')]",
                "enabled": "[parameters('convertRuleStatus')]",
                "source": {
                    "dataSourceId": "[variables('convertRuleSourceWorkspace').SourceId]"
                },
                "action": {
                    "odata.type": "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.LogToMetricAction",
                    "criteria": [{
                            "metricName": "[parameters('convertRuleMetric')]",
                            "dimensions": []
                        }
                    ]
                }
            }
        },
        {
            "name": "[parameters('alertName')]",
            "type": "Microsoft.Insights/metricAlerts",
            "location": "global",
            "apiVersion": "2018-03-01",
            "tags": {},
            "dependsOn":["[resourceId('Microsoft.Insights/scheduledQueryRules',parameters('convertRuleName'))]"],
            "properties": {
                "description": "[parameters('alertDescription')]",
                "severity": "[parameters('alertSeverity')]",
                "enabled": "[parameters('isEnabled')]",
                "scopes": ["[parameters('resourceId')]"],
                "evaluationFrequency":"[parameters('evaluationFrequency')]",
                "windowSize": "[parameters('windowSize')]",
                "criteria": {
                    "odata.type": "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria",
                    "allOf": [
                        {
                            "name" : "1st criterion",
                            "metricName": "[parameters('metricName')]",
                            "dimensions":[],
                            "operator": "[parameters('operator')]",
                            "threshold" : "[parameters('threshold')]",
                            "timeAggregation": "[parameters('timeAggregation')]"
                        }
                    ]
                },
                "actions": [
                    {
                        "actionGroupId": "[parameters('actionGroupId')]"
                    }
                ]
            }
        }
    ]
}

نفترض أن JSON أعلاه يتم حفظه كما metricfromLogsAlertStatic.json -- ثم يمكن أن يقترن مع معلمة JSON ملف لإنشاء قالب الموارد القائمة. يتم سرد نموذج معلمة JSON الملف أدناه:

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "convertRuleName": {
            "value": "TestLogtoMetricRule" 
        },
        "convertRuleDescription": {
            "value": "Test rule to extract metrics from logs via template"
        },
        "convertRuleRegion": {
            "value": "West Central US"
        },
        "convertRuleStatus": {
            "value": "true"
        },
        "convertRuleMetric": {
            "value": "Average_% Idle Time"
        },
        "alertName": {
            "value": "TestMetricAlertonLog"
        },
        "alertDescription": {
            "value": "New multi-dimensional metric alert created via template"
        },
        "alertSeverity": {
            "value":3
        },
        "isEnabled": {
            "value": true
        },
        "resourceId": {
            "value": "/subscriptions/1234-56789-1234-567a/resourceGroups/myRG/providers/Microsoft.OperationalInsights/workspaces/workspaceName"
        },
        "metricName":{
            "value": "Average_% Idle Time"
        },
        "operator": {
            "value": "GreaterThan"
        },
        "threshold":{
            "value": "1"
        },
        "timeAggregation":{
            "value": "Average"
        },
        "actionGroupId": {
            "value": "/subscriptions/1234-56789-1234-567a/resourceGroups/myRG/providers/microsoft.insights/actionGroups/actionGroupName"
        }
    }
}

بافتراض حفظ ملف المعلمة أعلاه ك metricfromLogsAlertStatic.parameters.json؛ ثم يمكن للمرء إنشاء تنبيه قياسي للسجلات باستخدام قالب المورد للإنشاء في مدخل Microsoft Azure.

بدلاً من ذلك، يمكن للمرء استخدام الأمر Azure PowerShell أدناه أيضًا:

New-AzResourceGroupDeployment -ResourceGroupName "myRG" -TemplateFile metricfromLogsAlertStatic.json TemplateParameterFile metricfromLogsAlertStatic.parameters.json

أو استخدم نشر قالب الموارد باستخدام Azure CLI:

az deployment group create --resource-group myRG --template-file metricfromLogsAlertStatic.json --parameters @metricfromLogsAlertStatic.parameters.json

تنبيهات قياسية للسجلات ذات العتبات الديناميكية

لتحقيق نفس الشيء، يمكن للمرء استخدام نموذج Azure Resource Manager Template أدناه - حيث يعتمد إنشاء تنبيه قياسي للعتبات الديناميكية على الإنشاء الناجح للقاعدة لاستخراج المقاييس من السجلات عبر scheduledQueryRule.

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "convertRuleName": {
            "type": "string",
            "minLength": 1,
            "metadata": {
                "description": "Name of the rule to convert log to metric"
            }
        },
        "convertRuleDescription": {
            "type": "string",
            "minLength": 1,
            "metadata": {
                "description": "Description for log converted to metric"
            }
        },
        "convertRuleRegion": {
            "type": "string",
            "minLength": 1,
            "metadata": {
                "description": "Name of the region used by workspace"
            }
        },
        "convertRuleStatus": {
            "type": "string",
            "defaultValue": "true",
            "metadata": {
                "description": "Specifies whether the log conversion rule is enabled"
            }
        },
        "convertRuleMetric": {
            "type": "string",
            "minLength": 1,
            "metadata": {
                "description": "Name of the metric once extraction done from logs."
            }
        },
        "alertName": {
            "type": "string",
            "minLength": 1,
            "metadata": {
                "description": "Name of the alert"
            }
        },
        "alertDescription": {
            "type": "string",
            "defaultValue": "This is a metric alert",
            "metadata": {
                "description": "Description of alert"
            }
        },
        "alertSeverity": {
            "type": "int",
            "defaultValue": 3,
            "allowedValues": [
                0,
                1,
                2,
                3,
                4
            ],
            "metadata": {
                "description": "Severity of alert {0,1,2,3,4}"
            }
        },
        "isEnabled": {
            "type": "bool",
            "defaultValue": true,
            "metadata": {
                "description": "Specifies whether the alert is enabled"
            }
        },
        "resourceId": {
            "type": "string",
            "minLength": 1,
            "metadata": {
                "description": "Full Resource ID of the resource emitting the metric that will be used for the comparison. For example: /subscriptions/00000000-0000-0000-0000-0000-00000000/resourceGroups/ResourceGroupName/providers/Microsoft.OperationalInsights/workspaces/workspaceName"
            }
        },
        "metricName": {
            "type": "string",
            "minLength": 1,
            "metadata": {
                "description": "Name of the metric used in the comparison to activate the alert."
            }
        },
        "operator": {
            "type": "string",
            "defaultValue": "GreaterOrLessThan",
            "allowedValues": [
                "GreaterThan",
                "LessThan",
                "GreaterOrLessThan"
            ],
            "metadata": {
                "description": "Operator comparing the current value with the threshold value."
            }
        },
        "alertSensitivity": {
            "type": "string",
            "defaultValue": "Medium",
            "allowedValues": [
                "High",
                "Medium",
                "Low"
            ],
            "metadata": {
                "description": "Tunes how 'noisy' the Dynamic Thresholds alerts will be: 'High' will result in more alerts while 'Low' will result in fewer alerts."
            }
        },
        "numberOfEvaluationPeriods": {
            "type": "string",
            "defaultValue": "4",
            "metadata": {
                "description": "The number of periods to check in the alert evaluation."
            }
        },
        "minFailingPeriodsToAlert": {
            "type": "string",
            "defaultValue": "3",
            "metadata": {
                "description": "The number of unhealthy periods to alert on (must be lower or equal to numberOfEvaluationPeriods)."
            }
        },
        "timeAggregation": {
            "type": "string",
            "defaultValue": "Average",
            "allowedValues": [
                "Average",
                "Minimum",
                "Maximum",
                "Total"
            ],
            "metadata": {
                "description": "How the data that is collected should be combined over time."
            }
        },
        "windowSize": {
            "type": "string",
            "defaultValue": "PT5M",
            "metadata": {
                "description": "Period of time used to monitor alert activity based on the threshold. Must be between five minutes and one day. ISO 8601 duration format."
            }
        },
        "evaluationFrequency": {
            "type": "string",
            "defaultValue": "PT1M",
            "metadata": {
                "description": "how often the metric alert is evaluated represented in ISO 8601 duration format"
            }
        },
        "actionGroupId": {
            "type": "string",
            "defaultValue": "",
            "metadata": {
                "description": "The ID of the action group that is triggered when the alert is activated or deactivated"
            }
        }
    },
    "variables": {
        "convertRuleSourceWorkspace": {
            "SourceId": "/subscriptions/1234-56789-1234-567a/resourceGroups/resourceGroupName/providers/Microsoft.OperationalInsights/workspaces/workspaceName"
        }
    },
    "resources": [
        {
            "name": "[parameters('convertRuleName')]",
            "type": "Microsoft.Insights/scheduledQueryRules",
            "apiVersion": "2018-04-16",
            "location": "[parameters('convertRuleRegion')]",
            "properties": {
                "description": "[parameters('convertRuleDescription')]",
                "enabled": "[parameters('convertRuleStatus')]",
                "source": {
                    "dataSourceId": "[variables('convertRuleSourceWorkspace').SourceId]"
                },
                "action": {
                    "odata.type": "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.LogToMetricAction",
                    "criteria": [{
                            "metricName": "[parameters('convertRuleMetric')]",
                            "dimensions": []
                        }
                    ]
                }
            }
        },
        {
            "name": "[parameters('alertName')]",
            "type": "Microsoft.Insights/metricAlerts",
            "location": "global",
            "apiVersion": "2018-03-01",
            "tags": {},
            "dependsOn":["[resourceId('Microsoft.Insights/scheduledQueryRules',parameters('convertRuleName'))]"],
            "properties": {
                "description": "[parameters('alertDescription')]",
                "severity": "[parameters('alertSeverity')]",
                "enabled": "[parameters('isEnabled')]",
                "scopes": ["[parameters('resourceId')]"],
                "evaluationFrequency":"[parameters('evaluationFrequency')]",
                "windowSize": "[parameters('windowSize')]",
                "criteria": {
                    "odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria",
                    "allOf": [
                        {
                            "criterionType": "DynamicThresholdCriterion",
                            "name" : "1st criterion",
                            "metricName": "[parameters('metricName')]",
                            "dimensions":[],
                            "operator": "[parameters('operator')]",
                            "alertSensitivity": "[parameters('alertSensitivity')]",
                            "failingPeriods": {
                                "numberOfEvaluationPeriods": "[parameters('numberOfEvaluationPeriods')]",
                                "minFailingPeriodsToAlert": "[parameters('minFailingPeriodsToAlert')]"
                            },
                            "timeAggregation": "[parameters('timeAggregation')]"
                        }
                    ]
                },
                "actions": [
                    {
                        "actionGroupId": "[parameters('actionGroupId')]"
                    }
                ]
            }
        }
    ]
}

ونفترض أن JSON أعلاه يتم حفظه كما metricfromLogsAlertDynamic.json - ثم يمكن أن يقترن مع معلمة JSON ملف لإنشاء قالب الموارد على أساس. يتم سرد نموذج معلمة JSON الملف أدناه:

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "convertRuleName": {
            "value": "TestLogtoMetricRule"
        },
        "convertRuleDescription": {
            "value": "Test rule to extract metrics from logs via template"
        },
        "convertRuleRegion": {
            "value": "West Central US"
        },
        "convertRuleStatus": {
            "value": "true"
        },
        "convertRuleMetric": {
            "value": "Average_% Idle Time"
        },
        "alertName": {
            "value": "TestMetricAlertonLog"
        },
        "alertDescription": {
            "value": "New multi-dimensional metric alert created via template"
        },
        "alertSeverity": {
            "value":3
        },
        "isEnabled": {
            "value": true
        },
        "resourceId": {
            "value": "/subscriptions/1234-56789-1234-567a/resourceGroups/myRG/providers/Microsoft.OperationalInsights/workspaces/workspaceName"
        },
        "metricName":{
            "value": "Average_% Idle Time"
        },
        "operator": {
            "value": "GreaterOrLessThan"
          },
          "alertSensitivity": {
              "value": "Medium"
          },
          "numberOfEvaluationPeriods": {
              "value": "4"
          },
          "minFailingPeriodsToAlert": {
              "value": "3"
          },
        "timeAggregation":{
            "value": "Average"
        },
        "actionGroupId": {
            "value": "/subscriptions/1234-56789-1234-567a/resourceGroups/myRG/providers/microsoft.insights/actionGroups/actionGroupName"
        }
    }
}

بافتراض حفظ ملف المعلمة أعلاه ك metricfromLogsAlertDynamic.parameters.json؛ ثم يمكن للمرء إنشاء تنبيه قياسي للسجلات باستخدام قالب المورد للإنشاء في مدخل Microsoft Azure.

بدلاً من ذلك، يمكن للمرء استخدام الأمر Azure PowerShell أدناه أيضًا:

New-AzResourceGroupDeployment -ResourceGroupName "myRG" -TemplateFile metricfromLogsAlertDynamic.json TemplateParameterFile metricfromLogsAlertDynamic.parameters.json

أو استخدم نشر قالب الموارد باستخدام Azure CLI:

az deployment group create --resource-group myRG --template-file metricfromLogsAlertDynamic.json --parameters @metricfromLogsAlertDynamic.parameters.json

الخطوات التالية