From 90a294fca4845153be79d926b7415be5375522ac Mon Sep 17 00:00:00 2001 From: meydand Date: Mon, 30 Jan 2023 09:27:49 +0200 Subject: [PATCH] [Hub Generated] Review request for Microsoft.AlertsManagement to add version preview/2023-01-01-preview (#22248) * Adds base for updating Microsoft.AlertsManagement from version stable/2021-08-08 to version 2023-01-01-preview * Updates readme * Updates API version in new specs and examples * Add alertRuleRecommendations swagger file * Fix json * revert * revert * Fix json * Fix validations * Fixes * remove client thing * validation fixes * prettier fixes * Fix title * Delete error response definition * Fix version * Fix readme * separate methods * Fix pageble * Fix subscription level examples * Fix pageble * Fix readme * Fix readme file * Another try * Return list of recommendations * PR fixes * Add resource standard properties * Fix misplles * PR comments * Fix propreties definition name * flatten the properties --------- Co-authored-by: yashmuel <63585146+yashmuel@users.noreply.github.com> Co-authored-by: Meydan Dayan --- .../AlertRuleRecommendations.json | 329 ++++++++++++++++++ ...RuleRecommendations_GetByResource_MAC.json | 291 ++++++++++++++++ ...tRuleRecommendations_GetByResource_VM.json | 244 +++++++++++++ ...Recommendations_GetBySubscription_MAC.json | 283 +++++++++++++++ ...eRecommendations_GetBySubscription_VM.json | 241 +++++++++++++ .../resource-manager/readme.md | 9 + 6 files changed, 1397 insertions(+) create mode 100644 specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-01-01-preview/AlertRuleRecommendations.json create mode 100644 specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-01-01-preview/examples/AlertRuleRecommendations_GetByResource_MAC.json create mode 100644 specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-01-01-preview/examples/AlertRuleRecommendations_GetByResource_VM.json create mode 100644 specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-01-01-preview/examples/AlertRuleRecommendations_GetBySubscription_MAC.json create mode 100644 specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-01-01-preview/examples/AlertRuleRecommendations_GetBySubscription_VM.json diff --git a/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-01-01-preview/AlertRuleRecommendations.json b/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-01-01-preview/AlertRuleRecommendations.json new file mode 100644 index 000000000000..0d76b3d59be3 --- /dev/null +++ b/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-01-01-preview/AlertRuleRecommendations.json @@ -0,0 +1,329 @@ +{ + "swagger": "2.0", + "info": { + "version": "2023-01-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." + }, + "host": "management.azure.com", + "schemes": [ + "https" + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "security": [ + { + "azure_auth": [ + "user_impersonation" + ] + } + ], + "securityDefinitions": { + "azure_auth": { + "type": "oauth2", + "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", + "flow": "implicit", + "description": "Azure Active Directory OAuth2 Flow", + "scopes": { + "user_impersonation": "impersonate your user account" + } + } + }, + "paths": { + "/{resourceUri}/providers/Microsoft.AlertsManagement/alertRuleRecommendations": { + "get": { + "tags": [ + "alertRuleRecommendations" + ], + "description": "Retrieve alert rule recommendations for a resource.", + "operationId": "AlertRuleRecommendations_ListByResource", + "parameters": [ + { + "$ref": "#/parameters/ResourceUriParameter" + }, + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "Successful request for a list of alert rule recommendations", + "schema": { + "$ref": "#/definitions/AlertRuleRecommendationsListResponse" + } + }, + "default": { + "description": "Error response describing why the operation failed.", + "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" + } + } + } + }, + "/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/alertRuleRecommendations": { + "get": { + "tags": [ + "alertRuleRecommendations" + ], + "description": "Retrieve alert rule recommendations for a target type.", + "operationId": "AlertRuleRecommendations_ListByTargetType", + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/SubscriptionIdParameter" + }, + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/TargetTypeParameter" + } + ], + "responses": { + "200": { + "description": "Successful request for a list of alert rule recommendations", + "schema": { + "$ref": "#/definitions/AlertRuleRecommendationsListResponse" + } + }, + "default": { + "description": "Error response describing why the operation failed.", + "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" + } + } + } + } + }, + "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": "client" + } + }, + "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" + ], + "properties": { + "alertRuleType": { + "type": "string", + "description": "The recommendation alert rule type." + }, + "displayInformation": { + "$ref": "#/definitions/DisplayInformationItem" + }, + "ruleArmTemplate": { + "$ref": "#/definitions/ruleArmTemplate" + } + } + }, + "DisplayInformationItem": { + "description": "Provides the display information for an alert rule recommendation recommendations.", + "type": "object", + "properties": { + "ruleInfo": { + "type": "string", + "description": "The alert rule information." + }, + "infoBallonMessage": { + "type": "string", + "description": "The information to display inside an information balloon." + }, + "infoBallonLink": { + "type": "string", + "description": "The documentation link to display inside an information balloon." + }, + "metricAlertsDisplayInformation": { + "$ref": "#/definitions/MetricAlertsDisplayInformation" + } + } + }, + "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" + ], + "x-ms-enum": { + "name": "MetricAlertsDisplayUnit", + "modelAsString": true + } + }, + "MetricAlertsDisplayInformation": { + "description": "Provides display information specific for Metric Alerts rule.", + "type": "object", + "required": [ + "metricDisplayName", + "displayUnits" + ], + "properties": { + "metricDisplayName": { + "type": "string", + "description": "The metric display name to use in the UI for the metric alert rule." + }, + "displayUnits": { + "$ref": "#/definitions/MetricAlertsDisplayUnit", + "description": "The display units to use in the UI for the metric alert rule." + } + } + }, + "ruleArmTemplate": { + "description": "A complete ARM template to deploy the alert rules.", + "type": "object", + "required": [ + "$schema", + "contentVersion", + "variables", + "parameters", + "resources" + ], + "properties": { + "$schema": { + "type": "string", + "description": "JSON schema reference" + }, + "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" + }, + "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": [] + } + } + } + } +} diff --git a/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-01-01-preview/examples/AlertRuleRecommendations_GetByResource_MAC.json b/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-01-01-preview/examples/AlertRuleRecommendations_GetByResource_MAC.json new file mode 100644 index 000000000000..63405fa6c887 --- /dev/null +++ b/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-01-01-preview/examples/AlertRuleRecommendations_GetByResource_MAC.json @@ -0,0 +1,291 @@ +{ + "parameters": { + "resourceUri": "subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourceGroups/GenevaAlertRP-RunnerResources-eastus/providers/microsoft.monitor/accounts/alertsrp-eastus-pgms", + "api-version": "2023-01-01-preview" + }, + "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", + "properties": { + "alertRuleType": "Microsoft.AlertsManagement/prometheusRuleGroups", + "displayInformation": { + "ruleInfo": "Rule Information for first recording rule." + }, + "ruleArmTemplate": { + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "targetResourceId": { + "type": "string", + "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": [], + "metadata": { + "description": "Insert Action groups ids to attach them to the below alert rules." + } + }, + "location": { + "type": "string", + "defaultValue": "eastus" + }, + "clusterNameForPrometheus": { + "type": "string" + }, + "alertNamePrefix": { + "type": "string", + "defaultValue": "NodeRecordingRulesRuleGroup", + "minLength": 1, + "metadata": { + "description": "prefix of the alert rule name" + } + }, + "alertName": { + "type": "string", + "defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('clusterNameForPrometheus'))]", + "minLength": 1, + "metadata": { + "description": "Name of the alert rule" + } + } + }, + "variables": { + "scopes": "[array(parameters('targetResourceId'))]", + "copy": [ + { + "name": "actionsForPrometheusRuleGroups", + "count": "[length(parameters('actionGroupIds'))]", + "input": { + "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForPrometheusRuleGroups')]]" + } + } + ] + }, + "resources": [ + { + "name": "[parameters('alertName')]", + "type": "Microsoft.AlertsManagement/prometheusRuleGroups", + "apiVersion": "2021-07-22-preview", + "location": "[parameters('location')]", + "properties": { + "description": "Node Recording Rules RuleGroup", + "scopes": "[variables('scopes')]", + "clusterName": "[parameters('clusterNameForPrometheus')]", + "interval": "PT1M", + "rules": [ + { + "record": "instance:node_num_cpu:sum", + "expression": "count without (cpu, mode) ( node_cpu_seconds_total{job=\"node\",mode=\"idle\"})" + } + ] + } + } + ] + } + } + }, + { + "id": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourceGroups/GenevaAlertRP-RunnerResources-eastus/providers/microsoft.monitor/accounts/alertsrp-eastus-pgms/providers/Microsoft.AlertsManagement/alertRuleRecommendations/KubernetesReccordingRulesRuleGroup", + "name": "KubernetesReccordingRulesRuleGroup", + "type": "Microsoft.AlertsManagement/alertRuleRecommendations", + "properties": { + "alertRuleType": "Microsoft.AlertsManagement/prometheusRuleGroups", + "displayInformation": { + "ruleInfo": "Rule Information for second recording rule." + }, + "ruleArmTemplate": { + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "targetResourceId": { + "type": "string", + "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": [], + "metadata": { + "description": "Insert Action groups ids to attach them to the below alert rules." + } + }, + "location": { + "type": "string", + "defaultValue": "eastus" + }, + "clusterNameForPrometheus": { + "type": "string" + }, + "alertNamePrefix": { + "type": "string", + "defaultValue": "KubernetesReccordingRulesRuleGroup", + "minLength": 1, + "metadata": { + "description": "prefix of the alert rule name" + } + }, + "alertName": { + "type": "string", + "defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('clusterNameForPrometheus'))]", + "minLength": 1, + "metadata": { + "description": "Name of the alert rule" + } + } + }, + "variables": { + "scopes": "[array(parameters('targetResourceId'))]", + "copy": [ + { + "name": "actionsForPrometheusRuleGroups", + "count": "[length(parameters('actionGroupIds'))]", + "input": { + "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForPrometheusRuleGroups')]]" + } + } + ] + }, + "resources": [ + { + "name": "[parameters('alertName')]", + "type": "Microsoft.AlertsManagement/prometheusRuleGroups", + "apiVersion": "2021-07-22-preview", + "location": "[parameters('location')]", + "properties": { + "description": "Kubernetes Recording Rules RuleGroup", + "scopes": "[variables('scopes')]", + "clusterName": "[parameters('clusterNameForPrometheus')]", + "interval": "PT1M", + "rules": [ + { + "record": "node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate", + "expression": "sum by (cluster, namespace, pod, container) ( irate(container_cpu_usage_seconds_total{job=\"cadvisor\", image!=\"\"}[5m])) * on (cluster, namespace, pod) group_left(node) topk by (cluster, namespace, pod) ( 1, max by(cluster, namespace, pod, node) (kube_pod_info{node!=\"\"}))" + } + ] + } + } + ] + } + } + }, + { + "id": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourceGroups/GenevaAlertRP-RunnerResources-eastus/providers/microsoft.monitor/accounts/alertsrp-eastus-pgms/providers/Microsoft.AlertsManagement/alertRuleRecommendations/KubernetesAlert-DefaultAlert", + "name": "KubernetesAlert-DefaultAlert", + "type": "Microsoft.AlertsManagement/alertRuleRecommendations", + "properties": { + "alertRuleType": "Microsoft.AlertsManagement/prometheusRuleGroups", + "displayInformation": { + "ruleInfo": "Rule Information for alerting rule." + }, + "ruleArmTemplate": { + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "targetResourceId": { + "type": "string", + "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": [], + "metadata": { + "description": "Insert Action groups ids to attach them to the below alert rules." + } + }, + "location": { + "type": "string", + "defaultValue": "eastus" + }, + "clusterNameForPrometheus": { + "type": "string" + }, + "alertNamePrefix": { + "type": "string", + "defaultValue": "KubernetesAlert-DefaultAlerts", + "minLength": 1, + "metadata": { + "description": "prefix of the alert rule name" + } + }, + "alertName": { + "type": "string", + "defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('clusterNameForPrometheus'))]", + "minLength": 1, + "metadata": { + "description": "Name of the alert rule" + } + } + }, + "variables": { + "scopes": "[array(parameters('targetResourceId'))]", + "copy": [ + { + "name": "actionsForPrometheusRuleGroups", + "count": "[length(parameters('actionGroupIds'))]", + "input": { + "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForPrometheusRuleGroups')]]" + } + } + ] + }, + "resources": [ + { + "name": "[parameters('alertName')]", + "type": "Microsoft.AlertsManagement/prometheusRuleGroups", + "apiVersion": "2021-07-22-preview", + "location": "[parameters('location')]", + "properties": { + "description": "Kubernetes Alert RuleGroup-DefaultAlerts", + "scopes": "[variables('scopes')]", + "clusterName": "[parameters('clusterNameForPrometheus')]", + "interval": "PT1M", + "rules": [ + { + "alert": "KubePodCrashLooping", + "expression": "max_over_time(kube_pod_container_status_waiting_reason{reason=\"CrashLoopBackOff\", job=\"kube-state-metrics\"}[5m]) >= 1", + "for": "PT15M", + "labels": { + "severity": "warning" + }, + "Severity": 3, + "actions": "[variables('actionsForPrometheusRuleGroups')]" + }, + { + "alert": "KubePodNotReady", + "expression": "sum by (namespace, pod, cluster) ( max by(namespace, pod, cluster) ( kube_pod_status_phase{job=\"kube-state-metrics\", phase=~\"Pending|Unknown\"} ) * on(namespace, pod, cluster) group_left(owner_kind) topk by(namespace, pod, cluster) ( 1, max by(namespace, pod, owner_kind, cluster) (kube_pod_owner{owner_kind!=\"Job\"}) )) > 0", + "for": "PT15M", + "labels": { + "severity": "warning" + }, + "Severity": 3, + "actions": "[variables('actionsForPrometheusRuleGroups')]" + } + ] + } + } + ] + } + } + } + ] + } + } + } +} diff --git a/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-01-01-preview/examples/AlertRuleRecommendations_GetByResource_VM.json b/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-01-01-preview/examples/AlertRuleRecommendations_GetByResource_VM.json new file mode 100644 index 000000000000..cf39b5ab635c --- /dev/null +++ b/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-01-01-preview/examples/AlertRuleRecommendations_GetByResource_VM.json @@ -0,0 +1,244 @@ +{ + "parameters": { + "resourceUri": "subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourcegroups/test/providers/Microsoft.Compute/virtualMachines/testMachineCanBeSafelyDeleted", + "api-version": "2023-01-01-preview" + }, + "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", + "properties": { + "alertRuleType": "Microsoft.Insights/metricAlerts", + "displayInformation": { + "infoBallonMessage": "Rule1 InfoBalloon Message", + "infoBallonLink": "Rule1 InfoBalloon Link", + "metricAlertsDisplayInformation": { + "metricDisplayName": "Percentage CPU", + "displayUnits": "Percentage" + } + }, + "ruleArmTemplate": { + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "targetResourceId": { + "type": "string", + "defaultValue": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourcegroups/test/providers/Microsoft.Compute/virtualMachines/testMachineCanBeSafelyDeleted" + }, + "targetResourceName": { + "type": "string", + "defaultValue": "testmachinecanbesafelydeleted" + }, + "actionGroupIds": { + "type": "array", + "defaultValue": [], + "metadata": { + "description": "Insert Action groups ids to attach them to the below alert rules." + } + }, + "alertNamePrefix": { + "type": "string", + "defaultValue": "Percentage CPU", + "minLength": 1, + "metadata": { + "description": "prefix of the alert rule name" + } + }, + "alertName": { + "type": "string", + "defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('targetResourceName'))]", + "minLength": 1, + "metadata": { + "description": "Name of the alert rule" + } + }, + "alertSeverity": { + "type": "int", + "allowedValues": [ + 0, + 1, + 2, + 3, + 4 + ], + "defaultValue": 3, + "metadata": { + "description": "Severity of alert {0,1,2,3,4}" + } + }, + "threshold": { + "type": "int", + "defaultValue": 80, + "metadata": { + "description": "The threshold value at which the alert is activated." + } + } + }, + "variables": { + "scopes": "[array(parameters('targetResourceId'))]", + "copy": [ + { + "name": "actionsForMetricAlerts", + "count": "[length(parameters('actionGroupIds'))]", + "input": { + "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForMetricAlerts')]]" + } + } + ] + }, + "resources": [ + { + "name": "[parameters('alertName')]", + "type": "Microsoft.Insights/metricAlerts", + "apiVersion": "2018-03-01", + "location": "global", + "properties": { + "description": "Percentage CPU is greater than 80 %", + "severity": "[parameters('alertSeverity')]", + "enabled": true, + "scopes": "[variables('scopes')]", + "evaluationFrequency": "PT5M", + "windowSize": "PT5M", + "criteria": { + "odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", + "allOf": [ + { + "name": "Metric1", + "metricName": "Percentage CPU", + "operator": "GreaterThan", + "threshold": "[parameters('threshold')]", + "timeAggregation": "Average" + } + ] + }, + "actions": "[variables('actionsForMetricAlerts')]" + } + } + ] + } + } + }, + { + "id": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourcegroups/test/providers/Microsoft.Compute/virtualMachines/testMachineCanBeSafelyDeleted/providers/Microsoft.AlertsManagement/alertRuleRecommendations/Available Memory Bytes", + "name": "Available Memory Bytes", + "type": "Microsoft.AlertsManagement/alertRuleRecommendations", + "properties": { + "alertRuleType": "Microsoft.Insights/metricAlerts", + "displayInformation": { + "infoBallonMessage": "Rule2 InfoBalloon Message", + "infoBallonLink": "Rule2 InfoBalloon Link", + "metricAlertsDisplayInformation": { + "metricDisplayName": "Available Memory Bytes", + "displayUnits": "Gigabytes" + } + }, + "ruleArmTemplate": { + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "targetResourceId": { + "type": "string", + "defaultValue": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/resourcegroups/test/providers/Microsoft.Compute/virtualMachines/testMachineCanBeSafelyDeleted" + }, + "targetResourceName": { + "type": "string", + "defaultValue": "testmachinecanbesafelydeleted" + }, + "actionGroupIds": { + "type": "array", + "defaultValue": [], + "metadata": { + "description": "Insert Action groups ids to attach them to the below alert rules." + } + }, + "alertNamePrefix": { + "type": "string", + "defaultValue": "Available Memory Bytes", + "minLength": 1, + "metadata": { + "description": "prefix of the alert rule name" + } + }, + "alertName": { + "type": "string", + "defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('targetResourceName'))]", + "minLength": 1, + "metadata": { + "description": "Name of the alert rule" + } + }, + "alertSeverity": { + "type": "int", + "allowedValues": [ + 0, + 1, + 2, + 3, + 4 + ], + "defaultValue": 3, + "metadata": { + "description": "Severity of alert {0,1,2,3,4}" + } + }, + "threshold": { + "type": "int", + "defaultValue": 1000000000, + "metadata": { + "description": "The threshold value at which the alert is activated." + } + } + }, + "variables": { + "scopes": "[array(parameters('targetResourceId'))]", + "copy": [ + { + "name": "actionsForMetricAlerts", + "count": "[length(parameters('actionGroupIds'))]", + "input": { + "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForMetricAlerts')]]" + } + } + ] + }, + "resources": [ + { + "name": "[parameters('alertName')]", + "type": "Microsoft.Insights/metricAlerts", + "apiVersion": "2018-03-01", + "location": "global", + "properties": { + "description": "Available Memory Bytes is less than 1 GB", + "severity": "[parameters('alertSeverity')]", + "enabled": true, + "scopes": "[variables('scopes')]", + "evaluationFrequency": "PT5M", + "windowSize": "PT5M", + "criteria": { + "odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", + "allOf": [ + { + "name": "Metric1", + "metricName": "Available Memory Bytes", + "operator": "LessThan", + "threshold": "[parameters('threshold')]", + "timeAggregation": "Average" + } + ] + }, + "actions": "[variables('actionsForMetricAlerts')]" + } + } + ] + } + } + } + ] + } + } + } +} diff --git a/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-01-01-preview/examples/AlertRuleRecommendations_GetBySubscription_MAC.json b/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-01-01-preview/examples/AlertRuleRecommendations_GetBySubscription_MAC.json new file mode 100644 index 000000000000..e63ced794fe4 --- /dev/null +++ b/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-01-01-preview/examples/AlertRuleRecommendations_GetBySubscription_MAC.json @@ -0,0 +1,283 @@ +{ + "parameters": { + "subscriptionId": "2f00cc51-6809-498f-9ffc-48c42aff570d", + "targetType": "microsoft.monitor/accounts", + "api-version": "2023-01-01-preview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/providers/Microsoft.AlertsManagement/alertRuleRecommendations/NodeRecordingRulesRuleGroup", + "name": "NodeRecordingRulesRuleGroup", + "type": "Microsoft.AlertsManagement/alertRuleRecommendations", + "properties": { + "alertRuleType": "Microsoft.AlertsManagement/prometheusRuleGroups", + "displayInformation": { + "ruleInfo": "Rule Information for first recording rule." + }, + "ruleArmTemplate": { + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "targetResourceId": { + "type": "string" + }, + "targetResourceName": { + "type": "string" + }, + "actionGroupIds": { + "type": "array", + "defaultValue": [], + "metadata": { + "description": "Insert Action groups ids to attach them to the below alert rules." + } + }, + "location": { + "type": "string" + }, + "clusterNameForPrometheus": { + "type": "string" + }, + "alertNamePrefix": { + "type": "string", + "defaultValue": "NodeRecordingRulesRuleGroup", + "minLength": 1, + "metadata": { + "description": "prefix of the alert rule name" + } + }, + "alertName": { + "type": "string", + "defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('clusterNameForPrometheus'))]", + "minLength": 1, + "metadata": { + "description": "Name of the alert rule" + } + } + }, + "variables": { + "scopes": "[array(parameters('targetResourceId'))]", + "copy": [ + { + "name": "actionsForPrometheusRuleGroups", + "count": "[length(parameters('actionGroupIds'))]", + "input": { + "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForPrometheusRuleGroups')]]" + } + } + ] + }, + "resources": [ + { + "name": "[parameters('alertName')]", + "type": "Microsoft.AlertsManagement/prometheusRuleGroups", + "apiVersion": "2021-07-22-preview", + "location": "[parameters('location')]", + "properties": { + "description": "Node Recording Rules RuleGroup", + "scopes": "[variables('scopes')]", + "clusterName": "[parameters('clusterNameForPrometheus')]", + "interval": "PT1M", + "rules": [ + { + "record": "instance:node_num_cpu:sum", + "expression": "count without (cpu, mode) ( node_cpu_seconds_total{job=\"node\",mode=\"idle\"})" + } + ] + } + } + ] + } + } + }, + { + "id": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/providers/Microsoft.AlertsManagement/alertRuleRecommendations/KubernetesReccordingRulesRuleGroup", + "name": "KubernetesReccordingRulesRuleGroup", + "type": "Microsoft.AlertsManagement/alertRuleRecommendations", + "properties": { + "alertRuleType": "Microsoft.AlertsManagement/prometheusRuleGroups", + "displayInformation": { + "ruleInfo": "Rule Information for second recording rule." + }, + "ruleArmTemplate": { + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "targetResourceId": { + "type": "string" + }, + "targetResourceName": { + "type": "string" + }, + "actionGroupIds": { + "type": "array", + "defaultValue": [], + "metadata": { + "description": "Insert Action groups ids to attach them to the below alert rules." + } + }, + "location": { + "type": "string" + }, + "clusterNameForPrometheus": { + "type": "string" + }, + "alertNamePrefix": { + "type": "string", + "defaultValue": "KubernetesReccordingRulesRuleGroup", + "minLength": 1, + "metadata": { + "description": "prefix of the alert rule name" + } + }, + "alertName": { + "type": "string", + "defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('clusterNameForPrometheus'))]", + "minLength": 1, + "metadata": { + "description": "Name of the alert rule" + } + } + }, + "variables": { + "scopes": "[array(parameters('targetResourceId'))]", + "copy": [ + { + "name": "actionsForPrometheusRuleGroups", + "count": "[length(parameters('actionGroupIds'))]", + "input": { + "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForPrometheusRuleGroups')]]" + } + } + ] + }, + "resources": [ + { + "name": "[parameters('alertName')]", + "type": "Microsoft.AlertsManagement/prometheusRuleGroups", + "apiVersion": "2021-07-22-preview", + "location": "[parameters('location')]", + "properties": { + "description": "Kubernetes Recording Rules RuleGroup", + "scopes": "[variables('scopes')]", + "clusterName": "[parameters('clusterNameForPrometheus')]", + "interval": "PT1M", + "rules": [ + { + "record": "node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate", + "expression": "sum by (cluster, namespace, pod, container) ( irate(container_cpu_usage_seconds_total{job=\"cadvisor\", image!=\"\"}[5m])) * on (cluster, namespace, pod) group_left(node) topk by (cluster, namespace, pod) ( 1, max by(cluster, namespace, pod, node) (kube_pod_info{node!=\"\"}))" + } + ] + } + } + ] + } + } + }, + { + "id": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/providers/Microsoft.AlertsManagement/alertRuleRecommendations/KubernetesAlert-DefaultAlerts", + "name": "KubernetesAlert-DefaultAlerts", + "type": "Microsoft.AlertsManagement/alertRuleRecommendations", + "properties": { + "alertRuleType": "Microsoft.AlertsManagement/prometheusRuleGroups", + "displayInformation": { + "ruleInfo": "Rule Information for alerting rule." + }, + "ruleArmTemplate": { + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "targetResourceId": { + "type": "string" + }, + "targetResourceName": { + "type": "string" + }, + "actionGroupIds": { + "type": "array", + "defaultValue": [], + "metadata": { + "description": "Insert Action groups ids to attach them to the below alert rules." + } + }, + "location": { + "type": "string" + }, + "clusterNameForPrometheus": { + "type": "string" + }, + "alertNamePrefix": { + "type": "string", + "defaultValue": "KubernetesAlert-DefaultAlerts", + "minLength": 1, + "metadata": { + "description": "prefix of the alert rule name" + } + }, + "alertName": { + "type": "string", + "defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('clusterNameForPrometheus'))]", + "minLength": 1, + "metadata": { + "description": "Name of the alert rule" + } + } + }, + "variables": { + "scopes": "[array(parameters('targetResourceId'))]", + "copy": [ + { + "name": "actionsForPrometheusRuleGroups", + "count": "[length(parameters('actionGroupIds'))]", + "input": { + "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForPrometheusRuleGroups')]]" + } + } + ] + }, + "resources": [ + { + "name": "[parameters('alertName')]", + "type": "Microsoft.AlertsManagement/prometheusRuleGroups", + "apiVersion": "2021-07-22-preview", + "location": "[parameters('location')]", + "properties": { + "description": "Kubernetes Alert RuleGroup-DefaultAlerts", + "scopes": "[variables('scopes')]", + "clusterName": "[parameters('clusterNameForPrometheus')]", + "interval": "PT1M", + "rules": [ + { + "alert": "KubePodCrashLooping", + "expression": "max_over_time(kube_pod_container_status_waiting_reason{reason=\"CrashLoopBackOff\", job=\"kube-state-metrics\"}[5m]) >= 1", + "for": "PT15M", + "labels": { + "severity": "warning" + }, + "Severity": 3, + "actions": "[variables('actionsForPrometheusRuleGroups')]" + }, + { + "alert": "KubePodNotReady", + "expression": "sum by (namespace, pod, cluster) ( max by(namespace, pod, cluster) ( kube_pod_status_phase{job=\"kube-state-metrics\", phase=~\"Pending|Unknown\"} ) * on(namespace, pod, cluster) group_left(owner_kind) topk by(namespace, pod, cluster) ( 1, max by(namespace, pod, owner_kind, cluster) (kube_pod_owner{owner_kind!=\"Job\"}) )) > 0", + "for": "PT15M", + "labels": { + "severity": "warning" + }, + "Severity": 3, + "actions": "[variables('actionsForPrometheusRuleGroups')]" + } + ] + } + } + ] + } + } + } + ] + } + } + } +} diff --git a/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-01-01-preview/examples/AlertRuleRecommendations_GetBySubscription_VM.json b/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-01-01-preview/examples/AlertRuleRecommendations_GetBySubscription_VM.json new file mode 100644 index 000000000000..09be7e820482 --- /dev/null +++ b/specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2023-01-01-preview/examples/AlertRuleRecommendations_GetBySubscription_VM.json @@ -0,0 +1,241 @@ +{ + "parameters": { + "subscriptionId": "2f00cc51-6809-498f-9ffc-48c42aff570d", + "targetType": "microsoft.compute/virtualmachines", + "api-version": "2023-01-01-preview" + }, + "responses": { + "200": { + "body": { + "value": [ + { + "id": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/providers/Microsoft.AlertsManagement/alertRuleRecommendations/Percentage CPU", + "name": "Percentage CPU", + "type": "Microsoft.AlertsManagement/alertRuleRecommendations", + "properties": { + "alertRuleType": "Microsoft.Insights/metricAlerts", + "displayInformation": { + "infoBallonMessage": "Rule1 InfoBalloon Message", + "infoBallonLink": "Rule1 InfoBalloon Link", + "metricAlertsDisplayInformation": { + "metricDisplayName": "Percentage CPU", + "displayUnits": "Percentage" + } + }, + "ruleArmTemplate": { + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "targetResourceId": { + "type": "string" + }, + "targetResourceName": { + "type": "string" + }, + "actionGroupIds": { + "type": "array", + "defaultValue": [], + "metadata": { + "description": "Insert Action groups ids to attach them to the below alert rules." + } + }, + "alertNamePrefix": { + "type": "string", + "defaultValue": "Percentage CPU", + "minLength": 1, + "metadata": { + "description": "prefix of the alert rule name" + } + }, + "alertName": { + "type": "string", + "defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('targetResourceName'))]", + "minLength": 1, + "metadata": { + "description": "Name of the alert rule" + } + }, + "alertSeverity": { + "type": "int", + "allowedValues": [ + 0, + 1, + 2, + 3, + 4 + ], + "defaultValue": 3, + "metadata": { + "description": "Severity of alert {0,1,2,3,4}" + } + }, + "threshold": { + "type": "int", + "defaultValue": 80, + "metadata": { + "description": "The threshold value at which the alert is activated." + } + } + }, + "variables": { + "scopes": "[array(parameters('targetResourceId'))]", + "copy": [ + { + "name": "actionsForMetricAlerts", + "count": "[length(parameters('actionGroupIds'))]", + "input": { + "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForMetricAlerts')]]" + } + } + ] + }, + "resources": [ + { + "name": "[parameters('alertName')]", + "type": "Microsoft.Insights/metricAlerts", + "apiVersion": "2018-03-01", + "location": "global", + "properties": { + "description": "Percentage CPU is greater than 80 %", + "severity": "[parameters('alertSeverity')]", + "enabled": true, + "scopes": "[variables('scopes')]", + "evaluationFrequency": "PT5M", + "windowSize": "PT5M", + "criteria": { + "odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", + "allOf": [ + { + "name": "Metric1", + "metricName": "Percentage CPU", + "operator": "GreaterThan", + "threshold": "[parameters('threshold')]", + "timeAggregation": "Average" + } + ] + }, + "actions": "[variables('actionsForMetricAlerts')]" + } + } + ] + } + } + }, + { + "id": "/subscriptions/2f00cc51-6809-498f-9ffc-48c42aff570d/providers/Microsoft.AlertsManagement/alertRuleRecommendations/Available Memory Bytes", + "name": "Available Memory Bytes", + "type": "Microsoft.AlertsManagement/alertRuleRecommendations", + "properties": { + "alertRuleType": "Microsoft.Insights/metricAlerts", + "displayInformation": { + "infoBallonMessage": "Rule2 InfoBalloon Message", + "infoBallonLink": "Rule2 InfoBalloon Link", + "metricAlertsDisplayInformation": { + "metricDisplayName": "Available Memory Bytes", + "displayUnits": "Gigabytes" + } + }, + "ruleArmTemplate": { + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "targetResourceId": { + "type": "string" + }, + "targetResourceName": { + "type": "string" + }, + "actionGroupIds": { + "type": "array", + "defaultValue": [], + "metadata": { + "description": "Insert Action groups ids to attach them to the below alert rules." + } + }, + "alertNamePrefix": { + "type": "string", + "defaultValue": "Available Memory Bytes", + "minLength": 1, + "metadata": { + "description": "prefix of the alert rule name" + } + }, + "alertName": { + "type": "string", + "defaultValue": "[concat('parameters('alertNamePrefix'), ' - ', parameters('targetResourceName'))]", + "minLength": 1, + "metadata": { + "description": "Name of the alert rule" + } + }, + "alertSeverity": { + "type": "int", + "allowedValues": [ + 0, + 1, + 2, + 3, + 4 + ], + "defaultValue": 3, + "metadata": { + "description": "Severity of alert {0,1,2,3,4}" + } + }, + "threshold": { + "type": "int", + "defaultValue": 1000000000, + "metadata": { + "description": "The threshold value at which the alert is activated." + } + } + }, + "variables": { + "scopes": "[array(parameters('targetResourceId'))]", + "copy": [ + { + "name": "actionsForMetricAlerts", + "count": "[length(parameters('actionGroupIds'))]", + "input": { + "actiongroupId": "[parameters('actionGroupIds')[copyIndex('actionsForMetricAlerts')]]" + } + } + ] + }, + "resources": [ + { + "name": "[parameters('alertName')]", + "type": "Microsoft.Insights/metricAlerts", + "apiVersion": "2018-03-01", + "location": "global", + "properties": { + "description": "Available Memory Bytes is less than 1 GB", + "severity": "[parameters('alertSeverity')]", + "enabled": true, + "scopes": "[variables('scopes')]", + "evaluationFrequency": "PT5M", + "windowSize": "PT5M", + "criteria": { + "odata.type": "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", + "allOf": [ + { + "name": "Metric1", + "metricName": "Available Memory Bytes", + "operator": "LessThan", + "threshold": "[parameters('threshold')]", + "timeAggregation": "Average" + } + ] + }, + "actions": "[variables('actionsForMetricAlerts')]" + } + } + ] + } + } + } + ] + } + } + } +} diff --git a/specification/alertsmanagement/resource-manager/readme.md b/specification/alertsmanagement/resource-manager/readme.md index 81ebea9dc031..503d91c2d214 100644 --- a/specification/alertsmanagement/resource-manager/readme.md +++ b/specification/alertsmanagement/resource-manager/readme.md @@ -44,6 +44,14 @@ openapi-type: arm tag: package-2021-08 ``` +### Tag: package-preview-2023-01 + +These settings apply only when `--tag=package-preview-2023-01` is specified on the command line. + +```yaml $(tag) == 'package-preview-2023-01' +input-file: + - Microsoft.AlertsManagement/preview/2023-01-01-preview/AlertRuleRecommendations.json +``` ### Tag: package-2021-08 @@ -55,6 +63,7 @@ input-file: - Microsoft.AlertsManagement/preview/2021-07-22-preview/PrometheusRuleGroups.json - Microsoft.AlertsManagement/preview/2019-05-05-preview/AlertsManagement.json - Microsoft.AlertsManagement/preview/2019-05-05-preview/SmartGroups.json + - Microsoft.AlertsManagement/preview/2023-01-01-preview/AlertRuleRecommendations.json ``` ### Tag: package-preview-2021-08