mirror of
https://github.com/dromara/hertzbeat.git
synced 2026-10-10 10:29:02 +00:00
Co-authored-by: YuLuo <yuluo08290126@gmail.com> Co-authored-by: tomsun28 <tomsun28@outlook.com> Co-authored-by: Calvin <naruse_shinji@163.com>
28 lines
2.2 KiB
Markdown
28 lines
2.2 KiB
Markdown
---
|
|
id: plugin
|
|
title: Custom plugin
|
|
sidebar_label: 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
|
|
|
|
1. Pull the master branch code `git clone https://github.com/apache/hertzbeat.git` and locate the `plugin` module's
|
|
`Plugin` interface.
|
|

|
|
2. In the `org.apache.hertzbeat.plugin.impl` directory, create a new interface implementation class, such as `org.apache.hertzbeat.plugin.impl.DemoPluginImpl`, and receive the `Alert` class as a parameter, implement the `alert` method, the logic is customized by the user, here we simply print the object.
|
|

|
|
3. Package the `hertzbeat-plugin` module.
|
|

|
|
4. Copy the packaged `jar` package to the `ext-lib` directory under the installation directory (for `docker` installations, mount the `ext-lib` directory first, then copy it there).
|
|

|
|
5. Then restart `HertzBeat` to enable the customized post-alert handling policy.
|