搜索

7.3. 添加 Alertmanager Webhook

download PDF

您可以向现有 Alertmanager 配置添加新 webhook,以接收有关存储集群运行状况的实时警报。您必须启用传入的 webhook,以允许将消息异步到第三方应用程序中。

例如,如果一个 OSD 在 Red Hat Ceph Storage 集群中停机,您可以将 Alertmanager 配置为在 Google chat 上发送通知。

前提条件

  • 正在运行的 Red Hat Ceph Storage 集群启用了监控堆栈组件。
  • 在接收第三方应用程序上配置的传入 Webhook。

流程

  1. 登录 cephadm shell:

    示例

    [root@host01 ~]# cephadm shell

  2. 将 Alertmanager 配置为使用 Webhook 进行通知:

    语法

    service_type: alertmanager
    spec:
      user_data:
        default_webhook_urls:
        - "_URLS_"

    default_webhook_urls 是添加到默认接收器 webhook_configs 配置中的额外 URL 列表。

    示例

    service_type: alertmanager
    spec:
      user_data:
        webhook_configs:
        - url: 'http:127.0.0.10:8080'

  3. 更新 Alertmanager 配置:

    示例

    [ceph: root@host01 /]#  ceph orch reconfig alertmanager

验证

  • 从 Alertmanager 到 Gchat 的通知示例:

    示例

    using: https://chat.googleapis.com/v1/spaces/(xx- space identifyer -xx)/messages
    posting: {'status': 'resolved', 'labels': {'alertname': 'PrometheusTargetMissing', 'instance': 'postgres-exporter.host03.chest
    response: 200
    response: {
    "name": "spaces/(xx- space identifyer -xx)/messages/3PYDBOsIofE.3PYDBOsIofE",
    "sender": {
    "name": "users/114022495153014004089",
    "displayName": "monitoring",
    "avatarUrl": "",
    "email": "",
    "domainId": "",
    "type": "BOT",
    "isAnonymous": false,
    "caaEnabled": false
    },
    "text": "Prometheus target missing (instance postgres-exporter.cluster.local:9187)\n\nA Prometheus target has disappeared. An e
    "cards": [],
    "annotations": [],
    "thread": {
    "name": "spaces/(xx- space identifyer -xx)/threads/3PYDBOsIofE"
    },
    "space": {
    "name": "spaces/(xx- space identifyer -xx)",
    "type": "ROOM",
    "singleUserBotDm": false,
    "threaded": false,
    "displayName": "_privmon",
    "legacyGroupChat": false
    },
    "fallbackText": "",
    "argumentText": "Prometheus target missing (instance postgres-exporter.cluster.local:9187)\n\nA Prometheus target has disappea
    "attachment": [],
    "createTime": "2022-06-06T06:17:33.805375Z",
    "lastUpdateTime": "2022-06-06T06:17:33.805375Z"

Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.