chore: import upstream snapshot with attribution
MCP Bash Server CI / Test MCP Bash Server (dev) (push) Has been cancelled
MCP Bash Server CI / Test MCP Bash Server (release) (push) Has been cancelled

This commit is contained in:
wehub-resource-sync
2026-07-13 13:11:39 +08:00
commit c8cebdfeee
4654 changed files with 626756 additions and 0 deletions
+285
View File
@@ -0,0 +1,285 @@
---
id: extend-http-default
title: HTTP Protocol System Default Parsing Method
sidebar_label: Default Parsing Method
---
> 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**
## HertzBeat data format specification
Note⚠️ The response data is JSON format.
Single layer format key-value
```json
{
"metricName1": "metricValue",
"metricName2": "metricValue",
"metricName3": "metricValue",
"metricName4": "metricValue"
}
```
Multilayer formatSet key value in the array
```json
[
{
"metricName1": "metricValue",
"metricName2": "metricValue",
"metricName3": "metricValue",
"metricName4": "metricValue"
},
{
"metricName1": "metricValue",
"metricName2": "metricValue",
"metricName3": "metricValue",
"metricName4": "metricValue"
}
]
```
eg
Query the CPU information of the custom system. The exposed interface is `/metrics/cpu`. We need `hostname,core,usage` Metric.
If there is only one virtual machine, its single-layer format is :
```json
{
"hostname": "linux-1",
"core": 1,
"usage": 78.0,
"allTime": 200,
"runningTime": 100
}
```
If there are multiple virtual machines, the multilayer format is: :
```json
[
{
"hostname": "linux-1",
"core": 1,
"usage": 78.0,
"allTime": 200,
"runningTime": 100
},
{
"hostname": "linux-2",
"core": 3,
"usage": 78.0,
"allTime": 566,
"runningTime": 34
},
{
"hostname": "linux-3",
"core": 4,
"usage": 38.0,
"allTime": 500,
"runningTime": 20
}
]
```
**The corresponding monitoring template yml can be configured as follows**
```yaml
category: custom
# The monitoring type eg: linux windows tomcat mysql aws...
app: a_example
# The monitoring i18n name
name:
zh-CN: 模拟应用
en-US: EXAMPLE APP
# The description and help of this monitoring type
help:
zh-CN: HertzBeat 支持自定义监控,您只需配置监控模板 YML 就能适配一款自定义的监控类型。`<br>`定义流程如下:HertzBeat 页面 -> 监控模板菜单 -> 新增监控类型 -> 配置自定义监控模板YML -> 点击保存应用 -> 使用新监控类型添加监控。
en-US: "HertzBeat supports custom monitoring, and you only need to configure the monitoring template YML to adapt to a custom monitoring type. `<br>`Definition process as follow: HertzBeat Pages -> Main Menu -> Monitor Template -> edit and save -> apply this template."
zh-TW: HertzBeat支持自定義監控,您只需配寘監控模板YML就能適配一款自定義的監控類型。`<br>`定義流程如下:HertzBeat頁面->監控模板選單->新增監控類型->配寘自定義監控模板YML ->點擊保存應用->使用新監控類型添加監控。
helpLink:
zh-CN: https://hertzbeat.apache.org/zh-cn/docs/advanced/extend-point/
en-US: https://hertzbeat.apache.org/docs/advanced/extend-point/
# 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: Target 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: 80
# param field input placeholder
placeholder: 'Please Input Port'
# 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: 50
# 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
# field-param field key
- field: ssl
# name-param field display i18n name
name:
zh-CN: 启动SSL
en-US: SSL
# type-param field type(boolean mapping the html switch tag)
type: boolean
# required-true or false
required: false
# field-param field key
- field: method
# name-param field display i18n name
name:
zh-CN: 请求方式
en-US: Method
# 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: GET
value: GET
- label: POST
value: POST
- label: PUT
value: PUT
- label: DELETE
value: DELETE
# field-param field key
- field: headers
# name-param field display i18n name
name:
zh-CN: 请求Headers
en-US: Headers
# type-param field type(key-value mapping the html key-value input tags)
type: key-value
# required-true or false
required: false
# when type is key-value, use keyAlias to config key alias name
keyAlias: Header Name
# when type is key-value, use valueAlias to config value alias name
valueAlias: Header Value
# collect metrics config list
metrics:
# metrics - cpu
- name: cpu
# metrics name i18n label
i18n:
zh-CN: CPU 信息
en-US: CPU Info
# metrics scheduling priority(0->127)->(high->low), metrics with the same priority will be scheduled in parallel
# priority 0's metrics 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, i18n-metric name i18n label, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), label-whether it is a metrics label field
- field: hostname
type: 1
label: true
i18n:
zh-CN: 主机名称
en-US: Host Name
- field: usage
type: 0
unit: '%'
i18n:
zh-CN: 使用率
en-US: Usage
- field: cores
type: 0
i18n:
zh-CN: 核数
en-US: Cores
- field: waitTime
type: 0
unit: s
i18n:
zh-CN: 主机名称
en-US: Host Name
# (optional)metrics field alias name, it is used as an alias field to map and convert the collected data and metrics field
aliasFields:
- hostname
- core1
- core2
- usage
- allTime
- runningTime
# mapping and conversion expressions, use these and aliasField above to calculate metrics value
# eg: cores=core1+core2, usage=usage, waitTime=allTime-runningTime
calculates:
- hostname=hostname
- cores=core1+core2
- usage=usage
- waitTime=allTime-runningTime
# the protocol used for monitoring, eg: sql, ssh, http, telnet, wmi, snmp, sdk
protocol: http
# the config content when protocol is http
http:
# http host: ipv4 ipv6 domain
host: ^_^host^_^
# http port
port: ^_^port^_^
# http url
url: /metrics/cpu
# http method: GET POST PUT DELETE PATCH
method: GET
# if enabled https
ssl: false
# http request header content
headers:
^_^headers^_^: ^_^headers^_^
# http request params
params:
param1: param1
param2: param2
# http auth
authorization:
# http auth type: Basic Auth, Digest Auth, Bearer Token
type: Basic Auth
basicAuthUsername: ^_^username^_^
basicAuthPassword: ^_^password^_^
# http response data parse type: default-hertzbeat rule, jsonpath-jsonpath script, website-for website monitoring, prometheus-prometheus exporter rule
parseType: jsonPath
parseScript: '$'
```
@@ -0,0 +1,220 @@
---
id: extend-http-example-hertzbeat
title: Tutorial 1 Adapting a monitoring type based on HTTP protocol
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.
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 metric 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 metric data.
```json
{
"code": 200,
"msg": "success",
"data": {}
}
```
As above, usually our background API interface will design such a general return. The same is true for the background of the hertzbeat system. Today, we will use the hertzbeat API as an example, add a new monitoring type **hertzbeat**, and monitor and collect its system summary statistics API
`http://localhost:1157/api/summary`, the response data is:
```json
{
"msg": null,
"code": 0,
"data": {
"apps": [
{
"category": "service",
"app": "jvm",
"status": 0,
"size": 2,
"availableSize": 0,
"unManageSize": 2,
"unAvailableSize": 0,
"unReachableSize": 0
},
{
"category": "service",
"app": "website",
"status": 0,
"size": 2,
"availableSize": 0,
"unManageSize": 2,
"unAvailableSize": 0,
"unReachableSize": 0
}
]
}
}
```
**This time we get the metric data such as `category`, `app`, `status`, `size`, `availableSize` under the app.**
### Add custom monitoring template `hertzbeat`
**HertzBeat Dashboard** -> **Monitoring Templates** -> **New Template** -> **Config Monitoring Template Yml** -> **Save and Apply** -> **Add A Monitoring with The New Monitoring Type**
> 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.
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
category: custom
# The monitoring type eg: linux windows tomcat mysql aws...
app: hertzbeat
name:
zh-CN: HertzBeat
en-US: HertzBeat
# The description and help of this monitoring type
help:
zh-CN: HertzBeat 对 HertzBeat 监控系统的通用指标进行测量监控。`<br>`您可以点击 “`<i>`新建 HertzBeat监控系统`</i>`” 并进行配置,或者选择“`<i>`更多操作`</i>`”,导入已有配置。
en-US: HertzBeat monitors HertzBeat Monitor through general performance metric. You could click the "`<i>`New HertzBeat Monitor`</i>`" button and proceed with the configuration or import an existing setup through the "`<i>`More Actions`</i>`" menu.
zh-TW: HertzBeat對HertzBeat監控系統的通用名額進行量測監控。`<br>`您可以點擊“`<i>`新建HertzBeat監控系統`</i>`”並進行配寘,或者選擇“`<i>`更多操作`</i>`”,導入已有配寘。
helpLink:
zh-CN: https://hertzbeat.apache.org/zh-cn/docs/help/hertzbeat
en-US: https://hertzbeat.apache.org/docs/help/hertzbeat
params:
- field: host
name:
zh-CN: 目标Host
en-US: Target Host
type: host
required: true
- field: port
name:
zh-CN: 端口
en-US: Port
type: number
range: '[0,65535]'
required: true
defaultValue: 1157
- field: ssl
name:
zh-CN: 启用HTTPS
en-US: HTTPS
type: boolean
required: true
- field: timeout
name:
zh-CN: 超时时间(ms)
en-US: Timeout(ms)
type: number
required: false
hide: true
- field: authType
name:
zh-CN: 认证方式
en-US: Auth Type
type: radio
required: false
hide: true
options:
- label: Basic Auth
value: Basic Auth
- label: Digest Auth
value: Digest Auth
- field: username
name:
zh-CN: 用户名
en-US: Username
type: text
limit: 50
required: false
hide: true
- field: password
name:
zh-CN: 密码
en-US: Password
type: password
required: false
hide: true
metrics:
# the first metrics summary
# attention: Built-in monitoring metrics contains (responseTime - Response time)
- name: summary
# metrics scheduling priority(0->127)->(high->low), metrics with the same priority will be scheduled in parallel
# priority 0's metrics is availability metrics, it will be scheduled first, only availability metrics collect success will the scheduling continue
priority: 0
# collect metrics content
fields:
# metrics content contains field-metric name, type-metric type:0-number,1-string, instance-if is metrics, unit-metric unit('%','ms','MB')
- field: app
type: 1
label: true
- field: category
type: 1
- field: status
type: 0
- field: size
type: 0
- field: availableSize
type: 0
# the protocol used for monitoring, eg: sql, ssh, http, telnet, wmi, snmp, sdk, we use HTTP protocol here
protocol: http
# the config content when protocol is http
http:
# host: ipv4 ipv6 domain
host: ^_^host^_^
# http 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
timeout: ^_^timeout^_^
# http method: GET POST PUT DELETE PATCH, default fixed value is GET
method: GET
# if enabled https, default value is false
ssl: ^_^ssl^_^
# http auth
authorization:
# http auth type: Basic Auth, Digest Auth, Bearer Token
type: ^_^authType^_^
basicAuthUsername: ^_^username^_^
basicAuthPassword: ^_^password^_^
digestAuthUsername: ^_^username^_^
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
parseType: jsonPath
parseScript: '$.data.apps.*'
```
**The addition is complete, now we save and apply. We can see that the system page has added a `hertzbeat` monitoring type.**
![HertzBeat](/img/docs/advanced/extend-http-example-1.png)
### The system page adds the monitoring of `hertzbeat` monitoring type
> We click Add `HertzBeat Monitoring Tool`, configure monitoring IP, port, collection cycle, account password in advanced settings, etc., click OK to add monitoring.
![HertzBeat](/img/docs/advanced/extend-http-example-2.png)
![HertzBeat](/img/docs/advanced/extend-http-example-3.png)
> After a certain period of time (depending on the collection cycle), we can see the specific metric data and historical charts in the monitoring details!
![HertzBeat](/img/docs/advanced/extend-http-example-4.png)
### Set threshold alarm notification
> Next, we can set the threshold normally. After the alarm is triggered, we can view it in the alarm center, add recipients, set alarm notifications, etc. Have Fun!!!
----
#### over
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 star us on GitHub Gitee, thank you very much.
**github: [https://github.com/apache/hertzbeat](https://github.com/apache/hertzbeat)**
@@ -0,0 +1,408 @@
---
id: extend-http-example-token
title: Tutorial 2 Obtain TOKEN index value based on HTTP protocol for subsequent collection and 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 metrics, first call the authentication interface to obtain the TOKEN, and use the TOKEN as a parameter for the subsequent metrics collection and authentication.
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).
## Request process
【**Authentication information metrics (highest priority)**】【**HTTP interface carries account password call**】->【**Response data analysis**】->【**Analysis and issuance of TOKEN-accessToken as an metric**] -> [**Assign accessToken as a variable parameter to other collection index groups**]
> Here we still use the hertzbeat monitoring example of Tutorial 1! The hertzbeat background interface not only supports the basic direct account password authentication used in Tutorial 1, but also supports token authentication.
**We need `POST` to call the login interface `/api/account/auth/form` to get `accessToken`, the request body (json format) is as follows**:
```json
{
"credential": "hertzbeat",
"identifier": "admin"
}
```
**The response structure data is as follows**:
```json
{
"data": {
"token": "xxxx",
"refreshToken": "xxxx"
},
"msg": null,
"code": 0
}
```
### Add custom monitoring type `hertzbeat_token`
**HertzBeat Dashboard** -> **Monitoring Templates** -> **New Template** -> **Config Monitoring Template Yml** -> **Save and Apply** -> **Add A Monitoring with The New Monitoring Type**
> 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.
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
category: custom
# The monitoring type eg: linux windows tomcat mysql aws...
app: hertzbeat_token
# The monitoring i18n name
name:
zh-CN: HertzBeat(Token)
en-US: HertzBeat(Token)
# The description and help of this monitoring type
help:
zh-CN: HertzBeat 对 HertzBeat监控(Token)进行测量监控。`<br>`您可以点击 “`<i>`新建 HertzBeat监控(Token)`</i>`” 并进行配置,或者选择“`<i>`更多操作`</i>`”,导入已有配置。
en-US: HertzBeat monitors HertzBeat Monitor(Token). You could click the "`<i>`New HertzBeat Monitor(Token)`</i>`" button and proceed with the configuration or import an existing setup through the "`<i>`More Actions`</i>`" menu.
zh-TW: HertzBeat對HertzBeat監控(Token)進行量測監控。`<br>`您可以點擊“`<i>`新建HertzBeat監控(Token`</i>`”並進行配寘,或者選擇“`<i>`更多操作`</i>`”,導入已有配寘。
helpLink:
zh-CN: https://hertzbeat.apache.org/zh-cn/docs/help/hertzbeat_token
en-US: https://hertzbeat.apache.org/docs/help/hertzbeat_token
# 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: Target Host
# type-param field type(most mapping the html input type)
type: host
# required-true or false
required: true
- field: port
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
defaultValue: 1157
placeholder: 'Please input port'
- field: ssl
name:
zh-CN: 启动SSL
en-US: SSL
# type-param field type(boolean mapping the html switch tag)
type: boolean
required: false
- field: contentType
name:
zh-CN: Content-Type
en-US: Content-Type
type: text
placeholder: 'Request Body Type'
required: false
- field: payload
name:
zh-CN: 请求BODY
en-US: BODY
type: textarea
placeholder: 'Available When POST PUT'
required: false
# collect metrics config list
```
### Define metrics `auth` login request to get `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
category: custom
# The monitoring type eg: linux windows tomcat mysql aws...
app: hertzbeat_token
# The monitoring i18n name
name:
zh-CN: HertzBeat(Token)
en-US: HertzBeat(Token)
# The description and help of this monitoring type
help:
zh-CN: HertzBeat 对 HertzBeat监控(Token)进行测量监控。`<br>`您可以点击 “`<i>`新建 HertzBeat监控(Token)`</i>`” 并进行配置,或者选择“`<i>`更多操作`</i>`”,导入已有配置。
en-US: HertzBeat monitors HertzBeat Monitor(Token). You could click the "`<i>`New HertzBeat Monitor(Token)`</i>`" button and proceed with the configuration or import an existing setup through the "`<i>`More Actions`</i>`" menu.
zh-TW: HertzBeat對HertzBeat監控(Token)進行量測監控。`<br>`您可以點擊“`<i>`新建HertzBeat監控(Token`</i>`”並進行配寘,或者選擇“`<i>`更多操作`</i>`”,導入已有配寘。
helpLink:
zh-CN: https://hertzbeat.apache.org/zh-cn/docs/help/hertzbeat_token
en-US: https://hertzbeat.apache.org/docs/help/hertzbeat_token
# 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: Target Host
# type-param field type(most mapping the html input type)
type: host
# required-true or false
required: true
- field: port
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
defaultValue: 1157
placeholder: 'Please input port'
- field: ssl
name:
zh-CN: 启动SSL
en-US: SSL
# type-param field type(boolean mapping the html switch tag)
type: boolean
required: false
- field: contentType
name:
zh-CN: Content-Type
en-US: Content-Type
type: text
placeholder: 'Request Body Type'
required: false
- field: payload
name:
zh-CN: 请求BODY
en-US: BODY
type: textarea
placeholder: 'Available When POST PUT'
required: false
# collect metrics config list
metrics:
# metrics - auth
- name: auth
# metrics scheduling priority(0->127)->(high->low), metrics with the same priority will be scheduled in parallel
# priority 0's metrics 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'), label-whether it is a metrics label field
- field: token
type: 1
- field: refreshToken
type: 1
# the protocol used for monitoring, eg: sql, ssh, http, telnet, wmi, snmp, sdk
protocol: http
# the config content when protocol is http
http:
# http host: ipv4 ipv6 domain
host: ^_^host^_^
# http port
port: ^_^port^_^
# http url
url: /api/account/auth/form
# http method: GET POST PUT DELETE PATCH
method: POST
# if enabled https
ssl: ^_^ssl^_^
payload: ^_^payload^_^
# http request header content
headers:
content-type: ^_^contentType^_^
^_^headers^_^: ^_^headers^_^
# http request params
params:
^_^params^_^: ^_^params^_^
# http response data parse type: default-hertzbeat rule, jsonpath-jsonpath script, website-for website monitoring, prometheus-prometheus exporter rule
parseType: jsonPath
parseScript: '$.data'
---
```
**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
{
"credential": "hertzbeat",
"identifier": "admin"
}
```
![HertzBeat](/img/docs/advanced/extend-http-example-5.png)
**After the addition is successful, we can see the `token`, `refreshToken` metric data we collected on the details page.**
![HertzBeat](/img/docs/advanced/extend-http-example-6.png)
![HertzBeat](/img/docs/advanced/extend-http-example-7.png)
### Use `token` as a variable parameter to collect and use the following metricss
**Add an index group definition `summary` in `app-hertzbeat_token.yml`, which is the same as `summary` in Tutorial 1, and set the collection priority to 1**
**Set the authentication method in the HTTP protocol configuration of this index group to `Bearer Token`, assign the index `token` collected by the previous index group `auth` as a parameter, and use `^o^` as the internal replacement symbol, that is `^o^token^o^`. as follows:**
```yaml
- name: summary
# When the protocol is the http protocol, the specific collection configuration
http:
# authentication
authorization:
# Authentication methods: Basic Auth, Digest Auth, Bearer Token
type: Bearer Token
bearerTokenToken: ^o^token^o^
```
**The final `hertzbeat_token` template yml is defined as follows:**
```yaml
category: custom
# The monitoring type eg: linux windows tomcat mysql aws...
app: hertzbeat_token
# The monitoring i18n name
name:
zh-CN: HertzBeat(Token)
en-US: HertzBeat(Token)
# The description and help of this monitoring type
help:
zh-CN: HertzBeat 对 HertzBeat监控(Token)进行测量监控。`<br>`您可以点击 “`<i>`新建 HertzBeat监控(Token)`</i>`” 并进行配置,或者选择“`<i>`更多操作`</i>`”,导入已有配置。
en-US: HertzBeat monitors HertzBeat Monitor(Token). You could click the "`<i>`New HertzBeat Monitor(Token)`</i>`" button and proceed with the configuration or import an existing setup through the "`<i>`More Actions`</i>`" menu.
zh-TW: HertzBeat對HertzBeat監控(Token)進行量測監控。`<br>`您可以點擊“`<i>`新建HertzBeat監控(Token`</i>`”並進行配寘,或者選擇“`<i>`更多操作`</i>`”,導入已有配寘。
helpLink:
zh-CN: https://hertzbeat.apache.org/zh-cn/docs/help/hertzbeat_token
en-US: https://hertzbeat.apache.org/docs/help/hertzbeat_token
# 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: Target Host
# type-param field type(most mapping the html input type)
type: host
# required-true or false
required: true
- field: port
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
defaultValue: 1157
placeholder: 'Please input port'
- field: ssl
name:
zh-CN: 启动SSL
en-US: SSL
# type-param field type(boolean mapping the html switch tag)
type: boolean
required: false
- field: contentType
name:
zh-CN: Content-Type
en-US: Content-Type
type: text
placeholder: 'Request Body Type'
required: false
- field: payload
name:
zh-CN: 请求BODY
en-US: BODY
type: textarea
placeholder: 'Available When POST PUT'
required: false
# collect metrics config list
metrics:
# metrics - auth
- name: auth
# metrics scheduling priority(0->127)->(high->low), metrics with the same priority will be scheduled in parallel
# priority 0's metrics 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'), label-whether it is a metrics label field
- field: token
type: 1
- field: refreshToken
type: 1
# the protocol used for monitoring, eg: sql, ssh, http, telnet, wmi, snmp, sdk
protocol: http
# the config content when protocol is http
http:
# http host: ipv4 ipv6 domain
host: ^_^host^_^
# http port
port: ^_^port^_^
# http url
url: /api/account/auth/form
# http method: GET POST PUT DELETE PATCH
method: POST
# if enabled https
ssl: ^_^ssl^_^
payload: ^_^payload^_^
# http request header content
headers:
content-type: ^_^contentType^_^
^_^headers^_^: ^_^headers^_^
# http request params
params:
^_^params^_^: ^_^params^_^
# http response data parse type: default-hertzbeat rule, jsonpath-jsonpath script, website-for website monitoring, prometheus-prometheus exporter rule
parseType: jsonPath
parseScript: '$.data'
---
- name: summary
priority: 1
fields:
- field: app
type: 1
label: true
- field: category
type: 1
- field: status
type: 0
- field: size
type: 0
- field: availableSize
type: 0
protocol: http
http:
host: ^_^host^_^
port: ^_^port^_^
url: /api/summary
method: GET
ssl: ^_^ssl^_^
authorization:
type: Bearer Token
# ^o^xxx^o^ ^o^ substitution represents the value of the acquisition metric xxx of the previous priority
bearerTokenToken: ^o^token^o^
parseType: jsonPath
parseScript: '$.data.apps.*'
```
**After the configuration is complete, save and apply, and check the monitoring details page**
![HertzBeat](/img/docs/advanced/extend-http-example-8.png)
![HertzBeat](/img/docs/advanced/extend-http-example-9.png)
### Set threshold alarm notification
> Next, we can set the threshold normally. After the alarm is triggered, we can view it in the alarm center, add a new recipient, set alarm notification, etc. Have Fun!!!
---
#### over
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 star us on GitHub Gitee, thank you very much.
**github: [https://github.com/apache/hertzbeat](https://github.com/apache/hertzbeat)**
+174
View File
@@ -0,0 +1,174 @@
---
id: extend-http-jsonpath
title: HTTP Protocol JsonPath Parsing Method
sidebar_label: JsonPath Parsing Method
---
> 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.
**Use the JsonPath script to parse the response data into data that conforms to the data structure rules specified by HertzBeat**
## JsonPath Operator
[JSONPath online verification](https://www.jsonpath.cn)
| JSONPATH | Help description |
|------------------|----------------------------------------------------------------------------------------|
| $ | Root object or element |
| @ | Current object or element |
| . or [] | Child element operator |
| .. | Recursively match all child elements |
| * | Wildcard. Match all objects or elements |
| [] | Subscript operator, jsonpath index starts from 0 |
| [,] | Join operator, return multiple results as an array. Jsonpath allows the use of aliases |
| [start:end:step] | Array slice operator |
| ?() | Filter (script) expression |
| () | Script Expression |
### HertzBeat data format specification
Single layer format key-value
```json
{
"metricName1": "metricValue",
"metricName2": "metricValue",
"metricName3": "metricValue",
"metricName4": "metricValue"
}
```
Multilayer formatSet key value in the array
```json
[
{
"metricName1": "metricValue",
"metricName2": "metricValue",
"metricName3": "metricValue",
"metricName4": "metricValue"
},
{
"metricName1": "metricValue",
"metricName2": "metricValue",
"metricName3": "metricValue",
"metricName4": "metricValue"
}
]
```
#### Example
Query the value information of the custom system, and its exposed interface is `/metrics/person`. We need `type,num` Metric.
The raw data returned by the interface is as follows
```json
{
"firstName": "John",
"lastName" : "doe",
"age" : 26,
"address" : {
"streetAddress": "naist street",
"city" : "Nara",
"postalCode" : "630-0192"
},
"number": [
{
"type": "core",
"num": 3343
},
{
"type": "home",
"num": 4543
}
]
}
```
We use the jsonpath script to parse, and the corresponding script is: `$.number[*]`The parsed data structure is as follows
```json
[
{
"type": "core",
"num": 3343
},
{
"type": "home",
"num": 4543
}
]
```
This data structure conforms to the data format specification of HertzBeat, and the Metric `type,num` is successfully extracted.
**The corresponding monitoring template yml can be configured as follows**
```yaml
# The monitoring type categoryservice-application service monitoring db-database monitoring custom-custom monitoring os-operating system monitoring
category: custom
# Monitoring application type(consistent with the file name) eg: linux windows tomcat mysql aws...
app: example
name:
zh-CN: 模拟应用类型
en-US: EXAMPLE APP
params:
# field-field name identifier
- field: host
# name-parameter field display name
name:
zh-CN: 主机Host
en-US: Host
# type-field type, style(most mappings are input label type attribute)
type: host
# required or not true-required false-optional
required: true
- field: port
name:
zh-CN: 端口
en-US: Port
type: number
# When type is number, range is used to represent the range.
range: '[0,65535]'
required: true
# port default
defaultValue: 80
# Prompt information of parameter input box
placeholder: 'Please enter the port'
# Metric group list
metrics:
# The first monitoring Metric group person
# Notethe built-in monitoring Metrics have (responseTime - response time)
- name: cpu
# 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.
# 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
# metrics fields list
fields:
# Metric information include field: name type: field type(0-number: number, 1-string: string) label-if is metrics label unit: Metric unit
- field: type
type: 1
label: true
- field: num
type: 0
# protocol for monitoring and collection eg: sql, ssh, http, telnet, wmi, snmp, sdk
protocol: http
# Specific collection configuration when the protocol is HTTP protocol
http:
# host: ipv4 ipv6 domain name
host: ^_^host^_^
# port
port: ^_^port^_^
# url request interface path
url: /metrics/person
# request mode GET POST PUT DELETE PATCH
method: GET
# enable ssl/tls or not, that is to say, HTTP or HTTPS. The default is false
ssl: false
# parsing method for response data: default-system rules, jsonPath-jsonPath script, website-website availability Metric monitoring
# jsonPath parsing is used here
parseType: jsonPath
parseScript: '$.number[*]'
```
+326
View File
@@ -0,0 +1,326 @@
---
id: extend-http-xmlpath
title: HTTP Protocol XmlPath Parsing Method
sidebar_label: XmlPath Parsing Method
---
> After calling the HTTP API to obtain the response data, use the XmlPath script parsing method to parse the response data.
Note⚠️ The response data must be in XML format.
**Use XPath scripts to parse the response data into data that conforms to the data structure rules specified by HertzBeat.**
## XmlPath Parsing Logic
The XmlPath parsing method in HertzBeat uses a two-step XPath process:
1. **Main XPath Expression (`parseScript`)**: This XPath expression is defined in the `http` configuration section under `parseScript`. It is used to select one or more main XML nodes from the response. Each selected node will correspond to one row of metric data in HertzBeat.
2. **Relative Field XPath Expressions (`xpath`)**: For each metric field defined in the `fields` list, you can specify a relative `xpath`. This XPath expression is evaluated *relative to each main node* selected by the `parseScript` in step 1. It extracts the specific value for that metric field from the current main node.
This allows you to easily parse structured XML data where multiple records or items are present.
**Special Metrics**:
* `responseTime`: This built-in metric represents the HTTP request's response time and is automatically collected. It does not require an `xpath`.
* `keyword`: This built-in metric counts the occurrences of a specified keyword (configured in `http.keyword`) in the raw response body. It does not require an `xpath`.
### Example
Assume the HTTP API returns the following XML data:
```xml
<DeviceStatus xmlns="http://www.isapi.org/ver20/XMLSchema" version="2.0">
<CPUList>
<CPU>
<cpuUtilization>36.400002</cpuUtilization>
<CPU>
<CPUList>
<MemoryList>
<Memory>
<memoryUsage>399640</memoryUsage>
<memoryAvailable>98792</memoryAvailable>
<cacheSize>228492</cacheSize>
<Memory>
<MemoryList>
<NetPortStatusList>
<NetPortStatus>
<id>1</id>
<workSpeed>1000</workSpeed>
<NetPortStatus>
<NetPortStatus>
<id>2</id>
<workSpeed>0</workSpeed>
<NetPortStatus>
<NetPortStatusList>
<bootTime>2025-01-06 10:27:48</bootTime>
<deviceUpTime>87天0时55分59秒</deviceUpTime>
<lastCalibrationTime>2025-04-03 11:09:18</lastCalibrationTime>
<lastCalibrationTimeDiff>1</lastCalibrationTimeDiff>
<uploadTimeConsumingList>
<avgTime>16</avgTime>
<maxTime>23</maxTime>
<minTime>12</minTime>
</uploadTimeConsumingList>
<lastCalibrationTimeMode>NTP</lastCalibrationTimeMode>
<lastCalibrationTimeAddress>34.191.45.101</lastCalibrationTimeAddress>
<DeviceStatus>
```
We want to monitor the device status and extract various metrics.
Here's how you would configure the monitoring template YML:
```yaml
category: server
# The monitoring type eg: linux windows tomcat mysql aws...
app: hikvision_isapi
# The monitoring i18n name
name:
zh-CN: 海康威视 ISAPI
en-US: Hikvision ISAPI
# The description and help of this monitoring type
help:
zh-CN: 通过ISAPI接口监控海康威视设备状态,获取设备健康数据。
en-US: Monitor Hikvision devices through ISAPI interface to collect health data.
# Input params define for monitoring(render web ui by the definition)
params:
- field: host
name:
zh-CN: 主机Host
en-US: Host
type: host
required: true
- field: port
name:
zh-CN: 端口
en-US: Port
type: number
range: '[0,65535]'
required: true
defaultValue: 80
- field: timeout
name:
zh-CN: 超时时间(ms)
en-US: Timeout(ms)
type: number
range: '[1000,60000]'
required: true
defaultValue: 5000
- field: username
name:
zh-CN: 用户名
en-US: Username
type: text
required: true
- field: password
name:
zh-CN: 密码
en-US: Password
type: password
required: true
- field: ssl
name:
zh-CN: 启用HTTPS
en-US: SSL
type: boolean
required: false
defaultValue: false
# collect metrics config list
metrics:
- name: system_info
i18n:
zh-CN: 系统信息
en-US: System Info
priority: 0
protocol: http
http:
host: ^_^host^_^
port: ^_^port^_^
ssl: ^_^ssl^_^
url: /ISAPI/System/deviceInfo
method: GET
timeout: ^_^timeout^_^
authorization:
type: Digest Auth
digestAuthUsername: ^_^username^_^
digestAuthPassword: ^_^password^_^
parseType: xmlPath
parseScript: //DeviceInfo
fields:
- field: deviceName
type: 1
i18n:
zh-CN: 设备名称
en-US: Device Name
- field: deviceID
type: 1
i18n:
zh-CN: 设备ID
en-US: Device ID
- field: firmwareVersion
type: 1
i18n:
zh-CN: 固件版本
en-US: Firmware Version
- field: model
type: 1
i18n:
zh-CN: 设备型号
en-US: Device Model
- field: macAddress
type: 1
i18n:
zh-CN: mac地址
en-US: Mac Address
- name: status
i18n:
zh-CN: 设备状态
en-US: Status
priority: 0
protocol: http
http:
host: ^_^host^_^
port: ^_^port^_^
ssl: ^_^ssl^_^
url: /ISAPI/System/status
method: GET
timeout: ^_^timeout^_^
authorization:
type: Digest Auth
digestAuthUsername: ^_^username^_^
digestAuthPassword: ^_^password^_^
parseType: xmlPath
parseScript: //DeviceStatus
fields:
- field: CPU_utilization
i18n:
zh-CN: CPU 利用率
en-US: CPU Utilization
type: 0
unit: '%'
- field: memory_usage
i18n:
zh-CN: 内存使用量
en-US: Memory Usage
type: 0
unit: MB
- field: memory_available
i18n:
zh-CN: 可用内存
en-US: Memory Available
type: 0
unit: MB
- field: cache_size
i18n:
zh-CN: 缓存大小
en-US: Cache Size
type: 0
unit: MB
- field: net_port_1_speed
i18n:
zh-CN: 网口1速度
en-US: Net Port 1 Speed
type: 0
unit: Mbps
- field: net_port_2_speed
i18n:
zh-CN: 网口2速度
en-US: Net Port 2 Speed
type: 0
unit: Mbps
- field: boot_time
i18n:
zh-CN: 启动时间
en-US: Boot Time
type: 1
- field: device_uptime
i18n:
zh-CN: 运行时长
en-US: Device Uptime
type: 1
- field: last_calibration_time
i18n:
zh-CN: 上次校时时间
en-US: Last Calibration Time
type: 1
- field: last_calibration_time_diff
i18n:
zh-CN: 上次校时时间差
en-US: Last Calibration Time Diff
type: 0
unit: s
- field: avg_upload_time
i18n:
zh-CN: 平均上传耗时
en-US: Avg Upload Time
type: 0
unit: ms
- field: max_upload_time
i18n:
zh-CN: 最大上传耗时
en-US: Max Upload Time
type: 0
unit: ms
- field: min_upload_time
i18n:
zh-CN: 最小上传耗时
en-US: Min Upload Time
type: 0
unit: ms
- field: last_calibration_mode
i18n:
zh-CN: 上次校时模式
en-US: Last Calibration Mode
type: 1
- field: last_calibration_address
i18n:
zh-CN: 上次校时地址
en-US: Last Calibration Address
type: 1
- field: response_time
i18n:
zh-CN: 响应时间
en-US: Response Time
type: 0
unit: ms
aliasFields:
- CPUList/CPU/cpuUtilization
- MemoryList/Memory/memoryUsage
- MemoryList/Memory/memoryAvailable
- MemoryList/Memory/cacheSize
- NetPortStatusList/NetPortStatus[id='1']/workSpeed
- NetPortStatusList/NetPortStatus[id='2']/workSpeed
- bootTime
- deviceUpTime
- lastCalibrationTime
- lastCalibrationTimeDiff
- uploadTimeConsumingList/avgTime
- uploadTimeConsumingList/maxTime
- uploadTimeConsumingList/minTime
- lastCalibrationTimeMode
- lastCalibrationTimeAddress
- responseTime
calculates:
- CPU_utilization=CPUList/CPU/cpuUtilization
- memory_usage=MemoryList/Memory/memoryUsage
- memory_available=MemoryList/Memory/memoryAvailable
- cache_size=MemoryList/Memory/cacheSize
- net_port_1_speed=NetPortStatusList/NetPortStatus[id='1']/workSpeed
- net_port_2_speed=NetPortStatusList/NetPortStatus[id='2']/workSpeed
- boot_time=bootTime
- device_uptime=deviceUpTime
- last_calibration_time=lastCalibrationTime
- last_calibration_time_diff=lastCalibrationTimeDiff
- avg_upload_time=uploadTimeConsumingList/avgTime
- max_upload_time=uploadTimeConsumingList/maxTime
- min_upload_time=uploadTimeConsumingList/minTime
- last_calibration_mode=lastCalibrationTimeMode
- last_calibration_address=lastCalibrationTimeAddress
- response_time=responseTime
units:
- memory_usage=KB->MB
- memory_available=KB->MB
- cache_size=KB->MB
+281
View File
@@ -0,0 +1,281 @@
---
id: extend-http
title: HTTP Protocol Custom Monitoring
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
## HTTP protocol collection process
【**Call HTTP API**】->【**Response Verification**】->【**Parse Response Data**】->【**Default method parsingJsonPath 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.
HTTP protocol supports us to customize HTTP request path, request header, request parameters, request method, request body, etc.
**System default parsing method**HTTP interface returns the JSON data structure specified by hertzbeat, that is, the default parsing method can be used to parse the data and extract the corresponding Metric data. For details, refer to [**System Default Parsing**](extend-http-default)
**JsonPath script parsing method**Use JsonPath script to parse the response JSON data, return the data structure specified by the system, and then provide the corresponding Metric data. For details, refer to [**JsonPath Script Parsing**](extend-http-jsonpath)
### Custom Steps
**HertzBeat Dashboard** -> **Monitoring Templates** -> **New Template** -> **Config Monitoring Template Yml** -> **Save and Apply** -> **Add A Monitoring with The New Monitoring Type**
-------
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.
egDefine a custom monitoring type `app` named `example_http` which use the HTTP protocol to collect data.
**Monitoring Templates** -> **Config New Monitoring Template Yml** -> **Save and Apply**
```yaml
# The monitoring type categoryservice-application service monitoring db-database monitoring custom-custom monitoring os-operating system monitoring
category: custom
# The monitoring type eg: linux windows tomcat mysql aws...
app: a_example
# The monitoring i18n name
name:
zh-CN: 模拟应用
en-US: EXAMPLE APP
# The description and help of this monitoring type
help:
zh-CN: HertzBeat 支持自定义监控,您只需配置监控模板 YML 就能适配一款自定义的监控类型。`<br>`定义流程如下:HertzBeat 页面 -> 监控模板菜单 -> 新增监控类型 -> 配置自定义监控模板YML -> 点击保存应用 -> 使用新监控类型添加监控。
en-US: "HertzBeat supports custom monitoring, and you only need to configure the monitoring template YML to adapt to a custom monitoring type. `<br>`Definition process as follow: HertzBeat Pages -> Main Menu -> Monitor Template -> edit and save -> apply this template."
zh-TW: HertzBeat支持自定義監控,您只需配寘監控模板YML就能適配一款自定義的監控類型。`<br>`定義流程如下:HertzBeat頁面->監控模板選單->新增監控類型->配寘自定義監控模板YML ->點擊保存應用->使用新監控類型添加監控。
helpLink:
zh-CN: https://hertzbeat.apache.org/zh-cn/docs/advanced/extend-point/
en-US: https://hertzbeat.apache.org/docs/advanced/extend-point/
# 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: Target 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: 80
# param field input placeholder
placeholder: 'Please Input Port'
# 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: 50
# 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
# field-param field key
- field: ssl
# name-param field display i18n name
name:
zh-CN: 启动SSL
en-US: SSL
# type-param field type(boolean mapping the html switch tag)
type: boolean
# required-true or false
required: false
# field-param field key
- field: method
# name-param field display i18n name
name:
zh-CN: 请求方式
en-US: Method
# 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: GET
value: GET
- label: POST
value: POST
- label: PUT
value: PUT
- label: DELETE
value: DELETE
# field-param field key
- field: headers
# name-param field display i18n name
name:
zh-CN: 请求Headers
en-US: Headers
# type-param field type(key-value mapping the html key-value input tags)
type: key-value
# required-true or false
required: false
# when type is key-value, use keyAlias to config key alias name
keyAlias: Header Name
# when type is key-value, use valueAlias to config value alias name
valueAlias: Header Value
# collect metrics config list
metrics:
# metrics - cpu
- name: cpu
# metrics name i18n label
i18n:
zh-CN: CPU 信息
en-US: CPU Info
# metrics scheduling priority(0->127)->(high->low), metrics with the same priority will be scheduled in parallel
# priority 0's metrics 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, i18n-metric name i18n label, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), label-whether it is a metrics label field
- field: hostname
type: 1
label: true
i18n:
zh-CN: 主机名称
en-US: Host Name
- field: usage
type: 0
unit: '%'
i18n:
zh-CN: 使用率
en-US: Usage
- field: cores
type: 0
i18n:
zh-CN: 核数
en-US: Cores
- field: waitTime
type: 0
unit: s
i18n:
zh-CN: 主机名称
en-US: Host Name
# (optional)metrics field alias name, it is used as an alias field to map and convert the collected data and metrics field
aliasFields:
- hostname
- core1
- core2
- usage
- allTime
- runningTime
# mapping and conversion expressions, use these and aliasField above to calculate metrics value
# eg: cores=core1+core2, usage=usage, waitTime=allTime-runningTime
calculates:
- hostname=hostname
- cores=core1+core2
- usage=usage
- waitTime=allTime-runningTime
# the protocol used for monitoring, eg: sql, ssh, http, telnet, wmi, snmp, sdk
protocol: http
# the config content when protocol is http
http:
# http host: ipv4 ipv6 domain
host: ^_^host^_^
# http port
port: ^_^port^_^
# http url
url: /metrics/cpu
# http method: GET POST PUT DELETE PATCH
method: GET
# if enabled https
ssl: false
# http request header content
headers:
^_^headers^_^: ^_^headers^_^
# http request params
params:
param1: param1
param2: param2
# http auth
authorization:
# http auth type: Basic Auth, Digest Auth, Bearer Token
type: Basic Auth
basicAuthUsername: ^_^username^_^
basicAuthPassword: ^_^password^_^
# http response data parse type: default-hertzbeat rule, jsonpath-jsonpath script, website-for website monitoring, prometheus-prometheus exporter rule
parseType: jsonPath
parseScript: '$'
- name: memory
i18n:
zh-CN: 内存信息
en-US: Memory Info
priority: 1
fields:
- field: hostname
type: 1
label: true
i18n:
zh-CN: 主机名称
en-US: Hostname
- field: total
type: 0
unit: kb
i18n:
zh-CN: 总量
en-US: Total
- field: usage
type: 0
unit: '%'
i18n:
zh-CN: 使用率
en-US: Usage
- field: speed
type: 0
i18n:
zh-CN: 速率
en-US: Speed
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
```
+243
View File
@@ -0,0 +1,243 @@
---
id: extend-jdbc
title: JDBC Protocol Custom Monitoring
sidebar_label: JDBC 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 JDBC(support mysql,mariadb,postgresql,sqlserver at present) to customize Metric monitoring.
> JDBC protocol custom monitoring allows us to easily monitor Metrics we want by writing SQL query statement.
## JDBC protocol collection process
【**System directly connected to MYSQL**】->【**Run SQL query statement**】->【**parse response data: oneRow, multiRow, columns**】->【**Metric data extraction**】
It can be seen from the process that we define a monitoring type of JDBC protocol. We need to configure SSH request parameters, configure which Metrics to obtain, and configure query SQL statements.
### Data parsing method
We can obtain the corresponding Metric data through the data fields queried by SQL and the Metric mapping we need. At present, there are three mapping parsing methodsoneRow, multiRow, columns.
#### **oneRow**
> Query a row of data, return the column name of the result set through query and map them to the queried field.
eg
queried Metric fieldsone two three four
query SQLselect one, two, three, four from book limit 1;
Here the Metric field and the response data can be mapped into a row of collected data one by one.
#### **multiRow**
> Query multiple rows of data, return the column names of the result set and map them to the queried fields.
eg
queried Metric fieldsone two three four
query SQLselect one, two, three, four from book;
Here the Metric field and the response data can be mapped into multiple rows of collected data one by one.
#### **columns**
> Collect a row of Metric data. By matching the two columns of queried data (key value), key and the queried field, value is the value of the query field.
eg
queried fieldsone two three four
query SQLselect key, value from book;
SQL response data
| key | value |
|-------|-------|
| one | 243 |
| two | 435 |
| three | 332 |
| four | 643 |
Here by mapping the Metric field with the key of the response data, we can obtain the corresponding value as collection and monitoring data.
### Custom Steps
**HertzBeat Dashboard** -> **Monitoring Templates** -> **New Template** -> **Config Monitoring Template Yml** -> **Save and Apply** -> **Add A Monitoring with The New Monitoring Type**
-------
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.
egDefine a custom monitoring type `app` named `example_sql` which use the JDBC protocol to collect data.
```yaml
# The monitoring type categoryservice-application service monitoring db-database monitoring custom-custom monitoring os-operating system monitoring
category: db
# Monitoring application type(consistent with the file name) eg: linux windows tomcat mysql aws...
app: example_sql
name:
zh-CN: 模拟MYSQL应用类型
en-US: MYSQL EXAMPLE APP
# Monitoring parameter definition file is used to define required input parameter field structure definition Front-end page render input parameter box according to structure
params:
- field: host
name:
zh-CN: 主机Host
en-US: Host
type: host
required: true
- field: port
name:
zh-CN: 端口
en-US: Port
type: number
range: '[0,65535]'
required: true
defaultValue: 80
placeholder: 'Please enter the port'
- field: database
name:
zh-CN: 数据库名称
en-US: Database
type: text
required: false
- field: username
name:
zh-CN: 用户名
en-US: Username
type: text
limit: 50
required: false
- field: password
name:
zh-CN: 密码
en-US: Password
type: password
required: false
- field: url
name:
zh-CN: Url
en-US: Url
type: text
required: false
# Metric group list
metrics:
- name: basic
# 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.
# 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
# metrics fields list
fields:
# Metric information include field: name type: field type(0-number: number, 1-string: string) label-if is metrics label unit: Metric unit
- field: version
type: 1
label: true
- field: port
type: 1
- field: datadir
type: 1
- field: max_connections
type: 0
# (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:
- version
- version_compile_os
- version_compile_machine
- port
- datadir
- max_connections
# (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:
- port=port
- datadir=datadir
- max_connections=max_connections
- version=version+"_"+version_compile_os+"_"+version_compile_machine
protocol: jdbc
jdbc:
# host: ipv4 ipv6 domain name
host: ^_^host^_^
# port
port: ^_^port^_^
platform: mysql
username: ^_^username^_^
password: ^_^password^_^
database: ^_^database^_^
# SQL query methodoneRow, multiRow, columns
queryType: columns
# sql
sql: show global variables where Variable_name like 'version%' or Variable_name = 'max_connections' or Variable_name = 'datadir' or Variable_name = 'port';
url: ^_^url^_^
- name: status
priority: 1
fields:
# Metric information include field: name type: field type(0-number: number, 1-string: string) label-if is metrics label unit: Metric unit
- field: threads_created
type: 0
- field: threads_connected
type: 0
- field: threads_cached
type: 0
- field: threads_running
type: 0
# (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:
- threads_created
- threads_connected
- threads_cached
- threads_running
# (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:
- threads_created=threads_created
- threads_connected=threads_connected
- threads_cached=threads_cached
- threads_running=threads_running
protocol: jdbc
jdbc:
# host: ipv4 ipv6 domain name
host: ^_^host^_^
# port
port: ^_^port^_^
platform: mysql
username: ^_^username^_^
password: ^_^password^_^
database: ^_^database^_^
# SQL query method: oneRow, multiRow, columns
queryType: columns
# sql
sql: show global status where Variable_name like 'thread%' or Variable_name = 'com_commit' or Variable_name = 'com_rollback' or Variable_name = 'questions' or Variable_name = 'uptime';
url: ^_^url^_^
- name: innodb
priority: 2
fields:
# Metric information include field: name type: field type(0-number: number, 1-string: string) label-if is metrics label unit: Metric unit
- field: innodb_data_reads
type: 0
unit: times
- field: innodb_data_writes
type: 0
unit: times
- field: innodb_data_read
type: 0
unit: kb
- field: innodb_data_written
type: 0
unit: kb
protocol: jdbc
jdbc:
# host: ipv4 ipv6 domain name
host: ^_^host^_^
# port
port: ^_^port^_^
platform: mysql
username: ^_^username^_^
password: ^_^password^_^
database: ^_^database^_^
# SQL query methodoneRow, multiRow, columns
queryType: columns
# sql
sql: show global status where Variable_name like 'innodb%';
url: ^_^url^_^
```
+194
View File
@@ -0,0 +1,194 @@
---
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**
![HertzBeat](/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.
egDefine a custom monitoring type `app` named `example_jvm` which use the JVM protocol to collect data.
```yaml
# The monitoring type categoryservice-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: 50
# 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 scheduling priority(0->127)->(high->low), metrics with the same priority will be scheduled in parallel
# priority 0's metrics 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'), label-if is metrics label
- 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
label: 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^_^
```
+174
View File
@@ -0,0 +1,174 @@
---
id: extend-ngql
title: NGQL Custom Monitoring
sidebar_label: NGQL 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 JDBC(support mysql,mariadb,postgresql,sqlserver at present) to customize Metric monitoring.
> NGQL custom monitoring allows us to easily query metric data from the NebulaGraph graph database using NGQL or OpenCypher, supporting NebulaGraph 3.X versions.
## Data Parsing Methods
Mapping the fields returned by NGQL queries to the metrics we need allows us to obtain corresponding metric data. Currently, there are four mapping and parsing methods: filterCount, oneRow, multiRow, columns.
### **filterCount**
>
> Counts the number of results returned by a query based on specified fields, usually used in `SHOW ...` statements. If NGQL statements can directly return the count, it is recommended to use NGQL statements for counting.
> Syntax for the `commands` field: aliasField#NGQL#filterName#filterValue
> `aliasField`: corresponds to the value in the `aliasFields` in the monitoring template
> `NGQL`: query statement
> `filterName`: filter attribute name (optional)
> `filterValue`: filter attribute value (optional)
For example:
- online_meta_count#SHOW HOSTS META#Status#ONLINE
Counts the number of rows returned by `SHOW HOSTS META` where Status equals ONLINE.
- online_meta_count#SHOW HOSTS META##
Counts the number of rows returned by `SHOW HOSTS META`.
#### **oneRow**
> Queries a single row of data by mapping the column names of the query result set to the queried fields.
For example:
- Metrics fields: a, b
- NGQL query: match (v:metrics) return v.metrics.a as a, v.metrics.b as b;
Here, the metric fields can be mapped to the response data row by row.
Notes:
- When using the `oneRow` method, if a single query statement returns multiple rows of results, only the first row of results will be mapped to the metric fields.
- When the `commands` field contains two or more query statements and the returned fields of multiple query statements are the same, the fields returned by the subsequent statement will overwrite those returned by the previous statement.
- It is recommended to use the limit statement to limit the number of rows returned in the result set when defining `commands`.
#### **multiRow**
> Queries multiple rows of data by mapping the column names of the query result set to the queried fields.
For example:
- Metrics fields: a, b
- NGQL query: match (v:metrics) return v.metrics.a as a, v.metrics.b as b;
Here, the metric fields can be mapped to the response data row by row.
Notes:
- When using the `multiRow` method, the `commands` field can only contain one query statement.
#### **columns**
> Collects a single row of metric data by mapping two columns of data (key-value), where the key matches the queried fields and the value is the value of the queried field.
Notes:
- When using the `columns` method, the first two columns of the result set are mapped to collect data by default, where the first column corresponds to the metric name and the second column corresponds to the metric value.
- When the `commands` field contains two or more query statements and the first column of data returned by multiple query statements is duplicated, the result of the last statement will be retained.
### Customization Steps
**HertzBeat Page** -> **Monitoring Template Menu** -> **Add Monitoring Type** -> **Configure Custom Monitoring Template YML** -> **Click Save Application** -> **Use the New Monitoring Type to Add Monitoring**
![HertzBeat Page](/img/docs/advanced/extend-point-1.png)
-------
Configuration usages of the monitoring templates yml are detailed below.
### Monitoring Template 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: Customize a monitoring type named example_ngql, which collects metric data using NGQL.
```yaml
# Monitoring category: service-application service program-application program db-database custom-custom os-operating system bigdata-big data mid-middleware webserver-web server cache-cache cn-cloud native network-network monitoring, etc.
category: db
# Monitoring application type (consistent with the file name) eg: linux windows tomcat mysql aws...
app: example_ngql
name:
zh-CN: NGQL Custom Monitoring Application
en-US: NGQL Custom APP
# Monitoring parameter definition. These are input parameter variables, which can be written in the format of ^_^host^_^ to be replaced by system variable values in the later configuration
# This part is usually not modified
params:
# field-param field key
- field: host
name:
zh-CN: Target Host
en-US: Target Host
type: host
required: true
- field: graphPort
name:
zh-CN: Graph Port
en-US: Graph Port
type: number
range: '[0,65535]'
required: true
defaultValue: 9669
- field: username
name:
zh-CN: Username
en-US: Username
type: text
required: true
- field: password
name:
zh-CN: Password
en-US: Password
type: password
required: true
- field: spaceName
name:
zh-CN: Space Name
en-US: Space Name
type: text
required: false
- field: timeout
name:
zh-CN: Connect Timeout(ms)
en-US: Connect Timeout(ms)
type: number
unit: ms
range: '[0,100000]'
required: true
defaultValue: 6000
# Metric collection configuration list
metrics:
- name: base_info
i18n:
zh-CN: Vertex statistics
en-US: Vertex statistics
priority: 0
fields:
- field: tag1
type: 1
i18n:
zh-CN: tag1
en-US: tag1
- field: tag1
type: 1
i18n:
zh-CN: tag2
en-US: tag2
aliasFields:
- tag1
- tag2
protocol: ngql
ngql:
host: ^_^host^_^
username: ^_^username^_^
password: ^_^password^_^
port: ^_^graphPort^_^
spaceName: ^_^spaceName^_^
parseType: columns
# Define the query statements used to collect data
commands:
- match (v:tag1) return "tag1" as name ,count(v) as cnt
- match (v:tag2) return "tag2" as name ,count(v) as cnt
timeout: ^_^timeout^_^
```
+146
View File
@@ -0,0 +1,146 @@
---
id: extend-point
title: Custom Monitoring
sidebar_label: Custom Monitoring
---
> 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), [SSH protocol](extend-ssh), [JMX protocol](extend-jmx), [SNMP protocol](extend-snmp). And it will support more general protocols in the future.
## Custom Monitoring Steps
**HertzBeat Dashboard** -> **Monitoring Templates** -> **New Template** -> **Config Monitoring Template Yml** -> **Save and Apply** -> **Add A Monitoring with The New Monitoring Type**
### Custom Monitoring Metrics Refresh Interval
HertzBeat now supports setting different refresh intervals for various groups of monitoring metrics. This can be configured in the monitoring template under the `metrics` section by setting the `interval` field, with the unit being seconds. If not set, the default refresh interval specified during the creation of the monitoring will be used.
-------
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.
egDefine a custom monitoring type `app` named `example2` which use the HTTP protocol to collect data.
**Monitoring Templates** -> **Config New Monitoring Template Yml** -> **Save and Apply**
```yaml
# The monitoring type categoryservice-application service monitoring db-database monitoring custom-custom monitoring os-operating system monitoring
category: custom
# The monitoring type eg: linux windows tomcat mysql aws...
app: example2
# The monitoring i18n name
name:
zh-CN: 模拟网站监测
en-US: EXAMPLE WEBSITE
# The description and help of this monitoring type
help:
zh-CN: HertzBeat 支持自定义监控,您只需配置监控模板 YML 就能适配一款自定义的监控类型。`<br>`定义流程如下:HertzBeat 页面 -> 监控模板菜单 -> 新增监控类型 -> 配置自定义监控模板YML -> 点击保存应用 -> 使用新监控类型添加监控。
en-US: "HertzBeat supports custom monitoring, and you only need to configure the monitoring template YML to adapt to a custom monitoring type. `<br>`Definition process as follow: HertzBeat Pages -> Main Menu -> Monitor Template -> edit and save -> apply this template."
zh-TW: HertzBeat支持自定義監控,您只需配寘監控模板YML就能適配一款自定義的監控類型。`<br>`定義流程如下:HertzBeat頁面->監控模板選單->新增監控類型->配寘自定義監控模板YML ->點擊保存應用->使用新監控類型添加監控。
helpLink:
zh-CN: https://hertzbeat.apache.org/zh-cn/docs/advanced/extend-point/
en-US: https://hertzbeat.apache.org/docs/advanced/extend-point/
# 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: 80
# field-param field key
- field: uri
# name-param field display i18n name
name:
zh-CN: 相对路径
en-US: URI
# type-param field type(most mapping the html input tag)
type: text
# when type is text, use limit to limit string length
limit: 200
# required-true or false
required: false
# param field input placeholder
placeholder: 'Website uri path(no ip port) EG:/console'
# field-param field key
- field: ssl
# name-param field display i18n name
name:
zh-CN: 启用HTTPS
en-US: HTTPS
# type-param field type(most mapping the html input type)
type: boolean
# required-true or false
required: true
# 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 tag)
type: number
# required-true or false
required: false
# hide param-true or false
hide: true
metrics:
# metrics - summary, inner monitoring metrics (responseTime - response time, keyword - number of keywords)
- name: summary
# metrics scheduling priority(0->127)->(high->low), metrics with the same priority will be scheduled in parallel
# priority 0's metrics is availability metrics, it will be scheduled first, only availability metrics collect success will the scheduling continue
priority: 0
# refresh interval for this metrics group
interval: 600
# collect metrics content
fields:
# field-metric name, type-metric type(0-number,1-string), unit-metric unit('%','ms','MB'), label-if is metrics label
- field: responseTime
type: 0
unit: ms
- field: keyword
type: 0
# the protocol used for monitoring, eg: sql, ssh, http, telnet, wmi, snmp, sdk
protocol: http
# the config content when protocol is http
http:
# http host: ipv4 ipv6 domain
host: ^_^host^_^
# http port
port: ^_^port^_^
# http url
url: ^_^uri^_^
timeout: ^_^timeout^_^
# http method: GET POST PUT DELETE PATCH
method: GET
# if enabled https
ssl: ^_^ssl^_^
# http response data parse type: default-hertzbeat rule, jsonpath-jsonpath script, website-for website monitoring, prometheus-prometheus exporter rule
parseType: website
```
+26
View File
@@ -0,0 +1,26 @@
---
id: extend-push
title: Push Style Custom Monitoring
sidebar_label: Push Style Custom Monitoring
---
> Push style curstom monitor is a type of monitor which allow user to configure metrics format and push metrics to hertzbeat with their own service.
> Here we will introduce how to use this feature.
## Push style custom monitor collection process
【Peer Server Start Pushing Metrics】 -> 【HertzBeat Push Module Stage Metrics】-> 【HertzBeat Collect Module collect Metrics Periodically】
### Data parsing method
HertzBeat will parsing metrics with the format configured by user while adding new monitor.
### Create Monitor Steps
HertzBeat DashBoard -> Service Monitor -> Push Style Monitor -> New Push Style Monitor -> set Push Module Host (hertzbeat server ip, usually 127.0.0.1/localhost) -> set Push Module Port (hertzbeat server port, usually 1157) -> configure metrics field (unit: string, type: 0 number / 1 string) -> end
---
### Monitor Configuration Example
![HertzBeat](/img/docs/advanced/extend-push-example-1.png)
+171
View File
@@ -0,0 +1,171 @@
---
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**
![HertzBeat](/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.
egDefine a custom monitoring type `app` named `example_windows` which use the SNMP protocol to collect data.
```yaml
# The monitoring type categoryservice-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 scheduling priority(0->127)->(high->low), metrics with the same priority will be scheduled in parallel
# priority 0's metrics 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'), label-if is metrics label
- 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
```
+214
View File
@@ -0,0 +1,214 @@
---
id: extend-ssh
title: SSH Protocol Custom Monitoring
sidebar_label: SSH 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 SSH protocol to customize Metric monitoring.
> SSH protocol custom monitoring allows us to easily monitor and collect the Linux Metrics we want by writing sh command script.
## SSH protocol collection process
【**System directly connected to Linux**】->【**Run shell command script statement**】->【**parse response data: oneRow, multiRow**】->【**Metric data extraction**】
It can be seen from the process that we define a monitoring type of SSH protocol. We need to configure SSH request parameters, configure which Metrics to obtain, and configure query script statements.
### Data parsing method
We can obtain the corresponding Metric data through the data fields queried by the SHELL script and the Metric mapping we need. At present, there are two mapping parsing methodsoneRow and multiRow which can meet the needs of most Metrics.
#### **oneRow**
> Query out a column of data, return the field value (one value per row) of the result set through query and map them to the field.
eg
Metrics of Linux to be queried hostname-host nameuptime-start time
Host name original query command`hostname`
Start time original query command`uptime | awk -F "," '{print $1}'`
Then the query script of the two Metrics in hertzbeat is(Use `;` Connect them together)
`hostname; uptime | awk -F "," '{print $1}'`
The data responded by the terminal is
```shell
tombook
14:00:15 up 72 days
```
At last collected Metric data is mapped one by one as
hostname is `tombook`
uptime is `14:00:15 up 72 days`
Here the Metric field and the response data can be mapped into a row of collected data one by one
#### **multiRow**
> Query multiple rows of data, return the column names of the result set through the query, and map them to the Metric field of the query.
eg
Linux memory related Metric fields queriedtotal-Total memory, used-Used memory,free-Free memory, buff-cache-Cache size, available-Available memory
Memory metrics original query command`free -m`, Console response
```shell
total used free shared buff/cache available
Mem: 7962 4065 333 1 3562 3593
Swap: 8191 33 8158
```
In hertzbeat multiRow format parsing requires a one-to-one mapping between the column name of the response data and the indicator value, so the corresponding query SHELL script is:
`free -m | grep Mem | awk 'BEGIN{print "total used free buff_cache available"} {print $2,$3,$4,$6,$7}'`
Console response is
```shell
total used free buff_cache available
7962 4066 331 3564 3592
```
Here the Metric field and the response data can be mapped into collected data one by one.
### Custom Steps
**HertzBeat Dashboard** -> **Monitoring Templates** -> **New Template** -> **Config Monitoring Template Yml** -> **Save and Apply** -> **Add A Monitoring with The New Monitoring Type**
-------
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.
egDefine a custom monitoring type `app` named `example_linux` which use the SSH protocol to collect data.
```yaml
# The monitoring type categoryservice-application service monitoring db-database monitoring custom-custom monitoring os-operating system monitoring
category: os
# Monitoring application type(consistent with the file name) eg: linux windows tomcat mysql aws...
app: example_linux
name:
zh-CN: 模拟LINUX应用类型
en-US: LINUX EXAMPLE APP
params:
- field: host
name:
zh-CN: 主机Host
en-US: Host
type: host
required: true
- field: port
name:
zh-CN: 端口
en-US: Port
type: number
range: '[0,65535]'
required: true
defaultValue: 22
placeholder: 'Please enter the port'
- field: username
name:
zh-CN: 用户名
en-US: Username
type: text
limit: 50
required: true
- field: password
name:
zh-CN: 密码
en-US: Password
type: password
required: true
# Metric group list
metrics:
# The first monitoring Metric group basic
# Note: the built-in monitoring Metrics have (responseTime - response time)
- name: basic
# 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.
# 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
# metrics fields list
fields:
# Metric information include field: name type: field type(0-number: number, 1-string: string) label-if is metrics label unit: Metric unit
- field: hostname
type: 1
label: true
- field: version
type: 1
- field: uptime
type: 1
# protocol for monitoring and collection eg: sql, ssh, http, telnet, wmi, snmp, sdk
protocol: ssh
# Specific collection configuration when the protocol is SSH protocol
ssh:
# host: ipv4 ipv6 domain name
host: ^_^host^_^
# port
port: ^_^port^_^
username: ^_^username^_^
password: ^_^password^_^
script: (uname -r ; hostname ; uptime | awk -F "," '{print $1}' | sed "s/ //g") | sed ":a;N;s/\n/^/g;ta" | awk -F '^' 'BEGIN{print "version hostname uptime"} {print $1, $2, $3}'
# parsing method for response dataoneRow, multiRow
parseType: multiRow
- name: cpu
priority: 1
fields:
# Metric information include field: name type: field type(0-number: number, 1-string: string) label-if is metrics label unit: Metric unit
- field: info
type: 1
- field: cores
type: 0
unit: the number of cores
- field: interrupt
type: 0
unit: number
- field: load
type: 1
- field: context_switch
type: 0
unit: number
# protocol for monitoring and collection eg: sql, ssh, http, telnet, wmi, snmp, sdk
protocol: ssh
# Specific collection configuration when the protocol is SSH protocol
ssh:
# 主机host: ipv4 ipv6 domain name
host: ^_^host^_^
# port
port: ^_^port^_^
username: ^_^username^_^
password: ^_^password^_^
script: "LANG=C lscpu | awk -F: '/Model name/ {print $2}';awk '/processor/{core++} END{print core}' /proc/cpuinfo;uptime | sed 's/,/ /g' | awk '{for(i=NF-2;i<=NF;i++)print $i }' | xargs;vmstat 1 1 | awk 'NR==3{print $11}';vmstat 1 1 | awk 'NR==3{print $12}'"
parseType: oneRow
- name: memory
priority: 2
fields:
# Metric information include field: name type: field type(0-number: number, 1-string: string) label-if is metrics label unit: Metric unit
- field: total
type: 0
unit: Mb
- field: used
type: 0
unit: Mb
- field: free
type: 0
unit: Mb
- field: buff_cache
type: 0
unit: Mb
- field: available
type: 0
unit: Mb
# protocol for monitoring and collection eg: sql, ssh, http, telnet, wmi, snmp, sdk
protocol: ssh
# Specific collection configuration when the protocol is SSH protocol
ssh:
# host: ipv4 ipv6 domain name
host: ^_^host^_^
# port
port: ^_^port^_^
username: ^_^username^_^
password: ^_^password^_^
script: free -m | grep Mem | awk 'BEGIN{print "total used free buff_cache available"} {print $2,$3,$4,$6,$7}'
parseType: multiRow
```
+299
View File
@@ -0,0 +1,299 @@
---
id: extend-telnet
title: Telnet Protocol Custom Monitoring
sidebar_label: Telnet 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 Telnet to customize Metric monitoring.
> Telnet protocol custom monitoring allows us to easily monitor and collect the Linux Metrics we want by writing sh command script.
## Telnet protocol collection process
【**System directly connected to Linux**】->【**Run shell command script statement**】->【**parse response data: oneRow, multiRow**】->【**Metric data extraction**】
It can be seen from the process that we define a monitoring type of Telnet protocol. We need to configure Telnet request parameters, configure which Metrics to obtain, and configure query script statements.
### Data parsing method
By configuring the metrics `field`, `aliasFields` the `Telnet` 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**
![HertzBeat](/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.
egDefine a custom monitoring type `app` named `zookeeper` which use the telnet protocol to collect data.
```yaml
# The monitoring type categoryservice-application service monitoring db-database monitoring custom-custom monitoring os-operating system monitoring
# 监控类型所属类别:service-应用服务 program-应用程序 db-数据库 custom-自定义 os-操作系统 bigdata-大数据 mid-中间件 webserver-web服务器 cache-缓存 cn-云原生 network-网络监控等等
category: mid
# Monitoring application type(consistent with the file name) eg: linux windows tomcat mysql aws...
# 监控应用类型(与文件名保持一致) eg: linux windows tomcat mysql aws...
app: zookeeper
# The monitoring i18n name
# 监控类型国际化名称
name:
zh-CN: Zookeeper服务
en-US: Zookeeper Server
# 监控参数定义. field 这些为输入参数变量,即可以用^_^host^_^的形式写到后面的配置中,系统自动变量值替换
# 强制固定必须参数 - host
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
# 是否是必输项 true-必填 false-可选
required: true
# default
# 默认值
defaultValue: 2181
# param field input placeholder
# 参数输入框提示信息
placeholder: '请输入端口'
# field-param field key
# field-字段名称标识符
- field: timeout
# name-param field display i18n name
# name-参数字段显示名称
name:
zh-CN: 查询超时时间(ms)
en-US: Query Timeout(ms)
# type-param field type(most mapping the html input type)
# type-字段类型,样式(大部分映射input标签type属性)
type: number
# required-true or false
# 是否是必输项 true-必填 false-可选
required: false
# hide-is hide this field and put it in advanced layout
# 隐藏是隐藏这个字段,并把它放在高级布局
hide: true
# default
# 默认值
defaultValue: 6000
# collect metrics config list
# 采集指标配置列表
metrics:
# metrics - conf
# 第一个监控指标 conf
# 注意:内置监控指标有 (responseTime - 响应时间)
- name: conf
# metrics scheduling priority(0->127)->(high->low), metrics with the same priority will be scheduled in parallel
# priority 0's metrics 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'), label-if is metrics label
# 指标信息 包括 field名称 type字段类型:0-number数字,1-string字符串 label是否为标签 unit:指标单位
- field: clientPort
type: 0
i18n:
zh-CN: 客户端端口
en-US: Client Port
- field: dataDir
type: 1
i18n:
zh-CN: 数据目录
en-US: Data Directory
- field: dataDirSize
type: 0
unit: kb
i18n:
zh-CN: 数据目录大小
en-US: Data Directory Size
- field: dataLogDir
type: 1
i18n:
zh-CN: 日志目录
en-US: Data Log Directory
- field: dataLogSize
type: 0
unit: kb
i18n:
zh-CN: 日志目录大小
en-US: Data Log Size
- field: tickTime
type: 0
unit: ms
i18n:
zh-CN: 心跳间隔时间
en-US: Tick Time
- field: maxClientCnxns
type: 1
i18n:
zh-CN: 最大客户端连接数
en-US: Max Client Connections
- field: minSessionTimeout
type: 0
unit: ms
i18n:
zh-CN: 最小会话超时
en-US: Min Session Timeout
- field: maxSessionTimeout
type: 0
unit: ms
i18n:
zh-CN: 最大会话超时
en-US: Max Session Timeout
- field: serverId
type: 0
i18n:
zh-CN: 服务器ID
en-US: Server ID
# the protocol used for monitoring, eg: sql, ssh, http, telnet, wmi, snmp, sdk
# 监控采集使用协议 eg: sql, ssh, http, telnet, wmi, snmp, sdk
protocol: telnet
# the config content when protocol is telnet
# 当protocol为telnet协议时具体的采集配置
telnet:
# host: ipv4 ipv6 domain
# 主机host: ipv4 ipv6 域名
host: ^_^host^_^
# port
# 端口
port: ^_^port^_^
# timeout
# 超时时间
timeout: ^_^timeout^_^
# telnet instruction
# telnet指令
cmd: conf
- name: stats
priority: 1
fields:
- field: zk_version
type: 1
i18n:
zh-CN: ZooKeeper版本
en-US: ZooKeeper Version
- field: zk_server_state
type: 1
i18n:
zh-CN: 服务器状态
en-US: Server State
- field: zk_num_alive_connections
type: 0
unit:
i18n:
zh-CN: 存活连接数
en-US: Number of Alive Connections
- field: zk_avg_latency
type: 0
unit: ms
i18n:
zh-CN: 平均延迟
en-US: Average Latency
- field: zk_outstanding_requests
type: 0
unit:
i18n:
zh-CN: 未完成请求数
en-US: Outstanding Requests
- field: zk_znode_count
type: 0
unit:
i18n:
zh-CN: ZNode数量
en-US: ZNode Count
- field: zk_packets_sent
type: 0
unit:
i18n:
zh-CN: 发送数据包数
en-US: Packets Sent
- field: zk_packets_received
type: 0
unit:
i18n:
zh-CN: 接收数据包数
en-US: Packets Received
- field: zk_watch_count
type: 0
unit:
i18n:
zh-CN: Watch数量
en-US: Watch Count
- field: zk_max_file_descriptor_count
type: 0
unit:
i18n:
zh-CN: 最大文件描述符数量
en-US: Max File Descriptor Count
- field: zk_approximate_data_size
type: 0
unit: kb
i18n:
zh-CN: 大致数据大小
en-US: Approximate Data Size
- field: zk_open_file_descriptor_count
type: 0
unit:
i18n:
zh-CN: 打开的文件描述符数量
en-US: Open File Descriptor Count
- field: zk_max_latency
type: 0
unit: ms
i18n:
zh-CN: 最大延迟
en-US: Max Latency
- field: zk_ephemerals_count
type: 0
unit:
i18n:
zh-CN: 临时节点数量
en-US: Ephemerals Count
- field: zk_min_latency
type: 0
unit: ms
i18n:
zh-CN: 最小延迟
en-US: Min Latency
protocol: telnet
telnet:
host: ^_^host^_^
port: ^_^port^_^
timeout: ^_^timeout^_^
cmd: mntr
```
+232
View File
@@ -0,0 +1,232 @@
---
id: extend-tutorial
title: Quick Tutorial Customize and adapt a monitoring based on HTTP protocol
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 Apache HertzBeat.
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 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 metric data.
```json
{
"code": 200,
"msg": "success",
"data": {}
}
```
As above, usually our background API interface will design such a general return. The same is true for the background of the hertzbeat system. Today, we will use the hertzbeat API as an example, add a new monitoring type **hertzbeat**, and monitor and collect its system summary statistics API
`http://localhost:1157/api/summary`, the response data is:
```json
{
"msg": null,
"code": 0,
"data": {
"apps": [
{
"category": "service",
"app": "jvm",
"status": 0,
"size": 2,
"availableSize": 0,
"unManageSize": 2,
"unAvailableSize": 0,
"unReachableSize": 0
},
{
"category": "service",
"app": "website",
"status": 0,
"size": 2,
"availableSize": 0,
"unManageSize": 2,
"unAvailableSize": 0,
"unReachableSize": 0
}
]
}
}
```
**This time we get the metrics data such as `category`, `app`, `status`, `size`, `availableSize` under the app.**
### Add Monitoring Template Yml
**HertzBeat Dashboard** -> **Monitoring Templates** -> **New Template** -> **Config Monitoring Template Yml** -> **Save and Apply** -> **Add A Monitoring with The New Monitoring Type**
> 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.
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
# The monitoring type categoryservice-application service monitoring db-database monitoring custom-custom monitoring os-operating system monitoring
category: custom
# The monitoring type eg: linux windows tomcat mysql aws...
app: hertzbeat
# The monitoring i18n name
name:
zh-CN: HertzBeat监控系统
en-US: HertzBeat Monitor
# The description and help of this monitoring type
help:
zh-CN: HertzBeat 对 HertzBeat 监控系统的通用指标进行测量监控。`<br>`您可以点击 “`<i>`新建 HertzBeat监控系统`</i>`” 并进行配置,或者选择“`<i>`更多操作`</i>`”,导入已有配置。
en-US: HertzBeat monitors HertzBeat Monitor through general performance metric. You could click the "`<i>`New HertzBeat Monitor`</i>`" button and proceed with the configuration or import an existing setup through the "`<i>`More Actions`</i>`" menu.
zh-TW: HertzBeat對HertzBeat監控系統的通用名額進行量測監控。`<br>`您可以點擊“`<i>`新建HertzBeat監控系統`</i>`”並進行配寘,或者選擇“`<i>`更多操作`</i>`”,導入已有配寘。
helpLink:
zh-CN: https://hertzbeat.apache.org/zh-cn/docs/help/hertzbeat
en-US: https://hertzbeat.apache.org/docs/help/hertzbeat
# 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: 1157
- field: ssl
name:
zh-CN: 启用HTTPS
en-US: HTTPS
type: boolean
required: true
- field: timeout
name:
zh-CN: 超时时间(ms)
en-US: Timeout(ms)
type: number
required: false
hide: true
- field: authType
name:
zh-CN: 认证方式
en-US: Auth Type
type: radio
required: false
hide: true
options:
- label: Basic Auth
value: Basic Auth
- label: Digest Auth
value: Digest Auth
- field: username
name:
zh-CN: 用户名
en-US: Username
type: text
limit: 50
required: false
hide: true
- field: password
name:
zh-CN: 密码
en-US: Password
type: password
required: false
hide: true
metrics:
# the first metrics summary
# attention: Built-in monitoring metrics contains (responseTime - Response time)
- name: summary
# metrics scheduling priority(0->127)->(high->low), metrics with the same priority will be scheduled in parallel
# priority 0's metrics is availability metrics, it will be scheduled first, only availability metrics collect success will the scheduling continue
priority: 0
# collect metrics content
fields:
# metrics content contains field-metric name, type-metric type:0-number,1-string, label-if is metrics label, unit-metric unit('%','ms','MB')
- field: app
type: 1
label: true
- field: category
type: 1
- field: status
type: 0
- field: size
type: 0
- field: availableSize
type: 0
# the protocol used for monitoring, eg: sql, ssh, http, telnet, wmi, snmp, sdk, we use HTTP protocol here
protocol: http
# the config content when protocol is http
http:
# http host: ipv4 ipv6 domain
host: ^_^host^_^
# http 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
timeout: ^_^timeout^_^
# http method: GET POST PUT DELETE PATCH, default fixed value is GET
method: GET
# if enabled https, default value is false
ssl: ^_^ssl^_^
# http auth
authorization:
# http auth type: Basic Auth, Digest Auth, Bearer Token
type: ^_^authType^_^
basicAuthUsername: ^_^username^_^
basicAuthPassword: ^_^password^_^
digestAuthUsername: ^_^username^_^
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
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.**
![HertzBeat](/img/docs/advanced/extend-http-example-1.png)
### The system page adds the monitoring of `hertzbeat` monitoring type
> We click Add `HertzBeat Monitoring Tool`, configure monitoring IP, port, collection cycle, account password in advanced settings, etc., click OK to add monitoring.
![HertzBeat](/img/docs/advanced/extend-http-example-2.png)
![HertzBeat](/img/docs/advanced/extend-http-example-3.png)
> After a certain period of time (depending on the collection cycle), we can see the specific metric data and historical charts in the monitoring details!
![HertzBeat](/img/docs/advanced/extend-http-example-4.png)
### Set threshold alarm notification
> Next, we can set the threshold normally. After the alarm is triggered, we can view it in the alarm center, add a new recipient, set alarm notification, etc. Have Fun!!!
----
#### over
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 star us on GitHub Gitee, thank you very much. Thanks for the old iron support. Refill!
**github: [https://github.com/apache/hertzbeat](https://github.com/apache/hertzbeat)**