Membuat aturan alert.
Deskripsi operasi
Kami menyarankan Anda memanggil operasi CreateOrUpdateAlertRule untuk membuat aturan alert Prometheus.
Coba sekarang
Test
RAM authorization
Parameter permintaan
|
Parameter |
Type |
Required |
Description |
Example |
| RegionId |
string |
Yes |
ID Wilayah. |
cn-hangzhou |
| AlertName |
string |
Yes |
Nama aturan alert. |
Prometheus_Alert |
| ClusterId |
string |
Yes |
ID Kluster. |
c0bad479465464e1d8c1e641b0afb**** |
| Type |
string |
No |
Tipe aturan alert.
|
101 |
| NotifyType |
string |
No |
Tipe Notifikasi. Nilai valid:
|
ALERT_MANAGER |
| DispatchRuleId |
integer |
No |
ID Kebijakan Notifikasi. Parameter ini wajib diisi saat NotifyType diatur ke |
10282 |
| Expression |
string |
Yes |
Ekspresi alert. Ekspresi harus berupa pernyataan PromQL. |
100 * (sum(rate(container_cpu_usage_seconds_total[1m])) by (pod_name) / sum(label_replace(kube_pod_container_resource_limits_cpu_cores, \"pod_name\", \"$1\", \"pod\", \"(.*)\")) by (pod_name))>75 |
| Duration |
string |
Yes |
Durasi. Nilai valid: 1m hingga 1440m. Unit: minutes. |
10m |
| Message |
string |
Yes |
Paket alert. Anda dapat mereferensikan Label dalam format {{$labels.xxx}}. |
${{$labels.pod_name}}CPU使用率大于80%,当前值{{$value}}% |
| Labels |
string |
No |
String JSON Label. Anda harus menentukan Name dan Value Label. |
[{"Value": "critical","Name": "severity"}] |
| Annotations |
string |
No |
String JSON Anotasi. Anda harus menentukan Name dan Value Anotasi. |
[{"Value": "xxx","Name": "description"}] |
| Tags |
array<object> |
No |
Tag. |
|
|
object |
No |
Tag. |
||
| Key |
string |
No |
Kunci tag. |
type |
| Value |
string |
No |
Nilai tag. |
value1 |
Elemen respons
|
Element |
Type |
Description |
Example |
|
object |
|||
| RequestId |
string |
ID permintaan. |
9FEA6D00-317F-45E3-9004-7FB8B0B7**** |
| PrometheusAlertRule |
object |
Struktur yang dikembalikan. |
|
| Status |
integer |
Apakah aturan alert diaktifkan. Nilai valid:
|
1 |
| Type |
string |
Tipe aturan alert. |
Kubernetes组件告警 |
| NotifyType |
string |
Tipe Notifikasi. Nilai valid:
|
ALERT_MANAGER |
| Expression |
string |
Ekspresi alert. |
100 * (sum(rate(container_cpu_usage_seconds_total[1m])) by (pod_name) / sum(label_replace(kube_pod_container_resource_limits_cpu_cores, \"pod_name\", \"$1\", \"pod\", \"(.*)\")) by (pod_name))>75 |
| Message |
string |
Paket alert. Anda dapat mereferensikan Label dalam format {{$labels.xxx}}. |
${{$labels.pod_name}}CPU使用率大于80%,当前值{{$value}}% |
| Duration |
string |
Durasi. Nilai valid: 1m hingga 1440m. Unit: minutes. |
10m |
| DispatchRuleId |
integer |
ID Kebijakan Notifikasi. |
10282 |
| AlertName |
string |
Nama aturan alert. |
Prometheus_Alert |
| AlertId |
integer |
ID aturan alert. |
3888704 |
| ClusterId |
string |
ID Kluster. |
c0bad479465464e1d8c1e641b0afb**** |
| Labels |
array<object> |
Label aturan alert. |
|
|
object |
|||
| Name |
string |
The name of the tag. |
severity |
| Value |
string |
The value of the tag. |
critical |
| Annotations |
array<object> |
Anotasi aturan alert. |
|
|
object |
Anotasi aturan alert. |
||
| Name |
string |
The name of the annotation. |
message |
| Value |
string |
The value of the annotation. |
${{$labels.pod_name}}CPU使用率大于80%,当前值{{$value}}% |
| Code |
integer |
Kode status. Nilai 200 menunjukkan bahwa permintaan berhasil. |
200 |
| Success |
boolean |
Apakah pemanggilan berhasil. |
true |
| Message |
string |
Paket yang dikembalikan. |
success |
Contoh
Respons sukses
JSONformat
{
"RequestId": "9FEA6D00-317F-45E3-9004-7FB8B0B7****",
"PrometheusAlertRule": {
"Status": 1,
"Type": "Kubernetes组件告警",
"NotifyType": "ALERT_MANAGER",
"Expression": "100 * (sum(rate(container_cpu_usage_seconds_total[1m])) by (pod_name) / sum(label_replace(kube_pod_container_resource_limits_cpu_cores, \\\"pod_name\\\", \\\"$1\\\", \\\"pod\\\", \\\"(.*)\\\")) by (pod_name))>75",
"Message": "${{$labels.pod_name}}CPU使用率大于80%,当前值{{$value}}%",
"Duration": "10m",
"DispatchRuleId": 10282,
"AlertName": "Prometheus_Alert",
"AlertId": 3888704,
"ClusterId": "c0bad479465464e1d8c1e641b0afb****",
"Labels": [
{
"Name": "severity",
"Value": "critical"
}
],
"Annotations": [
{
"Name": "message",
"Value": "${{$labels.pod_name}}CPU使用率大于80%,当前值{{$value}}%"
}
]
},
"Code": 200,
"Success": true,
"Message": "success"
}
Kode kesalahan
Lihat Error Codes untuk daftar lengkap.
Catatan rilis
Lihat Release Notes untuk daftar lengkap.