apecloud / kubeblocks

KubeBlocks is an open-source control plane software that runs and manages databases, message queues and other stateful applications on K8s.
https://kubeblocks.io
GNU Affero General Public License v3.0
2.1k stars 172 forks source link

[Features] kbcli can send a test message to specific alert receiver #2103

Closed realzyy closed 12 months ago

realzyy commented 1 year ago

After users add new alert receivers to KubeBlocks, they want to test if the setting works appropriately. Without knowing the default alert events, they can test like this: $ kbcli alert list-receivers NAME WEBHOOK EMAIL SLACK CLUSTER SEVERITY
default-receiver
receiver-plhg9 channel=#kubeblocks-testing,username=KubeBlocksBot
$ kbcli alert test-receiver receiver-plhg9

If anything goes wrong, the users will not receive any messages from robots or webhooks.

ruijun2002 commented 1 year ago

As the receiver is configured with alarm rules, messages that do not conform to the rules cannot be sent to the receiver. Therefore, it is recommended to send test messages to webhook, slack or email channels to test whether these channels are working. For example,

kbcli alert list-receivers
NAME               WEBHOOK                                                                                 EMAIL   SLACK                                         CLUSTER   SEVERITY
default-receiver
receiver-vrr26                                                                                                     channel=#demo,username=kubeblocks-alert-bot
receiver-4b9dv     url=https://open.feishu.cn/open-apis/bot/v2/hook/1061a04f-c8dd-4748-9e54-c48example

# test message to slack
kbcli alert send-test-message --slack='channel=#demo,username=kubeblocks-alert-bot'

# test message to feishu bot
kbcli alert send-test-message --webhook='url=https://open.feishu.cn/open-apis/bot/v2/hook/1061a04f-c8dd-4748-9e54-c48example'