Skip to content

Commit d2ac59a

Browse files
authored
[doc] hertzbeat plugin doc. (apache#1980)
1 parent c4ed7d5 commit d2ac59a

File tree

10 files changed

+63
-4
lines changed

10 files changed

+63
-4
lines changed

home/docs/help/guide.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,7 @@ More details see&emsp;&#x1F449;&emsp;[Threshold alarm](alert_threshold) <br />
131131
&emsp;&#x1F449;&emsp;[Configure DingDing Robot Notification](alert_dingtalk) <br />
132132
&emsp;&#x1F449;&emsp;[Configure FeiShu Robot Notification](alert_feishu) <br />
133133
&emsp;&#x1F449;&emsp;[Configure Huawei Cloud SMN Notification](alert_smn) <br />
134+
135+
### Plugins
136+
137+
&emsp;&#x1F449;&emsp;[Plugin](plugin) <br />

home/docs/help/issue.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ The hertzbeat installed and deployed by the installation package is not availabl
2222
### Docker Deployment common issues
2323

2424
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**
25-
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.
25+
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.
2626
> Solution A:Configure application.yml. Change database connection address from localhost to external IP of the host machine.
2727
> Solution B:Use the Host network mode to start Docker, namely making Docker container and hosting share network. `docker run -d --network host .....`
2828
2929
2. **According to the process deploy,visit http://ip:1157/ no interface**
30-
Please refer to the following points to troubleshoot issuess
30+
Please refer to the following points to troubleshoot issues
3131
> 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.
3232
> two:Check whether dependent service, IP account and password configuration is correct in HertzBeat's configuration file `application.yml`.
3333
> > 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.
@@ -39,7 +39,7 @@ Please refer to the following points to troubleshoot issuess:
3939
### Package Deployment common issues
4040

4141
1. **According to the process deploy,visit http://ip:1157/ no interface**
42-
Please refer to the following points to troubleshoot issuess:
42+
Please refer to the following points to troubleshoot issues:
4343
> 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.
4444
> two:Check whether dependent services, IP account and password configuration is correct in HertzBeat's configuration file `hertzbeat/config/application.yml`.
4545
> 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.

home/docs/help/plugin.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
id: plugin
3+
title: Custom plugin
4+
sidebar_label: Custom plugin
5+
---
6+
7+
## Custom plugins
8+
### Introduction
9+
10+
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.
11+
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.
12+
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.
13+
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`.
14+
15+
### Specific uses
16+
1. Pull the master branch code `git clone https://github.com/apache/hertzbeat.git` and locate the `plugin` module's
17+
`Plugin` interface.
18+
![plugin-1.png](home/static/img/docs/help/plugin-1.png)
19+
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.
20+
![plugin-2.png](home/static/img/docs/help/plugin-2.png)
21+
3. Package the `hertzbeat-plugin` module.
22+
![plugin-3.png](home/static/img/docs/help/plugin-3.png)
23+
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).
24+
![plugin-4.png](home/static/img/docs/help/plugin-4.png)
25+
5. Then restart `HertzBeat` to enable the customized post-alert handling policy.

home/i18n/zh-cn/docusaurus-plugin-content-docs/current/help/guide.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,7 @@ sidebar_label: 帮助入门
130130
&emsp;&#x1F449;&emsp;[配置钉钉机器人通知](alert_dingtalk) <br />
131131
&emsp;&#x1F449;&emsp;[配置飞书机器人通知](alert_feishu) <br />
132132
&emsp;&#x1F449;&emsp;[配置华为云SMN通知](alert_smn) <br />
133+
134+
### 插件
135+
136+
&emsp;&#x1F449;&emsp;[插件](plugin) <br />
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
id: plugin
3+
title: 自定义插件
4+
sidebar_label: 自定义插件
5+
---
6+
7+
## 自定义插件
8+
### 简介
9+
10+
当前`Hertzbeat`在使用时,主要依赖`alert`模块对用户进行通知,然后用户采取一些措施如发送请求、执行`sql`、执行`shell`脚本等。
11+
但目前只能通过手动或者`webhook`接收告警信息进行自动化处理。基于此,`HertzBeat`新增了`plugin`模块,该模块有一个通用接口`Plugin`,用户可以自己实现这个接口的`alert`方法,接收`Alert`类作为参数进行自定义操作。
12+
用户添加自定义代码后,只需要对`plugin`模块进行打包,拷贝到安装目录下`/ext-lib`文件夹中,重启`HertzBeat`主程序,即可实现告警后执行自定义功能,无需自己重新打包部署整个程序。
13+
目前,`HertzBeat`只在告警后设置了触发`alert`方法,如需在采集、启动程序等时机设置触发方法,请在`https://github.com/apache/hertzbeat/issues/new/choose``Task`
14+
15+
### 具体使用
16+
1. 拉取主分支代码 `git clone https://github.com/apache/hertzbeat.git` ,定位到`plugin`模块的
17+
`Plugin`接口。
18+
![plugin-1.png](home/static/img/docs/help/plugin-1.png)
19+
2.`org.apache.hertzbeat.plugin.impl`目录下, 新建一个接口实现类,如`org.apache.hertzbeat.plugin.impl.DemoPluginImpl`,在实现类中接收`Alert`类作为参数,实现`alert`方法,逻辑由用户自定义,这里我们简单打印一下对象。
20+
![plugin-2.png](home/static/img/docs/help/plugin-2.png)
21+
3. 打包`hertzbeat-plugin`模块。
22+
![plugin-3.png](home/static/img/docs/help/plugin-3.png)
23+
4. 将打包后的`jar`包,拷贝到安装目录下的`ext-lib`目录下(若为`docker`安装则先将`ext-lib`目录挂载出来,再拷贝到该目录下)
24+
![plugin-4.png](home/static/img/docs/help/plugin-4.png)
25+
5. 然后重启`HertzBeat`,即可实现自定义告警后处理策略。

home/sidebars.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,8 @@
309309
"help/alert_smn"
310310
]
311311
},
312-
"help/issue"
312+
"help/issue",
313+
"help/plugin"
313314
]
314315
},
315316
{
321 KB
Loading
205 KB
Loading
131 KB
Loading
96.6 KB
Loading

0 commit comments

Comments
 (0)