Use the data analysis alarm mechanism to realize the two-way integration of Honghu and Feishu

Description of Requirement

To realize the two-way integration between Honghu and Feishu, relying on Honghu's alarm mechanism, it can send the information that users care about to Feishu. At the same time, relying on Feishu's powerful card message function, you can return to Honghu through the link (as shown below) in the Feishu message to facilitate users to further troubleshoot and analyze problems.

solution

1. The first step is to create an alarm

According to the document how Honghu integrates with Feishu

https://yanhuang.yuque.com/staff-sbytbc/rb5rur/kgihmq

You can operate step by step. In order to trigger the alarm more accurately, set a certain delay time according to your hardware configuration and usage. Generally speaking, 30S is enough.

2. The second step is to build a message template

2.1 Preliminary exploration of Honghu's warning token

Create an alarm based on the document | Yanhuang Data Platform Honghu Community Edition

http://www.yanhuangdata.com/honghu_manual/docs/alerting/create/#token-lists , you can get many meaningful alarm-related tokens, as shown in the figure below

Using these tokens, it is easy to know the context of the alarm, and it is thought that these tokens can be used to combine a rich alarm message.

2.2 Familiar with Honghu's alarm rendering template

Honghu's alarm information rendering engine, whether it is an email body or a webhook body, uses the Jinja2 template engine to render. Combined with the above-mentioned tokens, various templates can be built very flexibly to apply to different receiving ends. For details of the Jinja2 template, please refer to:

https://jinja.palletsprojects.com/en/3.1.x/templates/

2.3 Feishu's card message

Refer to the Feishu card message building tool:

https://open.feishu.cn/document/ukTMukTMukTM/uYzM3QjL2MzN04iNzcDN/message-card-builder

Feishu Card Message is ready to use out of the box, without too much learning cost, you can quickly create the card message you need for your business.

2.4 Final Template of Feishu Card Message

key tokens

  • Get the namespace of the program
  • Get the name of the program
  • Get the URL of the alert search job (note: currently the host needs to be hardcoded), and you can return to Honghu from Feishu through this URL.

2.5 Final rendering

The following card message contains namespace, application name, error message and a hyperlink that can return to Hongyu.

Huge value

It can push alarm information in a timely manner, currently supports email and Webhook, and most of the current software includes the Webhook function, so Honghu's support for the receiving end should be very rich.

Endogenous tokens plus Jinja2 rendering engine can construct message bodies of various receivers

The receiving end can return to Honghu, and the two-way integration facilitates the user to further explore the context at that time after receiving the alarm message, which provides the convenience of troubleshooting.

Follow-up

Regarding the alarm, I personally feel that Honghu can further improve in the following aspects:

  • Real-time alarm: At present, scheduled tasks are used to generate alarm information. In some cases, the message cannot be transmitted to the receiving end in real time, which may cause operation and maintenance failures.
  • The alarm editing page needs to be further improved in friendliness

For example, on the edit page above, the load is just an input box, and it is difficult to edit here when the message template is more complicated. My current practice is to edit it with a local editor first, and then copy it to this input box.

The best solution may be that Honghu provides an editing interface for message templates, allowing users to upload and edit message templates on Honghu. In the alarm interface, just link to a certain message template.

  • Due to the use of scheduled tasks to trigger alarms, there may be multiple alert logs in a certain period of time, and currently the receiving end can only receive the latest log. However, through the "Back to Honghu" button, users can see all alert logs in the corresponding query interface. Honghu can try to optimize this function, or suggest users to return to Honghu for more information.

development environment

Vector: 0.28.1

Honghu: 2.9.0

Feishu: 6.0.5

Guess you like

Origin blog.csdn.net/Yhpdata888/article/details/131793084