diff --git a/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/back-compatible.tsp b/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/back-compatible.tsp new file mode 100644 index 000000000000..d0a484f0e221 --- /dev/null +++ b/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/back-compatible.tsp @@ -0,0 +1,14 @@ +import "@azure-tools/typespec-client-generator-core"; + +using Azure.ClientGenerator.Core; +using Microsoft.AlertsManagement; + +#suppress "@azure-tools/typespec-azure-core/no-legacy-usage" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" +@@Legacy.flattenProperty(AlertRuleRecommendationResource.properties); + +@@clientLocation(AlertRuleRecommendationsOperationGroup.listByResource, + "AlertRuleRecommendations" +); +@@clientLocation(AlertRuleRecommendationsOperationGroup.listByTargetType, + "AlertRuleRecommendations" +); diff --git a/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/examples/2023-08-01-preview/AlertRuleRecommendations_GetByResource_MAC.json b/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/examples/2023-08-01-preview/AlertRuleRecommendations_GetByResource_MAC.json new file mode 100644 index 000000000000..7dbbb7982aff --- /dev/null +++ b/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/examples/2023-08-01-preview/AlertRuleRecommendations_GetByResource_MAC.json @@ -0,0 +1,296 @@ +{ + "parameters": { + "api-version": "2023-08-01-preview", + "resourceUri": "subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourceGroups/GenevaAlertRP-RunnerResources-eastus/providers/microsoft.monitor/accounts/alertsrp-eastus-pgms" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "name": "NodeRecordingRulesRuleGroup", + "type": "Microsoft.AlertsManagement/alertRuleRecommendations", + "id": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourceGroups/GenevaAlertRP-RunnerResources-eastus/providers/microsoft.monitor/accounts/alertsrp-eastus-pgms/providers/Microsoft.AlertsManagement/alertRuleRecommendations/NodeRecordingRulesRuleGroup", + "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": { + "actionGroupIds": { + "type": "array", + "defaultValue": [], + "metadata": { + "description": "Insert Action groups ids to attach them to the below alert rules." + } + }, + "alertName": { + "type": "string", + "defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('clusterNameForPrometheus'))]", + "metadata": { + "description": "Name of the alert rule" + }, + "minLength": 1 + }, + "alertNamePrefix": { + "type": "string", + "defaultValue": "NodeRecordingRulesRuleGroup", + "metadata": { + "description": "prefix of the alert rule name" + }, + "minLength": 1 + }, + "clusterNameForPrometheus": { + "type": "string" + }, + "location": { + "type": "string", + "defaultValue": "eastus" + }, + "targetResourceId": { + "type": "string", + "defaultValue": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourceGroups/GenevaAlertRP-RunnerResources-eastus/providers/microsoft.monitor/accounts/alertsrp-eastus-pgms" + }, + "targetResourceName": { + "type": "string", + "defaultValue": "alertsrp-eastus-pgms" + } + }, + "resources": [ + { + "name": "[parameters('alertName')]", + "type": "Microsoft.AlertsManagement/prometheusRuleGroups", + "apiVersion": "2021-07-22-preview", + "location": "[parameters('location')]", + "properties": { + "description": "Node Recording Rules RuleGroup", + "clusterName": "[parameters('clusterNameForPrometheus')]", + "interval": "PT1M", + "rules": [ + { + "expression": "count without (cpu, mode) ( node_cpu_seconds_total{job=\"node\",mode=\"idle\"})", + "record": "instance:node_num_cpu:sum" + } + ], + "scopes": "[variables('scopes')]" + } + } + ], + "variables": { + "copy": [ + { + "name": "actionsForPrometheusRuleGroups", + "count": "[length(parameters('actionGroupIds'))]", + "input": { + "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForPrometheusRuleGroups')]]" + } + } + ], + "scopes": "[array(parameters('targetResourceId'))]" + } + } + } + }, + { + "name": "KubernetesReccordingRulesRuleGroup", + "type": "Microsoft.AlertsManagement/alertRuleRecommendations", + "id": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourceGroups/GenevaAlertRP-RunnerResources-eastus/providers/microsoft.monitor/accounts/alertsrp-eastus-pgms/providers/Microsoft.AlertsManagement/alertRuleRecommendations/KubernetesReccordingRulesRuleGroup", + "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": { + "actionGroupIds": { + "type": "array", + "defaultValue": [], + "metadata": { + "description": "Insert Action groups ids to attach them to the below alert rules." + } + }, + "alertName": { + "type": "string", + "defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('clusterNameForPrometheus'))]", + "metadata": { + "description": "Name of the alert rule" + }, + "minLength": 1 + }, + "alertNamePrefix": { + "type": "string", + "defaultValue": "KubernetesReccordingRulesRuleGroup", + "metadata": { + "description": "prefix of the alert rule name" + }, + "minLength": 1 + }, + "clusterNameForPrometheus": { + "type": "string" + }, + "location": { + "type": "string", + "defaultValue": "eastus" + }, + "targetResourceId": { + "type": "string", + "defaultValue": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourceGroups/GenevaAlertRP-RunnerResources-eastus/providers/microsoft.monitor/accounts/alertsrp-eastus-pgms" + }, + "targetResourceName": { + "type": "string", + "defaultValue": "alertsrp-eastus-pgms" + } + }, + "resources": [ + { + "name": "[parameters('alertName')]", + "type": "Microsoft.AlertsManagement/prometheusRuleGroups", + "apiVersion": "2021-07-22-preview", + "location": "[parameters('location')]", + "properties": { + "description": "Kubernetes Recording Rules RuleGroup", + "clusterName": "[parameters('clusterNameForPrometheus')]", + "interval": "PT1M", + "rules": [ + { + "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!=\"\"}))", + "record": "node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate" + } + ], + "scopes": "[variables('scopes')]" + } + } + ], + "variables": { + "copy": [ + { + "name": "actionsForPrometheusRuleGroups", + "count": "[length(parameters('actionGroupIds'))]", + "input": { + "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForPrometheusRuleGroups')]]" + } + } + ], + "scopes": "[array(parameters('targetResourceId'))]" + } + } + } + }, + { + "name": "KubernetesAlert-DefaultAlert", + "type": "Microsoft.AlertsManagement/alertRuleRecommendations", + "id": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourceGroups/GenevaAlertRP-RunnerResources-eastus/providers/microsoft.monitor/accounts/alertsrp-eastus-pgms/providers/Microsoft.AlertsManagement/alertRuleRecommendations/KubernetesAlert-DefaultAlert", + "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": { + "actionGroupIds": { + "type": "array", + "defaultValue": [], + "metadata": { + "description": "Insert Action groups ids to attach them to the below alert rules." + } + }, + "alertName": { + "type": "string", + "defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('clusterNameForPrometheus'))]", + "metadata": { + "description": "Name of the alert rule" + }, + "minLength": 1 + }, + "alertNamePrefix": { + "type": "string", + "defaultValue": "KubernetesAlert-DefaultAlerts", + "metadata": { + "description": "prefix of the alert rule name" + }, + "minLength": 1 + }, + "clusterNameForPrometheus": { + "type": "string" + }, + "location": { + "type": "string", + "defaultValue": "eastus" + }, + "targetResourceId": { + "type": "string", + "defaultValue": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourceGroups/GenevaAlertRP-RunnerResources-eastus/providers/microsoft.monitor/accounts/alertsrp-eastus-pgms" + }, + "targetResourceName": { + "type": "string", + "defaultValue": "alertsrp-eastus-pgms" + } + }, + "resources": [ + { + "name": "[parameters('alertName')]", + "type": "Microsoft.AlertsManagement/prometheusRuleGroups", + "apiVersion": "2021-07-22-preview", + "location": "[parameters('location')]", + "properties": { + "description": "Kubernetes Alert RuleGroup-DefaultAlerts", + "clusterName": "[parameters('clusterNameForPrometheus')]", + "interval": "PT1M", + "rules": [ + { + "Severity": 3, + "actions": "[variables('actionsForPrometheusRuleGroups')]", + "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" + } + } + ], + "scopes": "[variables('scopes')]" + } + } + ], + "variables": { + "copy": [ + { + "name": "actionsForPrometheusRuleGroups", + "count": "[length(parameters('actionGroupIds'))]", + "input": { + "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForPrometheusRuleGroups')]]" + } + } + ], + "scopes": "[array(parameters('targetResourceId'))]" + } + } + } + } + ] + } + } + }, + "operationId": "AlertRuleRecommendations_ListByResource", + "title": "List alert rule recommendations for Monitoring accounts at resource level" +} diff --git a/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/examples/2023-08-01-preview/AlertRuleRecommendations_GetByResource_VM.json b/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/examples/2023-08-01-preview/AlertRuleRecommendations_GetByResource_VM.json new file mode 100644 index 000000000000..f6114b723ac3 --- /dev/null +++ b/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/examples/2023-08-01-preview/AlertRuleRecommendations_GetByResource_VM.json @@ -0,0 +1,242 @@ +{ + "parameters": { + "api-version": "2023-08-01-preview", + "resourceUri": "subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourcegroups/test/providers/Microsoft.Compute/virtualMachines/testMachineCanBeSafelyDeleted" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "name": "Percentage CPU", + "type": "Microsoft.AlertsManagement/alertRuleRecommendations", + "id": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourcegroups/test/providers/Microsoft.Compute/virtualMachines/testMachineCanBeSafelyDeleted/providers/Microsoft.AlertsManagement/alertRuleRecommendations/Percentage CPU", + "properties": { + "alertRuleType": "Microsoft.Insights/metricAlerts", + "displayInformation": { + "displayUnits": "Percentage", + "infoBallonLink": "Rule1 InfoBalloon Link", + "infoBallonMessage": "Rule1 InfoBalloon Message", + "metricDisplayName": "Percentage CPU" + }, + "ruleArmTemplate": { + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "actionGroupIds": { + "type": "array", + "defaultValue": [], + "metadata": { + "description": "Insert Action groups ids to attach them to the below alert rules." + } + }, + "alertName": { + "type": "string", + "defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('targetResourceName'))]", + "metadata": { + "description": "Name of the alert rule" + }, + "minLength": 1 + }, + "alertNamePrefix": { + "type": "string", + "defaultValue": "Percentage CPU", + "metadata": { + "description": "prefix of the alert rule name" + }, + "minLength": 1 + }, + "alertSeverity": { + "type": "int", + "allowedValues": [ + 0, + 1, + 2, + 3, + 4 + ], + "defaultValue": 3, + "metadata": { + "description": "Severity of alert {0,1,2,3,4}" + } + }, + "targetResourceId": { + "type": "string", + "defaultValue": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourcegroups/test/providers/Microsoft.Compute/virtualMachines/testMachineCanBeSafelyDeleted" + }, + "targetResourceName": { + "type": "string", + "defaultValue": "testmachinecanbesafelydeleted" + }, + "threshold": { + "type": "int", + "defaultValue": 80, + "metadata": { + "description": "The threshold value at which the alert is activated." + } + } + }, + "resources": [ + { + "name": "[parameters('alertName')]", + "type": "Microsoft.Insights/metricAlerts", + "apiVersion": "2018-03-01", + "location": "global", + "properties": { + "description": "Percentage CPU is greater than 80 %", + "actions": "[variables('actionsForMetricAlerts')]", + "criteria": { + "allOf": [ + { + "name": "Metric1", + "metricName": "Percentage CPU", + "operator": "GreaterThan", + "threshold": "[parameters('threshold')]", + "timeAggregation": "Average" + } + ], + "odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria" + }, + "enabled": true, + "evaluationFrequency": "PT5M", + "scopes": "[variables('scopes')]", + "severity": "[parameters('alertSeverity')]", + "windowSize": "PT5M" + } + } + ], + "variables": { + "copy": [ + { + "name": "actionsForMetricAlerts", + "count": "[length(parameters('actionGroupIds'))]", + "input": { + "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForMetricAlerts')]]" + } + } + ], + "scopes": "[array(parameters('targetResourceId'))]" + } + } + } + }, + { + "name": "Available Memory Bytes", + "type": "Microsoft.AlertsManagement/alertRuleRecommendations", + "id": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourcegroups/test/providers/Microsoft.Compute/virtualMachines/testMachineCanBeSafelyDeleted/providers/Microsoft.AlertsManagement/alertRuleRecommendations/Available Memory Bytes", + "properties": { + "alertRuleType": "Microsoft.Insights/metricAlerts", + "displayInformation": { + "displayUnits": "Gigabytes", + "infoBallonLink": "Rule2 InfoBalloon Link", + "infoBallonMessage": "Rule2 InfoBalloon Message", + "metricDisplayName": "Available Memory Bytes" + }, + "ruleArmTemplate": { + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "actionGroupIds": { + "type": "array", + "defaultValue": [], + "metadata": { + "description": "Insert Action groups ids to attach them to the below alert rules." + } + }, + "alertName": { + "type": "string", + "defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('targetResourceName'))]", + "metadata": { + "description": "Name of the alert rule" + }, + "minLength": 1 + }, + "alertNamePrefix": { + "type": "string", + "defaultValue": "Available Memory Bytes", + "metadata": { + "description": "prefix of the alert rule name" + }, + "minLength": 1 + }, + "alertSeverity": { + "type": "int", + "allowedValues": [ + 0, + 1, + 2, + 3, + 4 + ], + "defaultValue": 3, + "metadata": { + "description": "Severity of alert {0,1,2,3,4}" + } + }, + "targetResourceId": { + "type": "string", + "defaultValue": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourcegroups/test/providers/Microsoft.Compute/virtualMachines/testMachineCanBeSafelyDeleted" + }, + "targetResourceName": { + "type": "string", + "defaultValue": "testmachinecanbesafelydeleted" + }, + "threshold": { + "type": "int", + "defaultValue": 1000000000, + "metadata": { + "description": "The threshold value at which the alert is activated." + } + } + }, + "resources": [ + { + "name": "[parameters('alertName')]", + "type": "Microsoft.Insights/metricAlerts", + "apiVersion": "2018-03-01", + "location": "global", + "properties": { + "description": "Available Memory Bytes is less than 1 GB", + "actions": "[variables('actionsForMetricAlerts')]", + "criteria": { + "allOf": [ + { + "name": "Metric1", + "metricName": "Available Memory Bytes", + "operator": "LessThan", + "threshold": "[parameters('threshold')]", + "timeAggregation": "Average" + } + ], + "odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria" + }, + "enabled": true, + "evaluationFrequency": "PT5M", + "scopes": "[variables('scopes')]", + "severity": "[parameters('alertSeverity')]", + "windowSize": "PT5M" + } + } + ], + "variables": { + "copy": [ + { + "name": "actionsForMetricAlerts", + "count": "[length(parameters('actionGroupIds'))]", + "input": { + "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForMetricAlerts')]]" + } + } + ], + "scopes": "[array(parameters('targetResourceId'))]" + } + } + } + } + ] + } + } + }, + "operationId": "AlertRuleRecommendations_ListByResource", + "title": "List alert rule recommendations for virtual machines at resource level" +} diff --git a/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/examples/2023-08-01-preview/AlertRuleRecommendations_GetBySubscription_MAC.json b/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/examples/2023-08-01-preview/AlertRuleRecommendations_GetBySubscription_MAC.json new file mode 100644 index 000000000000..2b573718fe03 --- /dev/null +++ b/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/examples/2023-08-01-preview/AlertRuleRecommendations_GetBySubscription_MAC.json @@ -0,0 +1,288 @@ +{ + "parameters": { + "api-version": "2023-08-01-preview", + "subscriptionId": "2f00cc51-6809-498f-9ffc-48c42aff570d", + "targetType": "microsoft.monitor/accounts" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "name": "NodeRecordingRulesRuleGroup", + "type": "Microsoft.AlertsManagement/alertRuleRecommendations", + "id": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/providers/Microsoft.AlertsManagement/alertRuleRecommendations/NodeRecordingRulesRuleGroup", + "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": { + "actionGroupIds": { + "type": "array", + "defaultValue": [], + "metadata": { + "description": "Insert Action groups ids to attach them to the below alert rules." + } + }, + "alertName": { + "type": "string", + "defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('clusterNameForPrometheus'))]", + "metadata": { + "description": "Name of the alert rule" + }, + "minLength": 1 + }, + "alertNamePrefix": { + "type": "string", + "defaultValue": "NodeRecordingRulesRuleGroup", + "metadata": { + "description": "prefix of the alert rule name" + }, + "minLength": 1 + }, + "clusterNameForPrometheus": { + "type": "string" + }, + "location": { + "type": "string" + }, + "targetResourceId": { + "type": "string" + }, + "targetResourceName": { + "type": "string" + } + }, + "resources": [ + { + "name": "[parameters('alertName')]", + "type": "Microsoft.AlertsManagement/prometheusRuleGroups", + "apiVersion": "2021-07-22-preview", + "location": "[parameters('location')]", + "properties": { + "description": "Node Recording Rules RuleGroup", + "clusterName": "[parameters('clusterNameForPrometheus')]", + "interval": "PT1M", + "rules": [ + { + "expression": "count without (cpu, mode) ( node_cpu_seconds_total{job=\"node\",mode=\"idle\"})", + "record": "instance:node_num_cpu:sum" + } + ], + "scopes": "[variables('scopes')]" + } + } + ], + "variables": { + "copy": [ + { + "name": "actionsForPrometheusRuleGroups", + "count": "[length(parameters('actionGroupIds'))]", + "input": { + "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForPrometheusRuleGroups')]]" + } + } + ], + "scopes": "[array(parameters('targetResourceId'))]" + } + } + } + }, + { + "name": "KubernetesReccordingRulesRuleGroup", + "type": "Microsoft.AlertsManagement/alertRuleRecommendations", + "id": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/providers/Microsoft.AlertsManagement/alertRuleRecommendations/KubernetesReccordingRulesRuleGroup", + "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": { + "actionGroupIds": { + "type": "array", + "defaultValue": [], + "metadata": { + "description": "Insert Action groups ids to attach them to the below alert rules." + } + }, + "alertName": { + "type": "string", + "defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('clusterNameForPrometheus'))]", + "metadata": { + "description": "Name of the alert rule" + }, + "minLength": 1 + }, + "alertNamePrefix": { + "type": "string", + "defaultValue": "KubernetesReccordingRulesRuleGroup", + "metadata": { + "description": "prefix of the alert rule name" + }, + "minLength": 1 + }, + "clusterNameForPrometheus": { + "type": "string" + }, + "location": { + "type": "string" + }, + "targetResourceId": { + "type": "string" + }, + "targetResourceName": { + "type": "string" + } + }, + "resources": [ + { + "name": "[parameters('alertName')]", + "type": "Microsoft.AlertsManagement/prometheusRuleGroups", + "apiVersion": "2021-07-22-preview", + "location": "[parameters('location')]", + "properties": { + "description": "Kubernetes Recording Rules RuleGroup", + "clusterName": "[parameters('clusterNameForPrometheus')]", + "interval": "PT1M", + "rules": [ + { + "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!=\"\"}))", + "record": "node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate" + } + ], + "scopes": "[variables('scopes')]" + } + } + ], + "variables": { + "copy": [ + { + "name": "actionsForPrometheusRuleGroups", + "count": "[length(parameters('actionGroupIds'))]", + "input": { + "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForPrometheusRuleGroups')]]" + } + } + ], + "scopes": "[array(parameters('targetResourceId'))]" + } + } + } + }, + { + "name": "KubernetesAlert-DefaultAlerts", + "type": "Microsoft.AlertsManagement/alertRuleRecommendations", + "id": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/providers/Microsoft.AlertsManagement/alertRuleRecommendations/KubernetesAlert-DefaultAlerts", + "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": { + "actionGroupIds": { + "type": "array", + "defaultValue": [], + "metadata": { + "description": "Insert Action groups ids to attach them to the below alert rules." + } + }, + "alertName": { + "type": "string", + "defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('clusterNameForPrometheus'))]", + "metadata": { + "description": "Name of the alert rule" + }, + "minLength": 1 + }, + "alertNamePrefix": { + "type": "string", + "defaultValue": "KubernetesAlert-DefaultAlerts", + "metadata": { + "description": "prefix of the alert rule name" + }, + "minLength": 1 + }, + "clusterNameForPrometheus": { + "type": "string" + }, + "location": { + "type": "string" + }, + "targetResourceId": { + "type": "string" + }, + "targetResourceName": { + "type": "string" + } + }, + "resources": [ + { + "name": "[parameters('alertName')]", + "type": "Microsoft.AlertsManagement/prometheusRuleGroups", + "apiVersion": "2021-07-22-preview", + "location": "[parameters('location')]", + "properties": { + "description": "Kubernetes Alert RuleGroup-DefaultAlerts", + "clusterName": "[parameters('clusterNameForPrometheus')]", + "interval": "PT1M", + "rules": [ + { + "Severity": 3, + "actions": "[variables('actionsForPrometheusRuleGroups')]", + "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" + } + } + ], + "scopes": "[variables('scopes')]" + } + } + ], + "variables": { + "copy": [ + { + "name": "actionsForPrometheusRuleGroups", + "count": "[length(parameters('actionGroupIds'))]", + "input": { + "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForPrometheusRuleGroups')]]" + } + } + ], + "scopes": "[array(parameters('targetResourceId'))]" + } + } + } + } + ] + } + } + }, + "operationId": "AlertRuleRecommendations_ListByTargetType", + "title": "List alert rule recommendations for Monitoring accounts at subscription level" +} diff --git a/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/examples/2023-08-01-preview/AlertRuleRecommendations_GetBySubscription_VM.json b/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/examples/2023-08-01-preview/AlertRuleRecommendations_GetBySubscription_VM.json new file mode 100644 index 000000000000..d3b6867aa187 --- /dev/null +++ b/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/examples/2023-08-01-preview/AlertRuleRecommendations_GetBySubscription_VM.json @@ -0,0 +1,239 @@ +{ + "parameters": { + "api-version": "2023-08-01-preview", + "subscriptionId": "2f00cc51-6809-498f-9ffc-48c42aff570d", + "targetType": "microsoft.compute/virtualmachines" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "name": "Percentage CPU", + "type": "Microsoft.AlertsManagement/alertRuleRecommendations", + "id": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/providers/Microsoft.AlertsManagement/alertRuleRecommendations/Percentage CPU", + "properties": { + "alertRuleType": "Microsoft.Insights/metricAlerts", + "displayInformation": { + "displayUnits": "Percentage", + "infoBallonLink": "Rule1 InfoBalloon Link", + "infoBallonMessage": "Rule1 InfoBalloon Message", + "metricDisplayName": "Percentage CPU" + }, + "ruleArmTemplate": { + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "actionGroupIds": { + "type": "array", + "defaultValue": [], + "metadata": { + "description": "Insert Action groups ids to attach them to the below alert rules." + } + }, + "alertName": { + "type": "string", + "defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('targetResourceName'))]", + "metadata": { + "description": "Name of the alert rule" + }, + "minLength": 1 + }, + "alertNamePrefix": { + "type": "string", + "defaultValue": "Percentage CPU", + "metadata": { + "description": "prefix of the alert rule name" + }, + "minLength": 1 + }, + "alertSeverity": { + "type": "int", + "allowedValues": [ + 0, + 1, + 2, + 3, + 4 + ], + "defaultValue": 3, + "metadata": { + "description": "Severity of alert {0,1,2,3,4}" + } + }, + "targetResourceId": { + "type": "string" + }, + "targetResourceName": { + "type": "string" + }, + "threshold": { + "type": "int", + "defaultValue": 80, + "metadata": { + "description": "The threshold value at which the alert is activated." + } + } + }, + "resources": [ + { + "name": "[parameters('alertName')]", + "type": "Microsoft.Insights/metricAlerts", + "apiVersion": "2018-03-01", + "location": "global", + "properties": { + "description": "Percentage CPU is greater than 80 %", + "actions": "[variables('actionsForMetricAlerts')]", + "criteria": { + "allOf": [ + { + "name": "Metric1", + "metricName": "Percentage CPU", + "operator": "GreaterThan", + "threshold": "[parameters('threshold')]", + "timeAggregation": "Average" + } + ], + "odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria" + }, + "enabled": true, + "evaluationFrequency": "PT5M", + "scopes": "[variables('scopes')]", + "severity": "[parameters('alertSeverity')]", + "windowSize": "PT5M" + } + } + ], + "variables": { + "copy": [ + { + "name": "actionsForMetricAlerts", + "count": "[length(parameters('actionGroupIds'))]", + "input": { + "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForMetricAlerts')]]" + } + } + ], + "scopes": "[array(parameters('targetResourceId'))]" + } + } + } + }, + { + "name": "Available Memory Bytes", + "type": "Microsoft.AlertsManagement/alertRuleRecommendations", + "id": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/providers/Microsoft.AlertsManagement/alertRuleRecommendations/Available Memory Bytes", + "properties": { + "alertRuleType": "Microsoft.Insights/metricAlerts", + "displayInformation": { + "displayUnits": "Gigabytes", + "infoBallonLink": "Rule2 InfoBalloon Link", + "infoBallonMessage": "Rule2 InfoBalloon Message", + "metricDisplayName": "Available Memory Bytes" + }, + "ruleArmTemplate": { + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "actionGroupIds": { + "type": "array", + "defaultValue": [], + "metadata": { + "description": "Insert Action groups ids to attach them to the below alert rules." + } + }, + "alertName": { + "type": "string", + "defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('targetResourceName'))]", + "metadata": { + "description": "Name of the alert rule" + }, + "minLength": 1 + }, + "alertNamePrefix": { + "type": "string", + "defaultValue": "Available Memory Bytes", + "metadata": { + "description": "prefix of the alert rule name" + }, + "minLength": 1 + }, + "alertSeverity": { + "type": "int", + "allowedValues": [ + 0, + 1, + 2, + 3, + 4 + ], + "defaultValue": 3, + "metadata": { + "description": "Severity of alert {0,1,2,3,4}" + } + }, + "targetResourceId": { + "type": "string" + }, + "targetResourceName": { + "type": "string" + }, + "threshold": { + "type": "int", + "defaultValue": 1000000000, + "metadata": { + "description": "The threshold value at which the alert is activated." + } + } + }, + "resources": [ + { + "name": "[parameters('alertName')]", + "type": "Microsoft.Insights/metricAlerts", + "apiVersion": "2018-03-01", + "location": "global", + "properties": { + "description": "Available Memory Bytes is less than 1 GB", + "actions": "[variables('actionsForMetricAlerts')]", + "criteria": { + "allOf": [ + { + "name": "Metric1", + "metricName": "Available Memory Bytes", + "operator": "LessThan", + "threshold": "[parameters('threshold')]", + "timeAggregation": "Average" + } + ], + "odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria" + }, + "enabled": true, + "evaluationFrequency": "PT5M", + "scopes": "[variables('scopes')]", + "severity": "[parameters('alertSeverity')]", + "windowSize": "PT5M" + } + } + ], + "variables": { + "copy": [ + { + "name": "actionsForMetricAlerts", + "count": "[length(parameters('actionGroupIds'))]", + "input": { + "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForMetricAlerts')]]" + } + } + ], + "scopes": "[array(parameters('targetResourceId'))]" + } + } + } + } + ] + } + } + }, + "operationId": "AlertRuleRecommendations_ListByTargetType", + "title": "List alert rule recommendations for virtual machines at subscription level" +} diff --git a/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/main.tsp b/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/main.tsp new file mode 100644 index 000000000000..4067c594d32d --- /dev/null +++ b/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/main.tsp @@ -0,0 +1,42 @@ +/** + * PLEASE DO NOT REMOVE - USED FOR CONVERTER METRICS + * Generated by package: @autorest/openapi-to-typespec + * Parameters used: + * isFullCompatible: true + * guessResourceKey: false + * Version: 0.11.12 + * Date: 2025-12-04T00:53:18.631Z + */ +import "@typespec/rest"; +import "@typespec/versioning"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-azure-resource-manager"; +import "./models.tsp"; +import "./back-compatible.tsp"; +import "./routes.tsp"; + +using TypeSpec.Rest; +using TypeSpec.Http; +using Azure.ResourceManager.Foundations; +using Azure.Core; +using Azure.ResourceManager; +using TypeSpec.Versioning; +/** + * Azure Alerts Management Service provides a single pane of glass of alerts across Azure Monitor. + */ +#suppress "@azure-tools/typespec-azure-resource-manager/missing-operations-endpoint" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" +@armProviderNamespace +@service(#{ title: "Azure Alerts Management Service Resource Provider" }) +@versioned(Versions) +@armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v3) +namespace Microsoft.AlertsManagement; + +/** + * The available API versions. + */ +enum Versions { + /** + * The 2023-08-01-preview API version. + */ + v2023_08_01_preview: "2023-08-01-preview", +} diff --git a/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/models.tsp b/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/models.tsp new file mode 100644 index 000000000000..fa03781ca32f --- /dev/null +++ b/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/models.tsp @@ -0,0 +1,303 @@ +import "@typespec/rest"; +import "@typespec/http"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-azure-resource-manager"; + +using TypeSpec.Rest; +using TypeSpec.Http; +using Azure.ResourceManager; +using Azure.ResourceManager.Foundations; + +namespace Microsoft.AlertsManagement; + +/** + * The type of identity that created the resource. + */ +union CreatedByType { + string, + + /** + * User + */ + User: "User", + + /** + * Application + */ + Application: "Application", + + /** + * ManagedIdentity + */ + ManagedIdentity: "ManagedIdentity", + + /** + * Key + */ + Key: "Key", +} + +/** + * The unit to display for a metric alert rule. + */ +union MetricAlertsDisplayUnit { + string, + + /** + * None + */ + None: "None", + + /** + * Percentage + */ + Percentage: "Percentage", + + /** + * Bytes + */ + Bytes: "Bytes", + + /** + * Kilobytes + */ + Kilobytes: "Kilobytes", + + /** + * Megabytes + */ + Megabytes: "Megabytes", + + /** + * Gigabytes + */ + Gigabytes: "Gigabytes", + + /** + * Terabytes + */ + Terabytes: "Terabytes", + + /** + * Petabytes + */ + Petabytes: "Petabytes", + + /** + * BytesPerDay + */ + BytesPerDay: "BytesPerDay", + + /** + * BytesPerHour + */ + BytesPerHour: "BytesPerHour", + + /** + * BytesPerMinute + */ + BytesPerMinute: "BytesPerMinute", + + /** + * BytesPerSecond + */ + BytesPerSecond: "BytesPerSecond", + + /** + * KilobytesPerSecond + */ + KilobytesPerSecond: "KilobytesPerSecond", + + /** + * MegabytesPerSecond + */ + MegabytesPerSecond: "MegabytesPerSecond", + + /** + * GigabytesPerSecond + */ + GigabytesPerSecond: "GigabytesPerSecond", + + /** + * TerabytesPerSecond + */ + TerabytesPerSecond: "TerabytesPerSecond", + + /** + * PetabytesPerSecond + */ + PetabytesPerSecond: "PetabytesPerSecond", + + /** + * Count + */ + Count: "Count", + + /** + * Thousand + */ + Thousand: "Thousand", + + /** + * Million + */ + Million: "Million", + + /** + * Billion + */ + Billion: "Billion", + + /** + * Trillion + */ + Trillion: "Trillion", + + /** + * MicroSeconds + */ + MicroSeconds: "MicroSeconds", + + /** + * MilliSeconds + */ + MilliSeconds: "MilliSeconds", + + /** + * Seconds + */ + Seconds: "Seconds", + + /** + * Minutes + */ + Minutes: "Minutes", + + /** + * Hours + */ + Hours: "Hours", + + /** + * Days + */ + Days: "Days", + + /** + * CountPerDay + */ + CountPerDay: "CountPerDay", + + /** + * CountPerHour + */ + CountPerHour: "CountPerHour", + + /** + * CountPerMinute + */ + CountPerMinute: "CountPerMinute", + + /** + * CountPerSecond + */ + CountPerSecond: "CountPerSecond", + + /** + * ThousandPerSecond + */ + ThousandPerSecond: "ThousandPerSecond", + + /** + * MillionPerSecond + */ + MillionPerSecond: "MillionPerSecond", + + /** + * BillionPerSecond + */ + BillionPerSecond: "BillionPerSecond", + + /** + * TrillionPerSecond + */ + TrillionPerSecond: "TrillionPerSecond", +} + +/** + * List of alert rule recommendations. + */ +model AlertRuleRecommendationsListResponse + is Azure.Core.Page; + +/** + * A single alert rule recommendation resource. + */ +#suppress "@azure-tools/typespec-azure-core/composition-over-inheritance" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" +model AlertRuleRecommendationResource + extends Azure.ResourceManager.CommonTypes.ProxyResource { + /** + * recommendation properties. + */ + properties: AlertRuleRecommendationProperties; +} + +/** + * Describes the format of Alert Rule Recommendations response. + */ +model AlertRuleRecommendationProperties { + /** + * The recommendation alert rule type. + */ + alertRuleType: string; + + /** + * The recommendation alert rule category. + */ + category?: string; + + /** + * A dictionary that provides the display information for an alert rule recommendation. + */ + #suppress "@azure-tools/typespec-azure-resource-manager/arm-no-record" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" + displayInformation: Record; + + /** + * A complete ARM template to deploy the alert rules. + */ + ruleArmTemplate: RuleArmTemplate; +} + +/** + * A complete ARM template to deploy the alert rules. + */ +model RuleArmTemplate { + /** + * JSON schema reference + */ + $schema: string; + + /** + * A 4 number format for the version number of this template file. For example, 1.0.0.0 + */ + @pattern("(^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$)") + contentVersion: string; + + /** + * Variable definitions + */ + #suppress "@azure-tools/typespec-azure-core/no-unknown" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" + variables: unknown; + + /** + * Input parameter definitions + */ + #suppress "@azure-tools/typespec-azure-core/no-unknown" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" + parameters: unknown; + + /** + * Alert rule resource definitions + */ + #suppress "@azure-tools/typespec-azure-core/no-unknown" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" + resources: unknown[]; +} diff --git a/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/preview/2023-08-01-preview/AlertRuleRecommendations.json b/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/preview/2023-08-01-preview/AlertRuleRecommendations.json index 278add7fb142..645f734ff799 100644 --- a/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/preview/2023-08-01-preview/AlertRuleRecommendations.json +++ b/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/preview/2023-08-01-preview/AlertRuleRecommendations.json @@ -1,18 +1,23 @@ { "swagger": "2.0", "info": { - "version": "2023-08-01-preview", "title": "Azure Alerts Management Service Resource Provider", - "description": "Azure Alerts Management Service provides a single pane of glass of alerts across Azure Monitor." + "version": "2023-08-01-preview", + "description": "Azure Alerts Management Service provides a single pane of glass of alerts across Azure Monitor.", + "x-typespec-generated": [ + { + "emitter": "@azure-tools/typespec-autorest" + } + ] }, - "host": "management.azure.com", "schemes": [ "https" ], - "consumes": [ + "host": "management.azure.com", + "produces": [ "application/json" ], - "produces": [ + "consumes": [ "application/json" ], "security": [ @@ -25,170 +30,106 @@ "securityDefinitions": { "azure_auth": { "type": "oauth2", - "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", + "description": "Azure Active Directory OAuth2 Flow.", "flow": "implicit", - "description": "Azure Active Directory OAuth2 Flow", + "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", "scopes": { "user_impersonation": "impersonate your user account" } } }, + "tags": [], "paths": { "/{resourceUri}/providers/Microsoft.AlertsManagement/alertRuleRecommendations": { "get": { - "tags": [ - "alertRuleRecommendations" - ], - "description": "Retrieve alert rule recommendations for a resource.", "operationId": "AlertRuleRecommendations_ListByResource", + "description": "Retrieve alert rule recommendations for a resource.", "parameters": [ { - "$ref": "#/parameters/ResourceUriParameter" + "$ref": "../../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "../../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + "$ref": "#/parameters/Azure.ResourceManager.ResourceUriParameter" } ], "responses": { "200": { - "description": "Successful request for a list of alert rule recommendations", + "description": "The request has succeeded.", "schema": { "$ref": "#/definitions/AlertRuleRecommendationsListResponse" } }, "default": { - "description": "Error response describing why the operation failed.", + "description": "An unexpected error response.", "schema": { "$ref": "../../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" } } }, - "x-ms-pageable": { - "nextLinkName": "nextLink" - }, "x-ms-examples": { - "List alert rule recommendations for virtual machines at resource level": { - "$ref": "./examples/AlertRuleRecommendations_GetByResource_VM.json" - }, "List alert rule recommendations for Monitoring accounts at resource level": { "$ref": "./examples/AlertRuleRecommendations_GetByResource_MAC.json" + }, + "List alert rule recommendations for virtual machines at resource level": { + "$ref": "./examples/AlertRuleRecommendations_GetByResource_VM.json" } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink" } } }, "/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/alertRuleRecommendations": { "get": { - "tags": [ - "alertRuleRecommendations" - ], - "description": "Retrieve alert rule recommendations for a target type.", "operationId": "AlertRuleRecommendations_ListByTargetType", + "description": "Retrieve alert rule recommendations for a target type.", "parameters": [ { - "$ref": "../../../../../../common-types/resource-management/v3/types.json#/parameters/SubscriptionIdParameter" + "$ref": "../../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" }, { - "$ref": "../../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + "$ref": "../../../../../../common-types/resource-management/v3/types.json#/parameters/SubscriptionIdParameter" }, { - "$ref": "#/parameters/TargetTypeParameter" + "name": "targetType", + "in": "query", + "description": "The recommendations target type.", + "required": true, + "type": "string" } ], "responses": { "200": { - "description": "Successful request for a list of alert rule recommendations", + "description": "The request has succeeded.", "schema": { "$ref": "#/definitions/AlertRuleRecommendationsListResponse" } }, "default": { - "description": "Error response describing why the operation failed.", + "description": "An unexpected error response.", "schema": { "$ref": "../../../../../../common-types/resource-management/v3/types.json#/definitions/ErrorResponse" } } }, - "x-ms-pageable": { - "nextLinkName": "nextLink" - }, "x-ms-examples": { - "List alert rule recommendations for virtual machines at subscription level": { - "$ref": "./examples/AlertRuleRecommendations_GetBySubscription_VM.json" - }, "List alert rule recommendations for Monitoring accounts at subscription level": { "$ref": "./examples/AlertRuleRecommendations_GetBySubscription_MAC.json" + }, + "List alert rule recommendations for virtual machines at subscription level": { + "$ref": "./examples/AlertRuleRecommendations_GetBySubscription_VM.json" } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink" } } } }, - "parameters": { - "ResourceUriParameter": { - "name": "resourceUri", - "in": "path", - "required": true, - "type": "string", - "description": "The identifier of the resource.", - "x-ms-parameter-location": "method", - "x-ms-skip-url-encoding": true - }, - "TargetTypeParameter": { - "name": "targetType", - "in": "query", - "required": true, - "type": "string", - "description": "The recommendations target type.", - "x-ms-parameter-location": "method" - } - }, "definitions": { - "AlertRuleRecommendationsListResponse": { - "type": "object", - "description": "List of alert rule recommendations.", - "required": [ - "value" - ], - "properties": { - "value": { - "type": "array", - "items": { - "$ref": "#/definitions/AlertRuleRecommendationResource" - }, - "description": "the values for the alert rule recommendations." - }, - "nextLink": { - "description": "URL to fetch the next set of recommendations.", - "type": "string" - } - } - }, - "AlertRuleRecommendationResource": { - "type": "object", - "description": "A single alert rule recommendation resource.", - "allOf": [ - { - "$ref": "../../../../../../common-types/resource-management/v3/types.json#/definitions/ProxyResource" - } - ], - "required": [ - "properties" - ], - "properties": { - "properties": { - "$ref": "#/definitions/AlertRuleRecommendationProperties", - "x-ms-client-flatten": true, - "description": "recommendation properties." - } - } - }, "AlertRuleRecommendationProperties": { - "description": "Describes the format of Alert Rule Recommendations response.", "type": "object", - "required": [ - "alertRuleType", - "displayInformation", - "ruleArmTemplate" - ], + "description": "Describes the format of Alert Rule Recommendations response.", "properties": { "alertRuleType": { "type": "string", @@ -199,73 +140,66 @@ "description": "The recommendation alert rule category." }, "displayInformation": { - "description": "A dictionary that provides the display information for an alert rule recommendation.", "type": "object", + "description": "A dictionary that provides the display information for an alert rule recommendation.", "additionalProperties": { "type": "string" } }, "ruleArmTemplate": { - "$ref": "#/definitions/ruleArmTemplate" + "$ref": "#/definitions/RuleArmTemplate", + "description": "A complete ARM template to deploy the alert rules." } - } + }, + "required": [ + "alertRuleType", + "displayInformation", + "ruleArmTemplate" + ] }, - "MetricAlertsDisplayUnit": { - "type": "string", - "description": "The unit to display for a metric alert rule.", - "enum": [ - "None", - "Percentage", - "Bytes", - "Kilobytes", - "Megabytes", - "Gigabytes", - "Terabytes", - "Petabytes", - "BytesPerDay", - "BytesPerHour", - "BytesPerMinute", - "BytesPerSecond", - "KilobytesPerSecond", - "MegabytesPerSecond", - "GigabytesPerSecond", - "TerabytesPerSecond", - "PetabytesPerSecond", - "Count", - "Thousand", - "Million", - "Billion", - "Trillion", - "MicroSeconds", - "MilliSeconds", - "Seconds", - "Minutes", - "Hours", - "Days", - "CountPerDay", - "CountPerHour", - "CountPerMinute", - "CountPerSecond", - "ThousandPerSecond", - "MillionPerSecond", - "BillionPerSecond", - "TrillionPerSecond" + "AlertRuleRecommendationResource": { + "type": "object", + "description": "A single alert rule recommendation resource.", + "properties": { + "properties": { + "$ref": "#/definitions/AlertRuleRecommendationProperties", + "description": "recommendation properties.", + "x-ms-client-flatten": true + } + }, + "required": [ + "properties" ], - "x-ms-enum": { - "name": "MetricAlertsDisplayUnit", - "modelAsString": true - } + "allOf": [ + { + "$ref": "../../../../../../common-types/resource-management/v3/types.json#/definitions/ProxyResource" + } + ] }, - "ruleArmTemplate": { - "description": "A complete ARM template to deploy the alert rules.", + "AlertRuleRecommendationsListResponse": { "type": "object", + "description": "List of alert rule recommendations.", + "properties": { + "value": { + "type": "array", + "description": "The AlertRuleRecommendationResource items on this page", + "items": { + "$ref": "#/definitions/AlertRuleRecommendationResource" + } + }, + "nextLink": { + "type": "string", + "format": "uri", + "description": "The link to the next page of items" + } + }, "required": [ - "$schema", - "contentVersion", - "variables", - "parameters", - "resources" - ], + "value" + ] + }, + "RuleArmTemplate": { + "type": "object", + "description": "A complete ARM template to deploy the alert rules.", "properties": { "$schema": { "type": "string", @@ -273,26 +207,39 @@ }, "contentVersion": { "type": "string", - "pattern": "(^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$)", - "description": "A 4 number format for the version number of this template file. For example, 1.0.0.0" + "description": "A 4 number format for the version number of this template file. For example, 1.0.0.0", + "pattern": "(^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$)" }, "variables": { - "type": "object", "description": "Variable definitions" }, "parameters": { - "type": "object", "description": "Input parameter definitions" }, "resources": { "type": "array", "description": "Alert rule resource definitions", - "items": { - "type": "object" - }, - "x-ms-identifiers": [] + "items": {} } - } + }, + "required": [ + "$schema", + "contentVersion", + "variables", + "parameters", + "resources" + ] + } + }, + "parameters": { + "Azure.ResourceManager.ResourceUriParameter": { + "name": "resourceUri", + "in": "path", + "description": "The fully qualified Azure Resource manager identifier of the resource.", + "required": true, + "type": "string", + "x-ms-parameter-location": "method", + "x-ms-skip-url-encoding": true } } } diff --git a/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/preview/2023-08-01-preview/examples/AlertRuleRecommendations_GetByResource_MAC.json b/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/preview/2023-08-01-preview/examples/AlertRuleRecommendations_GetByResource_MAC.json index 1cc267fbfb70..7dbbb7982aff 100644 --- a/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/preview/2023-08-01-preview/examples/AlertRuleRecommendations_GetByResource_MAC.json +++ b/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/preview/2023-08-01-preview/examples/AlertRuleRecommendations_GetByResource_MAC.json @@ -1,16 +1,16 @@ { "parameters": { - "resourceUri": "subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourceGroups/GenevaAlertRP-RunnerResources-eastus/providers/microsoft.monitor/accounts/alertsrp-eastus-pgms", - "api-version": "2023-08-01-preview" + "api-version": "2023-08-01-preview", + "resourceUri": "subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourceGroups/GenevaAlertRP-RunnerResources-eastus/providers/microsoft.monitor/accounts/alertsrp-eastus-pgms" }, "responses": { "200": { "body": { "value": [ { - "id": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourceGroups/GenevaAlertRP-RunnerResources-eastus/providers/microsoft.monitor/accounts/alertsrp-eastus-pgms/providers/Microsoft.AlertsManagement/alertRuleRecommendations/NodeRecordingRulesRuleGroup", "name": "NodeRecordingRulesRuleGroup", "type": "Microsoft.AlertsManagement/alertRuleRecommendations", + "id": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourceGroups/GenevaAlertRP-RunnerResources-eastus/providers/microsoft.monitor/accounts/alertsrp-eastus-pgms/providers/Microsoft.AlertsManagement/alertRuleRecommendations/NodeRecordingRulesRuleGroup", "properties": { "alertRuleType": "Microsoft.AlertsManagement/prometheusRuleGroups", "category": "MyCategory1", @@ -21,14 +21,6 @@ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { - "targetResourceId": { - "type": "string", - "defaultValue": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourceGroups/GenevaAlertRP-RunnerResources-eastus/providers/microsoft.monitor/accounts/alertsrp-eastus-pgms" - }, - "targetResourceName": { - "type": "string", - "defaultValue": "alertsrp-eastus-pgms" - }, "actionGroupIds": { "type": "array", "defaultValue": [], @@ -36,42 +28,38 @@ "description": "Insert Action groups ids to attach them to the below alert rules." } }, - "location": { + "alertName": { "type": "string", - "defaultValue": "eastus" - }, - "clusterNameForPrometheus": { - "type": "string" + "defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('clusterNameForPrometheus'))]", + "metadata": { + "description": "Name of the alert rule" + }, + "minLength": 1 }, "alertNamePrefix": { "type": "string", "defaultValue": "NodeRecordingRulesRuleGroup", - "minLength": 1, "metadata": { "description": "prefix of the alert rule name" - } + }, + "minLength": 1 }, - "alertName": { + "clusterNameForPrometheus": { + "type": "string" + }, + "location": { "type": "string", - "defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('clusterNameForPrometheus'))]", - "minLength": 1, - "metadata": { - "description": "Name of the alert rule" - } + "defaultValue": "eastus" + }, + "targetResourceId": { + "type": "string", + "defaultValue": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourceGroups/GenevaAlertRP-RunnerResources-eastus/providers/microsoft.monitor/accounts/alertsrp-eastus-pgms" + }, + "targetResourceName": { + "type": "string", + "defaultValue": "alertsrp-eastus-pgms" } }, - "variables": { - "scopes": "[array(parameters('targetResourceId'))]", - "copy": [ - { - "name": "actionsForPrometheusRuleGroups", - "count": "[length(parameters('actionGroupIds'))]", - "input": { - "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForPrometheusRuleGroups')]]" - } - } - ] - }, "resources": [ { "name": "[parameters('alertName')]", @@ -80,25 +68,37 @@ "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\"})" + "expression": "count without (cpu, mode) ( node_cpu_seconds_total{job=\"node\",mode=\"idle\"})", + "record": "instance:node_num_cpu:sum" } - ] + ], + "scopes": "[variables('scopes')]" } } - ] + ], + "variables": { + "copy": [ + { + "name": "actionsForPrometheusRuleGroups", + "count": "[length(parameters('actionGroupIds'))]", + "input": { + "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForPrometheusRuleGroups')]]" + } + } + ], + "scopes": "[array(parameters('targetResourceId'))]" + } } } }, { - "id": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourceGroups/GenevaAlertRP-RunnerResources-eastus/providers/microsoft.monitor/accounts/alertsrp-eastus-pgms/providers/Microsoft.AlertsManagement/alertRuleRecommendations/KubernetesReccordingRulesRuleGroup", "name": "KubernetesReccordingRulesRuleGroup", "type": "Microsoft.AlertsManagement/alertRuleRecommendations", + "id": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourceGroups/GenevaAlertRP-RunnerResources-eastus/providers/microsoft.monitor/accounts/alertsrp-eastus-pgms/providers/Microsoft.AlertsManagement/alertRuleRecommendations/KubernetesReccordingRulesRuleGroup", "properties": { "alertRuleType": "Microsoft.AlertsManagement/prometheusRuleGroups", "category": "MyCategory1", @@ -109,14 +109,6 @@ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { - "targetResourceId": { - "type": "string", - "defaultValue": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourceGroups/GenevaAlertRP-RunnerResources-eastus/providers/microsoft.monitor/accounts/alertsrp-eastus-pgms" - }, - "targetResourceName": { - "type": "string", - "defaultValue": "alertsrp-eastus-pgms" - }, "actionGroupIds": { "type": "array", "defaultValue": [], @@ -124,42 +116,38 @@ "description": "Insert Action groups ids to attach them to the below alert rules." } }, - "location": { + "alertName": { "type": "string", - "defaultValue": "eastus" - }, - "clusterNameForPrometheus": { - "type": "string" + "defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('clusterNameForPrometheus'))]", + "metadata": { + "description": "Name of the alert rule" + }, + "minLength": 1 }, "alertNamePrefix": { "type": "string", "defaultValue": "KubernetesReccordingRulesRuleGroup", - "minLength": 1, "metadata": { "description": "prefix of the alert rule name" - } + }, + "minLength": 1 }, - "alertName": { + "clusterNameForPrometheus": { + "type": "string" + }, + "location": { "type": "string", - "defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('clusterNameForPrometheus'))]", - "minLength": 1, - "metadata": { - "description": "Name of the alert rule" - } + "defaultValue": "eastus" + }, + "targetResourceId": { + "type": "string", + "defaultValue": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourceGroups/GenevaAlertRP-RunnerResources-eastus/providers/microsoft.monitor/accounts/alertsrp-eastus-pgms" + }, + "targetResourceName": { + "type": "string", + "defaultValue": "alertsrp-eastus-pgms" } }, - "variables": { - "scopes": "[array(parameters('targetResourceId'))]", - "copy": [ - { - "name": "actionsForPrometheusRuleGroups", - "count": "[length(parameters('actionGroupIds'))]", - "input": { - "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForPrometheusRuleGroups')]]" - } - } - ] - }, "resources": [ { "name": "[parameters('alertName')]", @@ -168,25 +156,37 @@ "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!=\"\"}))" + "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!=\"\"}))", + "record": "node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate" } - ] + ], + "scopes": "[variables('scopes')]" } } - ] + ], + "variables": { + "copy": [ + { + "name": "actionsForPrometheusRuleGroups", + "count": "[length(parameters('actionGroupIds'))]", + "input": { + "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForPrometheusRuleGroups')]]" + } + } + ], + "scopes": "[array(parameters('targetResourceId'))]" + } } } }, { - "id": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourceGroups/GenevaAlertRP-RunnerResources-eastus/providers/microsoft.monitor/accounts/alertsrp-eastus-pgms/providers/Microsoft.AlertsManagement/alertRuleRecommendations/KubernetesAlert-DefaultAlert", "name": "KubernetesAlert-DefaultAlert", "type": "Microsoft.AlertsManagement/alertRuleRecommendations", + "id": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourceGroups/GenevaAlertRP-RunnerResources-eastus/providers/microsoft.monitor/accounts/alertsrp-eastus-pgms/providers/Microsoft.AlertsManagement/alertRuleRecommendations/KubernetesAlert-DefaultAlert", "properties": { "alertRuleType": "Microsoft.AlertsManagement/prometheusRuleGroups", "category": "MyCategory2", @@ -197,14 +197,6 @@ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { - "targetResourceId": { - "type": "string", - "defaultValue": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourceGroups/GenevaAlertRP-RunnerResources-eastus/providers/microsoft.monitor/accounts/alertsrp-eastus-pgms" - }, - "targetResourceName": { - "type": "string", - "defaultValue": "alertsrp-eastus-pgms" - }, "actionGroupIds": { "type": "array", "defaultValue": [], @@ -212,42 +204,38 @@ "description": "Insert Action groups ids to attach them to the below alert rules." } }, - "location": { + "alertName": { "type": "string", - "defaultValue": "eastus" - }, - "clusterNameForPrometheus": { - "type": "string" + "defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('clusterNameForPrometheus'))]", + "metadata": { + "description": "Name of the alert rule" + }, + "minLength": 1 }, "alertNamePrefix": { "type": "string", "defaultValue": "KubernetesAlert-DefaultAlerts", - "minLength": 1, "metadata": { "description": "prefix of the alert rule name" - } + }, + "minLength": 1 }, - "alertName": { + "clusterNameForPrometheus": { + "type": "string" + }, + "location": { "type": "string", - "defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('clusterNameForPrometheus'))]", - "minLength": 1, - "metadata": { - "description": "Name of the alert rule" - } + "defaultValue": "eastus" + }, + "targetResourceId": { + "type": "string", + "defaultValue": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourceGroups/GenevaAlertRP-RunnerResources-eastus/providers/microsoft.monitor/accounts/alertsrp-eastus-pgms" + }, + "targetResourceName": { + "type": "string", + "defaultValue": "alertsrp-eastus-pgms" } }, - "variables": { - "scopes": "[array(parameters('targetResourceId'))]", - "copy": [ - { - "name": "actionsForPrometheusRuleGroups", - "count": "[length(parameters('actionGroupIds'))]", - "input": { - "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForPrometheusRuleGroups')]]" - } - } - ] - }, "resources": [ { "name": "[parameters('alertName')]", @@ -256,39 +244,53 @@ "location": "[parameters('location')]", "properties": { "description": "Kubernetes Alert RuleGroup-DefaultAlerts", - "scopes": "[variables('scopes')]", "clusterName": "[parameters('clusterNameForPrometheus')]", "interval": "PT1M", "rules": [ { + "Severity": 3, + "actions": "[variables('actionsForPrometheusRuleGroups')]", "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')]" + } }, { + "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')]" + } } - ] + ], + "scopes": "[variables('scopes')]" } } - ] + ], + "variables": { + "copy": [ + { + "name": "actionsForPrometheusRuleGroups", + "count": "[length(parameters('actionGroupIds'))]", + "input": { + "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForPrometheusRuleGroups')]]" + } + } + ], + "scopes": "[array(parameters('targetResourceId'))]" + } } } } ] } } - } + }, + "operationId": "AlertRuleRecommendations_ListByResource", + "title": "List alert rule recommendations for Monitoring accounts at resource level" } diff --git a/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/preview/2023-08-01-preview/examples/AlertRuleRecommendations_GetByResource_VM.json b/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/preview/2023-08-01-preview/examples/AlertRuleRecommendations_GetByResource_VM.json index e4853226bc34..f6114b723ac3 100644 --- a/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/preview/2023-08-01-preview/examples/AlertRuleRecommendations_GetByResource_VM.json +++ b/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/preview/2023-08-01-preview/examples/AlertRuleRecommendations_GetByResource_VM.json @@ -1,36 +1,28 @@ { "parameters": { - "resourceUri": "subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourcegroups/test/providers/Microsoft.Compute/virtualMachines/testMachineCanBeSafelyDeleted", - "api-version": "2023-08-01-preview" + "api-version": "2023-08-01-preview", + "resourceUri": "subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourcegroups/test/providers/Microsoft.Compute/virtualMachines/testMachineCanBeSafelyDeleted" }, "responses": { "200": { "body": { "value": [ { - "id": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourcegroups/test/providers/Microsoft.Compute/virtualMachines/testMachineCanBeSafelyDeleted/providers/Microsoft.AlertsManagement/alertRuleRecommendations/Percentage CPU", "name": "Percentage CPU", "type": "Microsoft.AlertsManagement/alertRuleRecommendations", + "id": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourcegroups/test/providers/Microsoft.Compute/virtualMachines/testMachineCanBeSafelyDeleted/providers/Microsoft.AlertsManagement/alertRuleRecommendations/Percentage CPU", "properties": { "alertRuleType": "Microsoft.Insights/metricAlerts", "displayInformation": { - "infoBallonMessage": "Rule1 InfoBalloon Message", + "displayUnits": "Percentage", "infoBallonLink": "Rule1 InfoBalloon Link", - "metricDisplayName": "Percentage CPU", - "displayUnits": "Percentage" + "infoBallonMessage": "Rule1 InfoBalloon Message", + "metricDisplayName": "Percentage CPU" }, "ruleArmTemplate": { "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { - "targetResourceId": { - "type": "string", - "defaultValue": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourcegroups/test/providers/Microsoft.Compute/virtualMachines/testMachineCanBeSafelyDeleted" - }, - "targetResourceName": { - "type": "string", - "defaultValue": "testmachinecanbesafelydeleted" - }, "actionGroupIds": { "type": "array", "defaultValue": [], @@ -38,21 +30,21 @@ "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" - } + }, + "minLength": 1 + }, + "alertNamePrefix": { + "type": "string", + "defaultValue": "Percentage CPU", + "metadata": { + "description": "prefix of the alert rule name" + }, + "minLength": 1 }, "alertSeverity": { "type": "int", @@ -68,6 +60,14 @@ "description": "Severity of alert {0,1,2,3,4}" } }, + "targetResourceId": { + "type": "string", + "defaultValue": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourcegroups/test/providers/Microsoft.Compute/virtualMachines/testMachineCanBeSafelyDeleted" + }, + "targetResourceName": { + "type": "string", + "defaultValue": "testmachinecanbesafelydeleted" + }, "threshold": { "type": "int", "defaultValue": 80, @@ -76,18 +76,6 @@ } } }, - "variables": { - "scopes": "[array(parameters('targetResourceId'))]", - "copy": [ - { - "name": "actionsForMetricAlerts", - "count": "[length(parameters('actionGroupIds'))]", - "input": { - "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForMetricAlerts')]]" - } - } - ] - }, "resources": [ { "name": "[parameters('alertName')]", @@ -96,13 +84,8 @@ "location": "global", "properties": { "description": "Percentage CPU is greater than 80 %", - "severity": "[parameters('alertSeverity')]", - "enabled": true, - "scopes": "[variables('scopes')]", - "evaluationFrequency": "PT5M", - "windowSize": "PT5M", + "actions": "[variables('actionsForMetricAlerts')]", "criteria": { - "odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", "allOf": [ { "name": "Metric1", @@ -111,39 +94,48 @@ "threshold": "[parameters('threshold')]", "timeAggregation": "Average" } - ] + ], + "odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria" }, - "actions": "[variables('actionsForMetricAlerts')]" + "enabled": true, + "evaluationFrequency": "PT5M", + "scopes": "[variables('scopes')]", + "severity": "[parameters('alertSeverity')]", + "windowSize": "PT5M" } } - ] + ], + "variables": { + "copy": [ + { + "name": "actionsForMetricAlerts", + "count": "[length(parameters('actionGroupIds'))]", + "input": { + "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForMetricAlerts')]]" + } + } + ], + "scopes": "[array(parameters('targetResourceId'))]" + } } } }, { - "id": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourcegroups/test/providers/Microsoft.Compute/virtualMachines/testMachineCanBeSafelyDeleted/providers/Microsoft.AlertsManagement/alertRuleRecommendations/Available Memory Bytes", "name": "Available Memory Bytes", "type": "Microsoft.AlertsManagement/alertRuleRecommendations", + "id": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourcegroups/test/providers/Microsoft.Compute/virtualMachines/testMachineCanBeSafelyDeleted/providers/Microsoft.AlertsManagement/alertRuleRecommendations/Available Memory Bytes", "properties": { "alertRuleType": "Microsoft.Insights/metricAlerts", "displayInformation": { - "infoBallonMessage": "Rule2 InfoBalloon Message", + "displayUnits": "Gigabytes", "infoBallonLink": "Rule2 InfoBalloon Link", - "metricDisplayName": "Available Memory Bytes", - "displayUnits": "Gigabytes" + "infoBallonMessage": "Rule2 InfoBalloon Message", + "metricDisplayName": "Available Memory Bytes" }, "ruleArmTemplate": { "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { - "targetResourceId": { - "type": "string", - "defaultValue": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourcegroups/test/providers/Microsoft.Compute/virtualMachines/testMachineCanBeSafelyDeleted" - }, - "targetResourceName": { - "type": "string", - "defaultValue": "testmachinecanbesafelydeleted" - }, "actionGroupIds": { "type": "array", "defaultValue": [], @@ -151,21 +143,21 @@ "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" - } + }, + "minLength": 1 + }, + "alertNamePrefix": { + "type": "string", + "defaultValue": "Available Memory Bytes", + "metadata": { + "description": "prefix of the alert rule name" + }, + "minLength": 1 }, "alertSeverity": { "type": "int", @@ -181,6 +173,14 @@ "description": "Severity of alert {0,1,2,3,4}" } }, + "targetResourceId": { + "type": "string", + "defaultValue": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourcegroups/test/providers/Microsoft.Compute/virtualMachines/testMachineCanBeSafelyDeleted" + }, + "targetResourceName": { + "type": "string", + "defaultValue": "testmachinecanbesafelydeleted" + }, "threshold": { "type": "int", "defaultValue": 1000000000, @@ -189,18 +189,6 @@ } } }, - "variables": { - "scopes": "[array(parameters('targetResourceId'))]", - "copy": [ - { - "name": "actionsForMetricAlerts", - "count": "[length(parameters('actionGroupIds'))]", - "input": { - "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForMetricAlerts')]]" - } - } - ] - }, "resources": [ { "name": "[parameters('alertName')]", @@ -209,13 +197,8 @@ "location": "global", "properties": { "description": "Available Memory Bytes is less than 1 GB", - "severity": "[parameters('alertSeverity')]", - "enabled": true, - "scopes": "[variables('scopes')]", - "evaluationFrequency": "PT5M", - "windowSize": "PT5M", + "actions": "[variables('actionsForMetricAlerts')]", "criteria": { - "odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", "allOf": [ { "name": "Metric1", @@ -224,17 +207,36 @@ "threshold": "[parameters('threshold')]", "timeAggregation": "Average" } - ] + ], + "odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria" }, - "actions": "[variables('actionsForMetricAlerts')]" + "enabled": true, + "evaluationFrequency": "PT5M", + "scopes": "[variables('scopes')]", + "severity": "[parameters('alertSeverity')]", + "windowSize": "PT5M" } } - ] + ], + "variables": { + "copy": [ + { + "name": "actionsForMetricAlerts", + "count": "[length(parameters('actionGroupIds'))]", + "input": { + "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForMetricAlerts')]]" + } + } + ], + "scopes": "[array(parameters('targetResourceId'))]" + } } } } ] } } - } + }, + "operationId": "AlertRuleRecommendations_ListByResource", + "title": "List alert rule recommendations for virtual machines at resource level" } diff --git a/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/preview/2023-08-01-preview/examples/AlertRuleRecommendations_GetBySubscription_MAC.json b/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/preview/2023-08-01-preview/examples/AlertRuleRecommendations_GetBySubscription_MAC.json index 038fcf4f47cc..2b573718fe03 100644 --- a/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/preview/2023-08-01-preview/examples/AlertRuleRecommendations_GetBySubscription_MAC.json +++ b/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/preview/2023-08-01-preview/examples/AlertRuleRecommendations_GetBySubscription_MAC.json @@ -1,17 +1,17 @@ { "parameters": { + "api-version": "2023-08-01-preview", "subscriptionId": "2f00cc51-6809-498f-9ffc-48c42aff570d", - "targetType": "microsoft.monitor/accounts", - "api-version": "2023-08-01-preview" + "targetType": "microsoft.monitor/accounts" }, "responses": { "200": { "body": { "value": [ { - "id": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/providers/Microsoft.AlertsManagement/alertRuleRecommendations/NodeRecordingRulesRuleGroup", "name": "NodeRecordingRulesRuleGroup", "type": "Microsoft.AlertsManagement/alertRuleRecommendations", + "id": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/providers/Microsoft.AlertsManagement/alertRuleRecommendations/NodeRecordingRulesRuleGroup", "properties": { "alertRuleType": "Microsoft.AlertsManagement/prometheusRuleGroups", "category": "MyCategory1", @@ -22,12 +22,6 @@ "$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": [], @@ -35,41 +29,35 @@ "description": "Insert Action groups ids to attach them to the below alert rules." } }, - "location": { - "type": "string" - }, - "clusterNameForPrometheus": { - "type": "string" + "alertName": { + "type": "string", + "defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('clusterNameForPrometheus'))]", + "metadata": { + "description": "Name of the alert rule" + }, + "minLength": 1 }, "alertNamePrefix": { "type": "string", "defaultValue": "NodeRecordingRulesRuleGroup", - "minLength": 1, "metadata": { "description": "prefix of the alert rule name" - } + }, + "minLength": 1 }, - "alertName": { - "type": "string", - "defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('clusterNameForPrometheus'))]", - "minLength": 1, - "metadata": { - "description": "Name of the alert rule" - } + "clusterNameForPrometheus": { + "type": "string" + }, + "location": { + "type": "string" + }, + "targetResourceId": { + "type": "string" + }, + "targetResourceName": { + "type": "string" } }, - "variables": { - "scopes": "[array(parameters('targetResourceId'))]", - "copy": [ - { - "name": "actionsForPrometheusRuleGroups", - "count": "[length(parameters('actionGroupIds'))]", - "input": { - "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForPrometheusRuleGroups')]]" - } - } - ] - }, "resources": [ { "name": "[parameters('alertName')]", @@ -78,25 +66,37 @@ "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\"})" + "expression": "count without (cpu, mode) ( node_cpu_seconds_total{job=\"node\",mode=\"idle\"})", + "record": "instance:node_num_cpu:sum" } - ] + ], + "scopes": "[variables('scopes')]" } } - ] + ], + "variables": { + "copy": [ + { + "name": "actionsForPrometheusRuleGroups", + "count": "[length(parameters('actionGroupIds'))]", + "input": { + "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForPrometheusRuleGroups')]]" + } + } + ], + "scopes": "[array(parameters('targetResourceId'))]" + } } } }, { - "id": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/providers/Microsoft.AlertsManagement/alertRuleRecommendations/KubernetesReccordingRulesRuleGroup", "name": "KubernetesReccordingRulesRuleGroup", "type": "Microsoft.AlertsManagement/alertRuleRecommendations", + "id": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/providers/Microsoft.AlertsManagement/alertRuleRecommendations/KubernetesReccordingRulesRuleGroup", "properties": { "alertRuleType": "Microsoft.AlertsManagement/prometheusRuleGroups", "category": "MyCategory1", @@ -107,12 +107,6 @@ "$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": [], @@ -120,41 +114,35 @@ "description": "Insert Action groups ids to attach them to the below alert rules." } }, - "location": { - "type": "string" - }, - "clusterNameForPrometheus": { - "type": "string" + "alertName": { + "type": "string", + "defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('clusterNameForPrometheus'))]", + "metadata": { + "description": "Name of the alert rule" + }, + "minLength": 1 }, "alertNamePrefix": { "type": "string", "defaultValue": "KubernetesReccordingRulesRuleGroup", - "minLength": 1, "metadata": { "description": "prefix of the alert rule name" - } + }, + "minLength": 1 }, - "alertName": { - "type": "string", - "defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('clusterNameForPrometheus'))]", - "minLength": 1, - "metadata": { - "description": "Name of the alert rule" - } + "clusterNameForPrometheus": { + "type": "string" + }, + "location": { + "type": "string" + }, + "targetResourceId": { + "type": "string" + }, + "targetResourceName": { + "type": "string" } }, - "variables": { - "scopes": "[array(parameters('targetResourceId'))]", - "copy": [ - { - "name": "actionsForPrometheusRuleGroups", - "count": "[length(parameters('actionGroupIds'))]", - "input": { - "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForPrometheusRuleGroups')]]" - } - } - ] - }, "resources": [ { "name": "[parameters('alertName')]", @@ -163,25 +151,37 @@ "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!=\"\"}))" + "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!=\"\"}))", + "record": "node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate" } - ] + ], + "scopes": "[variables('scopes')]" } } - ] + ], + "variables": { + "copy": [ + { + "name": "actionsForPrometheusRuleGroups", + "count": "[length(parameters('actionGroupIds'))]", + "input": { + "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForPrometheusRuleGroups')]]" + } + } + ], + "scopes": "[array(parameters('targetResourceId'))]" + } } } }, { - "id": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/providers/Microsoft.AlertsManagement/alertRuleRecommendations/KubernetesAlert-DefaultAlerts", "name": "KubernetesAlert-DefaultAlerts", "type": "Microsoft.AlertsManagement/alertRuleRecommendations", + "id": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/providers/Microsoft.AlertsManagement/alertRuleRecommendations/KubernetesAlert-DefaultAlerts", "properties": { "alertRuleType": "Microsoft.AlertsManagement/prometheusRuleGroups", "category": "MyCategory2", @@ -192,12 +192,6 @@ "$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": [], @@ -205,41 +199,35 @@ "description": "Insert Action groups ids to attach them to the below alert rules." } }, - "location": { - "type": "string" - }, - "clusterNameForPrometheus": { - "type": "string" + "alertName": { + "type": "string", + "defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('clusterNameForPrometheus'))]", + "metadata": { + "description": "Name of the alert rule" + }, + "minLength": 1 }, "alertNamePrefix": { "type": "string", "defaultValue": "KubernetesAlert-DefaultAlerts", - "minLength": 1, "metadata": { "description": "prefix of the alert rule name" - } + }, + "minLength": 1 }, - "alertName": { - "type": "string", - "defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('clusterNameForPrometheus'))]", - "minLength": 1, - "metadata": { - "description": "Name of the alert rule" - } + "clusterNameForPrometheus": { + "type": "string" + }, + "location": { + "type": "string" + }, + "targetResourceId": { + "type": "string" + }, + "targetResourceName": { + "type": "string" } }, - "variables": { - "scopes": "[array(parameters('targetResourceId'))]", - "copy": [ - { - "name": "actionsForPrometheusRuleGroups", - "count": "[length(parameters('actionGroupIds'))]", - "input": { - "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForPrometheusRuleGroups')]]" - } - } - ] - }, "resources": [ { "name": "[parameters('alertName')]", @@ -248,39 +236,53 @@ "location": "[parameters('location')]", "properties": { "description": "Kubernetes Alert RuleGroup-DefaultAlerts", - "scopes": "[variables('scopes')]", "clusterName": "[parameters('clusterNameForPrometheus')]", "interval": "PT1M", "rules": [ { + "Severity": 3, + "actions": "[variables('actionsForPrometheusRuleGroups')]", "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')]" + } }, { + "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')]" + } } - ] + ], + "scopes": "[variables('scopes')]" } } - ] + ], + "variables": { + "copy": [ + { + "name": "actionsForPrometheusRuleGroups", + "count": "[length(parameters('actionGroupIds'))]", + "input": { + "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForPrometheusRuleGroups')]]" + } + } + ], + "scopes": "[array(parameters('targetResourceId'))]" + } } } } ] } } - } + }, + "operationId": "AlertRuleRecommendations_ListByTargetType", + "title": "List alert rule recommendations for Monitoring accounts at subscription level" } diff --git a/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/preview/2023-08-01-preview/examples/AlertRuleRecommendations_GetBySubscription_VM.json b/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/preview/2023-08-01-preview/examples/AlertRuleRecommendations_GetBySubscription_VM.json index b5d49af20f44..d3b6867aa187 100644 --- a/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/preview/2023-08-01-preview/examples/AlertRuleRecommendations_GetBySubscription_VM.json +++ b/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/preview/2023-08-01-preview/examples/AlertRuleRecommendations_GetBySubscription_VM.json @@ -1,35 +1,29 @@ { "parameters": { + "api-version": "2023-08-01-preview", "subscriptionId": "2f00cc51-6809-498f-9ffc-48c42aff570d", - "targetType": "microsoft.compute/virtualmachines", - "api-version": "2023-08-01-preview" + "targetType": "microsoft.compute/virtualmachines" }, "responses": { "200": { "body": { "value": [ { - "id": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/providers/Microsoft.AlertsManagement/alertRuleRecommendations/Percentage CPU", "name": "Percentage CPU", "type": "Microsoft.AlertsManagement/alertRuleRecommendations", + "id": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/providers/Microsoft.AlertsManagement/alertRuleRecommendations/Percentage CPU", "properties": { "alertRuleType": "Microsoft.Insights/metricAlerts", "displayInformation": { - "infoBallonMessage": "Rule1 InfoBalloon Message", + "displayUnits": "Percentage", "infoBallonLink": "Rule1 InfoBalloon Link", - "metricDisplayName": "Percentage CPU", - "displayUnits": "Percentage" + "infoBallonMessage": "Rule1 InfoBalloon Message", + "metricDisplayName": "Percentage CPU" }, "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": [], @@ -37,21 +31,21 @@ "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" - } + }, + "minLength": 1 + }, + "alertNamePrefix": { + "type": "string", + "defaultValue": "Percentage CPU", + "metadata": { + "description": "prefix of the alert rule name" + }, + "minLength": 1 }, "alertSeverity": { "type": "int", @@ -67,6 +61,12 @@ "description": "Severity of alert {0,1,2,3,4}" } }, + "targetResourceId": { + "type": "string" + }, + "targetResourceName": { + "type": "string" + }, "threshold": { "type": "int", "defaultValue": 80, @@ -75,18 +75,6 @@ } } }, - "variables": { - "scopes": "[array(parameters('targetResourceId'))]", - "copy": [ - { - "name": "actionsForMetricAlerts", - "count": "[length(parameters('actionGroupIds'))]", - "input": { - "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForMetricAlerts')]]" - } - } - ] - }, "resources": [ { "name": "[parameters('alertName')]", @@ -95,13 +83,8 @@ "location": "global", "properties": { "description": "Percentage CPU is greater than 80 %", - "severity": "[parameters('alertSeverity')]", - "enabled": true, - "scopes": "[variables('scopes')]", - "evaluationFrequency": "PT5M", - "windowSize": "PT5M", + "actions": "[variables('actionsForMetricAlerts')]", "criteria": { - "odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", "allOf": [ { "name": "Metric1", @@ -110,37 +93,48 @@ "threshold": "[parameters('threshold')]", "timeAggregation": "Average" } - ] + ], + "odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria" }, - "actions": "[variables('actionsForMetricAlerts')]" + "enabled": true, + "evaluationFrequency": "PT5M", + "scopes": "[variables('scopes')]", + "severity": "[parameters('alertSeverity')]", + "windowSize": "PT5M" } } - ] + ], + "variables": { + "copy": [ + { + "name": "actionsForMetricAlerts", + "count": "[length(parameters('actionGroupIds'))]", + "input": { + "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForMetricAlerts')]]" + } + } + ], + "scopes": "[array(parameters('targetResourceId'))]" + } } } }, { - "id": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/providers/Microsoft.AlertsManagement/alertRuleRecommendations/Available Memory Bytes", "name": "Available Memory Bytes", "type": "Microsoft.AlertsManagement/alertRuleRecommendations", + "id": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/providers/Microsoft.AlertsManagement/alertRuleRecommendations/Available Memory Bytes", "properties": { "alertRuleType": "Microsoft.Insights/metricAlerts", "displayInformation": { - "infoBallonMessage": "Rule2 InfoBalloon Message", + "displayUnits": "Gigabytes", "infoBallonLink": "Rule2 InfoBalloon Link", - "metricDisplayName": "Available Memory Bytes", - "displayUnits": "Gigabytes" + "infoBallonMessage": "Rule2 InfoBalloon Message", + "metricDisplayName": "Available Memory Bytes" }, "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": [], @@ -148,21 +142,21 @@ "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" - } + }, + "minLength": 1 + }, + "alertNamePrefix": { + "type": "string", + "defaultValue": "Available Memory Bytes", + "metadata": { + "description": "prefix of the alert rule name" + }, + "minLength": 1 }, "alertSeverity": { "type": "int", @@ -178,6 +172,12 @@ "description": "Severity of alert {0,1,2,3,4}" } }, + "targetResourceId": { + "type": "string" + }, + "targetResourceName": { + "type": "string" + }, "threshold": { "type": "int", "defaultValue": 1000000000, @@ -186,18 +186,6 @@ } } }, - "variables": { - "scopes": "[array(parameters('targetResourceId'))]", - "copy": [ - { - "name": "actionsForMetricAlerts", - "count": "[length(parameters('actionGroupIds'))]", - "input": { - "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForMetricAlerts')]]" - } - } - ] - }, "resources": [ { "name": "[parameters('alertName')]", @@ -206,13 +194,8 @@ "location": "global", "properties": { "description": "Available Memory Bytes is less than 1 GB", - "severity": "[parameters('alertSeverity')]", - "enabled": true, - "scopes": "[variables('scopes')]", - "evaluationFrequency": "PT5M", - "windowSize": "PT5M", + "actions": "[variables('actionsForMetricAlerts')]", "criteria": { - "odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", "allOf": [ { "name": "Metric1", @@ -221,17 +204,36 @@ "threshold": "[parameters('threshold')]", "timeAggregation": "Average" } - ] + ], + "odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria" }, - "actions": "[variables('actionsForMetricAlerts')]" + "enabled": true, + "evaluationFrequency": "PT5M", + "scopes": "[variables('scopes')]", + "severity": "[parameters('alertSeverity')]", + "windowSize": "PT5M" } } - ] + ], + "variables": { + "copy": [ + { + "name": "actionsForMetricAlerts", + "count": "[length(parameters('actionGroupIds'))]", + "input": { + "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForMetricAlerts')]]" + } + } + ], + "scopes": "[array(parameters('targetResourceId'))]" + } } } } ] } } - } + }, + "operationId": "AlertRuleRecommendations_ListByTargetType", + "title": "List alert rule recommendations for virtual machines at subscription level" } diff --git a/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/routes.tsp b/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/routes.tsp new file mode 100644 index 000000000000..8f7aaed21704 --- /dev/null +++ b/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/routes.tsp @@ -0,0 +1,47 @@ +// FIXME: Operations in this file are not detected as a resource operation, please confirm the conversion result manually + +import "@azure-tools/typespec-azure-core"; +import "@typespec/rest"; +import "./models.tsp"; +import "@azure-tools/typespec-azure-resource-manager"; +import "@typespec/openapi"; + +using TypeSpec.Rest; +using TypeSpec.Http; +using Azure.ResourceManager; +using TypeSpec.OpenAPI; + +namespace Microsoft.AlertsManagement; + +#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-interface-requires-decorator" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" +interface AlertRuleRecommendationsOperationGroup { + /** + * Retrieve alert rule recommendations for a resource. + */ + @autoRoute + @get + @action("alertRuleRecommendations") + @list + listByResource is ArmProviderActionSync< + Response = AlertRuleRecommendationsListResponse, + Scope = ExtensionResourceActionScope + >; + /** + * Retrieve alert rule recommendations for a target type. + */ + @autoRoute + @get + @action("alertRuleRecommendations") + @list + listByTargetType is ArmProviderActionSync< + Response = AlertRuleRecommendationsListResponse, + Scope = SubscriptionActionScope, + Parameters = { + /** + * The recommendations target type. + */ + @query("targetType") + targetType: string; + } + >; +} diff --git a/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/suppressions.yaml b/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/suppressions.yaml index 9eaf9ae0c569..11659ff6f261 100644 --- a/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/suppressions.yaml +++ b/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/suppressions.yaml @@ -1,6 +1,3 @@ - tool: TypeSpecRequirement path: ./preview/2023-01-01-preview/*.json - reason: Brownfield service not ready to migrate -- tool: TypeSpecRequirement - path: ./preview/2023-08-01-preview/*.json - reason: Brownfield service not ready to migrate + reason: Brownfield service not ready to migrate \ No newline at end of file diff --git a/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/tspconfig.yaml b/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/tspconfig.yaml new file mode 100644 index 000000000000..fbf5fd8f7e01 --- /dev/null +++ b/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/AlertRuleRecommendations/tspconfig.yaml @@ -0,0 +1,46 @@ +parameters: + "service-dir": + default: "sdk/alertrulerecommendations" +emit: + - "@azure-tools/typespec-autorest" +options: + "@azure-tools/typespec-autorest": + omit-unreachable-types: true + emitter-output-dir: "{project-root}" + azure-resource-provider-folder: "resource-manager" + output-file: "{version-status}/{version}/AlertRuleRecommendations.json" + arm-types-dir: "{project-root}/../../../../common-types/resource-management" + emit-lro-options: "all" + examples-dir: "{project-root}/examples" + "@azure-tools/typespec-python": + emitter-output-dir: "{output-dir}/{service-dir}/azure-mgmt-alertrulerecommendations" + namespace: "azure.mgmt.alertrulerecommendations" + generate-test: true + generate-sample: true + flavor: "azure" + "@azure-tools/typespec-java": + emitter-output-dir: "{output-dir}/{service-dir}/azure-resourcemanager-alertrulerecommendations" + namespace: "com.azure.resourcemanager.alertrulerecommendations" + service-name: "AlertRuleRecommendations" # human-readable service name, whitespace allowed + flavor: azure + "@azure-tools/typespec-ts": + service-dir: sdk/alertrulerecommendations + emitter-output-dir: "{output-dir}/{service-dir}/arm-alertrulerecommendations" + is-modular-library: true + flavor: "azure" + experimental-extensible-enums: true + package-details: + name: "@azure/arm-alertrulerecommendations" + "@azure-tools/typespec-go": + service-dir: "sdk/resourcemanager/alertrulerecommendations" + emitter-output-dir: "{output-dir}/{service-dir}/armalertrulerecommendations" + module: "github.com/Azure/azure-sdk-for-go/{service-dir}/armalertrulerecommendations" + fix-const-stuttering: true + flavor: "azure" + generate-samples: true + generate-fakes: true + head-as-boolean: true + inject-spans: true +linter: + extends: + - "@azure-tools/typespec-azure-rulesets/resource-manager"