你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
Prometheus Rule Groups - Create Or Update
创建或更新 Prometheus 规则组定义。
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/prometheusRuleGroups/{ruleGroupName}?api-version=2023-03-01
URI 参数
名称 | 在 | 必需 | 类型 | 说明 |
---|---|---|---|---|
resource
|
path | True |
string |
资源组的名称。 此名称不区分大小写。 |
rule
|
path | True |
string |
规则组的名称。 正则表达式模式: |
subscription
|
path | True |
string |
目标订阅的 ID。 |
api-version
|
query | True |
string |
要用于此操作的 API 版本。 |
请求正文
名称 | 必需 | 类型 | 说明 |
---|---|---|---|
location | True |
string |
资源所在的地理位置 |
properties.rules | True |
定义 Prometheus 规则组中的规则。 |
|
properties.scopes | True |
string[] |
目标 Azure Monitor 工作区资源 ID。 此 API 版本当前仅限于使用一个范围创建。 这在将来可能会更改。 |
properties.clusterName |
string |
将规则应用于特定群集中的数据。 |
|
properties.description |
string |
规则组说明。 |
|
properties.enabled |
boolean |
启用/禁用规则组。 |
|
properties.interval |
string |
运行以 ISO 8601 持续时间格式表示的 Prometheus 规则组的时间间隔。 应介于 1 到 15 分钟之间 |
|
tags |
object |
资源标记。 |
响应
名称 | 类型 | 说明 |
---|---|---|
200 OK |
确定 (已更新) 。 |
|
201 Created |
已创建 () 创建新的警报规则。 |
|
Other Status Codes |
描述操作失败原因的错误响应。 |
示例
Create or Update a cluster centric Prometheus |
Create or Update a Prometheus |
Create or Update a cluster centric PrometheusRuleGroup
示例请求
PUT https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/promResourceGroup/providers/Microsoft.AlertsManagement/prometheusRuleGroups/myPrometheusRuleGroup?api-version=2023-03-01
{
"location": "East US",
"properties": {
"description": "This is a rule group with culster centric configuration",
"interval": "PT10M",
"clusterName": "myClusterName",
"scopes": [
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/myResourceGroup/providers/microsoft.monitor/accounts/myAzureMonitorWorkspace",
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/myResourceGroup/providers/Microsoft.ContainerService/managedClusters/myClusterName"
],
"rules": [
{
"alert": "Billing_Processing_Very_Slow",
"expression": "job_type:billing_jobs_duration_seconds:99p5m > 30",
"enabled": true,
"severity": 2,
"for": "PT5M",
"labels": {
"team": "prod"
},
"annotations": {
"annotationName1": "annotationValue1"
},
"resolveConfiguration": {
"autoResolved": true,
"timeToResolve": "PT10M"
},
"actions": []
}
]
}
}
示例响应
{
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/promResourceGroup/providers/Microsoft.AlertsManagement/prometheusRuleGroups/myPrometheusRuleGroup",
"type": "Microsoft.AlertsManagement/prometheusRuleGroups",
"location": "East US",
"properties": {
"description": "This is a rule group with culster centric configuration",
"interval": "PT10M",
"clusterName": "myClusterName",
"scopes": [
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/myResourceGroup/providers/microsoft.monitor/accounts/myAzureMonitorWorkspace",
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/myResourceGroup/providers/Microsoft.ContainerService/managedClusters/myClusterName"
],
"rules": [
{
"alert": "Billing_Processing_Very_Slow",
"expression": "job_type:billing_jobs_duration_seconds:99p5m > 30",
"enabled": true,
"severity": 2,
"for": "PT5M",
"labels": {
"team": "prod"
},
"annotations": {
"annotationName1": "annotationValue1"
},
"resolveConfiguration": {
"autoResolved": true,
"timeToResolve": "PT10M"
},
"actions": []
}
]
}
}
{
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/promResourceGroup/providers/Microsoft.AlertsManagement/prometheusRuleGroups/myPrometheusRuleGroup",
"type": "Microsoft.AlertsManagement/prometheusRuleGroups",
"location": "East US",
"properties": {
"description": "This is a rule group with culster centric configuration",
"interval": "PT10M",
"clusterName": "myClusterName",
"scopes": [
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/myResourceGroup/providers/microsoft.monitor/accounts/myAzureMonitorWorkspace",
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/myResourceGroup/providers/Microsoft.ContainerService/managedClusters/myClusterName"
],
"rules": [
{
"alert": "Billing_Processing_Very_Slow",
"expression": "job_type:billing_jobs_duration_seconds:99p5m > 30",
"enabled": true,
"severity": 2,
"for": "PT5M",
"labels": {
"team": "prod"
},
"annotations": {
"annotationName1": "annotationValue1"
},
"resolveConfiguration": {
"autoResolved": true,
"timeToResolve": "PT10M"
},
"actions": []
}
]
}
}
Create or Update a PrometheusRuleGroup
示例请求
PUT https://management.azure.com/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/promResourceGroup/providers/Microsoft.AlertsManagement/prometheusRuleGroups/myPrometheusRuleGroup?api-version=2023-03-01
{
"location": "East US",
"properties": {
"description": "This is the description of the following rule group",
"enabled": true,
"interval": "PT10M",
"clusterName": "myClusterName",
"scopes": [
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/myResourceGroup/providers/microsoft.monitor/accounts/myAzureMonitorWorkspace"
],
"rules": [
{
"record": "job_type:billing_jobs_duration_seconds:99p5m",
"expression": "histogram_quantile(0.99, sum(rate(jobs_duration_seconds_bucket{service=\"billing-processing\"}[5m])) by (job_type))",
"labels": {
"team": "prod"
}
},
{
"alert": "Billing_Processing_Very_Slow",
"expression": "job_type:billing_jobs_duration_seconds:99p5m > 30",
"enabled": true,
"severity": 2,
"for": "PT5M",
"labels": {
"team": "prod"
},
"annotations": {
"annotationName1": "annotationValue1"
},
"resolveConfiguration": {
"autoResolved": true,
"timeToResolve": "PT10M"
},
"actions": [
{
"actionGroupId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/myrg/providers/microsoft.insights/actiongroups/myactiongroup",
"actionProperties": {
"key11": "value11",
"key12": "value12"
}
},
{
"actionGroupId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/myrg/providers/microsoft.insights/actiongroups/myotheractiongroup",
"actionProperties": {
"key21": "value21",
"key22": "value22"
}
}
]
}
]
}
}
示例响应
{
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/promResourceGroup/providers/Microsoft.AlertsManagement/prometheusRuleGroups/myPrometheusRuleGroup",
"type": "Microsoft.AlertsManagement/prometheusRuleGroups",
"location": "East US",
"properties": {
"description": "This is the description of the following rule group",
"enabled": true,
"interval": "PT10M",
"clusterName": "myClusterName",
"scopes": [
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/myResourceGroup/providers/microsoft.monitor/accounts/myAzureMonitorWorkspace"
],
"rules": [
{
"record": "job_type:billing_jobs_duration_seconds:99p5m",
"expression": "histogram_quantile(0.99, sum(rate(jobs_duration_seconds_bucket{service=\"billing-processing\"}[5m])) by (job_type))",
"labels": {
"team": "prod"
}
},
{
"alert": "Billing_Processing_Very_Slow",
"expression": "job_type:billing_jobs_duration_seconds:99p5m > 30",
"enabled": true,
"severity": 2,
"for": "PT5M",
"labels": {
"team": "prod"
},
"annotations": {
"annotationName1": "annotationValue1"
},
"resolveConfiguration": {
"autoResolved": true,
"timeToResolve": "PT10M"
},
"actions": [
{
"actionGroupId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/myrg/providers/microsoft.insights/actiongroups/myactiongroup",
"actionProperties": {
"key11": "value11",
"key12": "value12"
}
},
{
"actionGroupId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/myrg/providers/microsoft.insights/actiongroups/myotheractiongroup",
"actionProperties": {
"key21": "value21",
"key22": "value22"
}
}
]
}
]
}
}
{
"id": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/promResourceGroup/providers/Microsoft.AlertsManagement/prometheusRuleGroups/myPrometheusRuleGroup",
"type": "Microsoft.AlertsManagement/prometheusRuleGroups",
"location": "East US",
"properties": {
"description": "This is the description of the following rule group",
"enabled": true,
"interval": "PT10M",
"clusterName": "myClusterName",
"scopes": [
"/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/myResourceGroup/providers/microsoft.monitor/accounts/myAzureMonitorWorkspace"
],
"rules": [
{
"record": "job_type:billing_jobs_duration_seconds:99p5m",
"expression": "histogram_quantile(0.99, sum(rate(jobs_duration_seconds_bucket{service=\"billing-processing\"}[5m])) by (job_type))",
"labels": {
"team": "prod"
}
},
{
"alert": "Billing_Processing_Very_Slow",
"expression": "job_type:billing_jobs_duration_seconds:99p5m > 30",
"enabled": true,
"severity": 2,
"for": "PT5M",
"labels": {
"team": "prod"
},
"annotations": {
"annotationName1": "annotationValue1"
},
"resolveConfiguration": {
"autoResolved": true,
"timeToResolve": "PT10M"
},
"actions": [
{
"actionGroupId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/myrg/providers/microsoft.insights/actiongroups/myactiongroup",
"actionProperties": {
"key11": "value11",
"key12": "value12"
}
},
{
"actionGroupId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/myrg/providers/microsoft.insights/actiongroups/myotheractiongroup",
"actionProperties": {
"key21": "value21",
"key22": "value22"
}
}
]
}
]
}
}
定义
名称 | 说明 |
---|---|
created |
创建资源的标识类型。 |
Error |
资源管理错误附加信息。 |
Error |
错误详细信息。 |
Error |
错误响应 |
Prometheus |
Azure Prometheus 警报或记录规则。 |
Prometheus |
警报操作。 仅与警报相关。 |
Prometheus |
Prometheus 规则组资源。 |
Prometheus |
指定 Prometheus 警报规则配置。 |
system |
与资源的创建和上次修改相关的元数据。 |
createdByType
创建资源的标识类型。
名称 | 类型 | 说明 |
---|---|---|
Application |
string |
|
Key |
string |
|
ManagedIdentity |
string |
|
User |
string |
ErrorAdditionalInfo
资源管理错误附加信息。
名称 | 类型 | 说明 |
---|---|---|
info |
object |
其他信息。 |
type |
string |
其他信息类型。 |
ErrorDetail
错误详细信息。
名称 | 类型 | 说明 |
---|---|---|
additionalInfo |
错误附加信息。 |
|
code |
string |
错误代码。 |
details |
错误详细信息。 |
|
message |
string |
错误消息。 |
target |
string |
错误目标。 |
ErrorResponse
错误响应
名称 | 类型 | 说明 |
---|---|---|
error |
错误对象。 |
PrometheusRule
Azure Prometheus 警报或记录规则。
名称 | 类型 | 说明 |
---|---|---|
actions |
警报规则变为活动状态时以及解决警报条件时执行的操作。 |
|
alert |
string |
警报规则名称。 |
annotations |
object |
annotations 子句指定一组信息标签,可用于存储较长的其他信息,例如警报说明或 Runbook 链接。 批注值可以进行模板化。 |
enabled |
boolean |
启用/禁用规则。 |
expression |
string |
要计算的 PromQL 表达式。 https://prometheus.io/docs/prometheus/latest/querying/basics/. 按“interval”给定定期计算,结果记录为一组新的时序,指标名称由“record”提供。 |
for |
string |
触发前警报必须处于活动状态的时间量。 |
labels |
object |
存储结果之前要添加或覆盖的标签。 |
record |
string |
记录的指标名称。 |
resolveConfiguration |
定义用于解决触发的警报的配置。 仅与警报相关。 |
|
severity |
integer |
规则触发的警报的严重性。 必须介于 0 和 4 之间。 |
PrometheusRuleGroupAction
警报操作。 仅与警报相关。
名称 | 类型 | 说明 |
---|---|---|
actionGroupId |
string |
要使用的操作组的资源 ID。 |
actionProperties |
object |
操作组对象的属性。 |
PrometheusRuleGroupResource
Prometheus 规则组资源。
名称 | 类型 | 说明 |
---|---|---|
id |
string |
资源的完全限定的资源 ID。 例如 - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} |
location |
string |
资源所在的地理位置 |
name |
string |
资源的名称 |
properties.clusterName |
string |
将规则应用于特定群集中的数据。 |
properties.description |
string |
规则组说明。 |
properties.enabled |
boolean |
启用/禁用规则组。 |
properties.interval |
string |
运行以 ISO 8601 持续时间格式表示的 Prometheus 规则组的时间间隔。 应介于 1 到 15 分钟之间 |
properties.rules |
定义 Prometheus 规则组中的规则。 |
|
properties.scopes |
string[] |
目标 Azure Monitor 工作区资源 ID。 此 API 版本当前仅限于使用一个范围创建。 这在将来可能会更改。 |
systemData |
包含 createdBy 和 modifiedBy 信息的 Azure 资源管理器元数据。 |
|
tags |
object |
资源标记。 |
type |
string |
资源类型。 例如“Microsoft.Compute/virtualMachines”或“Microsoft.Storage/storageAccounts” |
PrometheusRuleResolveConfiguration
指定 Prometheus 警报规则配置。
名称 | 类型 | 说明 |
---|---|---|
autoResolved |
boolean |
启用警报自动解决。 |
timeToResolve |
string |
警报自动解决超时。 |
systemData
与资源的创建和上次修改相关的元数据。
名称 | 类型 | 说明 |
---|---|---|
createdAt |
string |
资源创建时间戳 (UTC) 。 |
createdBy |
string |
创建资源的标识。 |
createdByType |
创建资源的标识类型。 |
|
lastModifiedAt |
string |
资源上次修改的时间戳 (UTC) |
lastModifiedBy |
string |
上次修改资源的标识。 |
lastModifiedByType |
上次修改资源的标识类型。 |