• 告警通知
  • notification-manager 中wechat告警中alertSelector 不生效

企业微信告警配置如下

apiVersion: v1
data:
wechat: xxxxxxxxxxxxxx
kind: Secret
metadata:
labels:
app: notification-manager
name: bigdata-wechat-secret
namespace: kubesphere-monitoring-system
type: Opaque


apiVersion: notification.kubesphere.io/v2beta1
kind: Config
metadata:
name: bigdata-wechat-config
namespace: kubesphere-monitoring-system
labels:
app: notification-manager
type: tenant
user: juslink-bigdata
spec:
wechat:
wechatApiUrl: https://qyapi.weixin.qq.com/cgi-bin/
wechatApiSecret:
key: wechat
name: bigdata-wechat-secret
wechatApiCorpId: ww750dxxxxx3c3
wechatApiAgentId: “100xxxxx”


apiVersion: notification.kubesphere.io/v2beta1
kind: Receiver
metadata:
name: bigdata-wechat-receiver
namespace: kubesphere-monitoring-system
labels:
app: notification-manager
type: tenant
user: juslink-bigdata
spec:
wechat:
enabled: true
alertSelector:
matchExpressions:
- key: severity
operator: NOTIn
values:
- error
- critical
- key: job
operator: In
values:
- bigdata-node-prod
toUser:
- G1702949
wechatConfigSelector:
matchLabels:
app: notification-manager
type: tenant
user: juslink-bigdata

但是实际告警的消息接收到了带标签的job:bigdata-node-prod

请问,在企业微信告警中如何指定具体的 label,类似地,传统alertmanager做法:
- group_by: [‘alertname’,‘job’]
group_wait: 5m
group_interval: 10m
repeat_interval: 1h
receiver: ‘bigdata-wechat’
match_re:
severity: warning
job: !bigdata-node-prod

没看懂你想干嘛,按照你配置的alertSelector,收到有job:bigdata-node-prod标签的告警是符合预期的啊

    wanjunlei 我的预期是NotIn,已修改。现在告警的内容包含了,就是我指定的alertSelector并没有根据我的条件来告警,这个是global中的recevier配置

    你把通知消息打印处理确认下,消息有没有这个标签,我这边测试是没问题的

      wanjunlei 麻烦问下,alertSelector中选中的label是和kubesphere-monitoring-system-custom-alerting-rule-w78ck.yaml 这个config.js内容中rules规则中的lable匹配吗?

      • alert: bigdata-node-cpu-monitor
        annotations:
        message: ‘{{ $labels.instance }}主机, CPU利用率大于60%,请关注!’
        rule_update_time: “2021-06-28T04:58:57Z”
        summary: BigdataNodeCpuUsageHigh
        expr: 1 - avg(irate(node_cpu_seconds_total{job=~“bigdata-node-prod”,mode=“idle”}[1m])) by (instance) > 0.6
        for: 1m
        labels:
        alerttype: metric
        rule_id: 8d1e8498780e4941
        severity: critical
        这些lable应该是自定义的,我们能自定义添加label吗?

      wanjunlei 那问下就是比如说界面配置的规则想要归为一个组的话,是不是就不能实现了rule_id都是随机的

        10 天 后
        4 个月 后