建立規則檔案 - Amazon Managed Service for Prometheus

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

建立規則檔案

若要在 Amazon Managed Service for Prometheus 中使用規則,您會建立定義規則的規則檔案。Amazon Managed Service for Prometheus 規則檔案的格式,與獨立 Prometheus 中規則檔案的格式相同。如需詳細資訊,請參閱定義記錄規則警示規則

以下是規則檔案的基本範例:

groups: - name: test rules: - record: metric:recording_rule expr: avg(rate(container_cpu_usage_seconds_total[5m])) - name: alert-test rules: - alert: metric:alerting_rule expr: avg(rate(container_cpu_usage_seconds_total[5m])) > 0 for: 2m

如需更多警示規則範例,請參閱警示規則範例

注意

您可以在本機建立規則定義檔案,然後將其上傳到 Prometheus 的 Amazon 受管服務,也可以直接在 Prometheus 的 Amazon 受管服務主控台中建立、編輯和上傳定義。無論哪種方式,都適用相同的格式規則。若要進一步瞭解如何上傳和編輯檔案,請參閱將規則組態檔案上傳至適用於 Prometheus 的 Amazon 受管服務