Co-authored-by: YuLuo <yuluo08290126@gmail.com> Co-authored-by: tomsun28 <tomsun28@outlook.com> Co-authored-by: Calvin <naruse_shinji@163.com>
2.2 KiB
id, title, sidebar_label
| id | title | sidebar_label |
|---|---|---|
| plugin | Custom plugin | Custom plugin |
Custom plugins
Introduction
Currently, Hertzbeat relies on the alert module to notify the user, and then the user can take actions such as sending requests, executing sql, executing shell scripts, etc. However, this can only be automated manually or by webhook to receive the alert message.
However, at present, it is only possible to automate the process by receiving alert messages manually or through a webhook. For this reason, HertzBeat has added a new plugin module, which has a generic interface Plugin, which allows users to implement the alert method of this interface and receive the Alert class as a parameter to customize the operation.
After adding the customized code, you only need to package the plugin module, copy it to the /ext-lib folder under the installation directory, restart the HertzBeat main program, and then you can execute the customized function after the alert, without having to re-package and deploy the whole program by yourself.
Currently, HertzBeat only set up the trigger alert method after alarm, if you need to set up the trigger method at the time of acquisition, startup program, etc., please mention Task in https://github.com/apache/hertzbeat/issues/new/choose.
Specific uses
- Pull the master branch code
git clone https://github.com/apache/hertzbeat.gitand locate thepluginmodule'sPlugininterface.
- In the
org.apache.hertzbeat.plugin.impldirectory, create a new interface implementation class, such asorg.apache.hertzbeat.plugin.impl.DemoPluginImpl, and receive theAlertclass as a parameter, implement thealertmethod, the logic is customized by the user, here we simply print the object.
- Package the
hertzbeat-pluginmodule.
- Copy the packaged
jarpackage to theext-libdirectory under the installation directory (fordockerinstallations, mount theext-libdirectory first, then copy it there).
- Then restart
HertzBeatto enable the customized post-alert handling policy.