Giter Club home page Giter Club logo

notification-manager's Introduction

Notification Manager

Overview

Notification Manager manages notifications in multi-tenant K8s environment. It receives alerts, cloud event, and others (such as auditing, k8s events) from different senders and then send notifications to various tenant receivers based on tenant label like namespace or user.

Supported senders includes:

  • Prometheus Alertmanager
  • Custom sender
  • Prometheus (Coming soon)
  • Cloud Event (Coming soon)

Supported receivers includes:

Architecture

Notification Manager uses Receiver and Config CRDs to store notification configs like email, WeChat and slack. It also includes an operator to create and reconcile NotificationManager CRD which watches all receivers and configs, updates notification settings accordingly and sends notifications to users.

Architecture

Process

The incoming data (alert, cloud event and others) will cache in the cache firstly, then goes through steps such as silence, inhibit (coming soon), route, filter, aggregation, etc. Notifications will generate from data using template, then send to receivers and history webhook (if set).

Architecture

Silence

Silence is a straightforward way to simply mute notifications for a given time. It uses Silence CRD to define the silence policy. If incoming data matches an active silence, no notifications will be sent out for that data.

Route

Route find all receivers the notifications will send to. There are two ways to determine which receivers the notifications will send to, one is via Router CRD, and the other is auto-matching via the namespace label in the notification.

Usually the incoming data contains a namespace label, Notification Manager uses this label to decide which receiver to use for sending notifications:

  • For KubeSphere, Notification Manager will try to find tenants with the right to access the namespace from sidecar and then find receivers with user = xxx label.
  • For Kubernetes, Notification Manager will try to find receivers with namespace = xxx label.

For data without a namespace label, for example alerts of node or kubelet, user can set up a receiver with type = global label to receive notifications without a namespace label. A global receiver sends notifications for all notifications received regardless any label. A global receiver usually set for an admin role.

How the two methods work together is determined by the routePolicy.

Filter

Filter filters the notifications sent to receivers. There are two ways to filter notifications. One is using alertSelector in the receiver, the other is using tenant silence.

Aggregation

Aggregation groups notifications by groupLabels. Notifications in the same group will send together.

History

History is a webhook used to collect all notifications sent to receivers, it can be set via history.

QuickStart

Install

We assume you already have a Kubernetes cluster (v1.16+). You can install one using KubeKey if you haven't.

Install with yaml

# Deploy CRDs and the Notification Manager Operator:
kubectl apply -f https://github.com/kubesphere/notification-manager/releases/download/v2.5.2/bundle.yaml
# Deploy default template:
kubectl apply -f https://github.com/kubesphere/notification-manager/releases/download/v2.5.2/template.yaml
# Deploy built-in language packs.
kubectl apply -f https://github.com/kubesphere/notification-manager/releases/download/v2.5.2/zh-cn.yaml

Install with helm

helm install notification-manager --create-namespace -n kubesphere-monitoring-system https://github.com/kubesphere/notification-manager/releases/download/v2.5.2/notification-manager.tgz

Configure NotificationManager

NotificationManager CRD Defines the desired notification manager deployment. The Notification Manager Operator ensures a deployment meeting the resource requirements is running.

We should create a NotificationManager CR first, skip this when using helm install.

kubectl apply -f https://github.com/kubesphere/notification-manager/releases/download/v2.5.2/notification_manager.yaml

Configure sender

Notification Manager uses port 19093 and API path /api/v2/alerts to receive alerts sent from Alertmanager.

Config Alertmanager to send alerts to Notification Manager

To receive Alertmanager alerts, add webhook config like below to the receivers section of Alertmanager configuration file:

    "receivers":
     - "name": "notification-manager"
       "webhook_configs":
       - "url": "http://notification-manager-svc.kubesphere-monitoring-system.svc:19093/api/v2/alerts"

Customize sender

Below is the data structure passed to the notification manager, please refer to Data for more details.

{
  "alerts": [
    {
      "status": "firing",
      "labels": {
        "alertname": "KubePodCrashLooping",
        "container": "busybox-3jb7u6",
        "instance": "10.233.71.230:8080",
        "job": "kube-state-metrics",
        "namespace": "pp1",
        "pod": "dd1-0",
        "prometheus": "kubesphere-monitoring-system/k8s",
        "severity": "critical"
      },
      "annotations": {
        "message": "Pod pp1/dd1-0 (busybox-3jb7u6) is restarting 1.07 times / 5 minutes.",
      },
      "startsAt": "2020-02-26T07:05:04.989876849Z",
      "endsAt": "0001-01-01T00:00:00Z",
    }
  ],
}

A custom senders can send notifications using notification manager simply by sending data to http://notification-manager-svc.kubesphere-monitoring-system.svc:19093/api/v2/alerts.

Create receiver and config

Now it's time to create the receiver and config to receive notifications, you can find guides to create them in receiver and config.

Customize template

To customize the notification template, please refer to template.

Development

# Build notification-manager-operator and notification-manager docker images
make build 
# Push built docker images to docker registry
make push

Documentation

notification-manager's People

Contributors

benjaminhuo avatar bennu-li avatar ctrought avatar dependabot[bot] avatar east4ming avatar gentleelephant avatar haminhcong avatar happywzy avatar mangogoforward avatar mohamed-rafraf avatar qleelulu avatar txfs19260817 avatar wanjunlei avatar wenchajun avatar zhu733756 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

notification-manager's Issues

How does Router CRD use ORed? I want to match multiple alerts by multiple labels

like this:

apiVersion: notification.kubesphere.io/v2beta2
kind: Router
metadata:
  name: developer
spec:
  alertSelector:
    matchExpressions:
      - key: alertname
        operator: In
        values:
          - Watchdog
      - key: alert_source
        operator: In
        values:
          - loki
  receivers:
    name:
      - developer

All alerts with alertname: Watchdog or alert_source: loki in the labels are pushed to developer

send notification error" error="Secret \"feishu-config-secret\" not found"

I send notification to a feishu user with the following receiver:

apiVersion: notification.kubesphere.io/v2beta2
kind: Receiver
metadata:
  name: receiver-test
  labels:
    type: global
spec:
  feishu:
    alertSelector:
      matchExpressions:
      - key: severity
        operator: In
        values:
          - critical
    feishuConfigSelector:
      matchLabels:
        type: default
    user:
      - 3e55xxxx
    enabled: true
    tmplType: text
    tmplText:
      name: notification-manager-template
      namespace: kubesphere-monitoring-system

And I get the following error logs from the pod notification-manager-deployment-cd8b9b946-sshmp
image

Receiver resource not recognized

apiVersion: notification.kubesphere.io/v2beta2
kind: Receiver
metadata:
  name: global-receiver
  labels:
    type: global
spec:
  dingtalk:
    chatbot:
      webhook:
        value: "https://oapi.dingtalk.com/robot/send?XXXXXXXXXX"
      keywords:
        - kubesphere
    enabled: true
    template: nm.default.markdown
    titleTemplate: nm.default.subject
    tmplType: markdown
    tmplText:
      name: notification-manager-template
      namespace: kubesphere-monitoring-system

Simulate alerts with curl

curl -XPOST http://notification-manager-svc.kubesphere-monitoring-system.svc:19093/api/v2/alerts \
  -d '{"alerts":[{"status":"firing","labels":{"alertname":"KubePodCrashLooping","container":"busybox-3jb7u6","instance":"10.233.71.230:8080","job":"kube-state-metrics",
"namespace":"pp1","pod":"dd1-0","prometheus":"kubesphere-monitoring-system/k8s","severity":"critical"},"annotations":{"message":"Pod pp1/dd1-0 (busybox-3jb7u6) is restarting 1.07 times / 5 minutes."},"startsAt":"2020-02-26T07:05:04.989876849Z","endsAt":"0001-01-01T00
:00:00Z"}]}'

notification-manager logs
image

Only received the following information
image

This phenomenon seems to be that notification-manager does not use the specified template when processing the request sent by my Receiver

[Feature] Notification Manager Router and Silence

Currently, the notification manager uses the namespace of alert to determine which receivers the alert needs to be sent to, users cannot manually specify.

The router is used to specify which alerts need to be sent to which receivers. The router can enrich the notification strategy of the notification manager.

Silences are a straightforward way to simply mute alerts for a given time.

1645683875(1)

The Silence CRD maybe this.

apiVersion: notification.kubesphere.io/v2beta2
kind: Silences
metadata:
  name: silences
  labels: 
     type: global
spec:
  enabled: true
  alertSelector:
    matchLabels:
      alerttype: auditing
  startsAt: "2022-02-23T01:15:20Z"
  schedule: "30 * * * *"
  duration: 30m

If the duration is not set, the silences can be used as a global filter.

The Router CRD maybe this.

apiVersion: notification.kubesphere.io/v2beta3
kind: Router
metadata:
  name: router
spec:
  enabled: true
  matcher:
    matchLabels:
      alerttype: auditing
  receivers:  
    type: wechat
    name:
      - receiver1
      - receiver2
    regexName: ""
    selector:
      matchLabels:
        tenant: admin

Changes in NotificationManger CRD

apiVersion: notification.kubesphere.io/v2beta2
kind: NotificationManager
metadata:
  name: notification-manager
spec:
  batchMaxWait: 1m
  batchMaxSize: 100
  groupLabels:
  - namespace
  - alertname
  routePolicy: All

The batchMaxWait and batchMaxSize used to define how to pull alerts from the store.
The groupLabels is used to group alerts.
The routePolicy determines how to find receivers that notifications will be sent to, known values are RouterFirst and RouterOnly.
All: The alerts will send to the receivers which match the router, and the receivers of tenants who can access the namespace that the alert is in.
RouterFirst: The alerts will send to the receivers which match the router first, if no receiver is found, it will send to the receivers of tenants who can access the namespace that the alert is in.
RouterOnly: The alerts will send to the receivers which match the router only.

配置通知渠道报错

问题描述:

使用以下配置后一直报错。

环境:

Kubesphere 版本:3.4.1
notification-manager-operator 镜像:kubesphere/notification-manager-operator:v2.3.0
Kubernetes 版本:v1.26.10-eks

Receiver 配置

apiVersion: v1
kind: Secret
metadata:
  namespace: kubesphere-monitoring-system
  name: feishu-receiver-secret
type: Opaque
data:
  webhook: aHR0cHM6Ly9vcGVuLmZlaXNodS5jbi9vcGVuLWFwaXMvYm90L3YyL2hvb2svNzY1c3F3cXc3ODQtYWQzZTIwLTFjZTViOA==
  secret: TXZZbTkwTDNZeUwyaHZiMnN2TnpZMWMzRjNjWGMzT0RRdA==

---
apiVersion: notification.kubesphere.io/v2beta2
kind: Receiver
metadata:
  name: global-receiver
  namespace: kubesphere-monitoring-system
  labels:
    type: global
spec:
  feishu:
    alertSelector:
      matchExpressions:
        - key: namespace
          operator: DoesNotExist
    chatbot:
      webhook:
        valueFrom:
          secretKeyRef:
            key: webhook
            name: feishu-receiver-secret
            namespace: kubesphere-monitoring-system
      keywords:
        - kubesphere
      secret:
        valueFrom:
          secretKeyRef:
            key: secret
            name: feishu-receiver-secret
            namespace: kubesphere-monitoring-system
    enabled: true
    template: nm.feishu.post
    tmplType: post
    tmplText:
      name: notification-manager-template
      namespace: kubesphere-monitoring-system

错误输出:

notification-manager-operator 2023-11-22T19:48:33.884Z    DEBUG    controller-runtime.webhook.webhooks    received request    {"webhook": "/validate-notification-kubesp
here-io-v2beta2-receiver", "UID": "0c3c7a11-8314-4acf-9b1c-3c4be7d7c2a0", "kind": "notification.kubesphere.io/v2beta2, Kind=Receiver", "resource": {"group":"notificatio
n.kubesphere.io","version":"v2beta2","resource":"receivers"}}                                                                                                           
notification-manager-operator 2023-11-22T19:48:33.886Z    DEBUG    controller-runtime.webhook.webhooks    wrote response    {"webhook": "/validate-notification-kubesphe
re-io-v2beta2-receiver", "code": 200, "reason": "", "UID": "0c3c7a11-8314-4acf-9b1c-3c4be7d7c2a0", "allowed": true}                                                     
notification-manager-operator 2023/11/22 19:48:34 http: TLS handshake error from 10.0.150.252:50178: remote error: tls: bad certificate                                 
notification-manager-operator 2023/11/22 19:48:34 http: TLS handshake error from 10.0.130.212:39956: remote error: tls: bad certificate                                 
notification-manager-operator 2023/11/22 19:48:34 http: TLS handshake error from 10.0.130.212:39960: remote error: tls: bad certificate                                 
notification-manager-operator 2023/11/22 19:48:34 http: TLS handshake error from 10.0.150.252:50192: remote error: tls: bad certificate                                 
notification-manager-operator 2023/11/22 19:48:34 http: TLS handshake error from 10.0.130.212:39976: remote error: tls: bad certificate

the notification-manager send email failed

the notification-manager version is v1.4.0

the error log

image

level=info ts=2023-08-21T07:31:32.217747701+08:00 caller=config.go:601 msg="resource change" op=add name=default-email-config
level=info ts=2023-08-21T07:31:32.217852149+08:00 caller=config.go:601 msg="resource change" op=add name=default-wechat-config
level=info ts=2023-08-21T08:13:13.761899063+08:00 caller=config.go:601 msg="resource change" op=add name=global-email-receiver
level=info ts=2023-08-21T08:13:13.762065138+08:00 caller=config.go:601 msg="resource change" op=add name=global-wechat-receiver
level=error ts=2023-08-21T08:42:37.058250596+08:00 caller=email.go:193 msg="EmailNotifier: notify error" from=[email protected] to=[email protected] error="find auth mechanism: unknown auth mechanism: NTLM"
level=error ts=2023-08-21T08:42:37.058833098+08:00 caller=email.go:193 msg="EmailNotifier: notify error" from=[email protected] to=[email protected] error="find auth mechanism: unknown auth mechanism: NTLM"
level=error ts=2023-08-21T08:42:37.058879844+08:00 caller=handler.go:145 msg="Worker: notification sent error"

resource mapping not found for name: "notification-manager"

helm version
version.BuildInfo{Version:"v3.9.0", GitCommit:"7ceeda6c585217a19a1131663d8cd1f7d641b2a7", GitTreeState:"clean", GoVersion:"go1.18.2"}

notification-manager.tar v2.3.0

ERROR:

helm install notification-manager --create-namespace -n kubesphere-monitoring-system notification-manager.tar --dry-run --debug
install.go:178: [debug] Original chart version: ""
install.go:195: [debug] CHART PATH: /Users/eric/Downloads/notification/notification-manager.tar

install.go:210: [debug] WARNING: This chart or one of its subcharts contains CRDs. Rendering may fail or contain inaccuracies.
Error: INSTALLATION FAILED: unable to build kubernetes objects from release manifest: resource mapping not found for name: "notification-manager" namespace: "" from "": no matches for kind "NotificationManager" in version "notification.kubesphere.io/v2beta2"
ensure CRDs are installed first
helm.go:84: [debug] resource mapping not found for name: "notification-manager" namespace: "" from "": no matches for kind "NotificationManager" in version "notification.kubesphere.io/v2beta2"
ensure CRDs are installed first
unable to build kubernetes objects from release manifest
helm.sh/helm/v3/pkg/action.(*Install).RunWithContext
	helm.sh/helm/v3/pkg/action/install.go:277
main.runInstall
	helm.sh/helm/v3/cmd/helm/install.go:264
main.newInstallCmd.func2
	helm.sh/helm/v3/cmd/helm/install.go:125
github.com/spf13/cobra.(*Command).execute
	github.com/spf13/[email protected]/command.go:856
github.com/spf13/cobra.(*Command).ExecuteC
	github.com/spf13/[email protected]/command.go:974
github.com/spf13/cobra.(*Command).Execute
	github.com/spf13/[email protected]/command.go:902
main.main
	helm.sh/helm/v3/cmd/helm/helm.go:83
runtime.main
	runtime/proc.go:250
runtime.goexit
	runtime/asm_amd64.s:1571
INSTALLATION FAILED
main.newInstallCmd.func2
	helm.sh/helm/v3/cmd/helm/install.go:127
github.com/spf13/cobra.(*Command).execute
	github.com/spf13/[email protected]/command.go:856
github.com/spf13/cobra.(*Command).ExecuteC
	github.com/spf13/[email protected]/command.go:974
github.com/spf13/cobra.(*Command).Execute
	github.com/spf13/[email protected]/command.go:902
main.main
	helm.sh/helm/v3/cmd/helm/helm.go:83
runtime.main
	runtime/proc.go:250
runtime.goexit
	runtime/asm_amd64.s:1571

@benjaminhuo

Send the received alerts from different AlertManager'receiver as different notification-manager'receiver respectively

If the alertmanager is configured as follows

receivers:
  - name: "ops"
    webhook_configs:
      - url: "http://notification-manager-svc.kubesphere-monitoring-system.svc:19093/api/v2/alerts"
        send_resolved: true
  - name: "dev"
    webhook_configs:
      - url: "http://notification-manager-svc.kubesphere-monitoring-system.svc:19093/api/v2/alerts"

How notification-manager handles the alerts of different AlertManager'receivers with different receivers.notification.kubesphere.io.

不支持企业微信机器人

企业微信机器人是使用企业微信的企业最常用的一个工具,目前kubesphere中并不支持此功能,webhook也无法发送到企业微信机器人的webhook

sms receiver: Invalid value: "integer": spec.sms.phoneNumbers in body must be of type string: "integer"

I use the receiver.yaml as follows:

apiVersion: notification.kubesphere.io/v2beta2
kind: Receiver
metadata:
  name: global-receiver
  labels:
    type: tenant
    user: admin
spec:
  sms:
    alertSelector:
      matchExpressions:
      - key: namespace
        operator: DoesNotExist
    smsConfigSelector:
      matchLabels:
        type: tenant
        user: admin
    enabled: true
    template: nm.default.text
    tmplText:
      name: notification-manager-template
      namespace: kubesphere-monitoring-system
    phoneNumbers:
      - 13612345678

And got this error:

The Receiver "global-receiver" is invalid: spec.sms.phoneNumbers: Invalid value: "integer": spec.sms.phoneNumbers in body must be of type string: "integer"

Receiver is not recognized by NMs deployed in other namespaces because certificate issues

Is the certificate used by NM here?

image

~]# kubectl get pod,svc -n monitoring  | grep notif
pod/notification-manager-deployment-7bffdfc9f-f99jh   1/1     Running   0          34m
pod/notification-manager-operator-7cc9c59c75-fr759    2/2     Running   0          35m
service/notification-manager-controller-metrics   ClusterIP   10.109.222.237   <none>        8443/TCP    35m
service/notification-manager-svc                  ClusterIP   10.107.83.81     <none>        19093/TCP   34m
service/notification-manager-webhook              ClusterIP   10.110.101.226   <none>        443/TCP     35m
~]# kubectl apply -f receiver-global.yaml 
Error from server (InternalError): error when creating "receiver-global.yaml": Internal error occurred: failed calling webhook "vreceiver.notification.kubesphere.io": failed to call webhook: Post "https://notification-manager-webhook.monitoring.svc:443/validate-notification-kubesphere-io-v2beta2-receiver?timeout=10s": x509: certificate is valid for notification-manager-webhook.kubesphere-monitoring-system.svc, not notification-manager-webhook.monitoring.svc

When deployed in other clusters, the following error will occur

Error from server (InternalError): error when creating "receiver-global.yaml": Internal error occurred: failed calling webhook "vreceiver.notification.kubesphere.io": failed to call webhook: Post "https://notification-manager-webhook.monitoring.svc:443/validate-notification-kubesphere-io-v2beta2-receiver?timeout=10s": x509: certificate is valid for notification-manager-webhook.kubesphere-monitoring-system.svc, not notification-manager-webhook.monitoring.svc

unable to get: xxxxxx because of unknown namespace for the cache

配置了钉钉的告警,钉钉收不到信息,notification-manager-deployment 下的 notification-manager 容器报错:

level=error ts=2021-01-24T21:55:30.068356677+08:00 caller=config.go:503 msg="Failed to list rolebinding" err="unable to get: kube-ops because of unknown namespace for the cache"

level=error ts=2021-01-24T21:55:30.068424402+08:00 caller=config.go:549 msg="Unable to find tenantID" err="unable to get: kube-ops because of unknown namespace for the cache"

remove hostPath mounts

In OKD/OpenShift hostPath mounts require additional privileges provided through SecurityContextContraints. We'd like to avoid the use of hostPath mounts so we do not need to grant unnecessary privileges to worklodas, currently they are used to mount localtime from the node. Instead, it would be preferred for us to set a timezone environment variable (if desired) and let the underlying processes use if needed.

Receiving alert messages with Feishu is very slow

Using curl to access the /api/v2/alerts interface to send notifications to Feishu, it takes about 40 seconds. I also tried using prometheus alertmanager as the sender, it's also slow.
Is this normal and what can be done to improve it?

Error alarm under managed cluster

image

environment:
Kubesphere:3.20
Kubernetes:1.20.4

Under a managed cluster, it is normal for K8s master components to be invisible and should not be an alert.

I hope to provide a way to manually turn off the built-in alarm policy in the system or other ways to block this kind of alarm.

Proposal: Integrate SMS Service Crd For Notification-Manager

Currently, there is no configuration for SMS service platform among the numerous configurations of Notification-Manager. This proposal expects to design these crds to supplement it.

Introduction

We have integrated many message tunnel components, such as DingTalk, Email, Slack, Wechat, Webhook. However, SMS service is very different from these previous channel configurations, and there are many SMS service providers.

To overcome these challenges, the integration process can be roughly divided into three steps.

Step 1, create a default config crd for different SMS providers.

Step 2, create a global receiever config for different SMS providers.

Step 3, trigger the alerts with notification deployments.

Design SmsConfig Crd

A reference configuration is described as followings:

-----
apiVersion: notification.kubesphere.io/v2beta1
kind: Config
metadata:
  labels:
    app: notification-manager
    type: default
  name: default-sms-config
spec:
  sms:
       defaultProvider: "aliyun"
       providers:
         aliyun: 
            signName: xxxx 
            templateCode: xxx
            accessKeyId: xxx
            accessKeySecret: xxx
         tencent:
            templateID: xxx
            smsSdkAppid: xxx
            sign:xxxx    

Design SmsReceiever Crd

A reference configuration is described as followings:

apiVersion: notification.kubesphere.io/v2beta1
kind: Receiver
metadata:
  labels:
    app: notification-manager
    type: global
  name: global-sms-receiver
spec:
  sms:
    enabled: true
    smsConfigSelector:
      matchLabels:
        type: tenant
        user: user1
    alertSelector:
      matchLabels:
        alerttype: auditing
    phoneNumbers:
    - 13612344321
    - 13812344321

How to trigger the alerts

The different SMS service providers provide different method to send message. Therefore. the websocket server will be abstracted into common interfaces.

The whole process can be described as followings:

Reconciliation

Firstly,the nm operator is responsible for reconciliation while the crds creating or updating or deleting.

Get alerts

Secondly, the notification deployment will load the configuration of the sms receiever crd if it is enabled, using getMessage method by the defination of the alertSelector to filter alerts.

Send notifications

If the alerts are not empty, the sendMessage method can send notifications to the desired phoneNumbers with the selected SMS providers by using the common interfaces. In this way, the post request use the parameters of the selected SMS providers.

如何配置 a Receiver 接收的内容为英文, b Receiver 接受的内容为中文?

我想配置 a Receiver 接收的内容为英文, b Receiver 接受的内容为中文.

目前看了文档, 只有 NotificationManager 中可以定义 template.language.
但是如何在 b Receiver 中定义 language 为中文?
试过这样不行:

apiVersion: notification.kubesphere.io/v2beta2
kind: Receiver
metadata:
  name: global-receiver
  labels:
    type: tenant
    user: admin
spec:
  email:
    ...
    template:
      language: zh-cn
    ...

helm 安装v2.2.0 报错

helm install notification-manager helm -n kubesphere-monitoring-system

Error: unable to build kubernetes objects from release manifest: error validating “": error validating data: [ValidationError(NotificationManager.spec): unknown field "groupLabels” in io.kubesphere.notification.v2beta2.NotificationManager.spec, ValidationError(NotificationManager.spec): unknown field “template” in io.kubesphere.notification.v2beta2.NotificationManager.spec]

go vet error

我尝试做一些功能开发。本地测试发现go vet 会报错,虽然我的本地版本是go 1.9.但我认为这个报错应该解决。但我不知道从哪里下手。

pkg/notify/notifier/token.go:46:12: assignment copies lock value to t: (github.com/kubesphere/notification-manager/pkg/notify/notifier.token, bool) contains github.com/kubesphere/notification-manager/pkg/notify/notifier.token contains sync.Mutex

我看见token里面确实有mutex对象。这个对象在赋值的时候会对mutex进行拷贝。这段代码在2020年开发的,当时的版本应该go vet没检查到。现在最新的可能已经检查到这个bug了。

告警通知中的标题需要优化

如图:
1、当前告警不涉及namespace,在标题中应去掉该部分
image

2、通知设置为中文时,有部分内容未翻译【xxx firing alerts for】
image

notification-manger-webhook svc443端口不通

不知道我是否操作有误,我尝试在自己的k8s集群使用notification manger,但是执行bundle.yaml后创建的notification-manger-webhook这个svc的443端口拒绝链接,看似pod内9443端口未被监听,不知道具体是什么原因会出现这种情况呢

SMTP DDOS / Endless test alert

image

I just configured the alert system and it seemed to be okay, until It started sending emails endlessly, had to immediately disable alert.

I setup webhook and email

For the webhook I used this URL:

http://notification-manager-svc.kubesphere-monitoring-system.svc:19093/api/v2/alerts

I was trying to workout the webhook so I can hook it up to a discord channel, so I am not really sure but I think it created an endless loop 🤷‍♂️

源码clone下来之后,执行make build报错

错误内容如下:

# sigs.k8s.io/controller-runtime/pkg/log
/root/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/log/null.go:48:32: undefined: logr.InfoLogger
# sigs.k8s.io/controller-runtime/pkg/client
/root/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/client/typed_client.go:45:62: o.resourceMeta.Interface.Post().NamespaceIfScoped(o.Object.GetNamespace(), o.resourceMeta.isNamespaced()).Resource(o.resourceMeta.resource()).Body(obj).VersionedParams(createOpts.AsCreateOptions(), c.paramCodec).Context undefined (type *rest.Request has no field or method Context)
/root/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/client/typed_client.go:65:62: o.resourceMeta.Interface.Put().NamespaceIfScoped(o.Object.GetNamespace(), o.resourceMeta.isNamespaced()).Resource(o.resourceMeta.resource()).Name(o.Object.GetName()).Body(obj).VersionedParams(updateOpts.AsUpdateOptions(), c.paramCodec).Context undefined (type *rest.Request has no field or method Context)
/root/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/client/typed_client.go:85:37: o.resourceMeta.Interface.Delete().NamespaceIfScoped(o.Object.GetNamespace(), o.resourceMeta.isNamespaced()).Resource(o.resourceMeta.resource()).Name(o.Object.GetName()).Body(deleteOpts.AsDeleteOptions()).Context undefined (type *rest.Request has no field or method Context)
/root/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/client/typed_client.go:105:42: o.resourceMeta.Interface.Delete().NamespaceIfScoped(deleteAllOfOpts.ListOptions.Namespace, o.resourceMeta.isNamespaced()).Resource(o.resourceMeta.resource()).VersionedParams(deleteAllOfOpts.ListOptions.AsListOptions(), c.paramCodec).Body(deleteAllOfOpts.DeleteOptions.AsDeleteOptions()).Context undefined (type *rest.Request has no field or method Context)
/root/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/client/typed_client.go:129:13: o.resourceMeta.Interface.Patch(patch.Type()).NamespaceIfScoped(o.Object.GetNamespace(), o.resourceMeta.isNamespaced()).Resource(o.resourceMeta.resource()).Name(o.Object.GetName()).VersionedParams(patchOpts.ApplyOptions(opts).AsPatchOptions(), c.paramCodec).Body(data).Context undefined (type *rest.Request has no field or method Context)
/root/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/client/typed_client.go:143:25: r.Interface.Get().NamespaceIfScoped(key.Namespace, r.isNamespaced()).Resource(r.resource()).Context undefined (type *rest.Request has no field or method Context)
/root/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/client/typed_client.go:159:58: r.Interface.Get().NamespaceIfScoped(listOpts.Namespace, r.isNamespaced()).Resource(r.resource()).VersionedParams(listOpts.AsListOptions(), c.paramCodec).Context undefined (type *rest.Request has no field or method Context)
/root/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/client/typed_client.go:181:89: o.resourceMeta.Interface.Put().NamespaceIfScoped(o.Object.GetNamespace(), o.resourceMeta.isNamespaced()).Resource(o.resourceMeta.resource()).Name(o.Object.GetName()).SubResource("status").Body(obj).VersionedParams((&UpdateOptions literal).ApplyOptions(opts).AsUpdateOptions(), c.paramCodec).Context undefined (type *rest.Request has no field or method Context)
/root/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/client/typed_client.go:206:79: o.resourceMeta.Interface.Patch(patch.Type()).NamespaceIfScoped(o.Object.GetNamespace(), o.resourceMeta.isNamespaced()).Resource(o.resourceMeta.resource()).Name(o.Object.GetName()).SubResource("status").Body(data).VersionedParams(patchOpts.ApplyOptions(opts).AsPatchOptions(), c.paramCodec).Context undefined (type *rest.Request has no field or method Context)
/root/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/client/unstructured_client.go:55:63: o.resourceMeta.Interface.Post().NamespaceIfScoped(o.Object.GetNamespace(), o.resourceMeta.isNamespaced()).Resource(o.resourceMeta.resource()).Body(obj).VersionedParams(createOpts.AsCreateOptions(), uc.paramCodec).Context undefined (type *rest.Request has no field or method Context)
/root/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/client/unstructured_client.go:55:63: too many errors
# github.com/go-logr/zapr
/root/go/pkg/mod/github.com/go-logr/[email protected]/zapr.go:133:34: undefined: logr.InfoLogger
make: *** [vet] 错误 2

请问怎么解决?

webhook发送的body中未包含value信息

问题

  • 采用自定义服务转发webhook的消息格式,发送过来的请求中无相关实时值.Value,希望能够带上,用于告知管理员当前实时数据
{
  "receiver": "prometheus",
  "status": "firing",
  "alerts": [
    {
      "status": "firing",
      "labels": {
        "alerttype": "metric",
        "namespace": "pro",
        "owner_kind": "Deployment",
        "rule_id": "pro-e5df62249c7c718b",
        "severity": "error",
        "workload": "Deployment:pro1-web-v1",
        "cluster": "default",
        "alertname": "ram"
      },
      "annotations": {
        "rules": "[{\"_metricType\":\"namespace:workload_memory_usage:sum{$1}\",\"condition_type\":\">\",\"thresholds\":\"1\",\"unit\":\"Mi\"}]",
        "summary": "Deployment pro1-web-v1 内存用量 > 1Mi",
        "aliasName": "内存占用过高",
        "kind": "Deployment",
        "message": "请及时处理\n\n# @users wsn\n# @webhook xxxxx",
        "resources": "[\"pro1-web-v1\"]",
        "rule_update_time": "2023-06-19T06:49:26Z"
      },
      "startsAt": "2023-06-19T06:51:16.65157632Z",
      "endsAt": "0001-01-01T00:00:00Z",
      "generatorURL": "/graph?g0.expr=namespace%3Aworkload_memory_usage%3Asum%7Bnamespace%3D%22pro%22%2Cworkload%3D%22Deployment%3Apro1-web-v1%22%7D+%3E+1.048576e%2B06&g0.tab=1",
      "fingerprint": "cfd8b7774964e037"
    }
  ],
  "groupLabels": {
    "alertname": "ram",
    "namespace": "pro",
    "rule_id": "pro-e5df62249c7c718b"

  },

  "commonLabels": {
    "owner_kind": "Deployment",
    "rule_id": "pro-e5df62249c7c718b",
    "severity": "error",
    "workload": "Deployment:pro1-web-v1",
    "alertname": "ram",
    "alerttype": "metric",
    "namespace": "pro"
  },
  "commonAnnotations": {
    "summary": "Deployment pro1-web-v1 内存用量 > 1Mi",
    "aliasName": "内存占用过高",
    "kind": "Deployment",
    "message": "请及时处理\n\n# @users wsn\n# @webhook xxxxxx",
    "resources": "[\"pro1-web-v1\"]",
    "rule_update_time": "2023-06-19T06:49:26Z",
    "rules": "[{\"_metricType\":\"namespace:workload_memory_usage:sum{$1}\",\"condition_type\":\">\",\"thresholds\":\"1\",\"unit\":\"Mi\"}]"
  },
  "externalURL": "http://alertmanager-main-0:9093"
}

sms receiver: 17212345678 is not a valid phone number

I use api /api/v2/verify to verify the SMS, but I always get the following error, no matter whatphoneNumbers is.

{"Status":400,"Message":"sms receiver: 17212345678 is not a valid phone number"}

{"Status":400,"Message":"sms receiver: +8617212345678 is not a valid phone number"}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.