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.git
and locate theplugin
module'sPlugin
interface. - In the
org.apache.hertzbeat.plugin.impl
directory, create a new interface implementation class, such asorg.apache.hertzbeat.plugin.impl.DemoPluginImpl
, and receive theAlert
class as a parameter, implement thealert
method, the logic is customized by the user, here we simply print the object. - Package the
hertzbeat-plugin
module. - Copy the packaged
jar
package to theext-lib
directory under the installation directory (fordocker
installations, mount theext-lib
directory first, then copy it there). - Then restart
HertzBeat
to enable the customized post-alert handling policy.