首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在kube-prometheus-堆栈舵机图中覆盖警报管理器配置

如何在kube-prometheus-堆栈舵机图中覆盖警报管理器配置
EN

Stack Overflow用户
提问于 2022-04-19 12:12:54
回答 2查看 3.4K关注 0票数 3

我正在从kube-prometheus-stack头盔图中部署一个监视堆栈,并且我正在尝试配置警报管理器,以便它具有在Slack通道中进行警报的自定义配置。

吊舱中的配置是从/etc/alertmanager/config/alertmanager.yaml加载的。根据荚描述,这个文件是从自动生成的秘密中加载的:

代码语言:javascript
运行
复制
...
  volumeMounts:
   - mountPath: /etc/alertmanager/config
     name: config-volume
...
volumes:
  - name: config-volume
    secret:
      defaultMode: 420
      secretName: alertmanager-prometheus-community-kube-alertmanager-generated

如果我检查这个秘密,它包含在alertmanager.config中的默认值中找到的默认配置,我打算覆盖它。

如果我将以下配置传递给警报管理器以重新安装图表,则不会创建警报管理器荚:

代码语言:javascript
运行
复制
alertmanager:
  config:
    global:
      resolve_timeout: 5m
    route:
      group_by: ['job', 'alertname', 'priority']
      group_wait: 10s
      group_interval: 1m
      routes:
      - match:
          alertname: Watchdog
        receiver: 'null'
      - receiver: 'slack-notifications'
        continue: true
    receivers:
    - name: 'slack-notifications'
      slack-configs:
      - slack_api_url: <url here>
        title: '{{ .Status }} ({{ .Alerts.Firing | len }}): {{ .GroupLabels.SortedPairs.Values | join " " }}'
        text: '<!channel> {{ .CommonAnnotations.summary }}'
        channel: '#mychannel'

首先,如果我没有在values.yaml中传递任何配置,那么就成功地创建了警报管理器pod。

如何正确地覆盖警报管理器的配置,以便将使用自定义配置的正确文件装入/etc/alertmanger/config/alertmanager.yaml

EN

回答 2

Stack Overflow用户

发布于 2022-08-11 13:17:03

警报管理器需要某些非默认参数来覆盖默认值,因为它似乎在沉默中失败了。配置错误会导致吊舱不应用配置(https://github.com/prometheus-community/helm-charts/issues/1998)。对我起作用的是仔细配置警报管理器,并添加一个看门狗子路由和空接收器。

代码语言:javascript
运行
复制
route:
  group_by: [ '...' ]
  group_wait: 30s
  group_interval: 10s
  repeat_interval: 10s
  receiver: 'user1'
  routes:
    - match:
        alertname: Watchdog
        receiver: 'null'
receivers:
  - name: 'null'
  - ...
票数 2
EN

Stack Overflow用户

发布于 2022-04-20 11:20:56

也许以下步骤可以解决您的问题

1)从自定义alertmanager.yaml文件创建Config映射

代码语言:javascript
运行
复制
kubectl create configmap <name_of_the_configmap> --from-file=<path_and_name_of_thefile>

2)将Configmap作为卷安装到容器。

代码语言:javascript
运行
复制
...
  volumeMounts:
   - mountPath: /etc/alertmanager/config
     name: config-volume
  volumes:
    - name: config-volume
      configMap:
        # Provide the name of the ConfigMap containing the files you want
        # to add to the container
        name: <ConfigMap_Name_Created>

3)挂载configmap将覆盖容器内的文件。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71924744

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档