Bagikan melalui


Prometheus Rule Groups - Create Or Update

Membuat atau memperbarui definisi grup aturan Prometheus.

PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/prometheusRuleGroups/{ruleGroupName}?api-version=2023-03-01

Parameter URI

Nama Dalam Diperlukan Jenis Deskripsi
resourceGroupName
path True

string

Nama grup sumber daya. Nama tidak peka huruf besar/kecil.

ruleGroupName
path True

string

Nama grup aturan.

Regex pattern: ^[^:@/#{}%&+*<>?]+$

subscriptionId
path True

string

ID langganan target.

api-version
query True

string

Versi API yang digunakan untuk operasi ini.

Isi Permintaan

Nama Diperlukan Jenis Deskripsi
location True

string

Lokasi geografis tempat sumber daya berada

properties.rules True

PrometheusRule[]

Menentukan aturan dalam grup aturan Prometheus.

properties.scopes True

string[]

Id sumber daya ruang kerja Azure Monitor target. Versi api ini saat ini terbatas pada pembuatan dengan satu cakupan. Hal ini dapat berubah di masa mendatang.

properties.clusterName

string

Menerapkan aturan ke data dari kluster tertentu.

properties.description

string

Deskripsi grup aturan.

properties.enabled

boolean

Aktifkan/nonaktifkan grup aturan.

properties.interval

string

Interval untuk menjalankan grup aturan Prometheus yang diwakili dalam format durasi ISO 8601. Harus antara 1 dan 15 menit

tags

object

Tag sumber daya.

Respons

Nama Jenis Deskripsi
200 OK

PrometheusRuleGroupResource

OK (Diperbarui).

201 Created

PrometheusRuleGroupResource

Dibuat (Aturan Pemberitahuan Baru dibuat).

Other Status Codes

ErrorResponse

Respons kesalahan yang menjelaskan mengapa operasi gagal.

Contoh

Create or Update a cluster centric PrometheusRuleGroup
Create or Update a PrometheusRuleGroup

Create or Update a cluster centric PrometheusRuleGroup

Sample Request

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": []
      }
    ]
  }
}

Sample Response

{
  "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

Sample Request

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"
            }
          }
        ]
      }
    ]
  }
}

Sample Response

{
  "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"
            }
          }
        ]
      }
    ]
  }
}

Definisi

Nama Deskripsi
createdByType

Jenis identitas yang membuat sumber daya.

ErrorAdditionalInfo

Info tambahan kesalahan manajemen sumber daya.

ErrorDetail

Detail kesalahan.

ErrorResponse

Respons kesalahan

PrometheusRule

Aturan pemberitahuan atau perekaman Azure Prometheus.

PrometheusRuleGroupAction

Tindakan pemberitahuan. Hanya relevan untuk pemberitahuan.

PrometheusRuleGroupResource

Sumber daya grup aturan Prometheus.

PrometheusRuleResolveConfiguration

Menentukan konfigurasi aturan pemberitahuan Prometheus.

systemData

Metadata yang berkaitan dengan pembuatan dan modifikasi terakhir sumber daya.

createdByType

Jenis identitas yang membuat sumber daya.

Nama Jenis Deskripsi
Application

string

Key

string

ManagedIdentity

string

User

string

ErrorAdditionalInfo

Info tambahan kesalahan manajemen sumber daya.

Nama Jenis Deskripsi
info

object

Info tambahan.

type

string

Jenis info tambahan.

ErrorDetail

Detail kesalahan.

Nama Jenis Deskripsi
additionalInfo

ErrorAdditionalInfo[]

Info tambahan kesalahan.

code

string

Kode kesalahan.

details

ErrorDetail[]

Detail kesalahan.

message

string

Pesan kesalahan.

target

string

Target kesalahan.

ErrorResponse

Respons kesalahan

Nama Jenis Deskripsi
error

ErrorDetail

Objek kesalahan.

PrometheusRule

Aturan pemberitahuan atau perekaman Azure Prometheus.

Nama Jenis Deskripsi
actions

PrometheusRuleGroupAction[]

Tindakan yang dilakukan saat aturan pemberitahuan menjadi aktif, dan saat kondisi pemberitahuan diselesaikan.

alert

string

Nama aturan pemberitahuan.

annotations

object

Klausa anotasi menentukan sekumpulan label informasi yang dapat digunakan untuk menyimpan informasi tambahan yang lebih panjang seperti deskripsi pemberitahuan atau tautan runbook. Nilai anotasi dapat di-template.

enabled

boolean

Aktifkan/nonaktifkan aturan.

expression

string

Ekspresi PromQL untuk dievaluasi. https://prometheus.io/docs/prometheus/latest/querying/basics/. Dievaluasi secara berkala seperti yang diberikan oleh 'interval', dan hasilnya dicatat sebagai kumpulan rangkaian waktu baru dengan nama metrik seperti yang diberikan oleh 'rekaman'.

for

string

Jumlah pemberitahuan waktu harus aktif sebelum diaktifkan.

labels

object

Label untuk menambah atau menimpa sebelum menyimpan hasilnya.

record

string

Nama metrik yang direkam.

resolveConfiguration

PrometheusRuleResolveConfiguration

Menentukan konfigurasi untuk menyelesaikan pemberitahuan yang diaktifkan. Hanya relevan untuk pemberitahuan.

severity

integer

Tingkat keparahan pemberitahuan yang diaktifkan oleh aturan. Harus antara 0 dan 4.

PrometheusRuleGroupAction

Tindakan pemberitahuan. Hanya relevan untuk pemberitahuan.

Nama Jenis Deskripsi
actionGroupId

string

Id sumber daya dari grup tindakan yang akan digunakan.

actionProperties

object

Properti objek grup tindakan.

PrometheusRuleGroupResource

Sumber daya grup aturan Prometheus.

Nama Jenis Deskripsi
id

string

ID sumber daya yang sepenuhnya memenuhi syarat untuk sumber daya. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}

location

string

Lokasi geografis tempat sumber daya berada

name

string

Nama sumber daya.

properties.clusterName

string

Menerapkan aturan ke data dari kluster tertentu.

properties.description

string

Deskripsi grup aturan.

properties.enabled

boolean

Aktifkan/nonaktifkan grup aturan.

properties.interval

string

Interval untuk menjalankan grup aturan Prometheus yang diwakili dalam format durasi ISO 8601. Harus antara 1 dan 15 menit

properties.rules

PrometheusRule[]

Menentukan aturan dalam grup aturan Prometheus.

properties.scopes

string[]

Id sumber daya ruang kerja Azure Monitor target. Versi api ini saat ini terbatas pada pembuatan dengan satu cakupan. Hal ini dapat berubah di masa mendatang.

systemData

systemData

Metadata Azure Resource Manager yang berisi informasi createdBy dan modifiedBy.

tags

object

Tag sumber daya.

type

string

Jenis sumber daya. Misalnya, "Microsoft.Compute/virtualMachines" atau "Microsoft.Storage/storageAccounts"

PrometheusRuleResolveConfiguration

Menentukan konfigurasi aturan pemberitahuan Prometheus.

Nama Jenis Deskripsi
autoResolved

boolean

Aktifkan resolusi otomatis pemberitahuan.

timeToResolve

string

Batas waktu resolusi otomatis pemberitahuan.

systemData

Metadata yang berkaitan dengan pembuatan dan modifikasi terakhir sumber daya.

Nama Jenis Deskripsi
createdAt

string

Tanda waktu pembuatan sumber daya (UTC).

createdBy

string

Identitas yang membuat sumber daya.

createdByType

createdByType

Jenis identitas yang membuat sumber daya.

lastModifiedAt

string

Tanda waktu modifikasi terakhir sumber daya (UTC)

lastModifiedBy

string

Identitas yang terakhir memodifikasi sumber daya.

lastModifiedByType

createdByType

Jenis identitas yang terakhir mengubah sumber daya.