建立 ConfigMap 物件,並在 data 欄位中加入 alertmanager.yml 檔案中的自訂設定。
以下範例顯示 ConfigMap 物件在 alertmanager.yml 檔案中的樣子:
apiVersion:v1kind:ConfigMapmetadata:name:CONFIGMAP_NAME# The namespace must match your project namespace.namespace:PROJECT_NAMESPACEdata:# The file name must be alertmanager.ymlalertmanager.yml:|# Define your notification channels.# Add the custom configuration in the following lines of this file.# Follow the same syntax as in https://prometheus.io/docs/alerting/latest/configuration[...]
# Configure the observability pipeline.apiVersion:observability.gdc.goog/v1kind:ObservabilityPipelinemetadata:# The namespace must match your project namespace.namespace:PROJECT_NAMESPACEname:OBSERVABILITY_PIPELINE_NAMEspec:# Configure alerts.alerting:# The alerting configuration must be in the ConfigMap.# The value must match the ConfigMap name exactly.alertmanagerConfig:CONFIGMAP_NAME[...]
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-04 (世界標準時間)。"],[],[],null,["# Configure notification channels for alerts\n\nThis page outlines the process for configuring notification channels to receive\nalerts.\n\nNotification channels are the delivery mechanisms for your configured alerts.\nThe system notifies designated recipients through these channels when an event\ntriggers an alert. This process ensures that critical alerts reach the\nappropriate personnel through their preferred communication methods.\n\nIn Google Distributed Cloud (GDC) air-gapped appliance environments, predefined notification channels\nlike Slack or email are unavailable. To receive alerts, you must configure at\nleast one custom notification channel. You edit `ObservabilityPipeline` custom\nresources in your project namespace to apply channel configurations.\n\nBy customizing notification channels, administrators can achieve the following:\n\n- **Target specific recipients**: Direct alerts to individuals, teams, or on-call rotations responsible for addressing issues.\n- **Use preferred communication methods**: Deliver alerts through channels like SMS, PagerDuty, webhooks, or custom integrations, catering to individual preferences and operational workflows.\n- **Prevent alert fatigue**: Reduce noise and ensure that alerts are received by those who need to take action.\n\nImplementing notification channels in GDC requires\nadministrators to define the channel configuration within the system. This\nprocess typically involves specifying parameters like:\n\n- **Channel type**: the type of channel being used.\n- **Destination**: the endpoint where the system should send notifications.\n- **Authentication**: any required credentials for accessing the destination.\n\nBy configuring notification channels, administrators can ensure that the\nmonitoring platform effectively delivers critical alerts, enabling prompt\nresponses to potential issues and maintaining the stability and performance of\nGDC environments.\n\nBefore you begin\n----------------\n\nTo get the permissions that you need to manage `ObservabilityPipeline` custom\nresources, ask your Organization IAM Admin or Project IAM Admin to grant you one\nof the associated `ObservabilityPipeline` roles.\n\nAdditionally, to get the permissions that you need to manage `ConfigMap` objects\nin your project namespace required to define configuration rules, ask your\nOrganization IAM Admin or Project IAM Admin to grant you the ConfigMap Creator\nrole.\n\nDepending on the level of access and permissions you need, you might obtain\ncreator, editor, or viewer roles for these resources in an organization or a\nproject. For more information, see [Prepare IAM permissions](/distributed-cloud/hosted/docs/latest/appliance/platform/pa-user/obs-iam-permissions).\n\nConfigure notification channels\n-------------------------------\n\n| **Important:** Before configuring notification channels, ensure you have created alert rules in your project namespace. For more information, see [Create alert rules](/distributed-cloud/hosted/docs/latest/appliance/platform/pa-user/create-alert-rules).\n\nConfigure notification channels for alerts in your project namespace:\n\n1. Define your custom configuration for notification channels in a YAML file\n named `alertmanager.yml`. You must follow the same syntax as the\n Alertmanager specification:\n\n \u003chttps://prometheus.io/docs/alerting/latest/configuration/\u003e.\n2. Create a `ConfigMap` object and include your custom configuration from the\n `alertmanager.yml` file in the `data` field.\n\n The following example shows how the `ConfigMap` object must look with the\n `alertmanager.yml` file: \n\n apiVersion: v1\n kind: ConfigMap\n metadata:\n name: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eCONFIGMAP_NAME\u003c/span\u003e\u003c/var\u003e\n # The namespace must match your project namespace.\n namespace: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003ePROJECT_NAMESPACE\u003c/span\u003e\u003c/var\u003e\n data:\n # The file name must be alertmanager.yml\n alertmanager.yml: |\n # Define your notification channels.\n # Add the custom configuration in the following lines of this file.\n # Follow the same syntax as in https://prometheus.io/docs/alerting/latest/configuration\n\n [...]\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eCONFIGMAP_NAME\u003c/var\u003e: the name of the `ConfigMap` definition file. You use this name later in the `ObservabilityPipeline` custom resource.\n - \u003cvar translate=\"no\"\u003ePROJECT_NAMESPACE\u003c/var\u003e: your project namespace.\n3. Apply the `ConfigMap` object to the Management API server within the\n same namespace as your configured alerts:\n\n kubectl --kubeconfig \u003cvar translate=\"no\"\u003eKUBECONFIG_PATH\u003c/var\u003e apply -f \u003cvar translate=\"no\"\u003eCONFIGMAP_NAME\u003c/var\u003e.yaml\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eKUBECONFIG_PATH\u003c/var\u003e: the path to the kubeconfig file for the Management API server.\n - \u003cvar translate=\"no\"\u003eCONFIGMAP_NAME\u003c/var\u003e: the name of the `ConfigMap` definition file.\n4. Edit the `ObservabilityPipeline` custom resource specification to import\n your configuration to the `alertmanagerConfig` field:\n\n # Configure the observability pipeline.\n apiVersion: observability.gdc.goog/v1\n kind: ObservabilityPipeline\n metadata:\n # The namespace must match your project namespace.\n namespace: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003ePROJECT_NAMESPACE\u003c/span\u003e\u003c/var\u003e\n name: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eOBSERVABILITY_PIPELINE_NAME\u003c/span\u003e\u003c/var\u003e\n spec:\n # Configure alerts.\n alerting:\n # The alerting configuration must be in the ConfigMap.\n # The value must match the ConfigMap name exactly.\n alertmanagerConfig: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eCONFIGMAP_NAME\u003c/span\u003e\u003c/var\u003e\n\n [...]\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003ePROJECT_NAMESPACE\u003c/var\u003e: your project namespace.\n - \u003cvar translate=\"no\"\u003eOBSERVABILITY_PIPELINE_NAME\u003c/var\u003e: the name of the `ObservabilityPipeline` custom resource.\n - \u003cvar translate=\"no\"\u003eCONFIGMAP_NAME\u003c/var\u003e: the name you used for the `ConfigMap` definition file. The name must match exactly.\n\n | **Note:** In the `alerting` field of the `ObservabilityPipeline` custom resource, you can also define other configurations for the project namespace such as volumes (`volumes`) and volume mounts (`volumeMounts`). You reference volume mount names in the `alertmanager.yml` file.\n5. Save the file.\n\n6. Apply the changes of the `ObservabilityPipeline` custom resource to the\n Management API server within the same namespace as your configured alerts:\n\n kubectl --kubeconfig \u003cvar translate=\"no\"\u003eKUBECONFIG_PATH\u003c/var\u003e apply -f \u003cvar translate=\"no\"\u003eOBSERVABILITY_PIPELINE_NAME\u003c/var\u003e.yaml\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eKUBECONFIG_PATH\u003c/var\u003e: the path to the kubeconfig file for the Management API server.\n - \u003cvar translate=\"no\"\u003eOBSERVABILITY_PIPELINE_NAME\u003c/var\u003e: the name of the `ObservabilityPipeline` definition file."]]