Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[doc]Hertzbeat plugin doc. #1980

Merged
merged 2 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions home/docs/help/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,7 @@ More details see&emsp;&#x1F449;&emsp;[Threshold alarm](alert_threshold) <br />
&emsp;&#x1F449;&emsp;[Configure DingDing Robot Notification](alert_dingtalk) <br />
&emsp;&#x1F449;&emsp;[Configure FeiShu Robot Notification](alert_feishu) <br />
&emsp;&#x1F449;&emsp;[Configure Huawei Cloud SMN Notification](alert_smn) <br />

### Plugins

&emsp;&#x1F449;&emsp;[Plugin](plugin) <br />
6 changes: 3 additions & 3 deletions home/docs/help/issue.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ The hertzbeat installed and deployed by the installation package is not availabl
### Docker Deployment common issues

1. **MYSQL, TDENGINE and HertzBeat are deployed on the same host by Docker,HertzBeat use localhost or 127.0.0.1 connect to the database but fail**
The problems lies in Docker container failed to visit and connect localhost port. Beacuse the docker default network mode is Bridge mode which can't access loacl machine through localhost.
The problems lies in Docker container failed to visit and connect localhost port. Because the docker default network mode is Bridge mode which can't access local machine through localhost.
> Solution A:Configure application.yml. Change database connection address from localhost to external IP of the host machine.
> Solution B:Use the Host network mode to start Docker, namely making Docker container and hosting share network. `docker run -d --network host .....`

2. **According to the process deploy,visit http://ip:1157/ no interface**
Please refer to the following points to troubleshoot issuess
Please refer to the following points to troubleshoot issues
> one:Whether the MySQL database and tdengine database as dependent services have been successfully started, whether the corresponding hertzbeat database has been created, and whether the SQL script has been executed.
> two:Check whether dependent service, IP account and password configuration is correct in HertzBeat's configuration file `application.yml`.
> > three:`docker logs hertzbeat` Check whether the container log has errors. If you haven't solved the issue, report it to the communication group or community.
Expand All @@ -39,7 +39,7 @@ Please refer to the following points to troubleshoot issuess:
### Package Deployment common issues

1. **According to the process deploy,visit http://ip:1157/ no interface**
Please refer to the following points to troubleshoot issuess:
Please refer to the following points to troubleshoot issues:
> one:Whether the MySQL database and tdengine database as dependent services have been successfully started, whether the corresponding hertzbeat database has been created, and whether the SQL script has been executed.
> two:Check whether dependent services, IP account and password configuration is correct in HertzBeat's configuration file `hertzbeat/config/application.yml`.
> three: Check whether the running log has errors in `hertzbeat/logs/` directory. If you haven't solved the issue, report it to the communication group or community.
Expand Down
25 changes: 25 additions & 0 deletions home/docs/help/plugin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
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.
![plugin-1.png](home/static/img/docs/help/plugin-1.png)
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.
![plugin-2.png](home/static/img/docs/help/plugin-2.png)
3. Package the `hertzbeat-plugin` module.
![plugin-3.png](home/static/img/docs/help/plugin-3.png)
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).
![plugin-4.png](home/static/img/docs/help/plugin-4.png)
5. Then restart `HertzBeat` to enable the customized post-alert handling policy.
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,7 @@ sidebar_label: 帮助入门
&emsp;&#x1F449;&emsp;[配置钉钉机器人通知](alert_dingtalk) <br />
&emsp;&#x1F449;&emsp;[配置飞书机器人通知](alert_feishu) <br />
&emsp;&#x1F449;&emsp;[配置华为云SMN通知](alert_smn) <br />

### 插件

&emsp;&#x1F449;&emsp;[插件](plugin) <br />
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
id: plugin
title: 自定义插件
sidebar_label: 自定义插件
---

## 自定义插件
### 简介

当前`Hertzbeat`在使用时,主要依赖`alert`模块对用户进行通知,然后用户采取一些措施如发送请求、执行`sql`、执行`shell`脚本等。
但目前只能通过手动或者`webhook`接收告警信息进行自动化处理。基于此,`HertzBeat`新增了`plugin`模块,该模块有一个通用接口`Plugin`,用户可以自己实现这个接口的`alert`方法,接收`Alert`类作为参数进行自定义操作。
用户添加自定义代码后,只需要对`plugin`模块进行打包,拷贝到安装目录下`/ext-lib`文件夹中,重启`HertzBeat`主程序,即可实现告警后执行自定义功能,无需自己重新打包部署整个程序。
目前,`HertzBeat`只在告警后设置了触发`alert`方法,如需在采集、启动程序等时机设置触发方法,请在`https://github.com/apache/hertzbeat/issues/new/choose` 提`Task`。

### 具体使用
1. 拉取主分支代码 `git clone https://github.com/apache/hertzbeat.git` ,定位到`plugin`模块的
`Plugin`接口。
![plugin-1.png](home/static/img/docs/help/plugin-1.png)
2. 在`org.apache.hertzbeat.plugin.impl`目录下, 新建一个接口实现类,如`org.apache.hertzbeat.plugin.impl.DemoPluginImpl`,在实现类中接收`Alert`类作为参数,实现`alert`方法,逻辑由用户自定义,这里我们简单打印一下对象。
![plugin-2.png](home/static/img/docs/help/plugin-2.png)
3. 打包`hertzbeat-plugin`模块。
![plugin-3.png](home/static/img/docs/help/plugin-3.png)
4. 将打包后的`jar`包,拷贝到安装目录下的`ext-lib`目录下(若为`docker`安装则先将`ext-lib`目录挂载出来,再拷贝到该目录下)
![plugin-4.png](home/static/img/docs/help/plugin-4.png)
5. 然后重启`HertzBeat`,即可实现自定义告警后处理策略。
3 changes: 2 additions & 1 deletion home/sidebars.json
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,8 @@
"help/alert_smn"
]
},
"help/issue"
"help/issue",
"help/plugin"
]
},
{
Expand Down
Binary file added home/static/img/docs/help/plugin-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added home/static/img/docs/help/plugin-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added home/static/img/docs/help/plugin-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added home/static/img/docs/help/plugin-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading