...
 
Commits (18)
    https://gitcode.net/hertzbeat/hertzbeat/-/commit/06014941fd57f3d1dc88ff22ba5442ef308147fe [doc] add custom monitoring relate document (#1098) 2023-07-15T14:43:21+08:00 tomsun28 tomsun28@outlook.com https://gitcode.net/hertzbeat/hertzbeat/-/commit/b99dd6a45db50927eae34be233efe2077a2dfd3b [doc] add YutingNie as a contributor for code (#1103) 2023-07-17T14:10:48+08:00 allcontributors[bot] 46447321+allcontributors[bot]@users.noreply.github.com Co-authored-by: <span data-trailer="Co-authored-by:"><a href="mailto:46447321+allcontributors%5Bbot%5D@users.noreply.github.com" title="46447321+allcontributors[bot]@users.noreply.github.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg4" style="text-decoration: none">N</a><a href="mailto:46447321+allcontributors%5Bbot%5D@users.noreply.github.com" title="46447321+allcontributors[bot]@users.noreply.github.com">allcontributors[bot]</a> &lt;<a href="mailto:46447321+allcontributors%5Bbot%5D@users.noreply.github.com" title="46447321+allcontributors[bot]@users.noreply.github.com">46447321+allcontributors[bot]@users.noreply.github.com</a>&gt;</span> https://gitcode.net/hertzbeat/hertzbeat/-/commit/823ab127c01a852c6753df8af183408aaf19fe88 remove unreachable status (#1102) 2023-07-17T14:11:06+08:00 YutingNie 104416402+YutingNie@users.noreply.github.com Signed-off-by: <span data-trailer="Signed-off-by:" data-user="743570"><a href="https://gitcode.net/qq_53069902" title="yvettemisaki@outlook.com"><img alt="小白123789's avatar" src="https://profile.csdnimg.cn/C/0/3/1_qq_53069902" class="avatar s16 avatar-inline" title="小白123789"></a><a href="https://gitcode.net/qq_53069902" title="yvettemisaki@outlook.com">Yuting Nie</a> &lt;<a href="mailto:yvettemisaki@outlook.com" title="yvettemisaki@outlook.com">yvettemisaki@outlook.com</a>&gt;</span> https://gitcode.net/hertzbeat/hertzbeat/-/commit/ddbd8aa7d2895d45c0076960925b195f647573a5 auto update alert status (#1104) 2023-07-17T22:19:04+08:00 l646505418 50475131+l646505418@users.noreply.github.com https://gitcode.net/hertzbeat/hertzbeat/-/commit/ab6bbe40b4da4161c1d6e7cf148bc852473aa5fd feat: aviator fn for str contains, exists & matches (#1106) 2023-07-19T10:59:29+08:00 Mike Zhou mikezhoudev@gmail.com https://gitcode.net/hertzbeat/hertzbeat/-/commit/da8d504906fc830590b639dff16a83080955fd36 [doc] add mikezzb as a contributor for code (#1107) 2023-07-19T10:59:53+08:00 allcontributors[bot] 46447321+allcontributors[bot]@users.noreply.github.com https://gitcode.net/hertzbeat/hertzbeat/-/commit/88ec707780822ce02c8d614d7d7c0f4996550079 bugfix common alarm do not need monitorId tag existed (#1108) 2023-07-19T14:33:33+08:00 tomsun28 tomsun28@outlook.com https://gitcode.net/hertzbeat/hertzbeat/-/commit/819a06868e1d9a84fd401e65bd4a249c97289314 bugfix extern alert do not have labels mapping inner monitor (#1111) 2023-07-19T15:25:31+08:00 tomsun28 tomsun28@outlook.com https://gitcode.net/hertzbeat/hertzbeat/-/commit/5807f8d8adfce6e980a3f641be9ef6dc2c100e6f feature: support apache spark metrics monitoring (#1114) 2023-07-20T17:50:08+08:00 小笨蛋 105542329+a-little-fool@users.noreply.github.com https://gitcode.net/hertzbeat/hertzbeat/-/commit/a5d96984dad6c42ad8db9fcbf7bd875c38194151 [doc] add a-little-fool as a contributor for code (#1116) 2023-07-20T17:50:26+08:00 allcontributors[bot] 46447321+allcontributors[bot]@users.noreply.github.com Co-authored-by: <span data-trailer="Co-authored-by:"><a href="mailto:46447321+allcontributors%5Bbot%5D@users.noreply.github.com" title="46447321+allcontributors[bot]@users.noreply.github.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg5" style="text-decoration: none">N</a><a href="mailto:46447321+allcontributors%5Bbot%5D@users.noreply.github.com" title="46447321+allcontributors[bot]@users.noreply.github.com">allcontributors[bot]</a> &lt;<a href="mailto:46447321+allcontributors%5Bbot%5D@users.noreply.github.com" title="46447321+allcontributors[bot]@users.noreply.github.com">46447321+allcontributors[bot]@users.noreply.github.com</a>&gt;</span> https://gitcode.net/hertzbeat/hertzbeat/-/commit/04eeb10c59a30fce37a1e44c9715b91a5a195758 [Feature]Add third report of TenCloud (#1113) 2023-07-20T21:49:11+08:00 Logic zqr10159@126.com Signed-off-by: <span data-trailer="Signed-off-by:" data-user="1611705"><a href="https://gitcode.net/zqr10159" title="zqr10159@126.com"><img alt="zqr10159's avatar" src="https://profile-avatar.csdnimg.cn/default.jpg!1" class="avatar s16 avatar-inline" title="zqr10159"></a><a href="https://gitcode.net/zqr10159" title="zqr10159@126.com">Logic</a> &lt;<a href="mailto:zqr10159@126.com" title="zqr10159@126.com">zqr10159@126.com</a>&gt;</span> Signed-off-by: <span data-trailer="Signed-off-by:" data-user="23839"><a href="https://gitcode.net/sinat_25235033" title="tomsun28@outlook.com"><img alt="sinat_25235033's avatar" src="https://profile.csdnimg.cn/1/4/A/1_sinat_25235033" class="avatar s16 avatar-inline" title="sinat_25235033"></a><a href="https://gitcode.net/sinat_25235033" title="tomsun28@outlook.com">tomsun28</a> &lt;<a href="mailto:tomsun28@outlook.com" title="tomsun28@outlook.com">tomsun28@outlook.com</a>&gt;</span> Co-authored-by: <span data-trailer="Co-authored-by:" data-user="23839"><a href="https://gitcode.net/sinat_25235033" title="tomsun28@outlook.com"><img alt="sinat_25235033's avatar" src="https://profile.csdnimg.cn/1/4/A/1_sinat_25235033" class="avatar s16 avatar-inline" title="sinat_25235033"></a><a href="https://gitcode.net/sinat_25235033" title="tomsun28@outlook.com">tomsun28</a> &lt;<a href="mailto:tomsun28@outlook.com" title="tomsun28@outlook.com">tomsun28@outlook.com</a>&gt;</span> https://gitcode.net/hertzbeat/hertzbeat/-/commit/b20d9b74410a0825e5646a766d3439dd43fc4e20 [manager] fix: can query by tags when tagValue is null (#1118) 2023-07-21T10:49:46+08:00 l646505418 50475131+l646505418@users.noreply.github.com https://gitcode.net/hertzbeat/hertzbeat/-/commit/2de7179b255053b0528c3e4ae953547759bf2678 bugfix the notification template environment variable display error (#1120) 2023-07-22T10:42:58+08:00 tomsun28 tomsun28@outlook.com https://gitcode.net/hertzbeat/hertzbeat/-/commit/06aa5ebb530cc1fa02b8da76deae51fe585358d9 [doc] add littlezhongzer as a contributor for code (#1127) 2023-07-22T10:43:32+08:00 allcontributors[bot] 46447321+allcontributors[bot]@users.noreply.github.com Co-authored-by: <span data-trailer="Co-authored-by:"><a href="mailto:46447321+allcontributors%5Bbot%5D@users.noreply.github.com" title="46447321+allcontributors[bot]@users.noreply.github.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg2" style="text-decoration: none">N</a><a href="mailto:46447321+allcontributors%5Bbot%5D@users.noreply.github.com" title="46447321+allcontributors[bot]@users.noreply.github.com">allcontributors[bot]</a> &lt;<a href="mailto:46447321+allcontributors%5Bbot%5D@users.noreply.github.com" title="46447321+allcontributors[bot]@users.noreply.github.com">46447321+allcontributors[bot]@users.noreply.github.com</a>&gt;</span> https://gitcode.net/hertzbeat/hertzbeat/-/commit/1c67c068265068862c564619288e7fd95393ba0d feature:monitor brearer token api, ignore letter case to comparison (#1122) 2023-07-22T10:43:48+08:00 littlezhongzer 33685289+littlezhongzer@users.noreply.github.com Co-authored-by: <span data-trailer="Co-authored-by:"><a href="mailto:zhongcheng@winning.com.cn" title="zhongcheng@winning.com.cn"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg1" style="text-decoration: none">N</a><a href="mailto:zhongcheng@winning.com.cn" title="zhongcheng@winning.com.cn">zhongcheng</a> &lt;<a href="mailto:zhongcheng@winning.com.cn" title="zhongcheng@winning.com.cn">zhongcheng@winning.com.cn</a>&gt;</span> https://gitcode.net/hertzbeat/hertzbeat/-/commit/13f07997116106d439feaa4b91a988bdb46181c8 docs: enhance README (#1128) 2023-07-23T11:06:21+08:00 Mike Zhou mikezhoudev@gmail.com https://gitcode.net/hertzbeat/hertzbeat/-/commit/6aa52a57f5c297d8fbf96fa441d7f5df2a9884de update app-oracle.yml monitoring template (#1129) 2023-07-24T16:33:29+08:00 ChenXiangxxxxx 90089594+ChenXiangxxxxx@users.noreply.github.com Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:90089594+ChenXiangxxxxx@users.noreply.github.com" title="90089594+ChenXiangxxxxx@users.noreply.github.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg4" style="text-decoration: none">N</a><a href="mailto:90089594+ChenXiangxxxxx@users.noreply.github.com" title="90089594+ChenXiangxxxxx@users.noreply.github.com">ChenXiangxxxxx</a> &lt;<a href="mailto:90089594+ChenXiangxxxxx@users.noreply.github.com" title="90089594+ChenXiangxxxxx@users.noreply.github.com">90089594+ChenXiangxxxxx@users.noreply.github.com</a>&gt;</span> https://gitcode.net/hertzbeat/hertzbeat/-/commit/76dfef8c73c27117c64e2dacdef1c87b3dd7d2df [doc] add ChenXiangxxxxx as a contributor for code (#1130) 2023-07-24T16:33:51+08:00 allcontributors[bot] 46447321+allcontributors[bot]@users.noreply.github.com Co-authored-by: <span data-trailer="Co-authored-by:"><a href="mailto:46447321+allcontributors%5Bbot%5D@users.noreply.github.com" title="46447321+allcontributors[bot]@users.noreply.github.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg3" style="text-decoration: none">N</a><a href="mailto:46447321+allcontributors%5Bbot%5D@users.noreply.github.com" title="46447321+allcontributors[bot]@users.noreply.github.com">allcontributors[bot]</a> &lt;<a href="mailto:46447321+allcontributors%5Bbot%5D@users.noreply.github.com" title="46447321+allcontributors[bot]@users.noreply.github.com">46447321+allcontributors[bot]@users.noreply.github.com</a>&gt;</span>
...@@ -1233,6 +1233,51 @@ ...@@ -1233,6 +1233,51 @@
"contributions": [ "contributions": [
"code" "code"
] ]
},
{
"login": "YutingNie",
"name": "YutingNie",
"avatar_url": "https://avatars.githubusercontent.com/u/104416402?v=4",
"profile": "https://github.com/YutingNie",
"contributions": [
"code"
]
},
{
"login": "mikezzb",
"name": "Mike Zhou",
"avatar_url": "https://avatars.githubusercontent.com/u/23418428?v=4",
"profile": "https://github.com/mikezzb",
"contributions": [
"code"
]
},
{
"login": "a-little-fool",
"name": "小笨蛋",
"avatar_url": "https://avatars.githubusercontent.com/u/105542329?v=4",
"profile": "https://github.com/a-little-fool",
"contributions": [
"code"
]
},
{
"login": "littlezhongzer",
"name": "littlezhongzer",
"avatar_url": "https://avatars.githubusercontent.com/u/33685289?v=4",
"profile": "https://github.com/littlezhongzer",
"contributions": [
"code"
]
},
{
"login": "ChenXiangxxxxx",
"name": "ChenXiangxxxxx",
"avatar_url": "https://avatars.githubusercontent.com/u/90089594?v=4",
"profile": "https://github.com/ChenXiangxxxxx",
"contributions": [
"code"
]
} }
], ],
"contributorsPerLine": 7, "contributorsPerLine": 7,
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
## HertzBeat | [中文文档](README_CN.md) ## HertzBeat | [中文文档](README_CN.md)
> An open source, real-time monitoring system with custom-monitoring and agentLess. | 易用友好的开源实时监控告警系统,无需Agent,强大自定义监控能力. An open-source, real-time monitoring system with custom monitoring and agentless capabilities. | 易用友好的开源实时监控告警系统,无需Agent,强大自定义监控能力.
[![discord](https://img.shields.io/badge/chat-on%20discord-brightgreen)](https://discord.gg/Fb6M73htGr) [![discord](https://img.shields.io/badge/chat-on%20discord-brightgreen)](https://discord.gg/Fb6M73htGr)
[![Gitter](https://badges.gitter.im/hertzbeat/community.svg)](https://gitter.im/hertzbeat/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [![Gitter](https://badges.gitter.im/hertzbeat/community.svg)](https://gitter.im/hertzbeat/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
...@@ -30,24 +30,24 @@ ...@@ -30,24 +30,24 @@
## 🎡 <font color="green">Introduction</font> ## 🎡 <font color="green">Introduction</font>
> [HertzBeat](https://github.com/dromara/hertzbeat) is an open source, real-time monitoring system with custom-monitoring and agentLess. [HertzBeat](https://github.com/dromara/hertzbeat) is an open source, real-time monitoring system with custom monitoring and agentless capabilities. It combines **monitoring, alarm, and notification** features into one platform, and supports monitoring for web service, database, os, middleware, cloud-native, network and more.
> **Monitoring+Alarm+Notify** all in one. Support monitoring web service, database, os, middleware, cloud-native, network and more.
> Easy to use, full web-based operation, monitoring and alerting at the click of a mouse, zero learning cost.
> More flexible threshold rule, timely notification delivery by `Discord` `Slack` `Telegram` `Email` `DingDing` `WeChat` `FeiShu` `Webhook` `SMS`.
> We make protocols such as `Http, Jmx, Ssh, Snmp, Jdbc` configurable, and you only need to configure `YML` online to collect any metrics you want. ### Features
> Do you believe that you can immediately adapt a new monitoring type such as K8s or Docker just by configuring online?
> `HertzBeat`'s powerful custom-define, multi-type support, easy expansion, low coupling, hope to help developers and micro teams to quickly build their own monitoring system. * Easy to use, offering full web-based operations for monitoring and alerting with just a click of a mouse, all at zero learning cost.
> We also provide **[Monitoring SaaS Cloud](https://console.tancloud.cn)**, users no longer need to deploy a cumbersome monitoring system in order to monitor resources. **[Get started for free](https://console.tancloud.cn)**. * Provides a more flexible threshold rules and timely notifications delivered via `Discord` `Slack` `Telegram` `Email` `DingDing` `WeChat` `FeiShu` `Webhook` `SMS`.
* Makes protocols such as `Http, Jmx, Ssh, Snmp, Jdbc` configurable, allowing you to collect any desired metrics by simply configuring the `YML` file online. Imagine being able to quickly adapt to a new monitoring type like K8s or Docker simply by configuring online with HertzBeat.
* Powerful customization, multi-type support, easy expansion, and low coupling.
---- HertzBeat aims to help developers and teams quickly build their own monitoring system. We also provide **[Monitoring SaaS Cloud](https://console.tancloud.cn)**, users no longer need to deploy a cumbersome monitoring system to monitor their resources. **[Get started for free](https://console.tancloud.cn)**.
----
[![hertzbeat](home/static/img/home/1.png)](https://www.bilibili.com/video/BV1LY4y1m7rH/) [![hertzbeat](home/static/img/home/1.png)](https://www.bilibili.com/video/BV1LY4y1m7rH/)
[![hertzbeat](home/static/img/home/9.png)](https://www.bilibili.com/video/BV1LY4y1m7rH/) [![hertzbeat](home/static/img/home/9.png)](https://www.bilibili.com/video/BV1LY4y1m7rH/)
---- ----
## 🥐 Architecture ## 🥐 Architecture
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
## ⛄ Supported ## ⛄ Supported
> We define all monitoring collection types (mysql,jvm,k8s) as yml monitoring templates, and users can import these templates to support corresponding types of monitoring. > We define all monitoring collection types such as `mysql`, `jvm`, and `k8s` as `YML` monitoring templates, allowing users to import them to support corresponding types of monitoring.
> Welcome everyone to contribute your customized general monitoring type YML template during use. > Welcome everyone to contribute your customized general monitoring type YML template during use.
...@@ -92,8 +92,8 @@ ...@@ -92,8 +92,8 @@
## 🐕 Quick Start ## 🐕 Quick Start
- If you don’t want to deploy but use it directly, we provide [SAAS Monitoring Cloud-TanCloud](https://console.tancloud.cn), **[Log In For Free](https://console.tancloud.cn)**. - If you prefer to use HertzBeat directly without deploying it, we provide [SAAS Monitoring Cloud-TanCloud](https://console.tancloud.cn), **[Log In For Free](https://console.tancloud.cn)**.
- If you want to deploy HertzBeat local, please refer to the following Deployment Documentation for operation. - If you wish to deploy HertzBeat locally, please refer to the following Deployment Documentation for instructions.
### 🍞 Install HertzBeat ### 🍞 Install HertzBeat
...@@ -146,7 +146,7 @@ Detailed steps refer to [Install via Docker-Compose](script/docker-compose/READM ...@@ -146,7 +146,7 @@ Detailed steps refer to [Install via Docker-Compose](script/docker-compose/READM
## ✨ Contributors ## ✨ Contributors
Thanks these wonderful people, welcome to join us: Thanks to these wonderful people, welcome to join us:
[Contributor Guide](CONTRIBUTING.md) [Contributor Guide](CONTRIBUTING.md)
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --> <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
...@@ -321,6 +321,13 @@ Thanks these wonderful people, welcome to join us: ...@@ -321,6 +321,13 @@ Thanks these wonderful people, welcome to join us:
<td align="center" valign="top" width="14.28%"><a href="https://github.com/san346596324"><img src="https://avatars.githubusercontent.com/u/30828520?v=4?s=100" width="100px;" alt="渭雨"/><br /><sub><b>渭雨</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=san346596324" title="Code">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/san346596324"><img src="https://avatars.githubusercontent.com/u/30828520?v=4?s=100" width="100px;" alt="渭雨"/><br /><sub><b>渭雨</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=san346596324" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/luoxuanzao"><img src="https://avatars.githubusercontent.com/u/44692579?v=4?s=100" width="100px;" alt="liuxuezhuo"/><br /><sub><b>liuxuezhuo</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=luoxuanzao" title="Code">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/luoxuanzao"><img src="https://avatars.githubusercontent.com/u/44692579?v=4?s=100" width="100px;" alt="liuxuezhuo"/><br /><sub><b>liuxuezhuo</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=luoxuanzao" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/lisongning"><img src="https://avatars.githubusercontent.com/u/93140178?v=4?s=100" width="100px;" alt="lisongning"/><br /><sub><b>lisongning</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=lisongning" title="Code">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/lisongning"><img src="https://avatars.githubusercontent.com/u/93140178?v=4?s=100" width="100px;" alt="lisongning"/><br /><sub><b>lisongning</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=lisongning" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/YutingNie"><img src="https://avatars.githubusercontent.com/u/104416402?v=4?s=100" width="100px;" alt="YutingNie"/><br /><sub><b>YutingNie</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=YutingNie" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/mikezzb"><img src="https://avatars.githubusercontent.com/u/23418428?v=4?s=100" width="100px;" alt="Mike Zhou"/><br /><sub><b>Mike Zhou</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=mikezzb" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/a-little-fool"><img src="https://avatars.githubusercontent.com/u/105542329?v=4?s=100" width="100px;" alt="小笨蛋"/><br /><sub><b>小笨蛋</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=a-little-fool" title="Code">💻</a></td>
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/littlezhongzer"><img src="https://avatars.githubusercontent.com/u/33685289?v=4?s=100" width="100px;" alt="littlezhongzer"/><br /><sub><b>littlezhongzer</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=littlezhongzer" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/ChenXiangxxxxx"><img src="https://avatars.githubusercontent.com/u/90089594?v=4?s=100" width="100px;" alt="ChenXiangxxxxx"/><br /><sub><b>ChenXiangxxxxx</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=ChenXiangxxxxx" title="Code">💻</a></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
...@@ -332,7 +339,7 @@ Thanks these wonderful people, welcome to join us: ...@@ -332,7 +339,7 @@ Thanks these wonderful people, welcome to join us:
## 💬 Join discussion ## 💬 Join discussion
HertzBeat is a top project under the [Dromara Open Source Community](https://dromara.org/), Gitee GVP. HertzBeat is a top project under the [Dromara Open Source Community](https://dromara.org/). Gitee GVP.
##### Channel ##### Channel
......
...@@ -316,6 +316,13 @@ Thanks these wonderful people, welcome to join us: ...@@ -316,6 +316,13 @@ Thanks these wonderful people, welcome to join us:
<td align="center" valign="top" width="14.28%"><a href="https://github.com/san346596324"><img src="https://avatars.githubusercontent.com/u/30828520?v=4?s=100" width="100px;" alt="渭雨"/><br /><sub><b>渭雨</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=san346596324" title="Code">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/san346596324"><img src="https://avatars.githubusercontent.com/u/30828520?v=4?s=100" width="100px;" alt="渭雨"/><br /><sub><b>渭雨</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=san346596324" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/luoxuanzao"><img src="https://avatars.githubusercontent.com/u/44692579?v=4?s=100" width="100px;" alt="liuxuezhuo"/><br /><sub><b>liuxuezhuo</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=luoxuanzao" title="Code">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/luoxuanzao"><img src="https://avatars.githubusercontent.com/u/44692579?v=4?s=100" width="100px;" alt="liuxuezhuo"/><br /><sub><b>liuxuezhuo</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=luoxuanzao" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/lisongning"><img src="https://avatars.githubusercontent.com/u/93140178?v=4?s=100" width="100px;" alt="lisongning"/><br /><sub><b>lisongning</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=lisongning" title="Code">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/lisongning"><img src="https://avatars.githubusercontent.com/u/93140178?v=4?s=100" width="100px;" alt="lisongning"/><br /><sub><b>lisongning</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=lisongning" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/YutingNie"><img src="https://avatars.githubusercontent.com/u/104416402?v=4?s=100" width="100px;" alt="YutingNie"/><br /><sub><b>YutingNie</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=YutingNie" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/mikezzb"><img src="https://avatars.githubusercontent.com/u/23418428?v=4?s=100" width="100px;" alt="Mike Zhou"/><br /><sub><b>Mike Zhou</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=mikezzb" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/a-little-fool"><img src="https://avatars.githubusercontent.com/u/105542329?v=4?s=100" width="100px;" alt="小笨蛋"/><br /><sub><b>小笨蛋</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=a-little-fool" title="Code">💻</a></td>
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/littlezhongzer"><img src="https://avatars.githubusercontent.com/u/33685289?v=4?s=100" width="100px;" alt="littlezhongzer"/><br /><sub><b>littlezhongzer</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=littlezhongzer" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/ChenXiangxxxxx"><img src="https://avatars.githubusercontent.com/u/90089594?v=4?s=100" width="100px;" alt="ChenXiangxxxxx"/><br /><sub><b>ChenXiangxxxxx</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=ChenXiangxxxxx" title="Code">💻</a></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
...@@ -327,7 +334,7 @@ Thanks these wonderful people, welcome to join us: ...@@ -327,7 +334,7 @@ Thanks these wonderful people, welcome to join us:
## 💬 社区交流 ## 💬 社区交流
HertzBeat 赫兹跳动是 [Dromara开源社区](https://dromara.org/) 下顶级项目Gitee GVP。 HertzBeat 赫兹跳动是 [Dromara开源社区](https://dromara.org/) 下顶级项目Gitee GVP。
##### 微信交流群 ##### 微信交流群
......
...@@ -23,7 +23,9 @@ import com.googlecode.aviator.exception.CompileExpressionErrorException; ...@@ -23,7 +23,9 @@ import com.googlecode.aviator.exception.CompileExpressionErrorException;
import com.googlecode.aviator.exception.ExpressionRuntimeException; import com.googlecode.aviator.exception.ExpressionRuntimeException;
import com.googlecode.aviator.exception.ExpressionSyntaxErrorException; import com.googlecode.aviator.exception.ExpressionSyntaxErrorException;
import org.dromara.hertzbeat.alert.AlerterWorkerPool; import org.dromara.hertzbeat.alert.AlerterWorkerPool;
import org.dromara.hertzbeat.alert.dao.AlertDao;
import org.dromara.hertzbeat.alert.reduce.AlarmCommonReduce; import org.dromara.hertzbeat.alert.reduce.AlarmCommonReduce;
import org.dromara.hertzbeat.alert.service.AlertService;
import org.dromara.hertzbeat.common.queue.CommonDataQueue; import org.dromara.hertzbeat.common.queue.CommonDataQueue;
import org.dromara.hertzbeat.alert.dao.AlertMonitorDao; import org.dromara.hertzbeat.alert.dao.AlertMonitorDao;
import org.dromara.hertzbeat.common.entity.alerter.Alert; import org.dromara.hertzbeat.common.entity.alerter.Alert;
...@@ -37,16 +39,21 @@ import org.dromara.hertzbeat.common.util.CommonUtil; ...@@ -37,16 +39,21 @@ import org.dromara.hertzbeat.common.util.CommonUtil;
import org.dromara.hertzbeat.common.util.ResourceBundleUtil; import org.dromara.hertzbeat.common.util.ResourceBundleUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.domain.Specification;
import javax.persistence.criteria.Predicate;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static org.dromara.hertzbeat.common.constants.CommonConstants.ALERT_STATUS_CODE_PENDING;
import static org.dromara.hertzbeat.common.constants.CommonConstants.ALERT_STATUS_CODE_SOLVED;
/** /**
* Calculate alarms based on the alarm definition rules and collected data * Calculate alarms based on the alarm definition rules and collected data
* 根据告警定义规则和采集数据匹配计算告警 * 根据告警定义规则和采集数据匹配计算告警
* @author tom
* *
* @author tom
*/ */
@Configuration @Configuration
@Slf4j @Slf4j
...@@ -65,14 +72,16 @@ public class CalculateAlarm { ...@@ -65,14 +72,16 @@ public class CalculateAlarm {
private final AlertDefineService alertDefineService; private final AlertDefineService alertDefineService;
private final AlarmCommonReduce alarmCommonReduce; private final AlarmCommonReduce alarmCommonReduce;
private final ResourceBundle bundle; private final ResourceBundle bundle;
private final AlertService alertService;
public CalculateAlarm (AlerterWorkerPool workerPool, CommonDataQueue dataQueue, public CalculateAlarm(AlerterWorkerPool workerPool, CommonDataQueue dataQueue,
AlertDefineService alertDefineService, AlertMonitorDao monitorDao, AlertDefineService alertDefineService, AlertMonitorDao monitorDao,
AlarmCommonReduce alarmCommonReduce) { AlarmCommonReduce alarmCommonReduce, AlertService alertService) {
this.workerPool = workerPool; this.workerPool = workerPool;
this.dataQueue = dataQueue; this.dataQueue = dataQueue;
this.alarmCommonReduce = alarmCommonReduce; this.alarmCommonReduce = alarmCommonReduce;
this.alertDefineService = alertDefineService; this.alertDefineService = alertDefineService;
this.alertService = alertService;
this.bundle = ResourceBundleUtil.getBundle("alerter"); this.bundle = ResourceBundleUtil.getBundle("alerter");
this.triggeredAlertMap = new ConcurrentHashMap<>(128); this.triggeredAlertMap = new ConcurrentHashMap<>(128);
this.unAvailableMonitors = Collections.synchronizedSet(new HashSet<>(16)); this.unAvailableMonitors = Collections.synchronizedSet(new HashSet<>(16));
...@@ -154,7 +163,8 @@ public class CalculateAlarm { ...@@ -154,7 +163,8 @@ public class CalculateAlarm {
try { try {
Expression expression = AviatorEvaluator.compile(expr, true); Expression expression = AviatorEvaluator.compile(expr, true);
match = (Boolean) expression.execute(fieldValueMap); match = (Boolean) expression.execute(fieldValueMap);
} catch (CompileExpressionErrorException | ExpressionSyntaxErrorException compileException) { } catch (CompileExpressionErrorException |
ExpressionSyntaxErrorException compileException) {
log.error("Alert Define Rule: {} Compile Error: {}.", expr, compileException.getMessage()); log.error("Alert Define Rule: {} Compile Error: {}.", expr, compileException.getMessage());
} catch (ExpressionRuntimeException expressionRuntimeException) { } catch (ExpressionRuntimeException expressionRuntimeException) {
log.error("Alert Define Rule: {} Run Error: {}.", expr, expressionRuntimeException.getMessage()); log.error("Alert Define Rule: {} Run Error: {}.", expr, expressionRuntimeException.getMessage());
...@@ -188,7 +198,7 @@ public class CalculateAlarm { ...@@ -188,7 +198,7 @@ public class CalculateAlarm {
.tags(tags) .tags(tags)
.alertDefineId(define.getId()) .alertDefineId(define.getId())
.priority(define.getPriority()) .priority(define.getPriority())
.status(CommonConstants.ALERT_STATUS_CODE_PENDING) .status(ALERT_STATUS_CODE_PENDING)
.target(app + "." + metrics + "." + define.getField()) .target(app + "." + metrics + "." + define.getField())
.triggerTimes(1) .triggerTimes(1)
.firstAlarmTime(currentTimeMilli) .firstAlarmTime(currentTimeMilli)
...@@ -263,6 +273,10 @@ public class CalculateAlarm { ...@@ -263,6 +273,10 @@ public class CalculateAlarm {
.triggerTimes(1) .triggerTimes(1)
.build(); .build();
alarmCommonReduce.reduceAndSendAlarm(resumeAlert); alarmCommonReduce.reduceAndSendAlarm(resumeAlert);
Runnable updateStatusJob = () -> {
updateAvailabilityAlertStatus(monitorId, resumeAlert);
};
workerPool.executeJob(updateStatusJob);
} }
} }
} }
...@@ -285,7 +299,7 @@ public class CalculateAlarm { ...@@ -285,7 +299,7 @@ public class CalculateAlarm {
Alert.AlertBuilder alertBuilder = Alert.builder() Alert.AlertBuilder alertBuilder = Alert.builder()
.tags(tags) .tags(tags)
.priority(CommonConstants.ALERT_PRIORITY_CODE_EMERGENCY) .priority(CommonConstants.ALERT_PRIORITY_CODE_EMERGENCY)
.status(CommonConstants.ALERT_STATUS_CODE_PENDING) .status(ALERT_STATUS_CODE_PENDING)
.target(CommonConstants.AVAILABILITY) .target(CommonConstants.AVAILABILITY)
.content(AlertTemplateUtil.render(avaAlertDefine.getTemplate(), valueMap)) .content(AlertTemplateUtil.render(avaAlertDefine.getTemplate(), valueMap))
.firstAlarmTime(currentTimeMill) .firstAlarmTime(currentTimeMill)
...@@ -300,7 +314,7 @@ public class CalculateAlarm { ...@@ -300,7 +314,7 @@ public class CalculateAlarm {
triggeredAlertMap.put(String.valueOf(monitorId), alertBuilder.build()); triggeredAlertMap.put(String.valueOf(monitorId), alertBuilder.build());
} else { } else {
int times = preAlert.getTriggerTimes() + 1; int times = preAlert.getTriggerTimes() + 1;
if (preAlert.getStatus() == CommonConstants.ALERT_STATUS_CODE_PENDING) { if (preAlert.getStatus() == ALERT_STATUS_CODE_PENDING) {
times = 1; times = 1;
preAlert.setContent(AlertTemplateUtil.render(avaAlertDefine.getTemplate(), valueMap)); preAlert.setContent(AlertTemplateUtil.render(avaAlertDefine.getTemplate(), valueMap));
preAlert.setTags(tags); preAlert.setTags(tags);
...@@ -310,7 +324,7 @@ public class CalculateAlarm { ...@@ -310,7 +324,7 @@ public class CalculateAlarm {
preAlert.setLastAlarmTime(currentTimeMill); preAlert.setLastAlarmTime(currentTimeMill);
int defineTimes = avaAlertDefine.getTimes() == null ? 1 : avaAlertDefine.getTimes(); int defineTimes = avaAlertDefine.getTimes() == null ? 1 : avaAlertDefine.getTimes();
if (times >= defineTimes) { if (times >= defineTimes) {
preAlert.setStatus(CommonConstants.ALERT_STATUS_CODE_PENDING); preAlert.setStatus(ALERT_STATUS_CODE_PENDING);
alarmCommonReduce.reduceAndSendAlarm(preAlert.clone()); alarmCommonReduce.reduceAndSendAlarm(preAlert.clone());
unAvailableMonitors.add(monitorId); unAvailableMonitors.add(monitorId);
} else { } else {
...@@ -318,4 +332,38 @@ public class CalculateAlarm { ...@@ -318,4 +332,38 @@ public class CalculateAlarm {
} }
} }
} }
private void updateAvailabilityAlertStatus(long monitorId, Alert restoreAlert) {
List<Alert> availabilityAlerts = queryAvailabilityAlerts(monitorId, restoreAlert);
availabilityAlerts.stream().parallel().forEach(alert -> {
log.info("updating alert id:{}",alert.getId());
alertService.editAlertStatus(ALERT_STATUS_CODE_SOLVED, List.of(alert.getId()));
});
}
private List<Alert> queryAvailabilityAlerts(long monitorId, Alert restoreAlert) {
//create query condition
Specification<Alert> specification = (root, query, criteriaBuilder) -> {
List<Predicate> andList = new ArrayList<>();
Predicate predicateTags = criteriaBuilder.like(root.get("tags").as(String.class), "%" + monitorId + "%");
andList.add(predicateTags);
Predicate predicatePriority = criteriaBuilder.equal(root.get("priority"), CommonConstants.ALERT_PRIORITY_CODE_EMERGENCY);
andList.add(predicatePriority);
Predicate predicateStatus = criteriaBuilder.equal(root.get("status"), ALERT_STATUS_CODE_PENDING);
andList.add(predicateStatus);
Predicate predicateAlertTime = criteriaBuilder.lessThanOrEqualTo(root.get("lastAlarmTime"), restoreAlert.getLastAlarmTime());
andList.add(predicateAlertTime);
Predicate[] predicates = new Predicate[andList.size()];
return criteriaBuilder.and(andList.toArray(predicates));
};
//query results
return alertService.getAlerts(specification);
}
} }
package org.dromara.hertzbeat.alert.controller;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.dromara.hertzbeat.alert.service.AlertService;
import org.dromara.hertzbeat.alert.service.impl.AlertConvertTenCloudServiceImpl;
import org.dromara.hertzbeat.common.entity.dto.AlertReport;
import org.dromara.hertzbeat.common.entity.dto.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
/**
* @author zqr10159
* 第三方告警上报接口
*/
@Tag(name = "Extern Alarm Manage API | 第三方告警管理API")
@RestController
@RequestMapping(path = "/api/alerts/report", produces = {APPLICATION_JSON_VALUE})
public class AlertReportController {
@Autowired
AlertConvertTenCloudServiceImpl alertConvertTenCloudService;
@Autowired
private AlertService alertService;
@PostMapping("/tencloud")
@Operation(summary = "Interface for reporting external alarm information of tencloud | 对外上报告警信息 接口",
description = "对外 新增一个腾讯云告警")
public ResponseEntity<Message<Void>> addNewAlertReportTencent(@Valid @RequestBody String alertReport) {
AlertReport convert = alertConvertTenCloudService.convert(alertReport);
alertService.addNewAlertReport(convert);
return ResponseEntity.ok(new Message<>("Add report success"));
}
@PostMapping
@Operation(summary = "Interface for reporting external alarm information | 对外上报告警信息 接口",
description = "对外 新增一个告警")
public ResponseEntity<Message<Void>> addNewAlertReport(@Valid @RequestBody AlertReport alertReport) {
// 校验请求数据 TODO
alertService.addNewAlertReport(alertReport);
return ResponseEntity.ok(new Message<>("Add report success"));
}
}
...@@ -20,7 +20,6 @@ package org.dromara.hertzbeat.alert.controller; ...@@ -20,7 +20,6 @@ package org.dromara.hertzbeat.alert.controller;
import org.dromara.hertzbeat.alert.dto.AlertSummary; import org.dromara.hertzbeat.alert.dto.AlertSummary;
import org.dromara.hertzbeat.common.entity.alerter.Alert; import org.dromara.hertzbeat.common.entity.alerter.Alert;
import org.dromara.hertzbeat.alert.service.AlertService; import org.dromara.hertzbeat.alert.service.AlertService;
import org.dromara.hertzbeat.common.entity.dto.AlertReport;
import org.dromara.hertzbeat.common.entity.dto.Message; import org.dromara.hertzbeat.common.entity.dto.Message;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
...@@ -35,7 +34,6 @@ import org.springframework.web.bind.annotation.*; ...@@ -35,7 +34,6 @@ import org.springframework.web.bind.annotation.*;
import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Predicate;
import javax.validation.Valid;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
...@@ -144,13 +142,5 @@ public class AlertsController { ...@@ -144,13 +142,5 @@ public class AlertsController {
Message<AlertSummary> message = new Message<>(alertSummary); Message<AlertSummary> message = new Message<>(alertSummary);
return ResponseEntity.ok(message); return ResponseEntity.ok(message);
} }
@PostMapping("/report")
@Operation(summary = "Interface for reporting external alarm information | 对外上报告警信息 接口",
description = "对外 新增一个告警")
public ResponseEntity<Message<Void>> addNewAlertReport(@Valid @RequestBody AlertReport alertReport) {
// 校验请求数据 TODO
alertService.addNewAlertReport(alertReport);
return ResponseEntity.ok(new Message<>("Add report success"));
}
} }
package org.dromara.hertzbeat.alert.dto;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* @author zqr10159
* 腾讯云告警实体类
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class TenCloudAlertReport implements Serializable {
@JsonProperty("sessionID")
private String sessionId;
private String alarmStatus;
private String alarmType;
private AlarmObjInfo alarmObjInfo;
private AlarmPolicyInfo alarmPolicyInfo;
private String firstOccurTime;
private int durationTime;
private String recoverTime;
@Data
@AllArgsConstructor
@NoArgsConstructor
public static class AlarmObjInfo {
private String region;
private String namespace;
@JsonProperty("appID")
private String appId;
private String uin;
private Dimensions dimensions;
}
@Data
@AllArgsConstructor
@NoArgsConstructor
public static class Dimensions {
@JsonProperty("unInstanceID")
private String unInstanceId;
@JsonProperty("objID")
private String objId;
}
@Data
@AllArgsConstructor
@NoArgsConstructor
public static class AlarmPolicyInfo {
@JsonProperty("policyID")
private String policyId;
private String policyType;
private String policyName;
@JsonProperty("policyTypeCName")
private String policyTypeCname;
private Conditions conditions;
}
@Data
@AllArgsConstructor
@NoArgsConstructor
public static class Conditions {
private String metricName;
private String metricShowName;
private String calcType;
private String calcValue;
private String calcUnit;
private String currentValue;
private String historyValue;
private String unit;
private String period;
private String periodNum;
private String alarmNotifyType;
private long alarmNotifyPeriod;
}
}
...@@ -35,16 +35,16 @@ public class AlarmCommonReduce { ...@@ -35,16 +35,16 @@ public class AlarmCommonReduce {
Map<String, String> tags = alert.getTags(); Map<String, String> tags = alert.getTags();
String monitorIdStr = tags.get(CommonConstants.TAG_MONITOR_ID); String monitorIdStr = tags.get(CommonConstants.TAG_MONITOR_ID);
if (monitorIdStr == null) { if (monitorIdStr == null) {
log.error("alert tags monitorId can not be null: {}.", alert); log.debug("receiver extern alarm message: {}", alert);
return; } else {
} long monitorId = Long.parseLong(monitorIdStr);
long monitorId = Long.parseLong(monitorIdStr); List<Tag> tagList = alertMonitorDao.findMonitorIdBindTags(monitorId);
List<Tag> tagList = alertMonitorDao.findMonitorIdBindTags(monitorId); tagList.forEach(tag -> {
tagList.forEach(tag -> { if (!tags.containsKey(tag.getName())) {
if (!tags.containsKey(tag.getName())) { tags.put(tag.getName(), tag.getValue());
tags.put(tag.getName(), tag.getValue()); }
} });
}); }
// converge -> silence // converge -> silence
if (alarmConvergeReduce.filterConverge(alert) && alarmSilenceReduce.filterSilence(alert)) { if (alarmConvergeReduce.filterConverge(alert) && alarmSilenceReduce.filterSilence(alert)) {
dataQueue.sendAlertsData(alert); dataQueue.sendAlertsData(alert);
......
package org.dromara.hertzbeat.alert.service;
/**
* Alert Convert Interface.
* @author zqr10159
* @param <T> the type of object to convert the JSON into
*/
public interface AlertConvertService<T> {
/**
* Alert Convert Method.
*
* @param json the JSON string to convert
* @return the converted object of type T
*/
T convert(String json);
}
...@@ -91,4 +91,14 @@ public interface AlertService { ...@@ -91,4 +91,14 @@ public interface AlertService {
*/ */
void addNewAlertReport(AlertReport alertReport); void addNewAlertReport(AlertReport alertReport);
/**
* Dynamic conditional query
* 动态条件查询
*
* @param specification Query conditions 查询条件
* @return search result 查询结果
*/
List<Alert> getAlerts(Specification<Alert> specification);
} }
package org.dromara.hertzbeat.alert.service.impl;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.dromara.hertzbeat.alert.dto.TenCloudAlertReport;
import org.dromara.hertzbeat.alert.service.AlertConvertService;
import org.dromara.hertzbeat.common.entity.dto.AlertReport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.HashMap;
/**
* @author zqr10159
* 腾讯云告警转化类
*/
@Component
@Slf4j
public class AlertConvertTenCloudServiceImpl implements AlertConvertService<AlertReport> {
@Autowired
private ObjectMapper objectMapper;
@Override
public AlertReport convert(String json) {
TenCloudAlertReport tenCloudAlertReport;
AlertReport alert = null;
try {
tenCloudAlertReport = objectMapper.readValue(json, TenCloudAlertReport.class);
StringBuilder contentBuilder = new StringBuilder();
String content = contentBuilder.append("[").append("告警对象:地区")
.append(tenCloudAlertReport.getAlarmObjInfo().getRegion()).append("|")
.append(tenCloudAlertReport.getAlarmObjInfo().getNamespace()).append("]")
.append("[").append("告警内容:")
.append(tenCloudAlertReport.getAlarmPolicyInfo().getPolicyTypeCname()).append("|")
.append(tenCloudAlertReport.getAlarmPolicyInfo().getConditions().getMetricShowName()).append("|")
.append(tenCloudAlertReport.getAlarmPolicyInfo().getConditions().getMetricName())
.append(tenCloudAlertReport.getAlarmPolicyInfo().getConditions().getCalcType())
.append(tenCloudAlertReport.getAlarmPolicyInfo().getConditions().getCalcValue())
.append(tenCloudAlertReport.getAlarmPolicyInfo().getConditions().getCalcUnit()).append("]")
.append("[").append("当前数据")
.append(tenCloudAlertReport.getAlarmPolicyInfo().getConditions().getCurrentValue())
.append(tenCloudAlertReport.getAlarmPolicyInfo().getConditions().getCalcUnit()).append("]").toString();
HashMap<String, String> tagMap = new HashMap<>(1);
tagMap.put("app", "TenCloud");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
long occurTime = sdf.parse(tenCloudAlertReport.getFirstOccurTime()).getTime();
alert = AlertReport.builder().content(content)
.alertName("TenCloud|腾讯云")
.alertTime(occurTime)
.alertDuration(tenCloudAlertReport.getDurationTime())
.priority(1)
.reportType(1)
.labels(tagMap)
.annotations(tagMap).build();
} catch (JsonProcessingException|ParseException e) {
log.error("解析腾讯云告警内容失败!");
}
return alert;
}
}
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
package org.dromara.hertzbeat.alert.service.impl; package org.dromara.hertzbeat.alert.service.impl;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.dromara.hertzbeat.alert.reduce.AlarmCommonReduce; import org.dromara.hertzbeat.alert.reduce.AlarmCommonReduce;
import org.dromara.hertzbeat.alert.dao.AlertDao; import org.dromara.hertzbeat.alert.dao.AlertDao;
import org.dromara.hertzbeat.alert.dto.AlertPriorityNum; import org.dromara.hertzbeat.alert.dto.AlertPriorityNum;
...@@ -133,6 +134,12 @@ public class AlertServiceImpl implements AlertService { ...@@ -133,6 +134,12 @@ public class AlertServiceImpl implements AlertService {
alarmCommonReduce.reduceAndSendAlarm(buildAlertData(alertReport)); alarmCommonReduce.reduceAndSendAlarm(buildAlertData(alertReport));
} }
@Override
public List<Alert> getAlerts(Specification<Alert> specification) {
return alertDao.findAll(specification);
}
/** /**
* The external alarm information is converted to Alert 对外告警信息 转换为Alert * The external alarm information is converted to Alert 对外告警信息 转换为Alert
* @param alertReport 对外告警信息 * @param alertReport 对外告警信息
...@@ -161,4 +168,6 @@ public class AlertServiceImpl implements AlertService { ...@@ -161,4 +168,6 @@ public class AlertServiceImpl implements AlertService {
.build(); .build();
} }
} }
package org.dromara.hertzbeat.alert.controller;
import org.dromara.hertzbeat.alert.dto.TenCloudAlertReport;
import org.dromara.hertzbeat.alert.service.AlertService;
import org.dromara.hertzbeat.alert.service.impl.AlertConvertTenCloudServiceImpl;
import org.dromara.hertzbeat.common.constants.CommonConstants;
import org.dromara.hertzbeat.common.entity.dto.AlertReport;
import org.dromara.hertzbeat.common.util.JsonUtil;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
/**
* unit test for {@link AlertReportController }
* @author tom
*/
@ExtendWith(MockitoExtension.class)
class AlertReportControllerTest {
private MockMvc mockMvc;
@InjectMocks
private AlertReportController alertReportController;
@Mock
private AlertService alertService;
@Mock
AlertConvertTenCloudServiceImpl alertConvertTenCloudService;
@BeforeEach
void setUp() {
this.mockMvc = MockMvcBuilders.standaloneSetup(alertReportController).build();
}
@Test
void addNewAlertReportTencent() throws Exception {
TenCloudAlertReport report = TenCloudAlertReport.builder()
.sessionId("xxxxxxxx")
.alarmStatus("1")
.alarmType("metric")
.build();
mockMvc.perform(
MockMvcRequestBuilders
.post("/api/alerts/report/tencloud")
.contentType(MediaType.APPLICATION_JSON)
.content(JsonUtil.toJson(report))
)
.andExpect(status().isOk())
.andExpect(jsonPath("$.code").value((int) CommonConstants.SUCCESS_CODE))
.andExpect(content().json("{\"data\":null,\"msg\":\"Add report success\",\"code\":0}"))
.andReturn();
}
@Test
void addNewAlertReport() throws Exception {
mockMvc.perform(
MockMvcRequestBuilders
.post("/api/alerts/report")
.contentType(MediaType.APPLICATION_JSON)
.content(JsonUtil.toJson(AlertReport.builder().build()))
)
.andExpect(status().isOk())
.andExpect(jsonPath("$.code").value((int) CommonConstants.SUCCESS_CODE))
.andExpect(content().json("{\"data\":null,\"msg\":\"Add report success\",\"code\":0}"))
.andReturn();
}
}
...@@ -150,19 +150,4 @@ class AlertsControllerTest { ...@@ -150,19 +150,4 @@ class AlertsControllerTest {
.andExpect(content().json("{\"data\":{\"total\":0,\"dealNum\":0,\"rate\":0.0,\"priorityWarningNum\":0,\"priorityCriticalNum\":0,\"priorityEmergencyNum\":0},\"msg\":null,\"code\":0}")) .andExpect(content().json("{\"data\":{\"total\":0,\"dealNum\":0,\"rate\":0.0,\"priorityWarningNum\":0,\"priorityCriticalNum\":0,\"priorityEmergencyNum\":0},\"msg\":null,\"code\":0}"))
.andReturn(); .andReturn();
} }
@Test
void addNewAlertReport() throws Exception {
mockMvc.perform(
MockMvcRequestBuilders
.post("/api/alerts/report")
.contentType(MediaType.APPLICATION_JSON)
.content(JsonUtil.toJson(AlertReport.builder().build()))
)
.andExpect(status().isOk())
.andExpect(jsonPath("$.code").value((int) CommonConstants.SUCCESS_CODE))
.andExpect(content().json("{\"data\":null,\"msg\":\"Add report success\",\"code\":0}"))
.andReturn();
}
} }
...@@ -110,7 +110,7 @@ class AlertDefineServiceTest { ...@@ -110,7 +110,7 @@ class AlertDefineServiceTest {
@Test @Test
void getAlertDefine() { void getAlertDefine() {
long id = 1L; long id = 1L;
AlertDefine alertDefine = AlertDefine.builder().id(1L).build(); AlertDefine alertDefine = AlertDefine.builder().id(id).build();
when(alertDefineDao.findById(id)).thenReturn(Optional.of(alertDefine)); when(alertDefineDao.findById(id)).thenReturn(Optional.of(alertDefine));
assertDoesNotThrow(() -> alertDefineService.getAlertDefine(id)); assertDoesNotThrow(() -> alertDefineService.getAlertDefine(id));
} }
......
...@@ -543,7 +543,7 @@ public class HttpCollectImpl extends AbstractCollect { ...@@ -543,7 +543,7 @@ public class HttpCollectImpl extends AbstractCollect {
// 判断是否使用Bearer Token认证 // 判断是否使用Bearer Token认证
if (httpProtocol.getAuthorization() != null) { if (httpProtocol.getAuthorization() != null) {
HttpProtocol.Authorization authorization = httpProtocol.getAuthorization(); HttpProtocol.Authorization authorization = httpProtocol.getAuthorization();
if (DispatchConstants.BEARER_TOKEN.equals(authorization.getType())) { if (DispatchConstants.BEARER_TOKEN.equalsIgnoreCase(authorization.getType())) {
// 若使用 将token放入到header里面 // 若使用 将token放入到header里面
String value = DispatchConstants.BEARER + " " + authorization.getBearerTokenToken(); String value = DispatchConstants.BEARER + " " + authorization.getBearerTokenToken();
requestBuilder.addHeader(HttpHeaders.AUTHORIZATION, value); requestBuilder.addHeader(HttpHeaders.AUTHORIZATION, value);
......
...@@ -22,10 +22,12 @@ import com.googlecode.aviator.lexer.token.OperatorType; ...@@ -22,10 +22,12 @@ import com.googlecode.aviator.lexer.token.OperatorType;
import com.googlecode.aviator.runtime.function.AbstractFunction; import com.googlecode.aviator.runtime.function.AbstractFunction;
import com.googlecode.aviator.runtime.type.*; import com.googlecode.aviator.runtime.type.*;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import java.util.Map; import java.util.Map;
import java.util.regex.Pattern;
/** /**
* @author tomsun28 * @author tomsun28
...@@ -43,6 +45,8 @@ public class AviatorConfiguration { ...@@ -43,6 +45,8 @@ public class AviatorConfiguration {
AviatorEvaluator.getInstance() AviatorEvaluator.getInstance()
.useLRUExpressionCache(AVIATOR_LRU_CACHE_SIZE) .useLRUExpressionCache(AVIATOR_LRU_CACHE_SIZE)
.addFunction(new StrEqualFunction()); .addFunction(new StrEqualFunction());
// 配置自定义aviator函数
AviatorEvaluator.getInstance().addOpFunction(OperatorType.BIT_OR, new AbstractFunction() { AviatorEvaluator.getInstance().addOpFunction(OperatorType.BIT_OR, new AbstractFunction() {
@Override @Override
public AviatorObject call(final Map<String, Object> env, final AviatorObject arg1, public AviatorObject call(final Map<String, Object> env, final AviatorObject arg1,
...@@ -66,6 +70,10 @@ public class AviatorConfiguration { ...@@ -66,6 +70,10 @@ public class AviatorConfiguration {
return OperatorType.BIT_OR.getToken(); return OperatorType.BIT_OR.getToken();
} }
}); });
AviatorEvaluator.getInstance().addFunction(new StrContainsFunction());
AviatorEvaluator.getInstance().addFunction(new StrExistsFunction());
AviatorEvaluator.getInstance().addFunction(new StrMatchesFunction());
} }
/** /**
...@@ -75,12 +83,12 @@ public class AviatorConfiguration { ...@@ -75,12 +83,12 @@ public class AviatorConfiguration {
@Override @Override
public AviatorObject call(Map<String, Object> env, AviatorObject arg1, AviatorObject arg2) { public AviatorObject call(Map<String, Object> env, AviatorObject arg1, AviatorObject arg2) {
if (arg1 == null || arg2 == null) { if (arg1 == null || arg2 == null) {
return AviatorBoolean.valueOf(false); return AviatorBoolean.FALSE;
} }
Object leftTmp = arg1.getValue(env); Object leftTmp = arg1.getValue(env);
Object rightTmp = arg2.getValue(env); Object rightTmp = arg2.getValue(env);
if (leftTmp == null || rightTmp == null) { if (leftTmp == null || rightTmp == null) {
return AviatorBoolean.valueOf(false); return AviatorBoolean.FALSE;
} }
String left = String.valueOf(leftTmp); String left = String.valueOf(leftTmp);
String right = String.valueOf(rightTmp); String right = String.valueOf(rightTmp);
...@@ -91,4 +99,76 @@ public class AviatorConfiguration { ...@@ -91,4 +99,76 @@ public class AviatorConfiguration {
return "equals"; return "equals";
} }
} }
/**
* 自定义aviator判断字符串1是否包含字符串2 (case-insensitive)
*/
private static class StrContainsFunction extends AbstractFunction {
@Override
public AviatorObject call(Map<String, Object> env, AviatorObject arg1, AviatorObject arg2) {
if (arg1 == null || arg2 == null) {
return AviatorBoolean.FALSE;
}
Object leftTmp = arg1.getValue(env);
Object rightTmp = arg2.getValue(env);
if (leftTmp == null || rightTmp == null) {
return AviatorBoolean.FALSE;
}
String left = String.valueOf(leftTmp);
String right = String.valueOf(rightTmp);
return AviatorBoolean.valueOf(StringUtils.containsIgnoreCase(left, right));
}
@Override
public String getName() {
return "contains";
}
}
/**
* 自定义aviator判断环境中是否存在字符串
*/
private static class StrExistsFunction extends AbstractFunction {
@Override
public AviatorObject call(Map<String, Object> env, AviatorObject arg) {
if (arg == null) {
return AviatorBoolean.FALSE;
}
Object keyTmp = arg.getValue(env);
if (keyTmp == null) {
return AviatorBoolean.FALSE;
}
String key = String.valueOf(keyTmp);
return AviatorBoolean.valueOf(env.containsKey(key));
}
@Override
public String getName() {
return "exists";
}
}
/**
* 自定义aviator判断字符串是否匹配regex
* - regex需要加上""或者''
*/
private static class StrMatchesFunction extends AbstractFunction {
@Override
public AviatorObject call(Map<String, Object> env, AviatorObject arg1, AviatorObject arg2) {
if (arg1 == null || arg2 == null) {
return AviatorBoolean.FALSE;
}
Object strTmp = arg1.getValue(env);
Object regexTmp = arg2.getValue(env);
if (strTmp == null || regexTmp == null) {
return AviatorBoolean.FALSE;
}
String str = String.valueOf(strTmp);
String regex = String.valueOf(regexTmp);
boolean isMatch = Pattern.compile(regex).matcher(str).matches();
return AviatorBoolean.valueOf(isMatch);
}
@Override
public String getName() {
return "matches";
}
}
} }
package org.dromara.hertzbeat.common.config;
import com.googlecode.aviator.AviatorEvaluator;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import java.util.HashMap;
import java.util.Map;
/**
* @author mikezzb
*
*/
class AviatorConfigurationTest {
@BeforeAll
static void setUp() {
AviatorConfiguration aviatorConfig = new AviatorConfiguration();
aviatorConfig.configAviatorEvaluator();
}
@Test
void testCustomStringFunctions() {
Map<String, Object> env = new HashMap<>();
env.put("k1", "Intel");
env.put("k2", "intel");
env.put("k3", "Ubuntu 18.04.6 LTS");
env.put("k4", "ubuntu");
env.put("k5", "Ubntu");
env.put("k6", null);
// test StrEqualFunction
String expr1 = "equals(k1,k2)"; // case-insensitive
Boolean res1 = (Boolean) AviatorEvaluator.compile(expr1).execute(env);
Assertions.assertTrue(res1);
String expr2 = "equals(k1,k3)";
Boolean res2 = (Boolean) AviatorEvaluator.compile(expr2).execute(env);
Assertions.assertFalse(res2);
// test StrContainsFunction
String expr3 = "contains(k3,k4)"; // case-insensitive
Boolean res3 = (Boolean) AviatorEvaluator.compile(expr3).execute(env);
Assertions.assertTrue(res3);
String expr4 = "contains(k4,k3)";
Boolean res4 = (Boolean) AviatorEvaluator.compile(expr4).execute(env);
Assertions.assertFalse(res4);
String expr5 = "contains(k3,k5)"; // subsequence
Boolean res5 = (Boolean) AviatorEvaluator.compile(expr5).execute(env);
Assertions.assertFalse(res5);
// test StrExistsFunction
String expr6 = "exists('DNE_Key1')";
Boolean res6 = (Boolean) AviatorEvaluator.compile(expr6).execute(env);
Assertions.assertFalse(res6);
String expr7 = "exists('k6')";
Boolean res7 = (Boolean) AviatorEvaluator.compile(expr7).execute(env);
Assertions.assertTrue(res7);
// test StrMatchesFunction
String regex1 = "'^[a-zA-Z0-9]+$'"; // only alphanumeric
String expr8 = "matches(k6," + regex1 + ")";
env.put("k6", "Ubntu50681269");
Boolean res8 = (Boolean) AviatorEvaluator.compile(expr8).execute(env);
Assertions.assertTrue(res8);
env.put("k6", "Ubnt_u50681269");
Boolean res9 = (Boolean) AviatorEvaluator.compile(expr8).execute(env);
Assertions.assertFalse(res9);
String regex2 = "'^Ubuntu.*'"; // starts with
String expr9 = "matches(k3," + regex2 + ")";
Boolean res10 = (Boolean) AviatorEvaluator.compile(expr9).execute(env);
Assertions.assertTrue(res10);
env.put("k3", "Ubunt_u50681269");
Boolean res11 = (Boolean) AviatorEvaluator.compile(expr9).execute(env);
Assertions.assertFalse(res11);
String regex3 = "\"^\\\\[LOG\\\\].*error$\""; // starts & ends with
String expr10 = "matches(k7," + regex3 + ")";
env.put("k7", "[LOG] detected system error");
Boolean res12 = (Boolean) AviatorEvaluator.compile(expr10).execute(env);
Assertions.assertTrue(res12);
env.put("k7", "[LOG detected system error");
Boolean res13 = (Boolean) AviatorEvaluator.compile(expr10).execute(env);
Assertions.assertFalse(res13);
}
}
\ No newline at end of file
...@@ -9,6 +9,14 @@ Learn From [webdriverio](https://webdriver.io/) ...@@ -9,6 +9,14 @@ Learn From [webdriverio](https://webdriver.io/)
yarn install yarn install
``` ```
## I18N
```console
yarn write-translations --locale zh-cn
yarn write-translations --locale en
```
## Local Development ## Local Development
```console ```console
......
...@@ -17,13 +17,16 @@ Website: hertzbeat.com | tancloud.cn ...@@ -17,13 +17,16 @@ Website: hertzbeat.com | tancloud.cn
### What is HertzBeat? ### What is HertzBeat?
> HertzBeat is an open source real-time monitoring and alerting tool with powerful custom monitoring capabilities and no Agent required. > [HertzBeat](https://github.com/dromara/hertzbeat) is an open source, real-time monitoring system with custom-monitoring and agentLess.
> It supports monitoring of application services, database, operating system, middleware, cloud native, network and other metrics, and threshold alert notification in one step. > **Monitoring+Alarm+Notify** all in one. Support monitoring web service, database, os, middleware, cloud-native, network and more.
> Support more liberal threshold rules (calculation expressions), `email` `Discord` `Slack` `Telegram` `Pegging` `WeChat` `FlyBook` `SMS` `Webhook` and other ways to timely delivery. > Easy to use, full web-based operation, monitoring and alerting at the click of a mouse, zero learning cost.
> More flexible threshold rule, timely notification delivery by `Discord` `Slack` `Telegram` `Email` `DingDing` `WeChat` `FeiShu` `Webhook` `SMS`.
> We have made the protocol specifications such as `Http,Jmx,Ssh,Snmp,Jdbc` configurable so that you can simply configure `YML` to use these protocols to customize the collection of any metrics you want. > We make protocols such as `Http, Jmx, Ssh, Snmp, Jdbc` configurable, and you only need to configure `YML` online to collect any metrics you want.
> Do you believe that you can immediately adapt a new monitoring type such as K8s or Docker just by configuring online?
> Do you believe that you can immediately adapt a new monitoring type such as K8s or Docker just by defining YML? > `HertzBeat`'s powerful custom-define, multi-type support, easy expansion, low coupling, hope to help developers and micro teams to quickly build their own monitoring system.
> We also provide **[Monitoring SaaS Cloud](https://console.tancloud.cn)**, users no longer need to deploy a cumbersome monitoring system in order to monitor resources. **[Get started for free](https://console.tancloud.cn)**.
![](https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/4236e748f5ac4352b7cf4bb65ccf97aa~tplv-k3u1fbpfcp-zoom-1.image) ![](https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/4236e748f5ac4352b7cf4bb65ccf97aa~tplv-k3u1fbpfcp-zoom-1.image)
......
--- ---
title: 开源实时监控 HertzBeat v1.3.2 发布, 更稳定更易用 title: Open source monitoring HertzBeat v1.3.2 released, Easier to use
author: tom author: tom
author_title: tom author_title: tom
author_url: https://github.com/tomsun28 author_url: https://github.com/tomsun28
...@@ -8,21 +8,24 @@ tags: [opensource, practice] ...@@ -8,21 +8,24 @@ tags: [opensource, practice]
keywords: [open source monitoring system, alerting system, Linux monitoring] keywords: [open source monitoring system, alerting system, Linux monitoring]
--- ---
官网: hertzbeat.com | tancloud.cn Website: hertzbeat.com | tancloud.cn
![](https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/a9629ef5bb6e486cacddb899f1495c6e~tplv-k3u1fbpfcp-zoom-1.image) ![](https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/a9629ef5bb6e486cacddb899f1495c6e~tplv-k3u1fbpfcp-zoom-1.image)
### HertzBeat 介绍 ### What is HertzBeat?
> HertzBeat赫兹跳动 是一个拥有强大自定义监控能力,无需 Agent 的开源实时监控告警工具。 > [HertzBeat](https://github.com/dromara/hertzbeat) is an open source, real-time monitoring system with custom-monitoring and agentLess.
> 致力于**易用友好**,全 WEB 页面操作,鼠标点一点就能监控告警,零上手学习成本。 > **Monitoring+Alarm+Notify** all in one. Support monitoring web service, database, os, middleware, cloud-native, network and more.
> 集 **监控+告警+通知** 为一体,支持对应用服务,数据库,操作系统,中间件,云原生,网络等指标监控,阈值告警通知一步到位。 > Easy to use, full web-based operation, monitoring and alerting at the click of a mouse, zero learning cost.
> 支持更自由化的阈值规则(计算表达式),`邮件` `Discord` `Slack` `Telegram` `钉钉` `微信` `飞书` `短信` `Webhook` 等方式及时送达。 > More flexible threshold rule, timely notification delivery by `Discord` `Slack` `Telegram` `Email` `DingDing` `WeChat` `FeiShu` `Webhook` `SMS`.
> 我们将`Http,Jmx,Ssh,Snmp,Jdbc`等协议规范可配置化,您只需配置`YML`就能使用这些协议去自定义采集任何您想要的指标。 > We make protocols such as `Http, Jmx, Ssh, Snmp, Jdbc` configurable, and you only need to configure `YML` online to collect any metrics you want.
> Do you believe that you can immediately adapt a new monitoring type such as K8s or Docker just by configuring online?
> `HertzBeat`'s powerful custom-define, multi-type support, easy expansion, low coupling, hope to help developers and micro teams to quickly build their own monitoring system.
> We also provide **[Monitoring SaaS Cloud](https://console.tancloud.cn)**, users no longer need to deploy a cumbersome monitoring system in order to monitor resources. **[Get started for free](https://console.tancloud.cn)**.
![](https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/4236e748f5ac4352b7cf4bb65ccf97aa~tplv-k3u1fbpfcp-zoom-1.image) ![](https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/4236e748f5ac4352b7cf4bb65ccf97aa~tplv-k3u1fbpfcp-zoom-1.image)
...@@ -31,50 +34,71 @@ keywords: [open source monitoring system, alerting system, Linux monitoring] ...@@ -31,50 +34,71 @@ keywords: [open source monitoring system, alerting system, Linux monitoring]
**Gitee: https://gitee.com/dromara/hertzbeat** **Gitee: https://gitee.com/dromara/hertzbeat**
### v1.3.2 来了 ### v1.3.2
**这次累计 27 位小伙伴们的辛苦贡献才出来了这个令人欣喜的版本。 感谢他们!爱心💗** Hi guys! Major release. HertzBeat v1.3.2 has published.
这个版本我们支持对**freebsd, debian, opensuse, redhat, apache doris**等新的监控类型和指标。 **This delightful version came out of the hard work of 27 friends. Thank them! Love 💗**
- 支持WEB页面配置邮件服务器,取代之前的文件配置 In this version, we support new monitoring types and indicators for **freebsd, debian, opensuse, redhat, apache doris**, etc.
- 支持告警收敛,是否遇到了重复告警频繁发送,有了告警收敛马上解决
- 公共消息队列支持Kafka,除了我们默认的内置内存消息队列,也支持了外置Kafka消息队列,提升系统性能。
- 新的监控中心页面,聚合所有监控类型,不用像之前那样切来切去了。
- 支持标签分组展示,把同一业务类别的监控们分组标记,统一管理。
- 阈值配置不仅仅有表达式,还支持更人性化的操作UI,之前的表达式对新人不太友好很容易出错,现在可以直接UI操作啦,它可以和表达式互相切换。
- 还有HTTP ipv6等更多功能。
修复了大量BUG,完善文档代码,提高了整体的稳定可用性。更多新功能欢迎探索! - Support WEB page configuration mail server, replace the previous file configuration
- Supports alarm convergence. If repeated alarms are frequently sent, it will be resolved immediately with alarm convergence
- The public message queue supports Kafka. In addition to our default built-in memory message queue, it also supports an external Kafka message queue to improve system performance.
- The new monitoring center page aggregates all monitoring types, no need to switch back and forth like before.
- Support label group display, group and mark monitors of the same business category for unified management.
- Threshold configuration not only has expressions, but also supports a more user-friendly operation UI. The previous expressions were not friendly to newcomers and were prone to errors. Now you can directly operate the UI, and it can switch between expressions.
- There are many more functions such as HTTP ipv6.
Fixed a large number of BUG, improved the document code, and improved the overall stability and usability. More new features are welcome to explore!
只需要一条docker命令即可安装体验hertzbeat: Let's Try Now!
Only one docker command is needed to install and experience hertzbeat:
`docker run -d -p 1157:1157 --name hertzbeat tancloud/hertzbeat` `docker run -d -p 1157:1157 --name hertzbeat tancloud/hertzbeat`
若dockerhub网络超时,可以使用下面命令: ```or use quay.io (if dockerhub network connect timeout)```
`docker run -d -p 1157:1157 --name hertzbeat quay.io/tancloud/hertzbeat`
```docker run -d -p 1157:1157 --name hertzbeat quay.io/tancloud/hertzbeat```
---
Upgrade Note⚠️.
For h2 database users, sholud exec sql below:
```sql
ALTER TABLE HZB_PARAM DROP CONSTRAINT CONSTRAINT_82;;
```
How to Enable H2 WEB Console:
Modify `application.yml` and restart, access `ip:1157/h2-console`
```
spring:
h2:
console:
path: /h2-console
enabled: true
```
---- ----
## ⛄ 已支持
> 我们将监控采集类型(mysql,jvm,k8s)都定义为yml监控模版,用户可以导入这些模版来支持对应类型的监控! ## ⛄ Supported
> 欢迎大家一起贡献你使用过程中自定义的通用监控类型监控模版。
- Website, Port Telnet, Http Api, Ping Connect, Jvm, SiteMap, Ssl Certificate, SpringBoot2, FTP Server, SpringBoot3 - Site Monitor, Port Availability, Http Api, Ping Connectivity, Jvm, SiteMap Full Site, Ssl Certificate, SpringBoot, FTP Server
- Mysql, PostgreSQL, MariaDB, Redis, ElasticSearch, SqlServer, Oracle, MongoDB, DM, OpenGauss, ClickHouse, IoTDB, Redis Cluster, Redis Sentinel - Mysql, PostgreSQL, MariaDB, Redis, ElasticSearch, SqlServer, Oracle, MongoDB, Damon, OpenGauss, ClickHouse, IoTDB, Redis Cluster
- Linux, Ubuntu, CentOS, Windows, EulerOS, Fedora CoreOS, OpenSUSE, Rocky Linux, Red Hat, FreeBSD, AlmaLinux, Debian Linux - Linux, Ubuntu, CentOS, Windows
- Tomcat, Nacos, Zookeeper, RabbitMQ, Flink, Kafka, ShenYu, DynamicTp, Jetty, ActiveMQ - Tomcat, Nacos, Zookeeper, RabbitMQ, Flink, Kafka, ShenYu, DynamicTp, Jetty, ActiveMQ
- Kubernetes, Docker - Kubernetes, Docker
- CiscoSwitch, HpeSwitch, HuaweiSwitch, TpLinkSwitch, H3cSwitch - Huawei Switch, HPE Switch, TP-LINK Switch, Cisco Switch
- 和更多自定义监控模版。 - and more for your custom monitoring.
- 通知支持 Discord Slack Telegram 邮件 钉钉 微信 飞书 短信 Webhook。 - Notifications support `Discord` `Slack` `Telegram` `Mail` `Pinning` `WeChat` `FlyBook` `SMS` `Webhook`.
---- ----
**欢迎star三连来支持我们**
**Github: https://github.com/dromara/hertzbeat** **Github: https://github.com/dromara/hertzbeat**
**Gitee: https://gitee.com/dromara/hertzbeat** **Gitee: https://gitee.com/dromara/hertzbeat**
--- ---
id: extend-http-default id: extend-http-default
title: HTTP Protocol System Default Parsing Method title: HTTP Protocol System Default Parsing Method
sidebar_label: System Default Parsing Method sidebar_label: Default Parsing Method
--- ---
> After calling the HTTP interface to obtain the response data, use the default parsing method of hertzbeat to parse the response data. > After calling the HTTP api to obtain the response data, use the default parsing method of hertzbeat to parse the response data.
**The interface response data structure must be consistent with the data structure rules specified by hertzbeat** **The interface response data structure must be consistent with the data structure rules specified by hertzbeat**
...@@ -76,7 +76,7 @@ If there are multiple virtual machines, the multilayer format is: : ...@@ -76,7 +76,7 @@ If there are multiple virtual machines, the multilayer format is: :
] ]
``` ```
**The corresponding monitoring configuration definition file YML can be configured as follows** **The corresponding monitoring template yml can be configured as follows**
```yaml ```yaml
# The monitoring type category:service-application service monitoring db-database monitoring custom-custom monitoring os-operating system monitoring # The monitoring type category:service-application service monitoring db-database monitoring custom-custom monitoring os-operating system monitoring
......
...@@ -6,7 +6,7 @@ sidebar_label: Tutorial 1 Adapting an HTTP protocol monitoring ...@@ -6,7 +6,7 @@ sidebar_label: Tutorial 1 Adapting an HTTP protocol monitoring
Through this tutorial, we describe step by step how to add a monitoring type based on the http protocol under the hertzbeat monitoring tool. Through this tutorial, we describe step by step how to add a monitoring type based on the http protocol under the hertzbeat monitoring tool.
Before reading this tutorial, we hope that you are familiar with how to customize types, indicators, protocols, etc. from [Custom Monitoring] (extend-point) and [http Protocol Customization] (extend-http.md). Before reading this tutorial, we hope that you are familiar with how to customize types, metrics, protocols, etc. from [Custom Monitoring](extend-point) and [http Protocol Customization](extend-http).
### HTTP protocol parses the general response structure to obtain indicator data ### HTTP protocol parses the general response structure to obtain indicator data
...@@ -58,131 +58,147 @@ As above, usually our background API interface will design such a general return ...@@ -58,131 +58,147 @@ As above, usually our background API interface will design such a general return
**This time we get the indicator data such as `category`, `app`, `status`, `size`, `availableSize` under the app. ** **This time we get the indicator data such as `category`, `app`, `status`, `size`, `availableSize` under the app. **
### Add custom monitoring template `hertzbeat`
### Add corresponding application definition YML and parameter definition YML **HertzBeat Dashboard** -> **Monitoring Templates** -> **New Template** -> **Config Monitoring Template Yml** -> **Save and Apply** -> **Add A Monitoring with The New Monitoring Type**
1. Custom monitoring type needs to add configuration YML file > We define all monitoring collection types (mysql,jvm,k8s) as yml monitoring templates, and users can import these templates to support corresponding types of monitoring.
A monitoring configuration definition file named after the monitoring type - for example: app-hertzbeat.yml needs to be located in the installation directory /hertzbeat/define/
2. Configure the monitoring configuration definition file app-hertzbeat.yml > Monitoring template is used to define *the name of monitoring type(international), request parameter mapping, index information, collection protocol configuration information*, etc.
Here we define a custom monitoring type `app` named `hertzbeat` which use the HTTP protocol to collect data.
**Monitoring Templates** -> **Config New Monitoring Template Yml** -> **Save and Apply**
The monitoring configuration definition file is used to define the collection type, which protocol collection method needs to be used, the collection indicators, protocol configuration parameters, etc. We directly reuse the definition content in app-api.yml and modify it to our current monitoring type `hertzbeat` configuration parameters, as follows: Note⚠️We get `category`, `app` in the interface response data this time, Fields such as `status`, `size`, `availableSize` are used as indicator data.
```yaml ```yaml
# This monitoring type belongs to the category: service-application service monitoring db-database monitoring custom-custom monitoring os-operating system monitoring # The monitoring type category:service-application service monitoring db-database monitoring custom-custom monitoring os-operating system monitoring
category: custom category: custom
# Monitoring application type name (consistent with the file name) eg: linux windows tomcat mysql aws... # The monitoring type eg: linux windows tomcat mysql aws...
app: hertzbeat app: hertzbeat
# The monitoring i18n name
name: name:
en-GB: HertzBeat Monitoring Tool zh-CN: HertzBeat监控系统
en-US: Hertz Beat Monitor en-US: HertzBeat Monitor
# Input params define for monitoring(render web ui by the definition)
params: params:
- field: host # field-param field key
name: - field: host
en-CN: Host Host # name-param field display i18n name
en-US: Host name:
type: host zh-CN: 主机Host
required: true en-US: Host
- field: port # type-param field type(most mapping the html input type)
name: type: host
en-CN: port # required-true or false
en-US: Port required: true
type: number # field-param field key
range: '[0,65535]' - field: port
required: true # name-param field display i18n name
defaultValue: 1157 name:
- field: ssl zh-CN: 端口
name: en-US: Port
en-GB: Enable HTTPS # type-param field type(most mapping the html input type)
en-US: HTTPS type: number
type: boolean # when type is number, range is required
required: true range: '[0,65535]'
- field: timeout # required-true or false
name: required: true
en-CN: Timeout (ms) # default value
en-US: Timeout(ms) defaultValue: 1157
type: number - field: ssl
required: false name:
hide: true zh-CN: 启用HTTPS
- field: authType en-US: HTTPS
name: type: boolean
en-CN: Authentication method required: true
en-US: Auth Type - field: timeout
type: radio name:
required: false zh-CN: 超时时间(ms)
hide: true en-US: Timeout(ms)
options: type: number
- label: Basic Auth required: false
value: Basic Auth hide: true
- label: Digest Auth - field: authType
value: Digest Auth name:
- field: username zh-CN: 认证方式
name: en-US: Auth Type
en-CN: username type: radio
en-US: Username required: false
type: text hide: true
limit: 20 options:
required: false - label: Basic Auth
hide: true value: Basic Auth
- field: password - label: Digest Auth
name: value: Digest Auth
en-CN: Password - field: username
en-US: Password name:
type: password zh-CN: 用户名
required: false en-US: Username
hide: true type: text
# List of indicator groups limit: 20
required: false
hide: true
- field: password
name:
zh-CN: 密码
en-US: Password
type: password
required: false
hide: true
metrics: metrics:
# The first monitoring indicator group summary # the first metrics summary
# Note: Built-in monitoring indicators have (responseTime - response time) # attention: Built-in monitoring metrics contains (responseTime - Response time)
- name: summary - name: summary
priority: 0 # metrics group scheduling priority(0->127)->(high->low), metrics with the same priority will be scheduled in parallel
fields: # priority 0's metrics group is availability metrics, it will be scheduled first, only availability metrics collect success will the scheduling continue
# Indicator information includes field name type field type: 0-number, 1-string whether instance is the primary key of the instance unit: indicator unit priority: 0
- field: responseTime # collect metrics content
type: 0 fields:
unit: ms # metrics content contains field-metric name, type-metric type:0-number,1-string, instance-if is metrics group, unit-metric unit('%','ms','MB')
- field: app - field: app
type: 1 type: 1
instance: true instance: true
- field: category - field: category
type: 1 type: 1
- field: status - field: status
type: 0 type: 0
- field: size - field: size
type: 0 type: 0
- field: availableSize - field: availableSize
type: 0 type: 0
# Monitoring and collection protocol eg: sql, ssh, http, telnet, wmi, snmp, sdk, we use HTTP protocol here # the protocol used for monitoring, eg: sql, ssh, http, telnet, wmi, snmp, sdk, we use HTTP protocol here
protocol: http protocol: http
# When the protocol is the http protocol, the specific collection configuration # the config content when protocol is http
http: http:
host: ^_^host^_^ # http host: ipv4 ipv6 domain
# port host: ^_^host^_^
port: ^_^port^_^ # http port
# url request interface path, we don’t need to enter parameters here, it’s written as /api/summary port: ^_^port^_^
url: /api/summary # http url, we don't need to enter a parameter here, just set the fixed value to /api/summary
timeout: ^_^timeout^_^ url: /api/summary
# Request method GET POST PUT DELETE PATCH, hardcoded as timeout: ^_^timeout^_^
method: GET # http method: GET POST PUT DELETE PATCH, default fixed value is GET
# Whether to enable ssl/tls, that is, http or https, default false method: GET
ssl: ^_^ssl^_^ # if enabled https, default value is false
# authentication ssl: ^_^ssl^_^
authorization: # http auth
# Authentication methods: Basic Auth, Digest Auth, Bearer Token authorization:
type: ^_^authType^_^ # http auth type: Basic Auth, Digest Auth, Bearer Token
basicAuthUsername: ^_^username^_^ type: ^_^authType^_^
basicAuthPassword: ^_^password^_^ basicAuthUsername: ^_^username^_^
digestAuthUsername: ^_^username^_^ basicAuthPassword: ^_^password^_^
digestAuthPassword: ^_^password^_^ digestAuthUsername: ^_^username^_^
# Response data parsing method: default-system rules, jsonPath-jsonPath script, website-website usability indicator monitoring, we use jsonpath here to parse the response data digestAuthPassword: ^_^password^_^
parseType: jsonPath # http response data parse type: default-hertzbeat rule, jsonpath-jsonpath script, website-for website monitoring, we use jsonpath to parse response data here
parseScript: '$.data.apps.*' parseType: jsonPath
parseScript: '$.data.apps.*'
``` ```
**The addition is complete, now we restart the hertzbeat system. We can see that the system page has added a `hertzbeat` monitoring type. ** **The addition is complete, now we save and apply. We can see that the system page has added a `hertzbeat` monitoring type. **
![](/img/docs/advanced/extend-http-example-1.png) ![](/img/docs/advanced/extend-http-example-1.png)
...@@ -216,7 +232,7 @@ metrics: ...@@ -216,7 +232,7 @@ metrics:
This is the end of the practice of custom monitoring of the HTTP protocol. The HTTP protocol also has other parameters such as headers and params. We can define it like postman, and the playability is also very high! This is the end of the practice of custom monitoring of the HTTP protocol. The HTTP protocol also has other parameters such as headers and params. We can define it like postman, and the playability is also very high!
If you think hertzbeat is a good open source project, please give us a star on GitHub Gitee, thank you very much. Thanks for the old iron support. Refill! If you think hertzbeat is a good open source project, please give us a star on GitHub Gitee, thank you very much.
**github: https://github.com/dromara/hertzbeat** **github: https://github.com/dromara/hertzbeat**
......
...@@ -4,9 +4,9 @@ title: Tutorial 2 Obtain TOKEN index value based on HTTP protocol for subsequent ...@@ -4,9 +4,9 @@ title: Tutorial 2 Obtain TOKEN index value based on HTTP protocol for subsequent
sidebar_label: Tutorial 2 Get TOKEN for subsequent authentication sidebar_label: Tutorial 2 Get TOKEN for subsequent authentication
--- ---
Through this tutorial, we will describe step by step how to modify on the basis of tutorial 1, add an indicator group, first call the authentication interface to obtain the TOKEN, and use the TOKEN as a parameter for the subsequent indicator group collection and authentication. Through this tutorial, we will describe step by step how to modify on the basis of tutorial 1, add an metrics group, first call the authentication interface to obtain the TOKEN, and use the TOKEN as a parameter for the subsequent indicator group collection and authentication.
Before reading this tutorial, we hope that you are familiar with how to customize types, indicators, protocols, etc. from [Custom Monitoring] (extend-point) and [http Protocol Customization] (extend-http.md). Before reading this tutorial, we hope that you are familiar with how to customize types, indicators, protocols, etc. from [Custom Monitoring](extend-point) and [http Protocol Customization](extend-http).
### Request process ### Request process
...@@ -37,12 +37,19 @@ Before reading this tutorial, we hope that you are familiar with how to customiz ...@@ -37,12 +37,19 @@ Before reading this tutorial, we hope that you are familiar with how to customiz
### Add custom monitoring type `hertzbeat_token` ### Add custom monitoring type `hertzbeat_token`
1. The custom monitoring type needs to add a new configuration YML file. We directly reuse the `hertzbeat` monitoring type in Tutorial 1 and modify it based on it **HertzBeat Dashboard** -> **Monitoring Templates** -> **New Template** -> **Config Monitoring Template Yml** -> **Save and Apply** -> **Add A Monitoring with The New Monitoring Type**
A monitoring configuration definition file named after the monitoring type - app-hertzbeat_token.yml needs to be located in the installation directory /hertzbeat/define/ > We define all monitoring collection types (mysql,jvm,k8s) as yml monitoring templates, and users can import these templates to support corresponding types of monitoring.
The monitoring configuration definition file is used to define the collection type, which protocol collection method needs to be used, the collection indicators, protocol configuration parameters, etc.
We directly reuse the definition content in app-hertzbeat.yml and modify it to our current monitoring type `hertzbeat_auth` configuration parameters, such as `app, category, etc`. > Monitoring template is used to define *the name of monitoring type(international), request parameter mapping, index information, collection protocol configuration information*, etc.
1. The custom monitoring type needs to add a new configuration monitoring template yml. We directly reuse the `hertzbeat` monitoring type in Tutorial 1 and modify it based on it
A monitoring configuration definition file named after the monitoring type - hertzbeat_token
We directly reuse the definition content in `hertzbeat` and modify it to our current monitoring type `hertzbeat_auth` configuration parameters, such as `app, category, etc`.
```yaml ```yaml
# This monitoring type belongs to the category: service-application service monitoring db-database monitoring custom-custom monitoring os-operating system monitoring # This monitoring type belongs to the category: service-application service monitoring db-database monitoring custom-custom monitoring os-operating system monitoring
...@@ -101,9 +108,9 @@ metrics: .... ...@@ -101,9 +108,9 @@ metrics: ....
``` ```
### Define indicator group `auth` login request to get `token` ### Define metrics group `auth` login request to get `token`
1. Add an index group definition `auth` in `app-hertzbeat_token.yml`, set the collection priority to the highest 0, and collect the index `token`. 1. Add an index group definition `auth` in `hertzbeat_token`, set the collection priority to the highest 0, and collect the index `token`.
```yaml ```yaml
...@@ -196,7 +203,7 @@ metrics: ...@@ -196,7 +203,7 @@ metrics:
``` ```
**At this time, restart the hertzbeat system, add `hertzbeat_token` type monitoring on the system page, configure input parameters, `content-type` fill in `application/json`, `request Body` fill in the account password json as follows: ** **At this time, save and apply, add `hertzbeat_token` type monitoring on the system page, configure input parameters, `content-type` fill in `application/json`, `request Body` fill in the account password json as follows: **
```json ```json
{ {
...@@ -233,7 +240,7 @@ metrics: ...@@ -233,7 +240,7 @@ metrics:
bearerTokenToken: ^o^token^o^ bearerTokenToken: ^o^token^o^
``` ```
**The final `app-hertzbeat_token.yml` is defined as follows:** **The final `hertzbeat_token` template yml is defined as follows:**
```yaml ```yaml
...@@ -368,7 +375,7 @@ metrics: ...@@ -368,7 +375,7 @@ metrics:
``` ```
**After the configuration is complete, restart the `hertzbeat` system again, and check the monitoring details page** **After the configuration is complete, save and apply, and check the monitoring details page**
![](/img/docs/advanced/extend-http-example-8.png) ![](/img/docs/advanced/extend-http-example-8.png)
...@@ -384,7 +391,7 @@ metrics: ...@@ -384,7 +391,7 @@ metrics:
This is the end of the practice of custom monitoring of the HTTP protocol. The HTTP protocol also has other parameters such as headers and params. We can define it like postman, and the playability is also very high! This is the end of the practice of custom monitoring of the HTTP protocol. The HTTP protocol also has other parameters such as headers and params. We can define it like postman, and the playability is also very high!
If you think hertzbeat is a good open source project, please give us a star on GitHub Gitee, thank you very much. Thanks for the old iron support. Refill! If you think hertzbeat is a good open source project, please give us a star on GitHub Gitee, thank you very much.
**github: https://github.com/dromara/hertzbeat** **github: https://github.com/dromara/hertzbeat**
......
...@@ -3,7 +3,7 @@ id: extend-http-jsonpath ...@@ -3,7 +3,7 @@ id: extend-http-jsonpath
title: HTTP Protocol JsonPath Parsing Method title: HTTP Protocol JsonPath Parsing Method
sidebar_label: JsonPath Parsing Method sidebar_label: JsonPath Parsing Method
--- ---
> After calling the HTTP interface to obtain the response data, use JsonPath script parsing method to parse the response data. > After calling the HTTP api to obtain the response data, use JsonPath script parsing method to parse the response data.
Note⚠️ The response data is JSON format. Note⚠️ The response data is JSON format.
...@@ -95,7 +95,7 @@ We use the jsonpath script to parse, and the corresponding script is: `$.number[ ...@@ -95,7 +95,7 @@ We use the jsonpath script to parse, and the corresponding script is: `$.number[
``` ```
This data structure conforms to the data format specification of HertzBeat, and the Metric `type,num` is successfully extracted. This data structure conforms to the data format specification of HertzBeat, and the Metric `type,num` is successfully extracted.
**The corresponding monitoring configuration definition file YML can be configured as follows** **The corresponding monitoring template yml can be configured as follows**
```yaml ```yaml
# The monitoring type category:service-application service monitoring db-database monitoring custom-custom monitoring os-operating system monitoring # The monitoring type category:service-application service monitoring db-database monitoring custom-custom monitoring os-operating system monitoring
......
...@@ -7,7 +7,8 @@ sidebar_label: HTTP Protocol Custom Monitoring ...@@ -7,7 +7,8 @@ sidebar_label: HTTP Protocol Custom Monitoring
> From [Custom Monitoring](extend-point), you are familiar with how to customize types, Metrics, protocols, etc. Here we will introduce in detail how to use HTTP protocol to customize Metric monitoring > From [Custom Monitoring](extend-point), you are familiar with how to customize types, Metrics, protocols, etc. Here we will introduce in detail how to use HTTP protocol to customize Metric monitoring
### HTTP protocol collection process ### HTTP protocol collection process
**call HTTP interface**】->【**response verification**】->【**parse reponse data**】->【**default method parsing|JsonPath script parsing | XmlPath parsing(todo) | Prometheus parsing**】->【**Metric data extraction**
**Call HTTP API**】->【**Response Verification**】->【**Parse Response Data**】->【**Default method parsing|JsonPath script parsing | XmlPath parsing(todo) | Prometheus parsing**】->【**Metric data extraction**
It can be seen from the process that we define a monitoring type of HTTP protocol. We need to configure HTTP request parameters, configure which Metrics to obtain, and configure the parsing method and parsing script for response data. It can be seen from the process that we define a monitoring type of HTTP protocol. We need to configure HTTP request parameters, configure which Metrics to obtain, and configure the parsing method and parsing script for response data.
HTTP protocol supports us to customize HTTP request path, request header, request parameters, request method, request body, etc. HTTP protocol supports us to customize HTTP request path, request header, request parameters, request method, request body, etc.
...@@ -18,19 +19,22 @@ HTTP protocol supports us to customize HTTP request path, request header, reques ...@@ -18,19 +19,22 @@ HTTP protocol supports us to customize HTTP request path, request header, reques
### Custom Steps ### Custom Steps
In order to configure a custom monitoring type, you need to add and configure YML file. **HertzBeat Dashboard** -> **Monitoring Templates** -> **New Template** -> **Config Monitoring Template Yml** -> **Save and Apply** -> **Add A Monitoring with The New Monitoring Type**
1. Monitoring configuration definition file named after monitoring type - eg:example.yml in the installation directory /hertzbeat/define/
2. Restart hertzbeat system, we successfully fit a new custom monitoring type.
------- -------
Configuration usages of the two files are detailed below. Please pay attention to usage annotation.
### Monitoring configuration definition file Configuration usages of the monitoring templates yml are detailed below. Please pay attention to usage annotation.
### Monitoring Templates YML
> We define all monitoring collection types (mysql,jvm,k8s) as yml monitoring templates, and users can import these templates to support corresponding types of monitoring.
> Monitoring template is used to define *the name of monitoring type(international), request parameter mapping, index information, collection protocol configuration information*, etc.
> Monitoring configuration definition file is used to define *the name of monitoring type(international), request parameter mapping, index information, collection protocol configuration information*, etc. eg:Define a custom monitoring type `app` named `example_http` which use the HTTP protocol to collect data.
eg:Define a custom monitoring type named example_http which use the HTTP protocol to collect data. **Monitoring Templates** -> **Config New Monitoring Template Yml** -> **Save and Apply**
The file name: example_http.yml in /define/example_http.yml
```yaml ```yaml
# The monitoring type category:service-application service monitoring db-database monitoring custom-custom monitoring os-operating system monitoring # The monitoring type category:service-application service monitoring db-database monitoring custom-custom monitoring os-operating system monitoring
......
...@@ -49,19 +49,20 @@ Here by mapping the Metric field with the key of the response data, we can obta ...@@ -49,19 +49,20 @@ Here by mapping the Metric field with the key of the response data, we can obta
### Custom Steps ### Custom Steps
In order to configure a custom monitoring type, you need to add and configure YML file. **HertzBeat Dashboard** -> **Monitoring Templates** -> **New Template** -> **Config Monitoring Template Yml** -> **Save and Apply** -> **Add A Monitoring with The New Monitoring Type**
1. Monitoring configuration definition file named after monitoring type - eg:example_sql.yml in the installation directory /hertzbeat/app/
2. Restart hertzbeat system, we successfully fit a new custom monitoring type.
------- -------
Configuration usages of the file is detailed below. Please pay attention to usage annotation. Configuration usages of the monitoring templates yml are detailed below.
### Monitoring configuration definition file ### Monitoring Templates YML
> Monitoring configuration definition file is used to define *the name of monitoring type(international), request parameter mapping, index information, collection protocol configuration information*, etc. > We define all monitoring collection types (mysql,jvm,k8s) as yml monitoring templates, and users can import these templates to support corresponding types of monitoring.
eg:Define a custom monitoring type named example_sql which use the JDBC protocol to collect data.
The file name: example_sql.yml in /define/example_sql.yml > Monitoring template is used to define *the name of monitoring type(international), request parameter mapping, index information, collection protocol configuration information*, etc.
eg:Define a custom monitoring type `app` named `example_sql` which use the JDBC protocol to collect data.
```yaml ```yaml
# The monitoring type category:service-application service monitoring db-database monitoring custom-custom monitoring os-operating system monitoring # The monitoring type category:service-application service monitoring db-database monitoring custom-custom monitoring os-operating system monitoring
......
---
id: extend-jmx
title: JMX Protocol Custom Monitoring
sidebar_label: JMX Protocol Custom Monitoring
---
> From [Custom Monitoring](extend-point), you are familiar with how to customize types, Metrics, protocols, etc. Here we will introduce in detail how to use JMX to customize Metric monitoring.
> JMX protocol custom monitoring allows us to easily monitor Metrics we want by config JMX Mbeans Object.
### JMX protocol collection process
**Peer Server Enable Jmx Service**】->【**HertzBeat Connect Peer Server Jmx**】->【**Query Jmx Mbean Object Data**】->【**Metric data extraction**
It can be seen from the process that we define a monitoring type of JMX protocol. We need to configure JMX request parameters, configure which Metrics to obtain, and configure Mbeans Object.
### Data parsing method
By configuring the monitoring template YML metrics `field`, `aliasFields`, `objectName` of the `jmx` protocol to map and parse the `Mbean` object information exposed by the peer system.
### Custom Steps
**HertzBeat Dashboard** -> **Monitoring Templates** -> **New Template** -> **Config Monitoring Template Yml** -> **Save and Apply** -> **Add A Monitoring with The New Monitoring Type**
![](/img/docs/advanced/extend-point-1.png)
-------
Configuration usages of the monitoring templates yml are detailed below.
### Monitoring Templates YML
> We define all monitoring collection types (mysql,jvm,k8s) as yml monitoring templates, and users can import these templates to support corresponding types of monitoring.
> Monitoring template is used to define *the name of monitoring type(international), request parameter mapping, index information, collection protocol configuration information*, etc.
eg:Define a custom monitoring type `app` named `example_jvm` which use the JVM protocol to collect data.
```yaml
# The monitoring type category:service-application service monitoring db-database monitoring custom-custom monitoring os-operating system monitoring
category: service
# The monitoring type eg: linux windows tomcat mysql aws...
app: example_jvm
# The monitoring i18n name
name:
zh-CN: 自定义JVM虚拟机
en-US: CUSTOM JVM
# Input params define for monitoring(render web ui by the definition)
params:
# field-param field key
- field: host
# name-param field display i18n name
name:
zh-CN: 主机Host
en-US: Host
# type-param field type(most mapping the html input type)
type: host
# required-true or false
required: true
# field-param field key
- field: port
# name-param field display i18n name
name:
zh-CN: 端口
en-US: Port
# type-param field type(most mapping the html input type)
type: number
# when type is number, range is required
range: '[0,65535]'
# required-true or false
required: true
# default value
defaultValue: 9999
# field-param field key
- field: url
# name-param field display i18n name
name:
zh-CN: JMX URL
en-US: JMX URL
# type-param field type(most mapping the html input type)
type: text
# required-true or false
required: false
# hide param-true or false
hide: true
# param field input placeholder
placeholder: 'service:jmx:rmi:///jndi/rmi://host:port/jmxrmi'
# field-param field key
- field: username
# name-param field display i18n name
name:
zh-CN: 用户名
en-US: Username
# type-param field type(most mapping the html input type)
type: text
# when type is text, use limit to limit string length
limit: 20
# required-true or false
required: false
# hide param-true or false
hide: true
# field-param field key
- field: password
# name-param field display i18n name
name:
zh-CN: 密码
en-US: Password
# type-param field type(most mapping the html input tag)
type: password
# required-true or false
required: false
# hide param-true or false
hide: true
# collect metrics config list
metrics:
# metrics - basic
- name: basic
# metrics group scheduling priority(0->127)->(high->low), metrics with the same priority will be scheduled in parallel
# priority 0's metrics group is availability metrics, it will be scheduled first, only availability metrics collect success will the scheduling continue
priority: 0
# collect metrics content
fields:
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), instance-if is metrics group unique identifier
- field: VmName
type: 1
- field: VmVendor
type: 1
- field: VmVersion
type: 1
- field: Uptime
type: 0
unit: ms
# the protocol used for monitoring, eg: sql, ssh, http, telnet, wmi, snmp, sdk
protocol: jmx
# the config content when protocol is jmx
jmx:
# host: ipv4 ipv6 domain
host: ^_^host^_^
# port
port: ^_^port^_^
username: ^_^username^_^
password: ^_^password^_^
# jmx mbean object name
objectName: java.lang:type=Runtime
url: ^_^url^_^
- name: memory_pool
priority: 1
fields:
- field: name
type: 1
instance: true
- field: committed
type: 0
unit: MB
- field: init
type: 0
unit: MB
- field: max
type: 0
unit: MB
- field: used
type: 0
unit: MB
units:
- committed=B->MB
- init=B->MB
- max=B->MB
- used=B->MB
# (optional)metrics field alias name, it is used as an alias field to map and convert the collected data and metrics field
aliasFields:
- Name
- Usage->committed
- Usage->init
- Usage->max
- Usage->used
# mapping and conversion expressions, use these and aliasField above to calculate metrics value
# eg: cores=core1+core2, usage=usage, waitTime=allTime-runningTime
calculates:
- name=Name
- committed=Usage->committed
- init=Usage->init
- max=Usage->max
- used=Usage->used
protocol: jmx
jmx:
# host: ipv4 ipv6 domain
host: ^_^host^_^
# port
port: ^_^port^_^
username: ^_^username^_^
password: ^_^password^_^
objectName: java.lang:type=MemoryPool,name=*
url: ^_^url^_^
```
...@@ -3,190 +3,132 @@ id: extend-point ...@@ -3,190 +3,132 @@ id: extend-point
title: Custom Monitoring title: Custom Monitoring
sidebar_label: Custom Monitoring sidebar_label: Custom Monitoring
--- ---
> HertzBeat has custom monitoring ability. You only need to configure two YML file to fit a custom monitoring type. > HertzBeat has custom monitoring ability. You only need to configure monitoring template yml to fit a custom monitoring type.
> Custom monitoring currently supports [HTTP protocol](extend-http),[JDBC protocol](extend-jdbc)(mysql,mariadb,postgresql...), [SSH protocol](extend-ssh), JMX protocol, SNMP protocol. And it will support more general protocols in the future. > Custom monitoring currently supports [HTTP protocol](extend-http),[JDBC protocol](extend-jdbc), [SSH protocol](extend-ssh), [JMX protocol](extend-jmx), [SNMP protocol](extend-snmp). And it will support more general protocols in the future.
### Custom Steps ### Custom Monitoring Steps
**HertzBeat Dashboard** -> **Monitoring Templates** -> **New Template** -> **Config Monitoring Template Yml** -> **Save and Apply** -> **Add A Monitoring with The New Monitoring Type**
In order to configure a custom monitoring type, you need to add and configure YML file.
1. Monitoring configuration definition file named after monitoring type - eg:example.yml should be in the installation directory /hertzbeat/app/
2. Restart hertzbeat system, we successfully fit a new custom monitoring type.
------- -------
Configuration usages of the file are detailed below.
### Monitoring configuration definition file Configuration usages of the monitoring templates yml are detailed below.
### Monitoring Templates YML
> We define all monitoring collection types (mysql,jvm,k8s) as yml monitoring templates, and users can import these templates to support corresponding types of monitoring.
> Monitoring template is used to define *the name of monitoring type(international), request parameter mapping, index information, collection protocol configuration information*, etc.
eg:Define a custom monitoring type `app` named `example2` which use the HTTP protocol to collect data.
> Monitoring configuration definition file is used to define *the name of monitoring type(international), request parameter mapping, index information, collection protocol configuration information*, etc. **Monitoring Templates** -> **Config New Monitoring Template Yml** -> **Save and Apply**
eg:Define a custom monitoring type named example which use the HTTP protocol to collect data.
The file name: example.yml in /define/example.yml
```yaml ```yaml
# The monitoring type category:service-application service monitoring db-database monitoring custom-custom monitoring os-operating system monitoring # The monitoring type category:service-application service monitoring db-database monitoring custom-custom monitoring os-operating system monitoring
category: custom category: custom
# Monitoring application type(consistent with the file name) eg: linux windows tomcat mysql aws... # The monitoring type eg: linux windows tomcat mysql aws...
app: example app: example2
# The monitoring i18n name
name: name:
zh-CN: 模拟应用类型 zh-CN: 模拟网站监测
en-US: EXAMPLE APP en-US: EXAMPLE WEBSITE
param: # Input params define for monitoring(render web ui by the definition)
# field-field name identifier params:
# field-param field key
- field: host - field: host
# name-parameter field display name # name-param field display i18n name
name: name:
zh-CN: 主机Host zh-CN: 主机Host
en-US: Host en-US: Host
# type-field type, style(most mappings are input label type attribute) # type-param field type(most mapping the html input type)
type: host type: host
# required or not true-required false-optional # required-true or false
required: true required: true
# field-param field key
- field: port - field: port
# name-param field display i18n name
name: name:
zh-CN: 端口 zh-CN: 端口
en-US: Port en-US: Port
# type-param field type(most mapping the html input type)
type: number type: number
# When type is number, range is used to represent the range. # when type is number, range is required
range: '[0,65535]' range: '[0,65535]'
# required-true or false
required: true required: true
# port default # default value
defaultValue: 80 defaultValue: 80
# Prompt information of parameter input box # field-param field key
placeholder: 'Please enter the port' - field: uri
- field: username # name-param field display i18n name
name: name:
zh-CN: 用户名 zh-CN: 相对路径
en-US: Username en-US: URI
# type-param field type(most mapping the html input tag)
type: text type: text
# When type is text, use limit to indicate the string limit size # when type is text, use limit to limit string length
limit: 20 limit: 200
required: false # required-true or false
- field: password
name:
zh-CN: 密码
en-US: Password
type: password
required: false required: false
# param field input placeholder
placeholder: 'Website uri path(no ip port) EG:/console'
# field-param field key
- field: ssl - field: ssl
# name-param field display i18n name
name: name:
zh-CN: 动SSL zh-CN: 用HTTPS
en-US: Enable SSL en-US: HTTPS
# When type is boolean, front end uses switch to show the switch # type-param field type(most mapping the html input type)
type: boolean type: boolean
required: false # required-true or false
- field: method
name:
zh-CN: 请求方式
en-US: Method
type: radio
required: true required: true
# When type is radio or checkbox, option indicates the list of selectable values {name1:value1,name2:value2} # field-param field key
options: - field: timeout
- label: GET request # name-param field display i18n name
value: GET name:
- label: POST request zh-CN: 超时时间(ms)
value: POST en-US: Timeout(ms)
- label: PUT request # type-param field type(most mapping the html input tag)
value: PUT type: number
- label: DELETE request # required-true or false
value: DELETE required: false
# Metric group list # hide param-true or false
hide: true
metrics: metrics:
# The first monitoring Metric group cpu # metrics - summary, inner monitoring metrics (responseTime - response time, keyword - number of keywords)
# Note:: the built-in monitoring Metrics have (responseTime - response time) - name: summary
- name: cpu # metrics group scheduling priority(0->127)->(high->low), metrics with the same priority will be scheduled in parallel
# The smaller Metric group scheduling priority(0-127), the higher the priority. After completion of the high priority Metric group collection,the low priority Metric group will then be scheduled. Metric groups with the same priority will be scheduled in parallel. # priority 0's metrics group is availability metrics, it will be scheduled first, only availability metrics collect success will the scheduling continue
# Metric group with a priority of 0 is an availability group which will be scheduled first. If the collection succeeds, the scheduling will continue otherwise interrupt scheduling.
priority: 0 priority: 0
# Specific monitoring Metrics in the Metric group # collect metrics content
fields: fields:
# Metric information include field: name type: field type(0-number: number, 1-string: string) instance: primary key of instance or not unit: Metric unit # field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), instance-if is metrics group unique identifier
- field: hostname - field: responseTime
type: 1
instance: true
- field: usage
type: 0
unit: '%'
- field: cores
type: 0 type: 0
- field: waitTime unit: ms
- field: keyword
type: 0 type: 0
unit: s # the protocol used for monitoring, eg: sql, ssh, http, telnet, wmi, snmp, sdk
# (optional)Monitoring Metric alias mapping to the Metric name above. The field used to collect interface data is not the final Metric name directly. This alias is required for mapping conversion.
aliasFields:
- hostname
- core1
- core2
- usage
- allTime
- runningTime
# (optional)The Metric calculation expression works with the above alias to calculate the final required Metric value.
# eg: cores=core1+core2, usage=usage, waitTime=allTime-runningTime
calculates:
- hostname=hostname
- cores=core1+core2
- usage=usage
- waitTime=allTime-runningTime
# protocol for monitoring and collection eg: sql, ssh, http, telnet, wmi, snmp, sdk
protocol: http protocol: http
# Specific collection configuration when the protocol is HTTP protocol # the config content when protocol is http
http: http:
# host: ipv4 ipv6 domain name # http host: ipv4 ipv6 domain
host: ^_^host^_^ host: ^_^host^_^
# port # http port
port: ^_^port^_^ port: ^_^port^_^
# url request interface path # http url
url: /metrics/cpu url: ^_^uri^_^
# request mode GET POST PUT DELETE PATCH timeout: ^_^timeout^_^
# http method: GET POST PUT DELETE PATCH
method: GET method: GET
# enable ssl/tls or not, tthat is to say, HTTP or HTTPS. The default is false # if enabled https
ssl: false ssl: ^_^ssl^_^
# request header content # http response data parse type: default-hertzbeat rule, jsonpath-jsonpath script, website-for website monitoring, prometheus-prometheus exporter rule
headers: parseType: website
apiVersion: v1
# request parameter content
params:
param1: param1
param2: param2
# authorization
authorization:
# authorization method : Basic Auth, Digest Auth, Bearer Token
type: Basic Auth
basicAuthUsername: ^_^username^_^
basicAuthPassword: ^_^password^_^
# parsing method for reponse data: default-system rules, jsonPath-jsonPath script, website-website availability Metric monitoring
# todo xmlPath-xmlPath script,prometheus-Prometheus data rules
parseType: jsonPath
parseScript: '$'
- name: memory
priority: 1
fields:
- field: hostname
type: 1
instance: true
- field: total
type: 0
unit: kb
- field: usage
type: 0
unit: '%'
- field: speed
type: 0
protocol: http
http:
host: ^_^host^_^
port: ^_^port^_^
url: /metrics/memory
method: GET
headers:
apiVersion: v1
params:
param1: param1
param2: param2
authorization:
type: Basic Auth
basicAuthUsername: ^_^username^_^
basicAuthPassword: ^_^password^_^
parseType: default
``` ```
---
id: extend-snmp
title: SNMP Protocol Custom Monitoring
sidebar_label: SNMP Protocol Custom Monitoring
---
> From [Custom Monitoring](extend-point), you are familiar with how to customize types, Metrics, protocols, etc. Here we will introduce in detail how to use SNMP to customize Metric monitoring.
> JMX protocol custom monitoring allows us to easily monitor Metrics we want by config SNMP MIB OIDs.
### SNMP protocol collection process
**Peer Server Enable SNMP Service**】->【**HertzBeat Connect Peer Server SNMP**】->【**Query Oids Data**】->【**Metric data extraction**
It can be seen from the process that we define a monitoring type of Snmp protocol. We need to configure Snmp request parameters, configure which Metrics to obtain, and configure oids.
### Data parsing method
By configuring the metrics `field`, `aliasFields`, and `oids` under the `snmp` protocol of the monitoring template YML to capture the data specified by the peer and parse the mapping.
### Custom Steps
**HertzBeat Dashboard** -> **Monitoring Templates** -> **New Template** -> **Config Monitoring Template Yml** -> **Save and Apply** -> **Add A Monitoring with The New Monitoring Type**
![](/img/docs/advanced/extend-point-1.png)
-------
Configuration usages of the monitoring templates yml are detailed below.
### Monitoring Templates YML
> We define all monitoring collection types (mysql,jvm,k8s) as yml monitoring templates, and users can import these templates to support corresponding types of monitoring.
> Monitoring template is used to define *the name of monitoring type(international), request parameter mapping, index information, collection protocol configuration information*, etc.
eg:Define a custom monitoring type `app` named `example_windows` which use the SNMP protocol to collect data.
```yaml
# The monitoring type category:service-application service monitoring db-database monitoring mid-middleware custom-custom monitoring os-operating system monitoring
category: os
# The monitoring type eg: linux windows tomcat mysql aws...
app: windows
# The monitoring i18n name
name:
zh-CN: Windows操作系统
en-US: OS Windows
# Input params define for monitoring(render web ui by the definition)
params:
# field-param field key
- field: host
# name-param field display i18n name
name:
zh-CN: 主机Host
en-US: Host
# type-param field type(most mapping the html input type)
type: host
# required-true or false
required: true
# field-param field key
- field: port
# name-param field display i18n name
name:
zh-CN: 端口
en-US: Port
# type-param field type(most mapping the html input type)
type: number
# when type is number, range is required
range: '[0,65535]'
# required-true or false
required: true
# default value
defaultValue: 161
# field-param field key
- field: version
# name-param field display i18n name
name:
zh-CN: SNMP 版本
en-US: SNMP Version
# type-param field type(radio mapping the html radio tag)
type: radio
# required-true or false
required: true
# when type is radio checkbox, use option to show optional values {name1:value1,name2:value2}
options:
- label: SNMPv1
value: 0
- label: SNMPv2c
value: 1
# field-param field key
- field: community
# name-param field display i18n name
name:
zh-CN: SNMP 团体字
en-US: SNMP Community
# type-param field type(most mapping the html input type)
type: text
# when type is text, use limit to limit string length
limit: 100
# required-true or false
required: true
# param field input placeholder
placeholder: 'Snmp community for v1 v2c'
# field-param field key
- field: timeout
# name-param field display i18n name
name:
zh-CN: 超时时间(ms)
en-US: Timeout(ms)
# type-param field type(most mapping the html input type)
type: number
# when type is number, range is required
range: '[0,100000]'
# required-true or false
required: false
# hide-is hide this field and put it in advanced layout
hide: true
# default value
defaultValue: 6000
# collect metrics config list
metrics:
# metrics - system
- name: system
# metrics group scheduling priority(0->127)->(high->low), metrics with the same priority will be scheduled in parallel
# priority 0's metrics group is availability metrics, it will be scheduled first, only availability metrics collect success will the scheduling continue
priority: 0
# collect metrics content
fields:
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), instance-if is metrics group unique identifier
- field: name
type: 1
- field: descr
type: 1
- field: uptime
type: 1
- field: numUsers
type: 0
- field: services
type: 0
- field: processes
type: 0
- field: responseTime
type: 0
unit: ms
- field: location
type: 1
# the protocol used for monitoring, eg: sql, ssh, http, telnet, wmi, snmp, sdk
protocol: snmp
# the config content when protocol is snmp
snmp:
# server host: ipv4 ipv6 domain
host: ^_^host^_^
# server port
port: ^_^port^_^
# snmp connect timeout
timeout: ^_^timeout^_^
# snmp community
community: ^_^community^_^
# snmp version
version: ^_^version^_^
# snmp operation: get, walk
operation: get
# metrics oids: metric_name - oid_value
oids:
name: 1.3.6.1.2.1.1.5.0
descr: 1.3.6.1.2.1.1.1.0
uptime: 1.3.6.1.2.1.25.1.1.0
numUsers: 1.3.6.1.2.1.25.1.5.0
services: 1.3.6.1.2.1.1.7.0
processes: 1.3.6.1.2.1.25.1.6.0
location: 1.3.6.1.2.1.1.6.0
```
...@@ -55,21 +55,22 @@ total used free buff_cache available ...@@ -55,21 +55,22 @@ total used free buff_cache available
Here the Metric field and the response data can be mapped into collected data one by one. Here the Metric field and the response data can be mapped into collected data one by one.
### Custom Steps ### Custom Steps
In order to configure a custom monitoring type, you need to add and configure YML file. **HertzBeat Dashboard** -> **Monitoring Templates** -> **New Template** -> **Config Monitoring Template Yml** -> **Save and Apply** -> **Add A Monitoring with The New Monitoring Type**
1. Monitoring configuration definition file named after monitoring type - eg:example_linux.yml in the installation directory /hertzbeat/app/
2. Restart hertzbeat system, we successfully fit a new custom monitoring type.
------- -------
Configuration usages of the file are detailed below. Please pay attention to usage annotation. Configuration usages of the monitoring templates yml are detailed below.
### Monitoring configuration definition file ### Monitoring Templates YML
> Monitoring configuration definition file is used to define *the name of monitoring type(international), request parameter mapping, index information, collection protocol configuration information*, etc. > We define all monitoring collection types (mysql,jvm,k8s) as yml monitoring templates, and users can import these templates to support corresponding types of monitoring.
> Monitoring template is used to define *the name of monitoring type(international), request parameter mapping, index information, collection protocol configuration information*, etc.
eg:Define a custom monitoring type `app` named `example_linux` which use the SSH protocol to collect data.
eg:Define a custom monitoring type named example_linux which use the SSH protocol to collect data.
The file name: example_linux.yml in /define/example_linux.yml
```yaml ```yaml
# The monitoring type category:service-application service monitoring db-database monitoring custom-custom monitoring os-operating system monitoring # The monitoring type category:service-application service monitoring db-database monitoring custom-custom monitoring os-operating system monitoring
......
--- ---
id: extend-tutorial id: extend-tutorial
title: Quick Tutorial Customize and adapt a monitoring based on HTTP protocol title: Quick Tutorial Customize and adapt a monitoring based on HTTP protocol
sidebar_label: Quick Tutorial sidebar_label: Tutorial Case
--- ---
Through this tutorial, we describe step by step how to customize and adapt a monitoring type based on the http protocol under the hertzbeat monitoring tool. Through this tutorial, we describe step by step how to customize and adapt a monitoring type based on the http protocol under the hertzbeat monitoring tool.
Before reading this tutorial, we hope that you are familiar with how to customize types, indicators, protocols, etc. from [Custom Monitoring] (extend-point) and [http Protocol Customization] (extend-http.md). Before reading this tutorial, we hope that you are familiar with how to customize types, metrics, protocols, etc. from [Custom Monitoring](extend-point) and [Http Protocol Customization](extend-http).
### HTTP protocol parses the general response structure to obtain indicator data ### HTTP protocol parses the general response structure to obtain metrics data
> In many scenarios, we need to monitor the provided HTTP API interface and obtain the index value returned by the interface. In this article, we use the http custom protocol to parse our common http interface response structure, and obtain the fields in the returned body as indicator data. > In many scenarios, we need to monitor the provided HTTP API interface and obtain the index value returned by the interface. In this article, we use the http custom protocol to parse our common http interface response structure, and obtain the fields in the returned body as indicator data.
...@@ -56,133 +56,145 @@ As above, usually our background API interface will design such a general return ...@@ -56,133 +56,145 @@ As above, usually our background API interface will design such a general return
} }
``` ```
**This time we get the indicator data such as `category`, `app`, `status`, `size`, `availableSize` under the app. ** **This time we get the metrics data such as `category`, `app`, `status`, `size`, `availableSize` under the app. **
### Add corresponding application definition YML and parameter definition YML ### Add Monitoring Template Yml
1. Custom monitoring type needs to add configuration YML file **HertzBeat Dashboard** -> **Monitoring Templates** -> **New Template** -> **Config Monitoring Template Yml** -> **Save and Apply** -> **Add A Monitoring with The New Monitoring Type**
A monitoring configuration definition file named after the monitoring type - for example: app-hertzbeat.yml needs to be located in the installation directory /hertzbeat/define/ > We define all monitoring collection types (mysql,jvm,k8s) as yml monitoring templates, and users can import these templates to support corresponding types of monitoring.
Define which parameters we need to enter on the page. The general HTTP protocol parameters mainly include ip, port, headers, params, uri, account password, etc. We directly reuse the parameter definition content in param-api.yml and delete our No need to enter parameters such as uri parameters and keyword keywords.
Define what type of collection is, which protocol collection method needs to be used, what indicators are collected, protocol configuration parameters, etc. We directly reuse the definition content in app-api.yml and modify it to our current monitoring type `hertzbeat` configuration parameters, as follows: Note⚠️We get `category`, `app` in the interface response data this time, Fields such as `status`, `size`, `availableSize` are used as indicator data. > Monitoring template is used to define *the name of monitoring type(international), request parameter mapping, index information, collection protocol configuration information*, etc.
Here we define a custom monitoring type `app` named `hertzbeat` which use the HTTP protocol to collect data.
**Monitoring Templates** -> **Config New Monitoring Template Yml** -> **Save and Apply**
```yaml ```yaml
# This monitoring type belongs to the category: service-application service monitoring db-database monitoring custom-custom monitoring os-operating system monitoring # The monitoring type category:service-application service monitoring db-database monitoring custom-custom monitoring os-operating system monitoring
category: custom category: custom
# Monitoring application type name (consistent with the file name) eg: linux windows tomcat mysql aws... # The monitoring type eg: linux windows tomcat mysql aws...
app: hertzbeat app: hertzbeat
# The monitoring i18n name
name: name:
en-GB: HertzBeat Monitoring Tool zh-CN: HertzBeat监控系统
en-US: Hertz Beat Monitor en-US: HertzBeat Monitor
# Input params define for monitoring(render web ui by the definition)
params: params:
- field: host # field-param field key
name: - field: host
en-CN: Host Host # name-param field display i18n name
en-US: Host name:
type: host zh-CN: 主机Host
required: true en-US: Host
- field: port # type-param field type(most mapping the html input type)
name: type: host
en-CN: port # required-true or false
en-US: Port required: true
type: number # field-param field key
range: '[0,65535]' - field: port
required: true # name-param field display i18n name
defaultValue: 1157 name:
- field: ssl zh-CN: 端口
name: en-US: Port
en-GB: Enable HTTPS # type-param field type(most mapping the html input type)
en-US: HTTPS type: number
type: boolean # when type is number, range is required
required: true range: '[0,65535]'
- field: timeout # required-true or false
name: required: true
en-CN: Timeout (ms) # default value
en-US: Timeout(ms) defaultValue: 1157
type: number - field: ssl
required: false name:
hide: true zh-CN: 启用HTTPS
- field: authType en-US: HTTPS
name: type: boolean
en-CN: Authentication method required: true
en-US: Auth Type - field: timeout
type: radio name:
required: false zh-CN: 超时时间(ms)
hide: true en-US: Timeout(ms)
options: type: number
- label: Basic Auth required: false
value: Basic Auth hide: true
- label: Digest Auth - field: authType
value: Digest Auth name:
- field: username zh-CN: 认证方式
name: en-US: Auth Type
en-CN: username type: radio
en-US: Username required: false
type: text hide: true
limit: 20 options:
required: false - label: Basic Auth
hide: true value: Basic Auth
- field: password - label: Digest Auth
name: value: Digest Auth
en-CN: Password - field: username
en-US: Password name:
type: password zh-CN: 用户名
required: false en-US: Username
hide: true type: text
# List of indicator groups limit: 20
required: false
hide: true
- field: password
name:
zh-CN: 密码
en-US: Password
type: password
required: false
hide: true
metrics: metrics:
# The first monitoring indicator group summary # the first metrics summary
# Note: Built-in monitoring indicators have (responseTime - response time) # attention: Built-in monitoring metrics contains (responseTime - Response time)
- name: summary - name: summary
# The smaller the index group scheduling priority (0-127), the higher the priority, and the index group with low priority will not be scheduled until the collection of index groups with high priority is completed, and the index groups with the same priority will be scheduled and collected in parallel # metrics group scheduling priority(0->127)->(high->low), metrics with the same priority will be scheduled in parallel
# The indicator group with priority 0 is the availability indicator group, that is, it will be scheduled first, and other indicator groups will continue to be scheduled if the collection is successful, and the scheduling will be interrupted if the collection fails # priority 0's metrics group is availability metrics, it will be scheduled first, only availability metrics collect success will the scheduling continue
priority: 0 priority: 0
# Specific monitoring indicators in the indicator group # collect metrics content
fields: fields:
# Indicator information includes field name type field type: 0-number, 1-string whether instance is the primary key of the instance unit: indicator unit # metrics content contains field-metric name, type-metric type:0-number,1-string, instance-if is metrics group, unit-metric unit('%','ms','MB')
- field: responseTime - field: app
type: 0 type: 1
unit: ms instance: true
- field: app - field: category
type: 1 type: 1
instance: true - field: status
- field: category type: 0
type: 1 - field: size
- field: status type: 0
type: 0 - field: availableSize
- field: size type: 0
type: 0 # the protocol used for monitoring, eg: sql, ssh, http, telnet, wmi, snmp, sdk, we use HTTP protocol here
- field: availableSize protocol: http
type: 0 # the config content when protocol is http
# Monitoring and collection protocol eg: sql, ssh, http, telnet, wmi, snmp, sdk, we use HTTP protocol here http:
protocol: http # http host: ipv4 ipv6 domain
# When the protocol is the http protocol, the specific collection configuration host: ^_^host^_^
http: # http port
host: ^_^host^_^ port: ^_^port^_^
# port # http url, we don't need to enter a parameter here, just set the fixed value to /api/summary
port: ^_^port^_^ url: /api/summary
# url request interface path, we don’t need to enter parameters here, it’s written as /api/summary timeout: ^_^timeout^_^
url: /api/summary # http method: GET POST PUT DELETE PATCH, default fixed value is GET
timeout: ^_^timeout^_^ method: GET
# Request method GET POST PUT DELETE PATCH, hardcoded as # if enabled https, default value is false
method: GET ssl: ^_^ssl^_^
# Whether to enable ssl/tls, that is, http or https, default false # http auth
ssl: ^_^ssl^_^ authorization:
# authentication # http auth type: Basic Auth, Digest Auth, Bearer Token
authorization: type: ^_^authType^_^
# Authentication methods: Basic Auth, Digest Auth, Bearer Token basicAuthUsername: ^_^username^_^
type: ^_^authType^_^ basicAuthPassword: ^_^password^_^
basicAuthUsername: ^_^username^_^ digestAuthUsername: ^_^username^_^
basicAuthPassword: ^_^password^_^ digestAuthPassword: ^_^password^_^
digestAuthUsername: ^_^username^_^ # http response data parse type: default-hertzbeat rule, jsonpath-jsonpath script, website-for website monitoring, we use jsonpath to parse response data here
digestAuthPassword: ^_^password^_^ parseType: jsonPath
# Response data parsing method: default-system rules, jsonPath-jsonPath script, website-website usability indicator monitoring, we use jsonpath here to parse the response data parseScript: '$.data.apps.*'
parseType: jsonPath
parseScript: '$.data.apps.*'
``` ```
**The addition is complete, now we restart the hertzbeat system. We can see that the system page has added a `hertzbeat` monitoring type. ** **The addition is complete, now we restart the hertzbeat system. We can see that the system page has added a `hertzbeat` monitoring type. **
......
---
id: spark
title: Monitoring Spark
sidebar_label: Spark Monitor
keywords: [open source monitoring tool, open source java spark monitoring tool, monitoring spark metrics]
---
> Collect and monitor the general performance Metrics of Spark.
**Protocol Use:JMX**
### Spark App Enable JMX Protocol
1. Add Spark `VM options` When Start Server ⚠️ customIP
Refer: https://spark.apache.org/docs/latest/spark-standalone.html
**监控配置spark的监控主要分为Master、Worker、driver、executor监控。Master和Worker的监控在spark集群运行时即可监控,Driver和Excutor的监控需要针对某一个app来进行监控。**
**如果都要监控,需要根据以下步骤来配置**
## 第一步
**修改$SPARK_HOME/conf/spark-env.sh,添加以下语句:**
```shell
# JMX Port to use
SPARK_DAEMON_JAVA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"
# export SPARK_DAEMON_JAVA_OPTS="$SPARK_DAEMON_JAVA_OPTS -Dcom.sun.management.jmxremote.port=$JMX_PORT "
export SPARK_DAEMON_JAVA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=8712 "
```
语句中有$JMX_PORT,这个的值可以自定义,也可以获取一个随机数作为端口号。
如果端口自定义为一个具体的值,而 spark 的 Master 和其中之一的 Worker 在同一台机器上,会出现端口冲突的情况。
## 第二步
**vim $SPARK_HOME/conf/metrics.properties 添加如下内容**
```shell
*.sink.jmx.class=org.apache.spark.metrics.sink.JmxSink
master.source.jvm.class=org.apache.spark.metrics.source.JvmSource
worker.source.jvm.class=org.apache.spark.metrics.source.JvmSource
driver.source.jvm.class=org.apache.spark.metrics.source.JvmSource
executor.source.jvm.class=org.apache.spark.metrics.source.JvmSource
```
## 第三步
**vim $SPARK_HOME/conf/spark-defaults.conf,添加以下项为driver和executor设置监控端口,在有程序运行的情况下,此端口会被打开。**
```shell
spark.metrics.conf /opt/bigdata/spark/conf/metrics.properties
spark.driver.extraJavaOptions -XX:+PrintGCDetails -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.mana
gement.jmxremote.port=8712
spark.executor.extraJavaOptions -XX:+PrintGCDetails -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.mana
gement.jmxremote.port=8711
```
在spark的Master和Worker正常运行以及spark-submit提交了一个程序的情况下,可以从linux中查询出端口号码。
### Configuration parameter
| Parameter name | Parameter help description |
|---------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Monitoring Host | Monitored IPV4, IPV6 or domain name. Note⚠️Without protocol header (eg: https://, http://) |
| Monitoring name | Identify the name of this monitoring. The name needs to be unique |
| Port | Port provided by JMX |
| Username | JMX connection user name, optional |
| Password | JMX connection password, optional |
| Collection interval | Interval time of monitor periodic data collection, unit: second, and the minimum interval that can be set is 30 seconds |
| Whether to detect | Whether to detect and check the availability of monitoring before adding monitoring. Adding and modifying operations will continue only after the detection is successful |
| Description remarks | For more information about identifying and describing this monitoring, users can note information here |
### Collection Metrics
#### Metrics Set:memory_pool
| Metric name | Metric unit | Metric help description |
|-------------|-------------|-------------------------|
| name | | metrics name |
| committed | kb | total size |
| init | kb | init size |
| max | kb | max size |
| used | kb | used size |
#### Metrics Set:code_cache (Only Support JDK8)
| Metric name | Metric unit | Metric help description |
|-------------|-------------|-------------------------|
| committed | kb | total size |
| init | kb | init size |
| max | kb | max size |
| used | kb | used size |
#### Metrics Set:class_loading
| Metric name | Metric unit | Metric help description |
|-----------------------|-------------|--------------------------|
| LoadedClassCount | | Loaded Class Count |
| TotalLoadedClassCount | | Total Loaded Class Count |
| UnloadedClassCount | | Unloaded Class Count |
#### Metrics Set:thread
| Metric name | Metric unit | Metric help description |
|-------------------------|-------------|----------------------------|
| TotalStartedThreadCount | | Total Started Thread Count |
| ThreadCount | | Thread Count |
| PeakThreadCount | | Peak Thread Count |
| DaemonThreadCount | | Daemon Thread Count |
| CurrentThreadUserTime | ms | Current Thread User Time |
| CurrentThreadCpuTime | ms | Current Thread Cpu Time |
...@@ -201,6 +201,13 @@ Thanks to these wonderful people, welcome to join us: [Contributor Guide](contr ...@@ -201,6 +201,13 @@ Thanks to these wonderful people, welcome to join us: [Contributor Guide](contr
<td align="center" valign="top" width="14.28%"><a href="https://github.com/san346596324"><img src="https://avatars.githubusercontent.com/u/30828520?v=4?s=100" width="100px;" alt="渭雨"/><br /><sub><b>渭雨</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=san346596324" title="Code">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/san346596324"><img src="https://avatars.githubusercontent.com/u/30828520?v=4?s=100" width="100px;" alt="渭雨"/><br /><sub><b>渭雨</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=san346596324" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/luoxuanzao"><img src="https://avatars.githubusercontent.com/u/44692579?v=4?s=100" width="100px;" alt="liuxuezhuo"/><br /><sub><b>liuxuezhuo</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=luoxuanzao" title="Code">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/luoxuanzao"><img src="https://avatars.githubusercontent.com/u/44692579?v=4?s=100" width="100px;" alt="liuxuezhuo"/><br /><sub><b>liuxuezhuo</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=luoxuanzao" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/lisongning"><img src="https://avatars.githubusercontent.com/u/93140178?v=4?s=100" width="100px;" alt="lisongning"/><br /><sub><b>lisongning</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=lisongning" title="Code">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/lisongning"><img src="https://avatars.githubusercontent.com/u/93140178?v=4?s=100" width="100px;" alt="lisongning"/><br /><sub><b>lisongning</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=lisongning" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/YutingNie"><img src="https://avatars.githubusercontent.com/u/104416402?v=4?s=100" width="100px;" alt="YutingNie"/><br /><sub><b>YutingNie</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=YutingNie" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/mikezzb"><img src="https://avatars.githubusercontent.com/u/23418428?v=4?s=100" width="100px;" alt="Mike Zhou"/><br /><sub><b>Mike Zhou</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=mikezzb" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/a-little-fool"><img src="https://avatars.githubusercontent.com/u/105542329?v=4?s=100" width="100px;" alt="小笨蛋"/><br /><sub><b>小笨蛋</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=a-little-fool" title="Code">💻</a></td>
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/littlezhongzer"><img src="https://avatars.githubusercontent.com/u/33685289?v=4?s=100" width="100px;" alt="littlezhongzer"/><br /><sub><b>littlezhongzer</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=littlezhongzer" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/ChenXiangxxxxx"><img src="https://avatars.githubusercontent.com/u/90089594?v=4?s=100" width="100px;" alt="ChenXiangxxxxx"/><br /><sub><b>ChenXiangxxxxx</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=ChenXiangxxxxx" title="Code">💻</a></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
......
...@@ -15,6 +15,8 @@ Here is the architecture. ...@@ -15,6 +15,8 @@ Here is the architecture.
**We define all monitoring collection types (mysql, website, jvm, k8s) as yml templates, and users can import these templates into the hertzbeat system to support corresponding types of monitoring, which is very convenient!** **We define all monitoring collection types (mysql, website, jvm, k8s) as yml templates, and users can import these templates into the hertzbeat system to support corresponding types of monitoring, which is very convenient!**
![](/img/docs/advanced/extend-point-1.png)
**Welcome everyone to contribute your customized general monitoring type YML template during use. The available templates are as follows:** **Welcome everyone to contribute your customized general monitoring type YML template during use. The available templates are as follows:**
### Application service monitoring ### Application service monitoring
......
...@@ -203,7 +203,7 @@ ...@@ -203,7 +203,7 @@
"message": "Convenient" "message": "Convenient"
}, },
"custom-multi-support": { "custom-multi-support": {
"message": "Custom Monitor" "message": "Custom Monitoring"
}, },
"opensource": { "opensource": {
"message": "Opensource Friendly" "message": "Opensource Friendly"
...@@ -471,5 +471,11 @@ ...@@ -471,5 +471,11 @@
}, },
"quickstart": { "quickstart": {
"message": "Quick Start" "message": "Quick Start"
},
"Support HertzBeat": {
"message": "Support HertzBeat"
},
"Go to Github": {
"message": "Go to Github"
} }
} }
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
"description": "The label for category quickstart in sidebar docs" "description": "The label for category quickstart in sidebar docs"
}, },
"sidebar.docs.category.custom": { "sidebar.docs.category.custom": {
"message": "Custom Monitor", "message": "Custom Monitoring",
"description": "The label for category custom in sidebar docs" "description": "The label for category custom in sidebar docs"
}, },
"sidebar.docs.category.http": { "sidebar.docs.category.http": {
...@@ -66,5 +66,13 @@ ...@@ -66,5 +66,13 @@
"sidebar.docs.link.Install via HuaweiCloud": { "sidebar.docs.link.Install via HuaweiCloud": {
"message": "Install via HuaweiCloud", "message": "Install via HuaweiCloud",
"description": "The label for link Install via HuaweiCloud in sidebar docs, linking to https://marketplace.huaweicloud.com/contents/0477015c-ad63-4522-a308-816861769f0a#productid=OFFI863735781612109824" "description": "The label for link Install via HuaweiCloud in sidebar docs, linking to https://marketplace.huaweicloud.com/contents/0477015c-ad63-4522-a308-816861769f0a#productid=OFFI863735781612109824"
},
"sidebar.docs.category.jmx": {
"message": "JMX Protocol",
"description": "The label for category jmx in sidebar docs"
},
"sidebar.docs.category.snmp": {
"message": "SNMP Protocol",
"description": "The label for category snmp in sidebar docs"
} }
} }
...@@ -6,7 +6,7 @@ sidebar_label: Tutorial 1 Adapting an HTTP protocol monitoring ...@@ -6,7 +6,7 @@ sidebar_label: Tutorial 1 Adapting an HTTP protocol monitoring
Through this tutorial, we describe step by step how to add a monitoring type based on the http protocol under the hertzbeat monitoring tool. Through this tutorial, we describe step by step how to add a monitoring type based on the http protocol under the hertzbeat monitoring tool.
Before reading this tutorial, we hope that you are familiar with how to customize types, indicators, protocols, etc. from [Custom Monitoring] (extend-point) and [http Protocol Customization] (extend-http.md). Before reading this tutorial, we hope that you are familiar with how to customize types, indicators, protocols, etc. from [Custom Monitoring] (extend-point) and [http Protocol Customization] (extend-http).
### HTTP protocol parses the general response structure to obtain indicator data ### HTTP protocol parses the general response structure to obtain indicator data
......
...@@ -6,7 +6,7 @@ sidebar_label: Tutorial 2 Get TOKEN for subsequent authentication ...@@ -6,7 +6,7 @@ sidebar_label: Tutorial 2 Get TOKEN for subsequent authentication
Through this tutorial, we will describe step by step how to modify on the basis of tutorial 1, add an indicator group, first call the authentication interface to obtain the TOKEN, and use the TOKEN as a parameter for the subsequent indicator group collection and authentication. Through this tutorial, we will describe step by step how to modify on the basis of tutorial 1, add an indicator group, first call the authentication interface to obtain the TOKEN, and use the TOKEN as a parameter for the subsequent indicator group collection and authentication.
Before reading this tutorial, we hope that you are familiar with how to customize types, indicators, protocols, etc. from [Custom Monitoring] (extend-point) and [http Protocol Customization] (extend-http.md). Before reading this tutorial, we hope that you are familiar with how to customize types, indicators, protocols, etc. from [Custom Monitoring] (extend-point) and [http Protocol Customization] (extend-http).
### Request process ### Request process
......
...@@ -6,7 +6,7 @@ sidebar_label: Quick Tutorial ...@@ -6,7 +6,7 @@ sidebar_label: Quick Tutorial
Through this tutorial, we describe step by step how to customize and adapt a monitoring type based on the http protocol under the hertzbeat monitoring tool. Through this tutorial, we describe step by step how to customize and adapt a monitoring type based on the http protocol under the hertzbeat monitoring tool.
Before reading this tutorial, we hope that you are familiar with how to customize types, indicators, protocols, etc. from [Custom Monitoring] (extend-point) and [http Protocol Customization] (extend-http.md). Before reading this tutorial, we hope that you are familiar with how to customize types, indicators, protocols, etc. from [Custom Monitoring] (extend-point) and [http Protocol Customization] (extend-http).
### HTTP protocol parses the general response structure to obtain indicator data ### HTTP protocol parses the general response structure to obtain indicator data
......
...@@ -62,5 +62,17 @@ ...@@ -62,5 +62,17 @@
"item.label.华为云开源活动": { "item.label.华为云开源活动": {
"message": "HuaweiCloud Event", "message": "HuaweiCloud Event",
"description": "Navbar item with label 华为云开源活动" "description": "Navbar item with label 华为云开源活动"
},
"item.label.Docs": {
"message": "Docs",
"description": "Navbar item with label Docs"
},
"item.label.Others": {
"message": "Others",
"description": "Navbar item with label Others"
},
"item.label.contributors": {
"message": "Contributors",
"description": "Navbar item with label contributors"
} }
} }
...@@ -471,5 +471,14 @@ ...@@ -471,5 +471,14 @@
}, },
"quickstart": { "quickstart": {
"message": "快速开始" "message": "快速开始"
},
"Who uses HertzBeat?": {
"message": "Who uses HertzBeat?"
},
"Support HertzBeat": {
"message": "Support HertzBeat"
},
"Go to Github": {
"message": "Go to Github"
} }
} }
...@@ -66,5 +66,13 @@ ...@@ -66,5 +66,13 @@
"sidebar.docs.link.Install via HuaweiCloud": { "sidebar.docs.link.Install via HuaweiCloud": {
"message": "华为云方式部署", "message": "华为云方式部署",
"description": "The label for link Install via HuaweiCloud in sidebar docs, linking to https://marketplace.huaweicloud.com/contents/0477015c-ad63-4522-a308-816861769f0a#productid=OFFI863735781612109824" "description": "The label for link Install via HuaweiCloud in sidebar docs, linking to https://marketplace.huaweicloud.com/contents/0477015c-ad63-4522-a308-816861769f0a#productid=OFFI863735781612109824"
},
"sidebar.docs.category.jmx": {
"message": "JMX协议",
"description": "The label for category jmx in sidebar docs"
},
"sidebar.docs.category.snmp": {
"message": "SNMP协议",
"description": "The label for category snmp in sidebar docs"
} }
} }
...@@ -75,7 +75,7 @@ sidebar_label: 系统默认解析方式 ...@@ -75,7 +75,7 @@ sidebar_label: 系统默认解析方式
] ]
``` ```
**对应的监控配置定义文件YML可以配置为如下** **对应的监控模版YML可以配置为如下**
```yaml ```yaml
# 此监控类型所属类别:service-应用服务监控 db-数据库监控 custom-自定义监控 os-操作系统监控 # 此监控类型所属类别:service-应用服务监控 db-数据库监控 custom-自定义监控 os-操作系统监控
......
...@@ -6,7 +6,7 @@ sidebar_label: 教程一:适配一款HTTP协议监控 ...@@ -6,7 +6,7 @@ sidebar_label: 教程一:适配一款HTTP协议监控
通过此教程我们一步一步描述如何在hertzbeat监控系统下新增适配一款基于http协议的监控类型。 通过此教程我们一步一步描述如何在hertzbeat监控系统下新增适配一款基于http协议的监控类型。
阅读此教程前我们希望您已经从[自定义监控](extend-point)[http协议自定义](extend-http.md)了解熟悉了怎么自定义类型,指标,协议等。 阅读此教程前我们希望您已经从[自定义监控](extend-point)[http协议自定义](extend-http)了解熟悉了怎么自定义类型,指标,协议等。
### HTTP协议解析通用响应结构体,获取指标数据 ### HTTP协议解析通用响应结构体,获取指标数据
...@@ -59,15 +59,14 @@ sidebar_label: 教程一:适配一款HTTP协议监控 ...@@ -59,15 +59,14 @@ sidebar_label: 教程一:适配一款HTTP协议监控
**我们这次获取其app下的 `category`,`app`,`status`,`size`,`availableSize`等指标数据。** **我们这次获取其app下的 `category`,`app`,`status`,`size`,`availableSize`等指标数据。**
### 新增对应的应用定义YML和参数定义YML ### 新增自定义监控模版YML
1. 自定义监控类型需新增配置YML文件 **HertzBeat页面** -> **监控模版菜单** -> **新增监控类型** -> **配置自定义监控模版YML** -> **点击保存应用** -> **使用新监控类型添加监控**
用监控类型命名的监控配置定义文件 - 例如:app-hertzbeat.yml 需位于安装目录 /hertzbeat/define/ 下 > 监控模版YML用于定义 *监控类型的名称(国际化), 请求参数结构定义(前端页面根据配置自动渲染UI), 采集指标信息, 采集协议配置* 等。
> 即我们通过自定义这个监控模版,配置定义什么监控类型,前端页面需要输入什么参数,采集哪些性能指标,通过什么协议去采集。
2. 配置监控配置定义文件 app-hertzbeat.yml 样例:自定义一个名称为`hertzbeat`的自定义监控类型,其使用HTTP协议采集指标数据。
监控配置定义文件是用来定义采集类型是啥,需要用哪种协议采集方式,采集的指标是啥,协议的配置参数等。我们直接复用 app-api.yml 里面的定义内容,修改为我们当前的监控类型`hertzbeat`配置参数即可,如下:注意⚠️我们这次获取接口响应数据中的`category`,`app`,`status`,`size`,`availableSize`等字段作为指标数据。
```yaml ```yaml
# 此监控类型所属类别:service-应用服务监控 db-数据库监控 custom-自定义监控 os-操作系统监控 # 此监控类型所属类别:service-应用服务监控 db-数据库监控 custom-自定义监控 os-操作系统监控
......
...@@ -6,7 +6,7 @@ sidebar_label: 教程二:获取TOKEN后续认证使用 ...@@ -6,7 +6,7 @@ sidebar_label: 教程二:获取TOKEN后续认证使用
通过此教程我们一步一步描述如何在教程一的基础上改造,新增一个指标组,先调用认证接口获取TOKEN后,使用TOKEN作为参数供后面的指标组采集认证使用。 通过此教程我们一步一步描述如何在教程一的基础上改造,新增一个指标组,先调用认证接口获取TOKEN后,使用TOKEN作为参数供后面的指标组采集认证使用。
阅读此教程前我们希望您已经从[自定义监控](extend-point)[http协议自定义](extend-http.md)了解熟悉了怎么自定义类型,指标,协议等。 阅读此教程前我们希望您已经从[自定义监控](extend-point)[http协议自定义](extend-http)了解熟悉了怎么自定义类型,指标,协议等。
### 请求流程 ### 请求流程
...@@ -37,9 +37,7 @@ sidebar_label: 教程二:获取TOKEN后续认证使用 ...@@ -37,9 +37,7 @@ sidebar_label: 教程二:获取TOKEN后续认证使用
### 新增自定义监控类型`hertzbeat_token` ### 新增自定义监控类型`hertzbeat_token`
1. 自定义监控类型需新增配置YML文件,我们直接复用教程一的 `hertzbeat` 监控类型,在其基础上修改 1. 自定义监控类型需新增配置监控模版YML,我们直接复用教程一的 `hertzbeat` 监控类型,在其基础上修改
用监控类型命名的监控配置定义文件 - app-hertzbeat_token.yml 需位于安装目录 /hertzbeat/define/ 下
监控配置定义文件是用来定义采集类型是啥,需要用哪种协议采集方式,采集的指标是啥,协议的配置参数等。 监控配置定义文件是用来定义采集类型是啥,需要用哪种协议采集方式,采集的指标是啥,协议的配置参数等。
我们直接复用 app-hertzbeat.yml 里面的定义内容,修改为我们当前的监控类型`hertzbeat_auth`配置参数, 比如 `app, category等` 我们直接复用 app-hertzbeat.yml 里面的定义内容,修改为我们当前的监控类型`hertzbeat_auth`配置参数, 比如 `app, category等`
......
...@@ -12,18 +12,18 @@ sidebar_label: JsonPath解析方式 ...@@ -12,18 +12,18 @@ sidebar_label: JsonPath解析方式
#### JsonPath操作符 #### JsonPath操作符
[JSONPath在线验证](https://www.jsonpath.cn) [JSONPath在线验证](https://www.jsonpath.cn)
| JSONPATH | 帮助描述 | | JSONPATH | 帮助描述 |
| ----------- | ----------- | |------------------|-----------------------------------|
| $ | 根对象或元素 | | $ | 根对象或元素 |
| @ | 当前对象或元素 | | @ | 当前对象或元素 |
| . or [] | 子元素操作符 | | . or [] | 子元素操作符 |
| .. | 递归匹配所有子元素 | | .. | 递归匹配所有子元素 |
| * | 通配符. 匹配所有对象或元素. | | * | 通配符. 匹配所有对象或元素. |
| [] | 下标运算符,JsonPath索引从0开始 | | [] | 下标运算符,JsonPath索引从0开始 |
| [,] | 连接运算符,将多个结果拼成数组返回,JSONPath允许使用别名. | | [,] | 连接运算符,将多个结果拼成数组返回,JSONPath允许使用别名. |
| [start:end:step] | 数组切片运算符 | | [start:end:step] | 数组切片运算符 |
| ?() | 过滤器(脚本)表达式. | | ?() | 过滤器(脚本)表达式. |
| () | 脚本表达式. | | () | 脚本表达式. |
#### HertzBeat数据格式规范 #### HertzBeat数据格式规范
单层格式:key-value 单层格式:key-value
...@@ -95,7 +95,7 @@ sidebar_label: JsonPath解析方式 ...@@ -95,7 +95,7 @@ sidebar_label: JsonPath解析方式
``` ```
此数据结构符合HertzBeat的数据格式规范,成功提取指标`type,num`值。 此数据结构符合HertzBeat的数据格式规范,成功提取指标`type,num`值。
**对应的监控配置定义文件YML可以配置为如下** **对应的监控模版YML可以配置为如下**
```yaml ```yaml
# 此监控类型所属类别:service-应用服务监控 db-数据库监控 custom-自定义监控 os-操作系统监控 # 此监控类型所属类别:service-应用服务监控 db-数据库监控 custom-自定义监控 os-操作系统监控
......
...@@ -17,20 +17,21 @@ HTTP协议支持我们自定义HTTP请求路径,请求header,请求参数, ...@@ -17,20 +17,21 @@ HTTP协议支持我们自定义HTTP请求路径,请求header,请求参数,
### 自定义步骤 ### 自定义步骤
配置自定义监控类型需新增配置一个YML文件 **HertzBeat页面** -> **监控模版菜单** -> **新增监控类型** -> **配置自定义监控模版YML** -> **点击保存应用** -> **使用新监控类型添加监控**
1. 用监控类型命名的监控配置定义文件 - 例如:example.yml 需位于安装目录 /hertzbeat/define/ 下
2. 重启hertzbeat系统,我们就适配好了一个新的自定义监控类型。 ![](/img/docs/advanced/extend-point-1.png)
------- -------
下面详细介绍下YML文件的配置用法,请注意看使用注释。
### 监控配置定义文件YML 下面详细介绍下监控模版YML的配置用法,请注意看使用注释。
### 监控模版YML
> 监控配置定义文件用于定义 *监控类型的名称(国际化), 请求参数结构定义(前端页面根据配置自动渲染UI), 采集指标信息, 采集协议配置* 等。 > 监控模版YML用于定义 *监控类型的名称(国际化), 请求参数结构定义(前端页面根据配置自动渲染UI), 采集指标信息, 采集协议配置* 等。
> 即我们通过自定义这个YML文件,配置定义什么监控类型,前端页面需要输入什么参数,采集哪些性能指标,通过什么协议去采集。 > 即我们通过自定义这个监控模版,配置定义什么监控类型,前端页面需要输入什么参数,采集哪些性能指标,通过什么协议去采集。
样例:自定义一个名称为example_http的自定义监控类型,其使用HTTP协议采集指标数据。 样例:自定义一个名称为example_http的自定义监控类型,其使用HTTP协议采集指标数据。
文件名称: example_http.yml 位于 /define/example_http.yml
```yaml ```yaml
# 此监控类型所属类别:service-应用服务监控 db-数据库监控 custom-自定义监控 os-操作系统监控 # 此监控类型所属类别:service-应用服务监控 db-数据库监控 custom-自定义监控 os-操作系统监控
......
...@@ -39,31 +39,30 @@ SQL查询回来的数据字段和我们需要的指标映射,就能获取对 ...@@ -39,31 +39,30 @@ SQL查询回来的数据字段和我们需要的指标映射,就能获取对
SQL响应数据: SQL响应数据:
| key | value | | key | value |
| ----------- | ----------- | |----------|-------|
| one | 243 | | one | 243 |
| two | 435 | | two | 435 |
| three | 332 | | three | 332 |
| four | 643 | | four | 643 |
这里指标字段就能和响应数据的key映射,获取对应的value为其采集监控数据。 这里指标字段就能和响应数据的key映射,获取对应的value为其采集监控数据。
### 自定义步骤 ### 自定义步骤
配置自定义监控类型需新增配置YML文件 **HertzBeat页面** -> **监控模版菜单** -> **新增监控类型** -> **配置自定义监控模版YML** -> **点击保存应用** -> **使用新监控类型添加监控**
![](/img/docs/advanced/extend-point-1.png)
1. 用监控类型命名的监控配置定义文件 - 例如:example_sql.yml 需位于安装目录 /hertzbeat/define/ 下
2. 重启hertzbeat系统,我们就适配好了一个新的自定义监控类型。
------- -------
下面详细介绍下文件的配置用法,请注意看使用注释。 下面详细介绍下文件的配置用法,请注意看使用注释。
### 监控配置定义文件 ### 监控模版YML
> 监控配置定义文件用于定义 *监控类型的名称(国际化), 请求参数结构定义(前端页面根据配置自动渲染UI), 采集指标信息, 采集协议配置* 等。 > 监控配置定义文件用于定义 *监控类型的名称(国际化), 请求参数结构定义(前端页面根据配置自动渲染UI), 采集指标信息, 采集协议配置* 等。
> 即我们通过自定义这个YML文件,配置定义什么监控类型,前端页面需要输入什么参数,采集哪些性能指标,通过什么协议去采集。 > 即我们通过自定义这个YML,配置定义什么监控类型,前端页面需要输入什么参数,采集哪些性能指标,通过什么协议去采集。
样例:自定义一个名称为example_sql的自定义监控类型,其使用JDBC协议采集指标数据。 样例:自定义一个名称为example_sql的自定义监控类型,其使用JDBC协议采集指标数据。
文件名称: example_sql.yml 位于 /define/example_sql.yml
```yaml ```yaml
# 此监控类型所属类别:service-应用服务监控 db-数据库监控 custom-自定义监控 os-操作系统监控 # 此监控类型所属类别:service-应用服务监控 db-数据库监控 custom-自定义监控 os-操作系统监控
......
---
id: extend-jmx
title: JMX协议自定义监控
sidebar_label: JMX协议自定义监控
---
> 从[自定义监控](extend-point)了解熟悉了怎么自定义类型,指标,协议等,这里我们来详细介绍下用JMX协议自定义指标监控。
> JMX协议自定义监控可以让我们很方便的通过配置 JMX Mbean Object 就能监控采集到我们想监控的 Mbean 指标
### JMX协议采集流程
**对端JAVA应用暴露JMX服务**】->【**HertzBeat直连对端JMX服务**】->【**获取配置的 Mbean Object 数据**】->【**指标数据提取**
由流程可见,我们自定义一个JMX协议的监控类型,需要配置JMX请求参数,配置获取哪些指标,配置查询Object信息。
### 数据解析方式
通过配置监控模版YML的指标`field`, `aliasFields`, `jmx` 协议的 `objectName` 来和对端系统暴露的 `Mbean`对象信息映射解析。
### 自定义步骤
**HertzBeat页面** -> **监控模版菜单** -> **新增监控类型** -> **配置自定义监控模版YML** -> **点击保存应用** -> **使用新监控类型添加监控**
![](/img/docs/advanced/extend-point-1.png)
-------
下面详细介绍下监控模版的配置用法,请注意看使用注释。
### 监控模版YML
> 监控配置定义文件用于定义 *监控类型的名称(国际化), 请求参数结构定义(前端页面根据配置自动渲染UI), 采集指标信息, 采集协议配置* 等。
> 即我们通过自定义这个YML,配置定义什么监控类型,前端页面需要输入什么参数,采集哪些性能指标,通过什么协议去采集。
样例:自定义一个名称为 `example_jvm` 的自定义监控类型,其使用JMX协议采集指标数据。
```yaml
# The monitoring type category:service-application service monitoring db-database monitoring custom-custom monitoring os-operating system monitoring
# 监控类型所属类别:service-应用服务监控 db-数据库监控 custom-自定义监控 os-操作系统监控 cn-云原生cloud native network-网络监控
category: service
# The monitoring type eg: linux windows tomcat mysql aws...
# 监控类型 eg: linux windows tomcat mysql aws...
app: example_jvm
# The monitoring i18n name
# 监控类型国际化名称
name:
zh-CN: 自定义JVM虚拟机
en-US: CUSTOM JVM
# Input params define for monitoring(render web ui by the definition)
# 监控所需输入参数定义(根据定义渲染页面UI)
params:
# field-param field key
# field-字段名称标识符
- field: host
# name-param field display i18n name
# name-参数字段显示名称
name:
zh-CN: 主机Host
en-US: Host
# type-param field type(most mapping the html input type)
# type-字段类型,样式(大部分映射input标签type属性)
type: host
# required-true or false
# 是否是必输项 true-必填 false-可选
required: true
# field-param field key
# field-变量字段标识符
- field: port
# name-param field display i18n name
# name-参数字段显示名称
name:
zh-CN: 端口
en-US: Port
# type-param field type(most mapping the html input type)
# type-字段类型,样式(大部分映射input标签type属性)
type: number
# when type is number, range is required
# 当type为number时,用range表示范围
range: '[0,65535]'
# required-true or false
# required-是否是必输项 true-必填 false-可选
required: true
# default value
# 端口默认值
defaultValue: 9999
# field-param field key
# field-变量字段标识符
- field: url
# name-param field display i18n name
# name-参数字段显示名称
name:
zh-CN: JMX URL
en-US: JMX URL
# type-param field type(most mapping the html input type)
# type-字段类型,样式(大部分映射input标签type属性)
type: text
# required-true or false
# required-是否是必输项 true-必填 false-可选
required: false
# hide param-true or false
# 是否隐藏字段 true or false
hide: true
# param field input placeholder
# 参数输入框提示信息
placeholder: 'service:jmx:rmi:///jndi/rmi://host:port/jmxrmi'
# field-param field key
# field-变量字段标识符
- field: username
# name-param field display i18n name
# name-参数字段显示名称
name:
zh-CN: 用户名
en-US: Username
# type-param field type(most mapping the html input type)
# type-字段类型,样式(大部分映射input标签type属性)
type: text
# when type is text, use limit to limit string length
# 当type为text时,用limit表示字符串限制大小
limit: 20
# required-true or false
# required-是否是必输项 true-必填 false-可选
required: false
# hide param-true or false
# 是否隐藏字段 true or false
hide: true
# field-param field key
# field-变量字段标识符
- field: password
# name-param field display i18n name
# name-参数字段显示名称
name:
zh-CN: 密码
en-US: Password
# type-param field type(most mapping the html input tag)
# type-字段类型,样式(大部分映射input标签type属性)
type: password
# required-true or false
# required-是否是必输项 true-必填 false-可选
required: false
# hide param-true or false
# 是否隐藏字段 true or false
hide: true
# collect metrics config list
# 采集指标组配置列表
metrics:
# metrics - basic
# 监控指标组 - basic
- name: basic
# metrics group scheduling priority(0->127)->(high->low), metrics with the same priority will be scheduled in parallel
# priority 0's metrics group is availability metrics, it will be scheduled first, only availability metrics collect success will the scheduling continue
# 指标组调度优先级(0->127)->(优先级高->低) 优先级低的指标组会等优先级高的指标组采集完成后才会被调度, 相同优先级的指标组会并行调度采集
# 优先级为0的指标组为可用性指标组,即它会被首先调度,采集成功才会继续调度其它指标组,采集失败则中断调度
priority: 0
# collect metrics content
# 具体监控指标列表
fields:
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), instance-if is metrics group unique identifier
# field-指标名称, type-指标类型(0-number数字,1-string字符串), unit-指标单位('%','ms','MB'), instance-是否是指标集合唯一标识符字段
- field: VmName
type: 1
- field: VmVendor
type: 1
- field: VmVersion
type: 1
- field: Uptime
type: 0
unit: ms
# the protocol used for monitoring, eg: sql, ssh, http, telnet, wmi, snmp, sdk
# 用于监控的协议,例: sql, ssh, http, telnet, wmi, snmp, sdk
protocol: jmx
# the config content when protocol is jmx
jmx:
# host: ipv4 ipv6 domain
# 主机host: ipv4 ipv6 域名
host: ^_^host^_^
# port
# 端口
port: ^_^port^_^
username: ^_^username^_^
password: ^_^password^_^
# jmx mbean object name
# jmx mbean 对象名称
objectName: java.lang:type=Runtime
url: ^_^url^_^
- name: memory_pool
priority: 1
fields:
- field: name
type: 1
instance: true
- field: committed
type: 0
unit: MB
- field: init
type: 0
unit: MB
- field: max
type: 0
unit: MB
- field: used
type: 0
unit: MB
units:
- committed=B->MB
- init=B->MB
- max=B->MB
- used=B->MB
# (optional)metrics field alias name, it is used as an alias field to map and convert the collected data and metrics field
# (可选)监控指标别名, 做为中间字段与采集数据字段和指标字段映射转换
aliasFields:
- Name
- Usage->committed
- Usage->init
- Usage->max
- Usage->used
# mapping and conversion expressions, use these and aliasField above to calculate metrics value
# (可选)指标映射转换计算表达式,与上面的别名一起作用,计算出最终需要的指标值
# eg: cores=core1+core2, usage=usage, waitTime=allTime-runningTime
calculates:
- name=Name
- committed=Usage->committed
- init=Usage->init
- max=Usage->max
- used=Usage->used
protocol: jmx
jmx:
# host: ipv4 ipv6 domain
# 主机host: ipv4 ipv6 域名
host: ^_^host^_^
# port
# 端口
port: ^_^port^_^
username: ^_^username^_^
password: ^_^password^_^
objectName: java.lang:type=MemoryPool,name=*
url: ^_^url^_^
```
...@@ -3,193 +3,168 @@ id: extend-point ...@@ -3,193 +3,168 @@ id: extend-point
title: 自定义监控 title: 自定义监控
sidebar_label: 自定义监控 sidebar_label: 自定义监控
--- ---
> HertzBeat拥有自定义监控能力,您只需配置YML文件就能适配一款自定义的监控类型。 > HertzBeat拥有自定义监控能力,您只需配置监控模版YML就能适配一款自定义的监控类型。
> 目前自定义监控支持[HTTP协议](extend-http),[JDBC协议](extend-jdbc)(mysql,mariadb,postgresql..),[SSH协议](extend-ssh),JMX协议,SNMP协议,后续会支持更多通用协议。 > 目前自定义监控支持[HTTP协议](extend-http),[JDBC协议](extend-jdbc),[SSH协议](extend-ssh),[JMX协议](extend-jmx),[SNMP协议](extend-snmp),后续会支持更多通用协议。
### 自定义步骤 ### 自定义流程
配置自定义监控类型需新增配置一个YML文件 **HertzBeat页面** -> **监控模版菜单** -> **新增监控类型** -> **配置自定义监控模版YML** -> **点击保存应用** -> **使用新监控类型添加监控**
1. 用监控类型命名的监控配置定义文件 - 例如:example.yml 需位于安装目录 /hertzbeat/define/ 下
2. 重启hertzbeat系统,我们就适配好了一个新的自定义监控类型。
------- ![](/img/docs/advanced/extend-point-1.png)
下面详细介绍下这文件的配置用法。
### 监控配置定义文件 -------
> 监控配置定义文件用于定义 *监控类型的名称(国际化), 请求参数映射, 指标信息, 采集协议配置信息*等。 ### 监控模版YML
样例:自定义一个名称为example的自定义监控类型,其使用HTTP协议采集指标数据。 **HertzBeat的设计是一个监控模版对应一个监控类型,所有监控类型都是由监控模版来定义的**
文件名称: example.yml 位于 /define/example.yml
> 监控模版YML定义了 *监控类型的名称(国际化), 配置参数映射, 采集指标信息, 采集协议配置* 等。
下面使用样例详细介绍下这监控模版YML的配置用法。
样例:自定义一个 `app` 名称为 `example2` 的自定义监控类型,其使用HTTP协议采集指标数据。
[监控模版] -> [新增监控类型] -> [右边配置如下监控模版YML] -> [保存并应用]
```yaml ```yaml
# 此监控类型所属类别:service-应用服务监控 db-数据库监控 custom-自定义监控 os-操作系统监控 # The monitoring type category:service-application service monitoring db-database monitoring custom-custom monitoring os-operating system monitoring
# 监控类型所属类别:service-应用服务监控 db-数据库监控 custom-自定义监控 os-操作系统监控 cn-云原生cloud native network-网络监控
category: custom category: custom
# 监控应用类型(与文件名保持一致) eg: linux windows tomcat mysql aws... # The monitoring type eg: linux windows tomcat mysql aws...
app: example # 监控类型 eg: linux windows tomcat mysql aws...
app: example2
# The monitoring i18n name
# 监控类型国际化名称
name: name:
zh-CN: 模拟应用类型 zh-CN: 模拟网站监测
en-US: EXAMPLE APP en-US: EXAMPLE WEBSITE
# 监控参数定义. field 这些为输入参数变量,即可以用^_^host^_^的形式写到后面的配置中,系统自动变量值替换 # 监控所需输入参数定义(根据定义渲染页面UI)
# 强制固定必须参数 - host # Input params define for monitoring(render web ui by the definition)
params: params:
# field-字段名称标识符 # field-param field key
# field-变量字段标识符
- field: host - field: host
# name-param field display i18n name
# name-参数字段显示名称 # name-参数字段显示名称
name: name:
zh-CN: 主机Host zh-CN: 主机Host
en-US: Host en-US: Host
# type-param field type(most mapping the html input type)
# type-字段类型,样式(大部分映射input标签type属性) # type-字段类型,样式(大部分映射input标签type属性)
type: host type: host
# 是否是必输项 true-必填 false-可选 # required-true or false
# required-是否是必输项 true-必填 false-可选
required: true required: true
# field-param field key
# field-变量字段标识符
- field: port - field: port
# name-param field display i18n name
# name-参数字段显示名称
name: name:
zh-CN: 端口 zh-CN: 端口
en-US: Port en-US: Port
# type-param field type(most mapping the html input type)
# type-字段类型,样式(大部分映射input标签type属性)
type: number type: number
# when type is number, range is required
# 当type为number时,用range表示范围 # 当type为number时,用range表示范围
range: '[0,65535]' range: '[0,65535]'
# required-true or false
# required-是否是必输项 true-必填 false-可选
required: true required: true
# 端口默认值 # default value
# 默认值
defaultValue: 80 defaultValue: 80
# 参数输入框提示信息 # field-param field key
placeholder: '请输入端口' # field-变量字段标识符
- field: username - field: uri
# name-param field display i18n name
# name-参数字段显示名称
name: name:
zh-CN: 用户名 zh-CN: 相对路径
en-US: Username en-US: URI
# type-param field type(most mapping the html input tag)
# type-字段类型,样式(大部分映射input标签type属性)
type: text type: text
# when type is text, use limit to limit string length
# 当type为text时,用limit表示字符串限制大小 # 当type为text时,用limit表示字符串限制大小
limit: 20 limit: 200
required: false # required-true or false
- field: password # required-是否是必输项 true-必填 false-可选
name:
zh-CN: 密码
en-US: Password
type: password
required: false required: false
# 参数输入框提示信息
# param field input placeholder
placeholder: 'Website uri path(no ip port) EG:/console'
# field-param field key
# field-变量字段标识符
- field: ssl - field: ssl
# name-param field display i18n name
# name-参数字段显示名称
name: name:
zh-CN: 启动SSL zh-CN: 启用HTTPS
en-US: Enable SSL en-US: HTTPS
# 当type为boolean时,前端用switch展示开关 # type-param field type(most mapping the html input type)
# type-字段类型,样式(大部分映射input标签type属性)
type: boolean type: boolean
required: false # required-true or false
- field: method # required-是否是必输项 true-必填 false-可选
name:
zh-CN: 请求方式
en-US: Method
type: radio
required: true required: true
# 当type为radio单选框,checkbox复选框时,option表示可选项值列表 {name1:value1,name2:value2} # field-param field key
options: # field-变量字段标识符
- label: GET请求 - field: timeout
value: GET # name-param field display i18n name
- label: POST请求 # name-参数字段显示名称
value: POST name:
- label: PUT请求 zh-CN: 超时时间(ms)
value: PUT en-US: Timeout(ms)
- label: DELETE请求 # type-param field type(most mapping the html input tag)
value: DELETE # type-字段类型,样式(大部分映射input标签type属性)
# 指标组列表 type: number
# required-true or false
# required-是否是必输项 true-必填 false-可选
required: false
# hide param-true or false
# 是否隐藏字段 true or false
hide: true
metrics: metrics:
# 第一个监控指标组 cpu # metrics - summary, inner monitoring metrics (responseTime - response time, keyword - number of keywords)
# 注意:内置监控指标有 (responseTime - 响应时间) # 监控指标组 - summary, 内置监控指标有 (responseTime - 响应时间, keyword - 关键字数量)
- name: cpu - name: summary
# 指标组调度优先级(0-127)越小优先级越高,优先级低的指标组会等优先级高的指标组采集完成后才会被调度,相同优先级的指标组会并行调度采集 # 指标组调度优先级(0-127)越小优先级越高,优先级低的指标组会等优先级高的指标组采集完成后才会被调度,相同优先级的指标组会并行调度采集
# metrics group scheduling priority(0->127)->(high->low), metrics with the same priority will be scheduled in parallel
# priority 0's metrics group is availability metrics, it will be scheduled first, only availability metrics collect success will the scheduling continue
# 指标组调度优先级(0->127)->(优先级高->低) 优先级低的指标组会等优先级高的指标组采集完成后才会被调度, 相同优先级的指标组会并行调度采集
# 优先级为0的指标组为可用性指标组,即它会被首先调度,采集成功才会继续调度其它指标组,采集失败则中断调度 # 优先级为0的指标组为可用性指标组,即它会被首先调度,采集成功才会继续调度其它指标组,采集失败则中断调度
priority: 0 priority: 0
# 指标组中的具体监控指标 # collect metrics content
# 具体监控指标列表
fields: fields:
# 指标信息 包括 field名称 type字段类型:0-number数字,1-string字符串 instance是否为实例主键 unit:指标单位 # field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), instance-if is metrics group unique identifier
- field: hostname # field-指标名称, type-指标类型(0-number数字,1-string字符串), unit-指标单位('%','ms','MB'), instance-是否是指标集合唯一标识符字段
type: 1 - field: responseTime
instance: true
- field: usage
type: 0
unit: '%'
- field: cores
type: 0 type: 0
- field: waitTime unit: ms
- field: keyword
type: 0 type: 0
unit: s # the protocol used for monitoring, eg: sql, ssh, http, telnet, wmi, snmp, sdk
# (非必须)监控指标别名,与上面的指标名映射。用于采集接口数据字段不直接是最终指标名称,需要此别名做映射转换
aliasFields:
- hostname
- core1
- core2
- usage
- allTime
- runningTime
# (非必须)指标计算表达式,与上面的别名一起作用,计算出最终需要的指标值
# eg: cores=core1+core2, usage=usage, waitTime=allTime-runningTime
calculates:
- hostname=hostname
- cores=core1+core2
- usage=usage
- waitTime=allTime-runningTime
# 监控采集使用协议 eg: sql, ssh, http, telnet, wmi, snmp, sdk
protocol: http protocol: http
# 当protocol为http协议时具体的采集配置 # the config content when protocol is http
http: http:
# 主机host: ipv4 ipv6 域名 # http host: ipv4 ipv6 domain
host: ^_^host^_^ host: ^_^host^_^
# 端口 # http port
port: ^_^port^_^ port: ^_^port^_^
# url请求接口路径 # http url
url: /metrics/cpu url: ^_^uri^_^
# 请求方式 GET POST PUT DELETE PATCH timeout: ^_^timeout^_^
# http method: GET POST PUT DELETE PATCH
method: GET method: GET
# 是否启用ssl/tls,即是http还是https,默认false # if enabled https
ssl: false ssl: ^_^ssl^_^
# 请求头内容 # http response data parse type: default-hertzbeat rule, jsonpath-jsonpath script, website-for website monitoring, prometheus-prometheus exporter rule
headers: # http 响应数据解析方式: default-系统规则, jsonPath-jsonPath脚本, website-网站可用性指标监控, prometheus-Prometheus数据规则
apiVersion: v1 parseType: website
# 请求参数内容
params:
param1: param1
param2: param2
# 认证
authorization:
# 认证方式: Basic Auth, Digest Auth, Bearer Token
type: Basic Auth
basicAuthUsername: ^_^username^_^
basicAuthPassword: ^_^password^_^
# 响应数据解析方式: default-系统规则,jsonPath-jsonPath脚本,website-网站可用性指标监控
# todo xmlPath-xmlPath脚本,prometheus-Prometheus数据规则
parseType: jsonPath
parseScript: '$'
- name: memory
priority: 1
fields:
- field: hostname
type: 1
instance: true
- field: total
type: 0
unit: kb
- field: usage
type: 0
unit: '%'
- field: speed
type: 0
protocol: http
http:
host: ^_^host^_^
port: ^_^port^_^
url: /metrics/memory
method: GET
headers:
apiVersion: v1
params:
param1: param1
param2: param2
authorization:
type: Basic Auth
basicAuthUsername: ^_^username^_^
basicAuthPassword: ^_^password^_^
parseType: default
``` ```
---
id: extend-snmp
title: SNMP协议自定义监控
sidebar_label: SNMP协议自定义监控
---
> 从[自定义监控](extend-point)了解熟悉了怎么自定义类型,指标,协议等,这里我们来详细介绍下用 SNMP 协议自定义指标监控。
> SNMP 协议自定义监控可以让我们很方便的通过配置 Mib OID信息 就能监控采集到我们想监控的OID指标
### SNMP协议采集流程
**对端开启SNMP服务**】->【**HertzBeat直连对端SNMP服务**】->【**根据配置抓取对端OID指标信息**】->【**指标数据提取**
由流程可见,我们自定义一个SNMP协议的监控类型,需要配置SNMP请求参数,配置获取哪些指标,配置查询OID信息。
### 数据解析方式
通过配置监控模版YML的指标`field`, `aliasFields`, `snmp` 协议下的 `oids`来抓取对端指定的数据并解析映射。
### 自定义步骤
**HertzBeat页面** -> **监控模版菜单** -> **新增监控类型** -> **配置自定义监控模版YML** -> **点击保存应用** -> **使用新监控类型添加监控**
![](/img/docs/advanced/extend-point-1.png)
-------
下面详细介绍下文件的配置用法,请注意看使用注释。
### 监控模版YML
> 监控配置定义文件用于定义 *监控类型的名称(国际化), 请求参数结构定义(前端页面根据配置自动渲染UI), 采集指标信息, 采集协议配置* 等。
> 即我们通过自定义这个YML,配置定义什么监控类型,前端页面需要输入什么参数,采集哪些性能指标,通过什么协议去采集。
样例:自定义一个名称为 example_windows 的自定义监控类型,其使用 SNMP 协议采集指标数据。
```yaml
# The monitoring type category:service-application service monitoring db-database monitoring mid-middleware custom-custom monitoring os-operating system monitoring
# 监控类型所属类别:service-应用服务监控 db-数据库监控 mid-中间件 custom-自定义监控 os-操作系统监控 cn-云原生cloud native network-网络监控
category: os
# The monitoring type eg: linux windows tomcat mysql aws...
# 监控类型 eg: linux windows tomcat mysql aws...
app: windows
# The monitoring i18n name
# 监控类型国际化名称
name:
zh-CN: Windows操作系统
en-US: OS Windows
# 监控所需输入参数定义(根据定义渲染页面UI)
# Input params define for monitoring(render web ui by the definition)
params:
# field-param field key
# field-变量字段标识符
- field: host
# name-param field display i18n name
# name-参数字段显示名称
name:
zh-CN: 主机Host
en-US: Host
# type-param field type(most mapping the html input type)
# type-字段类型,样式(大部分映射input标签type属性)
type: host
# required-true or false
# required-是否是必输项 true-必填 false-可选
required: true
# field-param field key
# field-变量字段标识符
- field: port
# name-param field display i18n name
# name-参数字段显示名称
name:
zh-CN: 端口
en-US: Port
# type-param field type(most mapping the html input type)
# type-字段类型,样式(大部分映射input标签type属性)
type: number
# when type is number, range is required
# 当type为number时,用range表示范围
range: '[0,65535]'
# required-true or false
# required-是否是必输项 true-必填 false-可选
required: true
# default value
# 默认值
defaultValue: 161
# field-param field key
# field-变量字段标识符
- field: version
# name-param field display i18n name
# name-参数字段显示名称
name:
zh-CN: SNMP 版本
en-US: SNMP Version
# type-param field type(radio mapping the html radio tag)
# type-当type为radio时,前端用radio展示开关
type: radio
# required-true or false
# required-是否是必输项 true-必填 false-可选
required: true
# when type is radio checkbox, use option to show optional values {name1:value1,name2:value2}
# 当type为radio单选框, checkbox复选框时, option表示可选项值列表 {name1:value1,name2:value2}
options:
- label: SNMPv1
value: 0
- label: SNMPv2c
value: 1
# field-param field key
# field-变量字段标识符
- field: community
# name-param field display i18n name
# name-参数字段显示名称
name:
zh-CN: SNMP 团体字
en-US: SNMP Community
# type-param field type(most mapping the html input type)
# type-字段类型,样式(大部分映射input标签type属性)
type: text
# when type is text, use limit to limit string length
# 当type为text时,用limit表示字符串限制大小
limit: 100
# required-true or false
# required-是否是必输项 true-必填 false-可选
required: true
# 参数输入框提示信息
# param field input placeholder
placeholder: 'Snmp community for v1 v2c'
# field-param field key
# field-变量字段标识符
- field: timeout
# name-param field display i18n name
# name-参数字段显示名称
name:
zh-CN: 超时时间(ms)
en-US: Timeout(ms)
# type-param field type(most mapping the html input type)
# type-字段类型,样式(大部分映射input标签type属性)
type: number
# when type is number, range is required
# 当type为number时,用range表示范围
range: '[0,100000]'
# required-true or false
# required-是否是必输项 true-必填 false-可选
required: false
# hide-is hide this field and put it in advanced layout
# hide-是否隐藏此参数将其放入高级设置中
hide: true
# default value
# 默认值
defaultValue: 6000
# collect metrics config list
# 采集指标组配置列表
metrics:
# metrics - system
# 监控指标组 - system
- name: system
# metrics group scheduling priority(0->127)->(high->low), metrics with the same priority will be scheduled in parallel
# priority 0's metrics group is availability metrics, it will be scheduled first, only availability metrics collect success will the scheduling continue
# 指标组调度优先级(0->127)->(优先级高->低) 优先级低的指标组会等优先级高的指标组采集完成后才会被调度, 相同优先级的指标组会并行调度采集
# 优先级为0的指标组为可用性指标组,即它会被首先调度,采集成功才会继续调度其它指标组,采集失败则中断调度
priority: 0
# collect metrics content
# 具体监控指标列表
fields:
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), instance-if is metrics group unique identifier
# field-指标名称, type-指标类型(0-number数字,1-string字符串), unit-指标单位('%','ms','MB'), instance-是否是指标集合唯一标识符字段
- field: name
type: 1
- field: descr
type: 1
- field: uptime
type: 1
- field: numUsers
type: 0
- field: services
type: 0
- field: processes
type: 0
- field: responseTime
type: 0
unit: ms
- field: location
type: 1
# the protocol used for monitoring, eg: sql, ssh, http, telnet, wmi, snmp, sdk
protocol: snmp
# the config content when protocol is snmp
snmp:
# server host: ipv4 ipv6 domain
host: ^_^host^_^
# server port
port: ^_^port^_^
# snmp connect timeout
timeout: ^_^timeout^_^
# snmp community
# snmp 团体字
community: ^_^community^_^
# snmp version
version: ^_^version^_^
# snmp operation: get, walk
operation: get
# metrics oids: metric_name - oid_value
oids:
name: 1.3.6.1.2.1.1.5.0
descr: 1.3.6.1.2.1.1.1.0
uptime: 1.3.6.1.2.1.25.1.1.0
numUsers: 1.3.6.1.2.1.25.1.5.0
services: 1.3.6.1.2.1.1.7.0
processes: 1.3.6.1.2.1.25.1.6.0
location: 1.3.6.1.2.1.1.6.0
```
...@@ -3,7 +3,7 @@ id: extend-ssh ...@@ -3,7 +3,7 @@ id: extend-ssh
title: SSH协议自定义监控 title: SSH协议自定义监控
sidebar_label: SSH协议自定义监控 sidebar_label: SSH协议自定义监控
--- ---
> 从[自定义监控](extend-point)了解熟悉了怎么自定义类型,指标,协议等,这里我们来详细介绍下用SSH协议自定义指标监控。 > 从[自定义监控](extend-point)了解熟悉了怎么自定义类型,指标,协议等,这里我们来详细介绍下用SSH协议自定义指标监控。
> SSH协议自定义监控可以让我们很方便的通过写sh命令脚本就能监控采集到我们想监控的Linux指标 > SSH协议自定义监控可以让我们很方便的通过写sh命令脚本就能监控采集到我们想监控的Linux指标
### SSH协议采集流程 ### SSH协议采集流程
...@@ -57,20 +57,20 @@ total used free buff_cache available ...@@ -57,20 +57,20 @@ total used free buff_cache available
### 自定义步骤 ### 自定义步骤
配置自定义监控类型需新增配置YML文件 **HertzBeat页面** -> **监控模版菜单** -> **新增监控类型** -> **配置自定义监控模版YML** -> **点击保存应用** -> **使用新监控类型添加监控**
1. 用监控类型命名的监控配置定义文件 - 例如:example_linux.yml 需位于安装目录 /hertzbeat/define/ 下
2. 重启hertzbeat系统,我们就适配好了一个新的自定义监控类型。 ![](/img/docs/advanced/extend-point-1.png)
------- -------
下面详细介绍下文件的配置用法,请注意看使用注释。 下面详细介绍下文件的配置用法,请注意看使用注释。
### 监控配置定义文件 ### 监控模版YML
> 监控配置定义文件用于定义 *监控类型的名称(国际化), 请求参数结构定义(前端页面根据配置自动渲染UI), 采集指标信息, 采集协议配置* 等。 > 监控配置定义文件用于定义 *监控类型的名称(国际化), 请求参数结构定义(前端页面根据配置自动渲染UI), 采集指标信息, 采集协议配置* 等。
> 即我们通过自定义这个YML文件,配置定义什么监控类型,前端页面需要输入什么参数,采集哪些性能指标,通过什么协议去采集。 > 即我们通过自定义这个YML,配置定义什么监控类型,前端页面需要输入什么参数,采集哪些性能指标,通过什么协议去采集。
样例:自定义一个名称为example_linux的自定义监控类型,其使用SSH协议采集指标数据。 样例:自定义一个名称为example_linux的自定义监控类型,其使用SSH协议采集指标数据。
文件名称: example_linux.yml 位于 /define/example_linux.yml
```yaml ```yaml
# 此监控类型所属类别:service-应用服务监控 db-数据库监控 custom-自定义监控 os-操作系统监控 # 此监控类型所属类别:service-应用服务监控 db-数据库监控 custom-自定义监控 os-操作系统监控
......
--- ---
id: extend-tutorial id: extend-tutorial
title: 快速教程:自定义适配一款基于HTTP协议的监控 title: 自定义适配一款基于HTTP协议的新监控类型
sidebar_label: 快速教程 sidebar_label: 教程案例
--- ---
通过此教程我们一步一步描述如何在hertzbeat监控系统下自定义新增适配一款基于http协议的监控类型。 通过此教程我们一步一步描述如何在hertzbeat监控系统下自定义新增适配一款基于http协议的监控类型。
阅读此教程前我们希望您已经从[自定义监控](extend-point)[http协议自定义](extend-http.md)了解熟悉了怎么自定义类型,指标,协议等。 阅读此教程前我们希望您已经从[自定义监控](extend-point)[http协议自定义](extend-http)了解熟悉了怎么自定义类型,指标,协议等。
### HTTP协议解析通用响应结构体,获取指标数据 ### HTTP协议解析通用响应结构体,获取指标数据
...@@ -59,38 +59,62 @@ sidebar_label: 快速教程 ...@@ -59,38 +59,62 @@ sidebar_label: 快速教程
**我们这次获取其app下的 `category`,`app`,`status`,`size`,`availableSize`等指标数据。** **我们这次获取其app下的 `category`,`app`,`status`,`size`,`availableSize`等指标数据。**
### 新增对应的应用定义YML和参数定义YML ### 新增配置监控模版YML
1. 自定义监控类型需新增配置YML文件 **HertzBeat页面** -> **监控模版菜单** -> **新增监控类型** -> **配置自定义监控模版YML**
用监控类型命名的监控配置定义文件 - 例如:app-hertzbeat.yml 需位于安装目录 /hertzbeat/define/ 下 定义我们在页面上需要输入哪些参数,一般的HTTP协议参数主要有ip, port, headers, params, uri, 账户密码等,我们直接复用 `api`监控模版 里面的参数定义内容,删除其中的我们不需要输入的uri参数和keyword关键字等参数即可。
定义我们在页面上需要输入哪些参数,一般的HTTP协议参数主要有ip, port, headers, params, uri, 账户密码等,我们直接复用 param-api.yml 里面的参数定义内容,删除其中的我们不需要输入的uri参数和keyword关键字等参数即可。 定义采集类型是啥,需要用哪种协议采集方式,采集的指标是啥,协议的配置参数等。我们直接复用 `api`监控模版 里面的定义内容,修改为我们当前的监控类型`hertzbeat`配置参数即可,如下:注意⚠️我们这次获取接口响应数据中的`category`,`app`,`status`,`size`,`availableSize`等字段作为指标数据。
定义采集类型是啥,需要用哪种协议采集方式,采集的指标是啥,协议的配置参数等。我们直接复用 app-api.yml 里面的定义内容,修改为我们当前的监控类型`hertzbeat`配置参数即可,如下:注意⚠️我们这次获取接口响应数据中的`category`,`app`,`status`,`size`,`availableSize`等字段作为指标数据。
```yaml ```yaml
# 此监控类型所属类别:service-应用服务监控 db-数据库监控 custom-自定义监控 os-操作系统监控 # The monitoring type category:service-application service monitoring db-database monitoring custom-custom monitoring os-operating system monitoring
# 监控类型所属类别:service-应用服务监控 db-数据库监控 custom-自定义监控 os-操作系统监控 cn-云原生cloud native network-网络监控
category: custom category: custom
# 监控应用类型名称(与文件名保持一致) eg: linux windows tomcat mysql aws... # The monitoring type eg: linux windows tomcat mysql aws...
# 监控类型 eg: linux windows tomcat mysql aws...
app: hertzbeat app: hertzbeat
# The monitoring i18n name
# 监控类型国际化名称
name: name:
zh-CN: HertzBeat监控系统 zh-CN: HertzBeat监控系统
en-US: HertzBeat Monitor en-US: HertzBeat Monitor
# Input params define for monitoring(render web ui by the definition)
# 监控所需输入参数定义(根据定义渲染页面UI)
params: params:
# field-param field key
# field-字段名称标识符
- field: host - field: host
# name-param field display i18n name
# name-参数字段显示名称
name: name:
zh-CN: 主机Host zh-CN: 主机Host
en-US: Host en-US: Host
# type-param field type(most mapping the html input type)
# type-字段类型,样式(大部分映射input标签type属性)
type: host type: host
# required-true or false
# 是否是必输项 true-必填 false-可选
required: true required: true
# field-param field key
# field-变量字段标识符
- field: port - field: port
# name-param field display i18n name
# name-参数字段显示名称
name: name:
zh-CN: 端口 zh-CN: 端口
en-US: Port en-US: Port
# type-param field type(most mapping the html input type)
# type-字段类型,样式(大部分映射input标签type属性)
type: number type: number
# when type is number, range is required
# 当type为number时,用range表示范围
range: '[0,65535]' range: '[0,65535]'
# required-true or false
# required-是否是必输项 true-必填 false-可选
required: true required: true
# default value
# 端口默认值
defaultValue: 1157 defaultValue: 1157
- field: ssl - field: ssl
name: name:
...@@ -132,20 +156,22 @@ params: ...@@ -132,20 +156,22 @@ params:
type: password type: password
required: false required: false
hide: true hide: true
# 指标组列表
metrics: metrics:
# the first metrics summary
# attention: Built-in monitoring metrics contains (responseTime - Response time)
# 第一个监控指标组 summary # 第一个监控指标组 summary
# 注意:内置监控指标有 (responseTime - 响应时间) # 注意:内置监控指标有 (responseTime - 响应时间)
- name: summary - name: summary
# metrics group scheduling priority(0->127)->(high->low), metrics with the same priority will be scheduled in parallel
# priority 0's metrics group is availability metrics, it will be scheduled first, only availability metrics collect success will the scheduling continue
# 指标组调度优先级(0-127)越小优先级越高,优先级低的指标组会等优先级高的指标组采集完成后才会被调度,相同优先级的指标组会并行调度采集 # 指标组调度优先级(0-127)越小优先级越高,优先级低的指标组会等优先级高的指标组采集完成后才会被调度,相同优先级的指标组会并行调度采集
# 优先级为0的指标组为可用性指标组,即它会被首先调度,采集成功才会继续调度其它指标组,采集失败则中断调度 # 优先级为0的指标组为可用性指标组,即它会被首先调度,采集成功才会继续调度其它指标组,采集失败则中断调度
priority: 0 priority: 0
# collect metrics content
# 指标组中的具体监控指标 # 指标组中的具体监控指标
fields: fields:
# metrics content contains field-metric name, type-metric type:0-number,1-string, instance-if is metrics group, unit-metric unit('%','ms','MB')
# 指标信息 包括 field名称 type字段类型:0-number数字,1-string字符串 instance是否为实例主键 unit:指标单位 # 指标信息 包括 field名称 type字段类型:0-number数字,1-string字符串 instance是否为实例主键 unit:指标单位
- field: responseTime
type: 0
unit: ms
- field: app - field: app
type: 1 type: 1
instance: true instance: true
...@@ -156,43 +182,52 @@ metrics: ...@@ -156,43 +182,52 @@ metrics:
- field: size - field: size
type: 0 type: 0
- field: availableSize - field: availableSize
type: 0 type: 0
# 监控采集使用协议 eg: sql, ssh, http, telnet, wmi, snmp, sdk, 我们这里使用HTTP协议 # the protocol used for monitoring, eg: sql, ssh, http, telnet, wmi, snmp, sdk, we use HTTP protocol here
# 监控采集使用协议 eg: sql, ssh, http, telnet, wmi, snmp, sdk, 我们这里使用HTTP协议
protocol: http protocol: http
# 当protocol为http协议时具体的采集配置 # the config content when protocol is http
# 当protocol为http协议时具体的采集配置
http: http:
# http host: ipv4 ipv6 domain
# 主机host: ipv4 ipv6 域名 # 主机host: ipv4 ipv6 域名
host: ^_^host^_^ host: ^_^host^_^
# http port
# 端口 # 端口
port: ^_^port^_^ port: ^_^port^_^
# http url, we don't need to enter a parameter here, just set the fixed value to /api/summary
# url请求接口路径,我们这里不需要输入传参,写死为 /api/summary # url请求接口路径,我们这里不需要输入传参,写死为 /api/summary
url: /api/summary url: /api/summary
timeout: ^_^timeout^_^ timeout: ^_^timeout^_^
# 请求方式 GET POST PUT DELETE PATCH,写死为 # http method: GET POST PUT DELETE PATCH, default fixed value is GET
# 请求方式 GET POST PUT DELETE PATCH,写死为 GET
method: GET method: GET
# if enabled https, default value is false
# 是否启用ssl/tls,即是http还是https,默认false # 是否启用ssl/tls,即是http还是https,默认false
ssl: ^_^ssl^_^ ssl: ^_^ssl^_^
# http auth
# 认证 # 认证
authorization: authorization:
# http auth type: Basic Auth, Digest Auth, Bearer Token
# 认证方式: Basic Auth, Digest Auth, Bearer Token # 认证方式: Basic Auth, Digest Auth, Bearer Token
type: ^_^authType^_^ type: ^_^authType^_^
basicAuthUsername: ^_^username^_^ basicAuthUsername: ^_^username^_^
basicAuthPassword: ^_^password^_^ basicAuthPassword: ^_^password^_^
digestAuthUsername: ^_^username^_^ digestAuthUsername: ^_^username^_^
digestAuthPassword: ^_^password^_^ digestAuthPassword: ^_^password^_^
# http response data parse type: default-hertzbeat rule, jsonpath-jsonpath script, website-for website monitoring, we use jsonpath to parse response data here
# 响应数据解析方式: default-系统规则,jsonPath-jsonPath脚本,website-网站可用性指标监控,我们这里使用jsonpath来解析响应数据 # 响应数据解析方式: default-系统规则,jsonPath-jsonPath脚本,website-网站可用性指标监控,我们这里使用jsonpath来解析响应数据
parseType: jsonPath parseType: jsonPath
parseScript: '$.data.apps.*' parseScript: '$.data.apps.*'
``` ```
**新增完毕,现在我们重启hertzbeat系统。我们可以看到系统页面已经多了一个`hertzbeat`监控类型了。** **点击保存并应用。我们可以看到系统页面的自定义监控菜单已经多了一个`hertzbeat`监控类型了。**
![](/img/docs/advanced/extend-http-example-1.png) ![](/img/docs/advanced/extend-http-example-1.png)
### 系统页面添加对`hertzbeat`监控类型的监控 ### 页面添加对`hertzbeat`监控类型的监控
> 我们点击新增 `HertzBeat监控系统`,配置监控IP,端口,采集周期,高级设置里的账户密码等, 点击确定添加监控。 > 我们点击新增 `HertzBeat监控系统`,配置监控IP,端口,采集周期,高级设置里的账户密码等, 点击确定添加监控。
...@@ -218,10 +253,5 @@ metrics: ...@@ -218,10 +253,5 @@ metrics:
#### 完! #### 完!
HTTP协议的自定义监控的实践就到这里,HTTP协议还带其他参数headers,params等,我们可以像用postman一样去定义它,可玩性也非常高! HTTP协议的自定义监控的实践就到这里,HTTP协议还带其他参数 `headers,params` 等,我们可以像用postman一样去定义它,可玩性也非常高!
如果您觉得hertzbeat这个开源项目不错的话欢迎给我们在GitHub Gitee star哦,灰常感谢。感谢老铁们的支持。笔芯!
**github: https://github.com/dromara/hertzbeat**
**gitee: https://gitee.com/dromara/hertzbeat**
...@@ -200,6 +200,13 @@ Thanks these wonderful people, welcome to join us: [贡献者指南](contributin ...@@ -200,6 +200,13 @@ Thanks these wonderful people, welcome to join us: [贡献者指南](contributin
<td align="center" valign="top" width="14.28%"><a href="https://github.com/san346596324"><img src="https://avatars.githubusercontent.com/u/30828520?v=4?s=100" width="100px;" alt="渭雨"/><br /><sub><b>渭雨</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=san346596324" title="Code">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/san346596324"><img src="https://avatars.githubusercontent.com/u/30828520?v=4?s=100" width="100px;" alt="渭雨"/><br /><sub><b>渭雨</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=san346596324" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/luoxuanzao"><img src="https://avatars.githubusercontent.com/u/44692579?v=4?s=100" width="100px;" alt="liuxuezhuo"/><br /><sub><b>liuxuezhuo</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=luoxuanzao" title="Code">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/luoxuanzao"><img src="https://avatars.githubusercontent.com/u/44692579?v=4?s=100" width="100px;" alt="liuxuezhuo"/><br /><sub><b>liuxuezhuo</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=luoxuanzao" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/lisongning"><img src="https://avatars.githubusercontent.com/u/93140178?v=4?s=100" width="100px;" alt="lisongning"/><br /><sub><b>lisongning</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=lisongning" title="Code">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/lisongning"><img src="https://avatars.githubusercontent.com/u/93140178?v=4?s=100" width="100px;" alt="lisongning"/><br /><sub><b>lisongning</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=lisongning" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/YutingNie"><img src="https://avatars.githubusercontent.com/u/104416402?v=4?s=100" width="100px;" alt="YutingNie"/><br /><sub><b>YutingNie</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=YutingNie" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/mikezzb"><img src="https://avatars.githubusercontent.com/u/23418428?v=4?s=100" width="100px;" alt="Mike Zhou"/><br /><sub><b>Mike Zhou</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=mikezzb" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/a-little-fool"><img src="https://avatars.githubusercontent.com/u/105542329?v=4?s=100" width="100px;" alt="小笨蛋"/><br /><sub><b>小笨蛋</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=a-little-fool" title="Code">💻</a></td>
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/littlezhongzer"><img src="https://avatars.githubusercontent.com/u/33685289?v=4?s=100" width="100px;" alt="littlezhongzer"/><br /><sub><b>littlezhongzer</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=littlezhongzer" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/ChenXiangxxxxx"><img src="https://avatars.githubusercontent.com/u/90089594?v=4?s=100" width="100px;" alt="ChenXiangxxxxx"/><br /><sub><b>ChenXiangxxxxx</b></sub></a><br /><a href="https://github.com/dromara/hertzbeat/commits?author=ChenXiangxxxxx" title="Code">💻</a></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
......
...@@ -15,6 +15,8 @@ sidebar_label: 监控模版 ...@@ -15,6 +15,8 @@ sidebar_label: 监控模版
**我们将所有监控采集类型(mysql,website,jvm,k8s)都定义为yml模版,用户可以导入这些模版到hertzbeat系统中,使其支持对应类型的监控,非常方便!** **我们将所有监控采集类型(mysql,website,jvm,k8s)都定义为yml模版,用户可以导入这些模版到hertzbeat系统中,使其支持对应类型的监控,非常方便!**
![](/img/docs/advanced/extend-point-1.png)
**欢迎大家一起贡献你使用过程中自定义的通用监控类型YML模版,可用的模板如下:** **欢迎大家一起贡献你使用过程中自定义的通用监控类型YML模版,可用的模板如下:**
### 应用服务监控模版 ### 应用服务监控模版
......
...@@ -62,5 +62,17 @@ ...@@ -62,5 +62,17 @@
"item.label.华为云开源活动": { "item.label.华为云开源活动": {
"message": "华为云开源活动", "message": "华为云开源活动",
"description": "Navbar item with label 华为云开源活动" "description": "Navbar item with label 华为云开源活动"
},
"item.label.Docs": {
"message": "文档中心",
"description": "Navbar item with label Docs"
},
"item.label.Others": {
"message": "其它信息",
"description": "Navbar item with label Others"
},
"item.label.contributors": {
"message": "开发者们",
"description": "Navbar item with label contributors"
} }
} }
...@@ -60,6 +60,20 @@ ...@@ -60,6 +60,20 @@
"items": [ "items": [
"advanced/extend-ssh" "advanced/extend-ssh"
] ]
},
{
"type": "category",
"label": "jmx",
"items": [
"advanced/extend-jmx"
]
},
{
"type": "category",
"label": "snmp",
"items": [
"advanced/extend-snmp"
]
} }
] ]
}, },
......
...@@ -21,14 +21,14 @@ sidebar_label: 快速开始 ...@@ -21,14 +21,14 @@ sidebar_label: 快速开始
2. 创建名称为hertzbeat的数据库 2. 创建名称为hertzbeat的数据库
3. 执行位于项目仓库/script/sql/目录下的数据库脚本 [schema.sql](https://gitee.com/dromara/hertzbeat/raw/master/script/sql/schema.sql) 3. 执行位于项目仓库/script/sql/目录下的数据库脚本 [schema.sql](https://gitee.com/dromara/hertzbeat/raw/master/script/sql/schema.sql)
详细步骤参考 [依赖服务MYSQL安装初始化](mysql-init.md) 详细步骤参考 [依赖服务MYSQL安装初始化](mysql-init)
##### 安装TDengine ##### 安装TDengine
1. docker安装TDengine 1. docker安装TDengine
`docker run -d -p 6030-6049:6030-6049 -p 6030-6049:6030-6049/udp --name tdengine tdengine/tdengine:2.4.0.12` `docker run -d -p 6030-6049:6030-6049 -p 6030-6049:6030-6049/udp --name tdengine tdengine/tdengine:2.4.0.12`
2. 创建名称为hertzbeat的数据库 2. 创建名称为hertzbeat的数据库
详细步骤参考 [依赖服务TDengine安装初始化](tdengine-init.md) 详细步骤参考 [依赖服务TDengine安装初始化](tdengine-init)
### 🍞 HertzBeat安装 ### 🍞 HertzBeat安装
> HertzBeat支持通过源码安装启动,Docker容器运行和安装包方式安装部署。 > HertzBeat支持通过源码安装启动,Docker容器运行和安装包方式安装部署。
...@@ -36,14 +36,14 @@ sidebar_label: 快速开始 ...@@ -36,14 +36,14 @@ sidebar_label: 快速开始
#### 方式一:Docker方式快速安装 #### 方式一:Docker方式快速安装
`docker run -d -p 1157:1157 -v /opt/application.yml:/opt/hertzbeat/config/application.yml --name hertzbeat tancloud/hertzbeat:[版本tag]` `docker run -d -p 1157:1157 -v /opt/application.yml:/opt/hertzbeat/config/application.yml --name hertzbeat tancloud/hertzbeat:[版本tag]`
详细步骤参考 [通过Docker方式安装HertzBeat](docker-deploy.md) 详细步骤参考 [通过Docker方式安装HertzBeat](docker-deploy)
#### 方式二:通过安装包安装 #### 方式二:通过安装包安装
1. 下载您系统环境对应的安装包 [GITEE Release](https://gitee.com/dromara/hertzbeat/releases) [GITHUB Release](https://github.com/dromara/hertzbeat/releases) 1. 下载您系统环境对应的安装包 [GITEE Release](https://gitee.com/dromara/hertzbeat/releases) [GITHUB Release](https://github.com/dromara/hertzbeat/releases)
2. 配置HertzBeat的配置文件 hertzbeat/config/application.yml 2. 配置HertzBeat的配置文件 hertzbeat/config/application.yml
3. 部署启动 `$ ./startup.sh ` 3. 部署启动 `$ ./startup.sh `
详细步骤参考 [通过安装包安装HertzBeat](package-deploy.md) 详细步骤参考 [通过安装包安装HertzBeat](package-deploy)
#### 方式三:本地代码启动 #### 方式三:本地代码启动
1. 此为前后端分离项目,本地代码调试需要分别启动后端工程manager和前端工程web-app 1. 此为前后端分离项目,本地代码调试需要分别启动后端工程manager和前端工程web-app
......
...@@ -6,7 +6,7 @@ sidebar_label: 教程一:适配一款HTTP协议监控 ...@@ -6,7 +6,7 @@ sidebar_label: 教程一:适配一款HTTP协议监控
通过此教程我们一步一步描述如何在hertzbeat监控系统下新增适配一款基于http协议的监控类型。 通过此教程我们一步一步描述如何在hertzbeat监控系统下新增适配一款基于http协议的监控类型。
阅读此教程前我们希望您已经从[自定义监控](extend-point)[http协议自定义](extend-http.md)了解熟悉了怎么自定义类型,指标,协议等。 阅读此教程前我们希望您已经从[自定义监控](extend-point)[http协议自定义](extend-http)了解熟悉了怎么自定义类型,指标,协议等。
### HTTP协议解析通用响应结构体,获取指标数据 ### HTTP协议解析通用响应结构体,获取指标数据
......
...@@ -6,7 +6,7 @@ sidebar_label: 教程二:获取TOKEN后续认证使用 ...@@ -6,7 +6,7 @@ sidebar_label: 教程二:获取TOKEN后续认证使用
通过此教程我们一步一步描述如何在教程一的基础上改造,新增一个指标组,先调用认证接口获取TOKEN后,使用TOKEN作为参数供后面的指标组采集认证使用。 通过此教程我们一步一步描述如何在教程一的基础上改造,新增一个指标组,先调用认证接口获取TOKEN后,使用TOKEN作为参数供后面的指标组采集认证使用。
阅读此教程前我们希望您已经从[自定义监控](extend-point)[http协议自定义](extend-http.md)了解熟悉了怎么自定义类型,指标,协议等。 阅读此教程前我们希望您已经从[自定义监控](extend-point)[http协议自定义](extend-http)了解熟悉了怎么自定义类型,指标,协议等。
### 请求流程 ### 请求流程
......
...@@ -6,7 +6,7 @@ sidebar_label: 快速教程 ...@@ -6,7 +6,7 @@ sidebar_label: 快速教程
通过此教程我们一步一步描述如何在hertzbeat监控系统下自定义新增适配一款基于http协议的监控类型。 通过此教程我们一步一步描述如何在hertzbeat监控系统下自定义新增适配一款基于http协议的监控类型。
阅读此教程前我们希望您已经从[自定义监控](extend-point)[http协议自定义](extend-http.md)了解熟悉了怎么自定义类型,指标,协议等。 阅读此教程前我们希望您已经从[自定义监控](extend-point)[http协议自定义](extend-http)了解熟悉了怎么自定义类型,指标,协议等。
### HTTP协议解析通用响应结构体,获取指标数据 ### HTTP协议解析通用响应结构体,获取指标数据
......
...@@ -59,7 +59,7 @@ $ docker run -d -p 6667:6667 -p 31999:31999 -p 8181:8181 \ ...@@ -59,7 +59,7 @@ $ docker run -d -p 6667:6667 -p 31999:31999 -p 8181:8181 \
2. 浏览器访问 `localhost:1157` 即可开始,默认账号密码 `admin/hertzbeat` 2. 浏览器访问 `localhost:1157` 即可开始,默认账号密码 `admin/hertzbeat`
更多配置详细步骤参考 [通过Docker方式安装HertzBeat](docker-deploy.md) 更多配置详细步骤参考 [通过Docker方式安装HertzBeat](docker-deploy)
#### 方式二:通过安装包安装 #### 方式二:通过安装包安装
...@@ -69,7 +69,7 @@ $ docker run -d -p 6667:6667 -p 31999:31999 -p 8181:8181 \ ...@@ -69,7 +69,7 @@ $ docker run -d -p 6667:6667 -p 31999:31999 -p 8181:8181 \
4. 部署启动 `$ ./startup.sh ` 4. 部署启动 `$ ./startup.sh `
5. 浏览器访问 `localhost:1157` 即可开始,默认账号密码 `admin/hertzbeat` 5. 浏览器访问 `localhost:1157` 即可开始,默认账号密码 `admin/hertzbeat`
更多配置详细步骤参考 [通过安装包安装HertzBeat](package-deploy.md) 更多配置详细步骤参考 [通过安装包安装HertzBeat](package-deploy)
#### 方式三:本地代码启动 #### 方式三:本地代码启动
1. 此为前后端分离项目,本地代码调试需要分别启动后端工程manager和前端工程web-app 1. 此为前后端分离项目,本地代码调试需要分别启动后端工程manager和前端工程web-app
......
...@@ -39,43 +39,44 @@ import java.util.Map; ...@@ -39,43 +39,44 @@ import java.util.Map;
@RequiredArgsConstructor @RequiredArgsConstructor
@Slf4j @Slf4j
final class DbAlertStoreHandlerImpl implements AlertStoreHandler { final class DbAlertStoreHandlerImpl implements AlertStoreHandler {
private final MonitorService monitorService; private final MonitorService monitorService;
private final AlertService alertService; private final AlertService alertService;
@Override @Override
public void store(Alert alert) { public void store(Alert alert) {
// todo Using the cache does not directly manipulate the library
Map<String, String> tags = alert.getTags(); Map<String, String> tags = alert.getTags();
String monitorIdStr = tags.get(CommonConstants.TAG_MONITOR_ID); String monitorIdStr = tags.get(CommonConstants.TAG_MONITOR_ID);
if (monitorIdStr == null) { if (monitorIdStr != null) {
log.error("alert tags monitorId is null."); long monitorId = Long.parseLong(monitorIdStr);
return; Monitor monitor = monitorService.getMonitor(monitorId);
} if (monitor == null) {
long monitorId = Long.parseLong(monitorIdStr); log.warn("Dispatch alarm the monitorId: {} not existed, ignored.", monitorId);
Monitor monitor = monitorService.getMonitor(monitorId); return;
if (monitor == null) {
log.warn("Dispatch alarm the monitorId: {} not existed, ignored.", monitorId);
return;
}
if (monitor.getStatus() == CommonConstants.UN_MANAGE_CODE) {
// When monitoring is not managed, ignore and silence its alarm messages
// 当监控未管理时 忽略静默其告警信息
return;
}
if (monitor.getStatus() == CommonConstants.AVAILABLE_CODE) {
if (CommonConstants.AVAILABILITY.equals(alert.getTarget())) {
// Availability Alarm Need to change the monitoring status to unavailable
// 可用性告警 需变更监控状态为不可用
monitorService.updateMonitorStatus(monitor.getId(), CommonConstants.UN_AVAILABLE_CODE);
} }
} else { if (monitor.getStatus() == CommonConstants.UN_MANAGE_CODE) {
// If the alarm is restored, the monitoring state needs to be restored // When monitoring is not managed, ignore and silence its alarm messages
// 若是恢复告警 需对监控状态进行恢复 // 当监控未管理时 忽略静默其告警信息
if (alert.getStatus() == CommonConstants.ALERT_STATUS_CODE_RESTORED) { return;
monitorService.updateMonitorStatus(monitorId, CommonConstants.AVAILABLE_CODE);
} }
if (monitor.getStatus() == CommonConstants.AVAILABLE_CODE) {
if (CommonConstants.AVAILABILITY.equals(alert.getTarget())) {
// Availability Alarm Need to change the monitoring status to unavailable
// 可用性告警 需变更监控状态为不可用
monitorService.updateMonitorStatus(monitor.getId(), CommonConstants.UN_AVAILABLE_CODE);
}
} else {
// If the alarm is restored, the monitoring state needs to be restored
// 若是恢复告警 需对监控状态进行恢复
if (alert.getStatus() == CommonConstants.ALERT_STATUS_CODE_RESTORED) {
monitorService.updateMonitorStatus(monitorId, CommonConstants.AVAILABLE_CODE);
}
}
} else {
log.debug("store extern alert content: {}.", alert);
} }
// Alarm drop library 告警落库 // Alarm store db
alertService.addAlert(alert); alertService.addAlert(alert);
} }
} }
...@@ -99,11 +99,11 @@ public class MonitorsController { ...@@ -99,11 +99,11 @@ public class MonitorsController {
if (StringUtils.hasText(tag)) { if (StringUtils.hasText(tag)) {
String[] tagArr = tag.split(":"); String[] tagArr = tag.split(":");
String tagName = tagArr[0]; String tagName = tagArr[0];
String tagValue = tagArr[1];
ListJoin<Monitor, org.dromara.hertzbeat.common.entity.manager.Tag> tagJoin = root ListJoin<Monitor, org.dromara.hertzbeat.common.entity.manager.Tag> tagJoin = root
.join(root.getModel() .join(root.getModel()
.getList("tags", org.dromara.hertzbeat.common.entity.manager.Tag.class), JoinType.LEFT); .getList("tags", org.dromara.hertzbeat.common.entity.manager.Tag.class), JoinType.LEFT);
if (tagArr.length == TAG_LENGTH) { if (tagArr.length == TAG_LENGTH) {
String tagValue = tagArr[1];
andList.add(criteriaBuilder.equal(tagJoin.get("name"), tagName)); andList.add(criteriaBuilder.equal(tagJoin.get("name"), tagName));
andList.add(criteriaBuilder.equal(tagJoin.get("value"), tagValue)); andList.add(criteriaBuilder.equal(tagJoin.get("value"), tagValue));
} else { } else {
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
# The monitoring type category:service-application service monitoring db-database monitoring custom-custom monitoring os-operating system monitoring mid-middleware # The monitoring type category:service-application service monitoring db-database monitoring custom-custom monitoring os-operating system monitoring mid-middleware
# 监控类型所属类别:service-应用服务监控 db-数据库监控 custom-自定义监控 os-操作系统监控 cn-云原生cloud native network-网络监控 mid-中间件 # 监控类型所属类别:service-应用服务监控 db-数据库监控 custom-自定义监控 os-操作系统监控 cn-云原生cloud native network-网络监控 mid-中间件
category: custom category: mid
# The monitoring: airflow # The monitoring: airflow
# 监控类型 airflow # 监控类型 airflow
app: airflow app: airflow
...@@ -78,10 +78,6 @@ params: ...@@ -78,10 +78,6 @@ params:
hide: true hide: true
required: false required: false
# collect metrics config list # collect metrics config list
# 采集指标组配置列表 # 采集指标组配置列表
metrics: metrics:
...@@ -124,17 +120,12 @@ metrics: ...@@ -124,17 +120,12 @@ metrics:
type: 1 type: 1
- field: git_version - field: git_version
type: 1 type: 1
# 监控采集使用协议 eg: sql, ssh, http, telnet, wmi, snmp, sdk
protocol: http protocol: http
# 当protocol为http协议时具体的采集配置
http: http:
# 主机host: ipv4 ipv6 域名
host: ^_^host^_^ host: ^_^host^_^
# 端口
port: ^_^port^_^ port: ^_^port^_^
# url请求接口路径
url: /api/v1/version url: /api/v1/version
timeout: ^_^timeout^_^ timeout: ^_^timeout^_^
method: GET method: GET
parseType: jsonPath parseType: jsonPath
parseScript: '$' parseScript: '$'
\ No newline at end of file
...@@ -192,7 +192,8 @@ metrics: ...@@ -192,7 +192,8 @@ metrics:
password: ^_^password^_^ password: ^_^password^_^
database: ^_^database^_^ database: ^_^database^_^
timeout: ^_^timeout^_^ timeout: ^_^timeout^_^
queryType: oneRow queryType: multiRow
sql: select file_id, file_name, tablespace_name, status, bytes / 1024 / 1024 as bytes, blocks from dba_data_files sql: select file_id, file_name, tablespace_name, status, bytes / 1024 / 1024 as bytes, blocks from dba_data_files
url: ^_^url^_^ url: ^_^url^_^
...@@ -508,3 +509,44 @@ metrics: ...@@ -508,3 +509,44 @@ metrics:
queryType: columns queryType: columns
sql: select metric_name, value from gv$sysmetric where metric_name like '%Cache Hit Ratio' order by end_time asc sql: select metric_name, value from gv$sysmetric where metric_name like '%Cache Hit Ratio' order by end_time asc
url: ^_^url^_^ url: ^_^url^_^
- name: slow_query
priority: 1
fields:
- field: sql_id
type: 1
- field: child_number
type: 1
- field: executions
type: 1
unit: 次数
- field: per_secs
type: 1
unit:
- field: cpu_secs
type: 1
unit:
- field: buffer_gets
type: 1
- field: disk_reads
type: 1
- field: fetches
type: 1
- field: parse_calls
type: 1
- field: optimizer_cost
type: 1
- field: sql_text
type: 1
protocol: jdbc
jdbc:
host: ^_^host^_^
port: ^_^port^_^
platform: oracle
username: ^_^username^_^
password: ^_^password^_^
database: ^_^database^_^
timeout: ^_^timeout^_^
queryType: multiRow
sql: SELECT * FROM (SELECT sql_id, child_number, executions, ROUND(CASE WHEN executions = 0 THEN NULL ELSE elapsed_time / (executions*1000000) END,4) AS per_secs, cpu_time / 1000000 AS cpu_secs, buffer_gets, disk_reads, fetches, parse_calls, optimizer_cost, sql_text FROM v$sql ) where rownum <= 10 ORDER BY per_secs DESC
url: ^_^url^_^
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# The monitoring type category:service-application service monitoring db-database monitoring custom-custom monitoring os-operating system monitoring
# 监控类型所属类别:service-应用服务监控 db-数据库监控 custom-自定义监控 os-操作系统监控 cn-云原生cloud native network-网络监控 mid-中间件
category: mid
# The monitoring type eg: linux windows tomcat mysql aws...
# 监控类型 eg: linux windows tomcat mysql aws...
app: spark
# The monitoring i18n name
# 监控类型国际化名称
name:
zh-CN: Apache Spark
en-US: Apache Spark
# Input params define for monitoring(render web ui by the definition)
# 监控所需输入参数定义(根据定义渲染页面UI)
params:
# field-param field key
# field-字段名称标识符
- field: host
# name-param field display i18n name
# name-参数字段显示名称
name:
zh-CN: 主机Host
en-US: Host
# type-param field type(most mapping the html input type)
# type-字段类型,样式(大部分映射input标签type属性)
type: host
# required-true or false
# 是否是必输项 true-必填 false-可选
required: true
# field-param field key
# field-变量字段标识符
- field: port
# name-param field display i18n name
# name-参数字段显示名称
name:
zh-CN: 端口
en-US: Port
# type-param field type(most mapping the html input type)
# type-字段类型,样式(大部分映射input标签type属性)
type: number
# when type is number, range is required
# 当type为number时,用range表示范围
range: '[0,65535]'
# required-true or false
# required-是否是必输项 true-必填 false-可选
required: true
# default value
# 端口默认值
defaultValue: 8712
# field-param field key
# field-变量字段标识符
- field: url
# name-param field display i18n name
# name-参数字段显示名称
name:
zh-CN: JMX URL
en-US: JMX URL
# type-param field type(most mapping the html input type)
# type-字段类型,样式(大部分映射input标签type属性)
type: text
# required-true or false
# required-是否是必输项 true-必填 false-可选
required: false
# hide param-true or false
# 是否隐藏字段 true or false
hide: true
# param field input placeholder
# 参数输入框提示信息
placeholder: 'service:jmx:rmi:///jndi/rmi://host:port/jmxrmi'
# field-param field key
# field-变量字段标识符
- field: username
# name-param field display i18n name
# name-参数字段显示名称
name:
zh-CN: 用户名
en-US: Username
# type-param field type(most mapping the html input type)
# type-字段类型,样式(大部分映射input标签type属性)
type: text
# when type is text, use limit to limit string length
# 当type为text时,用limit表示字符串限制大小
limit: 20
# required-true or false
# required-是否是必输项 true-必填 false-可选
required: false
# hide param-true or false
# 是否隐藏字段 true or false
hide: true
# field-param field key
# field-变量字段标识符
- field: password
# name-param field display i18n name
# name-参数字段显示名称
name:
zh-CN: 密码
en-US: Password
# type-param field type(most mapping the html input tag)
# type-字段类型,样式(大部分映射input标签type属性)
type: password
# required-true or false
# required-是否是必输项 true-必填 false-可选
required: false
# hide param-true or false
# 是否隐藏字段 true or false
hide: true
# collect metrics config list
# 采集指标组配置列表
metrics:
# metrics - basic
# 监控指标组 - basic
- name: basic
# metrics group scheduling priority(0->127)->(high->low), metrics with the same priority will be scheduled in parallel
# priority 0's metrics group is availability metrics, it will be scheduled first, only availability metrics collect success will the scheduling continue
# 指标组调度优先级(0->127)->(优先级高->低) 优先级低的指标组会等优先级高的指标组采集完成后才会被调度, 相同优先级的指标组会并行调度采集
# 优先级为0的指标组为可用性指标组,即它会被首先调度,采集成功才会继续调度其它指标组,采集失败则中断调度
priority: 0
# collect metrics content
# 具体监控指标列表
fields:
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), instance-if is metrics group unique identifier
# field-指标名称, type-指标类型(0-number数字,1-string字符串), unit-指标单位('%','ms','MB'), instance-是否是指标集合唯一标识符字段
- field: VmName
type: 1
- field: VmVendor
type: 1
- field: VmVersion
type: 1
- field: Uptime
type: 0
unit: ms
# the protocol used for monitoring, eg: sql, ssh, http, telnet, wmi, snmp, sdk
# 用于监控的协议,例: sql, ssh, http, telnet, wmi, snmp, sdk
protocol: jmx
# the config content when protocol is jmx
jmx:
# host: ipv4 ipv6 domain
# 主机host: ipv4 ipv6 域名
host: ^_^host^_^
# port
# 端口
port: ^_^port^_^
username: ^_^username^_^
password: ^_^password^_^
# jmx mbean object name
# jmx mbean 对象名称
objectName: java.lang:type=Runtime
url: ^_^url^_^
- name: memory_pool
priority: 1
fields:
- field: name
type: 1
instance: true
- field: committed
type: 0
unit: MB
- field: init
type: 0
unit: MB
- field: max
type: 0
unit: MB
- field: used
type: 0
unit: MB
units:
- committed=B->MB
- init=B->MB
- max=B->MB
- used=B->MB
# (optional)metrics field alias name, it is used as an alias field to map and convert the collected data and metrics field
# (可选)监控指标别名, 做为中间字段与采集数据字段和指标字段映射转换
aliasFields:
- Name
- Usage->committed
- Usage->init
- Usage->max
- Usage->used
# mapping and conversion expressions, use these and aliasField above to calculate metrics value
# (可选)指标映射转换计算表达式,与上面的别名一起作用,计算出最终需要的指标值
# eg: cores=core1+core2, usage=usage, waitTime=allTime-runningTime
calculates:
- name=Name
- committed=Usage->committed
- init=Usage->init
- max=Usage->max
- used=Usage->used
protocol: jmx
jmx:
# host: ipv4 ipv6 domain
# 主机host: ipv4 ipv6 域名
host: ^_^host^_^
# port
# 端口
port: ^_^port^_^
username: ^_^username^_^
password: ^_^password^_^
objectName: java.lang:type=MemoryPool,name=*
url: ^_^url^_^
- name: code_cache
priority: 5
fields:
- field: committed
type: 0
- field: init
type: 0
- field: max
type: 0
- field: used
type: 0
aliasFields:
- Usage->committed
- Usage->init
- Usage->max
- Usage->used
calculates:
- committed=Usage->committed
- init=Usage->init
- max=Usage->max
- used=Usage->used
protocol: jmx
jmx:
# host: ipv4 ipv6 domain
# 主机host: ipv4 ipv6 域名
host: ^_^host^_^
# port
# 端口
port: ^_^port^_^
username: ^_^username^_^
password: ^_^password^_^
objectName: java.lang:type=MemoryPool,name=Code Cache
url: ^_^url^_^
- name: class_loading
priority: 6
# collect metrics content
# 具体监控指标列表
fields:
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), instance-if is metrics group unique identifier
# field-指标名称, type-指标类型(0-number数字,1-string字符串), unit-指标单位('%','ms','MB'), instance-是否是指标集合唯一标识符字段
- field: LoadedClassCount
type: 0
- field: TotalLoadedClassCount
type: 0
- field: UnloadedClassCount
type: 0
protocol: jmx
jmx:
host: ^_^host^_^
port: ^_^port^_^
username: ^_^username^_^
password: ^_^password^_^
objectName: java.lang:type=ClassLoading
url: ^_^url^_^
- name: thread
priority: 7
# collect metrics content
# 指标组中的具体监控指标
fields:
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), instance-if is metrics group unique identifier
# field-指标名称, type-指标类型(0-number数字,1-string字符串), unit-指标单位('%','ms','MB'), instance-是否是指标集合唯一标识符字段
- field: TotalStartedThreadCount
type: 0
- field: ThreadCount
type: 0
- field: PeakThreadCount
type: 0
- field: DaemonThreadCount
type: 0
- field: CurrentThreadUserTime
type: 0
unit: s
- field: CurrentThreadCpuTime
type: 0
unit: s
protocol: jmx
jmx:
host: ^_^host^_^
port: ^_^port^_^
username: ^_^username^_^
password: ^_^password^_^
objectName: java.lang:type=Threading
url: ^_^url^_^
...@@ -54,6 +54,7 @@ resourceRole: ...@@ -54,6 +54,7 @@ resourceRole:
# 需要被过滤保护的资源,不认证鉴权直接访问 # 需要被过滤保护的资源,不认证鉴权直接访问
# /api/v1/source3===get 表示 /api/v1/source3===get 可以被任何人访问 无需登录认证鉴权 # /api/v1/source3===get 表示 /api/v1/source3===get 可以被任何人访问 无需登录认证鉴权
excludedResource: excludedResource:
- /api/alerts/**===*
- /api/account/auth/**===* - /api/account/auth/**===*
- /api/i18n/**===get - /api/i18n/**===get
- /api/metrics===get - /api/metrics===get
......
import { MockRequest } from '@delon/mock';
const list: any[] = [];
const total = 50;
for (let i = 0; i < total; i += 1) {
list.push({
id: i + 1,
disabled: i % 6 === 0,
href: 'https://ant.design',
avatar: [
'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png',
'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png'
][i % 2],
no: `TradeCode ${i}`,
title: `一个任务名称 ${i}`,
owner: '曲丽丽',
description: '这是一段描述',
callNo: Math.floor(Math.random() * 1000),
status: Math.floor(Math.random() * 10) % 4,
updatedAt: new Date(`2017-07-${Math.floor(i / 2) + 1}`),
createdAt: new Date(`2017-07-${Math.floor(i / 2) + 1}`),
progress: Math.ceil(Math.random() * 100)
});
}
function genData(params: any): { total: number; list: any[] } {
let ret = [...list];
const pi = +params.pi;
const ps = +params.ps;
const start = (pi - 1) * ps;
if (params.no) {
ret = ret.filter(data => data.no.indexOf(params.no) > -1);
}
return { total: ret.length, list: ret.slice(start, ps * pi) };
}
function saveData(id: number, value: any): { msg: string } {
const item = list.find(w => w.id === id);
if (!item) {
return { msg: '无效用户信息' };
}
Object.assign(item, value);
return { msg: 'ok' };
}
export const USERS = {
'/user': (req: MockRequest) => genData(req.queryString),
'/user/:id': (req: MockRequest) => list.find(w => w.id === +req.params.id),
'POST /user/:id': (req: MockRequest) => saveData(+req.params.id, req.body),
'/user/current': {
name: 'Cipchk',
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png',
userid: '00000001',
email: 'cipchk@qq.com',
signature: '海纳百川,有容乃大',
title: '交互专家',
group: '蚂蚁金服-某某某事业群-某某平台部-某某技术部-UED',
tags: [
{
key: '0',
label: '很有想法的'
},
{
key: '1',
label: '专注撩妹'
},
{
key: '2',
label: '帅~'
},
{
key: '3',
label: '通吃'
},
{
key: '4',
label: '专职后端'
},
{
key: '5',
label: '海纳百川'
}
],
notifyCount: 12,
country: 'China',
geographic: {
province: {
label: '上海',
key: '330000'
},
city: {
label: '市辖区',
key: '330100'
}
},
address: 'XX区XXX路 XX 号',
phone: '你猜-你猜你猜猜猜'
},
'POST /user/avatar': 'ok',
'POST /login/account': (req: MockRequest) => {
const data = req.body;
if (!(data.userName === 'admin' || data.userName === 'user') || data.password !== 'admin') {
return { msg: `Invalid username or password(admin/admin)` };
}
return {
msg: 'ok',
user: {
token: '123456789',
name: data.userName,
email: `${data.userName}@qq.com`,
id: 10000,
time: +new Date()
}
};
},
'POST /register': {
msg: 'ok'
}
};
...@@ -350,7 +350,7 @@ ...@@ -350,7 +350,7 @@
<code>&#36;{{ '{' + cascadeValues[2] + '}' }} : {{ 'alert.setting.template.metric-value' | i18n }}</code> <code>&#36;{{ '{' + cascadeValues[2] + '}' }} : {{ 'alert.setting.template.metric-value' | i18n }}</code>
</nz-list-item> </nz-list-item>
<nz-list-item *ngFor="let item of currentMetrics"> <nz-list-item *ngFor="let item of currentMetrics">
<code>&#36;{{ '{' + item + '}' }} : {{ 'alert.setting.template.other-value' | i18n }}</code> <code>&#36;{{ '{' + item.value + '}' }} : {{ 'alert.setting.template.other-value' | i18n }}</code>
</nz-list-item> </nz-list-item>
<nz-list-item *ngIf="cascadeValues.length == 3"> <nz-list-item *ngIf="cascadeValues.length == 3">
<code>&#36;&#123;instance&#125; : {{ 'alert.setting.template.instance-value' | i18n }}</code> <code>&#36;&#123;instance&#125; : {{ 'alert.setting.template.instance-value' | i18n }}</code>
......
...@@ -111,7 +111,6 @@ ...@@ -111,7 +111,6 @@
<nz-option [nzLabel]="'monitor.status.all' | i18n" nzValue="9"></nz-option> <nz-option [nzLabel]="'monitor.status.all' | i18n" nzValue="9"></nz-option>
<nz-option [nzLabel]="'monitor.status.available' | i18n" nzValue="1"></nz-option> <nz-option [nzLabel]="'monitor.status.available' | i18n" nzValue="1"></nz-option>
<nz-option [nzLabel]="'monitor.status.unavailable' | i18n" nzValue="2"></nz-option> <nz-option [nzLabel]="'monitor.status.unavailable' | i18n" nzValue="2"></nz-option>
<nz-option [nzLabel]="'monitor.status.unreachable' | i18n" nzValue="3"></nz-option>
<nz-option [nzLabel]="'monitor.status.un-manage' | i18n" nzValue="0"></nz-option> <nz-option [nzLabel]="'monitor.status.un-manage' | i18n" nzValue="0"></nz-option>
</nz-select> </nz-select>
</div> </div>
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<i nz-icon nzType="code"></i> <i nz-icon nzType="code"></i>
<span>{{ 'menu.extras.define' | i18n }}</span> <span>{{ 'menu.extras.define' | i18n }}</span>
<nz-tag <nz-tag
*ngIf="currentApp !== undefined" *ngIf="currentApp !== undefined && currentApp != null"
style="font-size: 14px; border-radius: 4px; margin-left: 4px" style="font-size: 14px; border-radius: 4px; margin-left: 4px"
nzColor="#3f51b5" nzColor="#3f51b5"
class="hoverClass" class="hoverClass"
......
...@@ -2,19 +2,15 @@ ...@@ -2,19 +2,15 @@
// `ng build ---prod` replaces `environment.ts` with `environment.prod.ts`. // `ng build ---prod` replaces `environment.ts` with `environment.prod.ts`.
// The list of file replacements can be found in `angular.json`. // The list of file replacements can be found in `angular.json`.
import { DelonMockModule } from '@delon/mock';
import { Environment } from '@delon/theme'; import { Environment } from '@delon/theme';
import * as MOCK_DATA from '../../_mock';
export const environment = { export const environment = {
production: false, production: false,
useHash: false, useHash: false,
api: { api: {
baseUrl: 'http://localhost:1157/api/', baseUrl: 'http://localhost:1157/api/',
refreshTokenEnabled: true refreshTokenEnabled: true
}, }
modules: [DelonMockModule.forRoot({ data: MOCK_DATA })]
} as Environment; } as Environment;
/* /*
......