Introduction
In today's digitized business environment, monitoring and alerting are playing crucial roles. It not only helps enterprises detect system anomalies in a timely manner but also effectively reduces business losses caused by faults. API7 Enterprise offers various alerting rules, enabling users to set flexible alerting strategies. Through the notification method of Webhook templates, alert information is sent to our commonly used Instant Messaging (IM) systems. This helps us monitor the system's operational status promptly and effectively, allowing for timely response and ensuring business continuity and stability.
Now, let's delve into how to use the API7 Enterprise to configure alerting rules and send alert information to existing IM systems via Webhook, helping you easily master the configuration process for this scenario.
Alerting Rules and Notifications
1. Alerting Strategies
API7 Enterprise currently supports multiple alerting strategies, allowing users to flexibly configure based on business needs. Common alerting strategies include:
Trigger an alert when a certificate is about to expire.
Trigger an alert when a gateway instance is offline.
Trigger an alert based on the quantity of status codes 4xx and 5xx.
Trigger an alert based on the ratio of status codes 4xx and 5xx.
In practical application, multiple strategies can be combined to meet various alerting needs, ensuring automatic alert triggering and notifying relevant personnel, thereby improving the response speed and efficiency of fault resolution.
2. Definition and Management of Alerting Levels
Alerting levels classify and identify different alerting situations, allowing users to clearly recognize the importance of alerts. Common alerting levels include high, medium, and low. Administrators set different alerting levels to ensure important alerts receive timely attention and handling. API7 Enterprise supports users in easily configuring and managing alerting levels to meet monitoring needs in different scenarios.
3. Mechanism of Alert Notifications
We can create Webhook templates in API7 Enterprise. When the system detects anomalies and triggers an alert, API7 Enterprise automatically calls the pre-configured Webhook address. It sends the alert information in the form of an HTTP POST request to the specified destination address. Webhook is a commonly used technology for communication between applications, allowing users to automatically send data to a specified URL when specific events occur.
Popular IM systems like Slack, Microsoft Teams, Lark, DingTalk, and WeCom provide Webhook robots for sending and receiving messages. Below, we use Lark as an example to detail how to integrate alert notifications with API7 Enterprise.
Integration with IM System Webhook Robots
Webhook robots in IM systems are special accounts used for automatically sending messages, notifying events, or performing specific operations. By configuring API7 Enterprise's Webhook template notifications to integrate with the Webhook robot address in the IM system, the automatic push of alert information is achieved, greatly enhancing the real-time accuracy of alert notifications.
Configuring Lark's Webhook Robot
- First, we need to create and configure a Webhook robot on Lark. In the corresponding group, find the option to add a group robot. Then we can see the option for Custom Bot.
- After adding an avatar and relevant description for the robot, click Next, and you will see the Webhook address. This address is used to receive alert information.
- Depending on your needs, you can set some security policy rules for your robot, such as keywords, IP whitelist, and more.
Configuring Alerting Rules in API7 Enterprise
- In API7 Enterprise, add an alerting strategy and specify the triggering conditions.
- Configure the Webhook notification template:
{ "msg_type": "text", "content": { "text": "API7 EE Alarm: 4xx error" } }
- For ease of future testing, we change the alert check interval to 1 minute.
- Enable the alerting strategy and the corresponding Webhook notification.
- Send a request with a
401
status code to trigger the alert:
curl -i http://127.0.0.1:9080/get
HTTP/1.1 401 Unauthorized
...
{"message":"Missing API key found in request"}
- Next, you should see the corresponding alert message sent by the Webhook robot in the Lark group.
Advanced Usage
The API7 Enterprise supports passing alert context variables through Webhook. Common variables include:
Title: {{ .Title }} Alert Title
Severity: {{ .Severity }} Alert Severity
Detail: {{ .Detail }} Alert Description
AlertEvents: {{ .AlertEvents.XXX }} Corresponding alert events based on different policy settings.
Conclusion
API7 Enterprise offers many powerful features, providing convenience and support for enterprise monitoring and API management. By using the Webhook alert notification mechanism integrated with IM systems, alert information can be quickly and accurately conveyed to relevant personnel, improving the speed and quality of fault response. This brings a more efficient and reliable monitoring and management experience to enterprises.