Alert Rule Recommendations - List By Target Type
A céltípusra vonatkozó riasztási szabályokra vonatkozó javaslatok lekérése.
GET https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/alertRuleRecommendations?api-version=2023-08-01-preview&targetType={targetType}
URI-paraméterek
Name | In | Kötelező | Típus | Description |
---|---|---|---|---|
subscription
|
path | True |
string minLength: 1 |
A cél-előfizetés azonosítója. |
api-version
|
query | True |
string minLength: 1 |
A művelethez használni kívánt API-verzió. |
target
|
query | True |
string |
A javaslatok céltípusa. |
Válaszok
Name | Típus | Description |
---|---|---|
200 OK |
Sikeres kérés a riasztási szabályokra vonatkozó javaslatok listájához |
|
Other Status Codes |
Hibaválasz, amely leírja, hogy miért nem sikerült a művelet. |
Biztonság
azure_auth
Azure Active Directory OAuth2 Flow
Típus:
oauth2
Folyamat:
implicit
Engedélyezési URL:
https://login.microsoftonline.com/common/oauth2/authorize
Hatókörök
Name | Description |
---|---|
user_impersonation | a felhasználói fiók megszemélyesítése |
Példák
List alert rule recommendations for Monitoring accounts at subscription level |
List alert rule recommendations for virtual machines at subscription level |
List alert rule recommendations for Monitoring accounts at subscription level
Mintakérelem
GET https://management.azure.com/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/providers/Microsoft.AlertsManagement/alertRuleRecommendations?api-version=2023-08-01-preview&targetType=microsoft.monitor/accounts
Mintaválasz
{
"value": [
{
"id": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/providers/Microsoft.AlertsManagement/alertRuleRecommendations/NodeRecordingRulesRuleGroup",
"name": "NodeRecordingRulesRuleGroup",
"type": "Microsoft.AlertsManagement/alertRuleRecommendations",
"properties": {
"alertRuleType": "Microsoft.AlertsManagement/prometheusRuleGroups",
"category": "MyCategory1",
"displayInformation": {
"ruleInfo": "Rule Information for first recording rule."
},
"ruleArmTemplate": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"targetResourceId": {
"type": "string"
},
"targetResourceName": {
"type": "string"
},
"actionGroupIds": {
"type": "array",
"defaultValue": [],
"metadata": {
"description": "Insert Action groups ids to attach them to the below alert rules."
}
},
"location": {
"type": "string"
},
"clusterNameForPrometheus": {
"type": "string"
},
"alertNamePrefix": {
"type": "string",
"defaultValue": "NodeRecordingRulesRuleGroup",
"minLength": 1,
"metadata": {
"description": "prefix of the alert rule name"
}
},
"alertName": {
"type": "string",
"defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('clusterNameForPrometheus'))]",
"minLength": 1,
"metadata": {
"description": "Name of the alert rule"
}
}
},
"variables": {
"scopes": "[array(parameters('targetResourceId'))]",
"copy": [
{
"name": "actionsForPrometheusRuleGroups",
"count": "[length(parameters('actionGroupIds'))]",
"input": {
"actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForPrometheusRuleGroups')]]"
}
}
]
},
"resources": [
{
"name": "[parameters('alertName')]",
"type": "Microsoft.AlertsManagement/prometheusRuleGroups",
"apiVersion": "2021-07-22-preview",
"location": "[parameters('location')]",
"properties": {
"description": "Node Recording Rules RuleGroup",
"scopes": "[variables('scopes')]",
"clusterName": "[parameters('clusterNameForPrometheus')]",
"interval": "PT1M",
"rules": [
{
"record": "instance:node_num_cpu:sum",
"expression": "count without (cpu, mode) ( node_cpu_seconds_total{job=\"node\",mode=\"idle\"})"
}
]
}
}
]
}
}
},
{
"id": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/providers/Microsoft.AlertsManagement/alertRuleRecommendations/KubernetesReccordingRulesRuleGroup",
"name": "KubernetesReccordingRulesRuleGroup",
"type": "Microsoft.AlertsManagement/alertRuleRecommendations",
"properties": {
"alertRuleType": "Microsoft.AlertsManagement/prometheusRuleGroups",
"category": "MyCategory1",
"displayInformation": {
"ruleInfo": "Rule Information for second recording rule."
},
"ruleArmTemplate": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"targetResourceId": {
"type": "string"
},
"targetResourceName": {
"type": "string"
},
"actionGroupIds": {
"type": "array",
"defaultValue": [],
"metadata": {
"description": "Insert Action groups ids to attach them to the below alert rules."
}
},
"location": {
"type": "string"
},
"clusterNameForPrometheus": {
"type": "string"
},
"alertNamePrefix": {
"type": "string",
"defaultValue": "KubernetesReccordingRulesRuleGroup",
"minLength": 1,
"metadata": {
"description": "prefix of the alert rule name"
}
},
"alertName": {
"type": "string",
"defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('clusterNameForPrometheus'))]",
"minLength": 1,
"metadata": {
"description": "Name of the alert rule"
}
}
},
"variables": {
"scopes": "[array(parameters('targetResourceId'))]",
"copy": [
{
"name": "actionsForPrometheusRuleGroups",
"count": "[length(parameters('actionGroupIds'))]",
"input": {
"actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForPrometheusRuleGroups')]]"
}
}
]
},
"resources": [
{
"name": "[parameters('alertName')]",
"type": "Microsoft.AlertsManagement/prometheusRuleGroups",
"apiVersion": "2021-07-22-preview",
"location": "[parameters('location')]",
"properties": {
"description": "Kubernetes Recording Rules RuleGroup",
"scopes": "[variables('scopes')]",
"clusterName": "[parameters('clusterNameForPrometheus')]",
"interval": "PT1M",
"rules": [
{
"record": "node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate",
"expression": "sum by (cluster, namespace, pod, container) ( irate(container_cpu_usage_seconds_total{job=\"cadvisor\", image!=\"\"}[5m])) * on (cluster, namespace, pod) group_left(node) topk by (cluster, namespace, pod) ( 1, max by(cluster, namespace, pod, node) (kube_pod_info{node!=\"\"}))"
}
]
}
}
]
}
}
},
{
"id": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/providers/Microsoft.AlertsManagement/alertRuleRecommendations/KubernetesAlert-DefaultAlerts",
"name": "KubernetesAlert-DefaultAlerts",
"type": "Microsoft.AlertsManagement/alertRuleRecommendations",
"properties": {
"alertRuleType": "Microsoft.AlertsManagement/prometheusRuleGroups",
"category": "MyCategory2",
"displayInformation": {
"ruleInfo": "Rule Information for alerting rule."
},
"ruleArmTemplate": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"targetResourceId": {
"type": "string"
},
"targetResourceName": {
"type": "string"
},
"actionGroupIds": {
"type": "array",
"defaultValue": [],
"metadata": {
"description": "Insert Action groups ids to attach them to the below alert rules."
}
},
"location": {
"type": "string"
},
"clusterNameForPrometheus": {
"type": "string"
},
"alertNamePrefix": {
"type": "string",
"defaultValue": "KubernetesAlert-DefaultAlerts",
"minLength": 1,
"metadata": {
"description": "prefix of the alert rule name"
}
},
"alertName": {
"type": "string",
"defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('clusterNameForPrometheus'))]",
"minLength": 1,
"metadata": {
"description": "Name of the alert rule"
}
}
},
"variables": {
"scopes": "[array(parameters('targetResourceId'))]",
"copy": [
{
"name": "actionsForPrometheusRuleGroups",
"count": "[length(parameters('actionGroupIds'))]",
"input": {
"actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForPrometheusRuleGroups')]]"
}
}
]
},
"resources": [
{
"name": "[parameters('alertName')]",
"type": "Microsoft.AlertsManagement/prometheusRuleGroups",
"apiVersion": "2021-07-22-preview",
"location": "[parameters('location')]",
"properties": {
"description": "Kubernetes Alert RuleGroup-DefaultAlerts",
"scopes": "[variables('scopes')]",
"clusterName": "[parameters('clusterNameForPrometheus')]",
"interval": "PT1M",
"rules": [
{
"alert": "KubePodCrashLooping",
"expression": "max_over_time(kube_pod_container_status_waiting_reason{reason=\"CrashLoopBackOff\", job=\"kube-state-metrics\"}[5m]) >= 1",
"for": "PT15M",
"labels": {
"severity": "warning"
},
"Severity": 3,
"actions": "[variables('actionsForPrometheusRuleGroups')]"
},
{
"alert": "KubePodNotReady",
"expression": "sum by (namespace, pod, cluster) ( max by(namespace, pod, cluster) ( kube_pod_status_phase{job=\"kube-state-metrics\", phase=~\"Pending|Unknown\"} ) * on(namespace, pod, cluster) group_left(owner_kind) topk by(namespace, pod, cluster) ( 1, max by(namespace, pod, owner_kind, cluster) (kube_pod_owner{owner_kind!=\"Job\"}) )) > 0",
"for": "PT15M",
"labels": {
"severity": "warning"
},
"Severity": 3,
"actions": "[variables('actionsForPrometheusRuleGroups')]"
}
]
}
}
]
}
}
}
]
}
List alert rule recommendations for virtual machines at subscription level
Mintakérelem
GET https://management.azure.com/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/providers/Microsoft.AlertsManagement/alertRuleRecommendations?api-version=2023-08-01-preview&targetType=microsoft.compute/virtualmachines
Mintaválasz
{
"value": [
{
"id": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/providers/Microsoft.AlertsManagement/alertRuleRecommendations/Percentage CPU",
"name": "Percentage CPU",
"type": "Microsoft.AlertsManagement/alertRuleRecommendations",
"properties": {
"alertRuleType": "Microsoft.Insights/metricAlerts",
"displayInformation": {
"infoBallonMessage": "Rule1 InfoBalloon Message",
"infoBallonLink": "Rule1 InfoBalloon Link",
"metricDisplayName": "Percentage CPU",
"displayUnits": "Percentage"
},
"ruleArmTemplate": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"targetResourceId": {
"type": "string"
},
"targetResourceName": {
"type": "string"
},
"actionGroupIds": {
"type": "array",
"defaultValue": [],
"metadata": {
"description": "Insert Action groups ids to attach them to the below alert rules."
}
},
"alertNamePrefix": {
"type": "string",
"defaultValue": "Percentage CPU",
"minLength": 1,
"metadata": {
"description": "prefix of the alert rule name"
}
},
"alertName": {
"type": "string",
"defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('targetResourceName'))]",
"minLength": 1,
"metadata": {
"description": "Name of the alert rule"
}
},
"alertSeverity": {
"type": "int",
"allowedValues": [
0,
1,
2,
3,
4
],
"defaultValue": 3,
"metadata": {
"description": "Severity of alert {0,1,2,3,4}"
}
},
"threshold": {
"type": "int",
"defaultValue": 80,
"metadata": {
"description": "The threshold value at which the alert is activated."
}
}
},
"variables": {
"scopes": "[array(parameters('targetResourceId'))]",
"copy": [
{
"name": "actionsForMetricAlerts",
"count": "[length(parameters('actionGroupIds'))]",
"input": {
"actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForMetricAlerts')]]"
}
}
]
},
"resources": [
{
"name": "[parameters('alertName')]",
"type": "Microsoft.Insights/metricAlerts",
"apiVersion": "2018-03-01",
"location": "global",
"properties": {
"description": "Percentage CPU is greater than 80 %",
"severity": "[parameters('alertSeverity')]",
"enabled": true,
"scopes": "[variables('scopes')]",
"evaluationFrequency": "PT5M",
"windowSize": "PT5M",
"criteria": {
"odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria",
"allOf": [
{
"name": "Metric1",
"metricName": "Percentage CPU",
"operator": "GreaterThan",
"threshold": "[parameters('threshold')]",
"timeAggregation": "Average"
}
]
},
"actions": "[variables('actionsForMetricAlerts')]"
}
}
]
}
}
},
{
"id": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/providers/Microsoft.AlertsManagement/alertRuleRecommendations/Available Memory Bytes",
"name": "Available Memory Bytes",
"type": "Microsoft.AlertsManagement/alertRuleRecommendations",
"properties": {
"alertRuleType": "Microsoft.Insights/metricAlerts",
"displayInformation": {
"infoBallonMessage": "Rule2 InfoBalloon Message",
"infoBallonLink": "Rule2 InfoBalloon Link",
"metricDisplayName": "Available Memory Bytes",
"displayUnits": "Gigabytes"
},
"ruleArmTemplate": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"targetResourceId": {
"type": "string"
},
"targetResourceName": {
"type": "string"
},
"actionGroupIds": {
"type": "array",
"defaultValue": [],
"metadata": {
"description": "Insert Action groups ids to attach them to the below alert rules."
}
},
"alertNamePrefix": {
"type": "string",
"defaultValue": "Available Memory Bytes",
"minLength": 1,
"metadata": {
"description": "prefix of the alert rule name"
}
},
"alertName": {
"type": "string",
"defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('targetResourceName'))]",
"minLength": 1,
"metadata": {
"description": "Name of the alert rule"
}
},
"alertSeverity": {
"type": "int",
"allowedValues": [
0,
1,
2,
3,
4
],
"defaultValue": 3,
"metadata": {
"description": "Severity of alert {0,1,2,3,4}"
}
},
"threshold": {
"type": "int",
"defaultValue": 1000000000,
"metadata": {
"description": "The threshold value at which the alert is activated."
}
}
},
"variables": {
"scopes": "[array(parameters('targetResourceId'))]",
"copy": [
{
"name": "actionsForMetricAlerts",
"count": "[length(parameters('actionGroupIds'))]",
"input": {
"actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForMetricAlerts')]]"
}
}
]
},
"resources": [
{
"name": "[parameters('alertName')]",
"type": "Microsoft.Insights/metricAlerts",
"apiVersion": "2018-03-01",
"location": "global",
"properties": {
"description": "Available Memory Bytes is less than 1 GB",
"severity": "[parameters('alertSeverity')]",
"enabled": true,
"scopes": "[variables('scopes')]",
"evaluationFrequency": "PT5M",
"windowSize": "PT5M",
"criteria": {
"odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria",
"allOf": [
{
"name": "Metric1",
"metricName": "Available Memory Bytes",
"operator": "LessThan",
"threshold": "[parameters('threshold')]",
"timeAggregation": "Average"
}
]
},
"actions": "[variables('actionsForMetricAlerts')]"
}
}
]
}
}
}
]
}
Definíciók
Name | Description |
---|---|
Alert |
Egyetlen riasztási szabály javaslati erőforrása. |
Alert |
A riasztási szabályokra vonatkozó javaslatok listája. |
created |
Az erőforrást létrehozó identitás típusa. |
Error |
Az erőforrás-kezelési hiba további információi. |
Error |
A hiba részletei. |
Error |
Hibaválasz |
rule |
Teljes ARM-sablon a riasztási szabályok üzembe helyezéséhez. |
system |
Az erőforrás létrehozásával és utolsó módosításával kapcsolatos metaadatok. |
AlertRuleRecommendationResource
Egyetlen riasztási szabály javaslati erőforrása.
Name | Típus | Description |
---|---|---|
id |
string |
Az erőforrás teljes erőforrás-azonosítója. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} |
name |
string |
Az erőforrás neve |
properties.alertRuleType |
string |
A javaslati riasztási szabály típusa. |
properties.category |
string |
A javaslati riasztási szabály kategóriája. |
properties.displayInformation |
object |
Egy szótár, amely a riasztási szabályokra vonatkozó javaslat megjelenítési adatait tartalmazza. |
properties.ruleArmTemplate |
Teljes ARM-sablon a riasztási szabályok üzembe helyezéséhez. |
|
systemData |
A createdBy és a modifiedBy adatokat tartalmazó Azure Resource Manager-metaadatok. |
|
type |
string |
Az erőforrás típusa. Pl. "Microsoft.Compute/virtualMachines" vagy "Microsoft.Storage/storageAccounts" |
AlertRuleRecommendationsListResponse
A riasztási szabályokra vonatkozó javaslatok listája.
Name | Típus | Description |
---|---|---|
nextLink |
string |
URL-cím a következő javaslatkészlet lekéréséhez. |
value |
a riasztási szabályokra vonatkozó javaslatok értékei. |
createdByType
Az erőforrást létrehozó identitás típusa.
Érték | Description |
---|---|
Application | |
Key | |
ManagedIdentity | |
User |
ErrorAdditionalInfo
Az erőforrás-kezelési hiba további információi.
Name | Típus | Description |
---|---|---|
info |
object |
A további információk. |
type |
string |
A további információtípus. |
ErrorDetail
A hiba részletei.
Name | Típus | Description |
---|---|---|
additionalInfo |
A hiba további információi. |
|
code |
string |
A hibakód. |
details |
A hiba részletei. |
|
message |
string |
A hibaüzenet. |
target |
string |
A hibacél. |
ErrorResponse
Hibaválasz
Name | Típus | Description |
---|---|---|
error |
A hibaobjektum. |
ruleArmTemplate
Teljes ARM-sablon a riasztási szabályok üzembe helyezéséhez.
Name | Típus | Description |
---|---|---|
$schema |
string |
JSON-sémahivatkozás |
contentVersion |
string pattern: (^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$) |
A sablonfájl verziószámának 4 számformátuma. Például: 1.0.0.0 |
parameters |
object |
Bemeneti paraméterdefiníciók |
resources |
object[] |
Riasztási szabály erőforrás-definíciói |
variables |
object |
Változódefiníciók |
systemData
Az erőforrás létrehozásával és utolsó módosításával kapcsolatos metaadatok.
Name | Típus | Description |
---|---|---|
createdAt |
string (date-time) |
Az erőforrás-létrehozás időbélyege (UTC). |
createdBy |
string |
Az erőforrást létrehozó identitás. |
createdByType |
Az erőforrást létrehozó identitás típusa. |
|
lastModifiedAt |
string (date-time) |
Az erőforrás utolsó módosításának időbélyege (UTC) |
lastModifiedBy |
string |
Az erőforrást legutóbb módosító identitás. |
lastModifiedByType |
Az erőforrást legutóbb módosító identitás típusa. |