Overview
Webhook is an API concept and is becoming more and more popular. The more things we can describe with events, the greater the scope of Webhook. Webhook is becoming more and more useful as a lightweight event-handling application.
To be exact, Webhoo is a Web callback or HTTP push API, a way to provide real-time information to apps or other applications. Webhook sends data as soon as the data is generated, i.e. you can receive data in real time. This is different from the typical API, which requires real-time polling to be fast enough. This is efficient both for production and for consumers, and the only drawback is the initial build-up difficulties.
Webhook is sometimes called a reverse API because he provides API rules that you need to design to use. Webhook will initiate an HTTP request to your app, typically a POST request, and the application is driven by the request.
Configuration
The first two articles mainly talk about mail and nail alert notification method, but the notification method is single, and relies on third-party services can not do cluster processing. For a more flexible and convenient and highly available implementation of our alert notification feature, here we implement the Webhook function ourselves.
The first two articles look here:
Grafana+prometheus system monitoring of the mail alarm function
Grafana+prometheus System monitoring nail alarm function
Webhook implementation look here:
We use the recently popular spring-boot to implement this function, some of the code is as follows:
/*** JSON data format* body:{* "IMAGEURL": "Http://grafana.org/assets/img/blog/mixed_styles.png",* "message": "Someone is testing the alert notification within Grafana.",* "RuleId": 0,* "RuleName": "Test notification",* "Ruleurl": "http://grafana.52itstyle.com/",* "state": "Alerting",* "title": "[alerting] Test notification",* "evalmatches": [* {"value": +, "metric": "High Value", "tags": null},* {"value": $, "metric": "Higher Value", "tags": null} * ] * } */ @RequestMapping("/send") PublicStringWebhook(@RequestBodyString body) {//Process alert information (mail, SMS, Staples)Logger.Info("Webhook alarm system, body:{}", body);return "Success"; }
Source
Code Cloud Address: Https://gitee.com/52itstyle/spring-boot-webhook
Webhook of Grafana+prometheus system monitoring