Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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"
);
Original file line number Diff line number Diff line change
@@ -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"
}
Loading
Loading