Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

bugfix auto generate monitor name error when add monitor #1384

Merged
merged 2 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public ClusterMsg.Message handle(ChannelHandlerContext ctx, ClusterMsg.Message m
this.timerDispatch = SpringContextHolder.getBean(TimerDispatch.class);
}
if (message.getMsg().contains(CommonConstants.COLLECTOR_AUTH_FAILED)) {
log.error("receive client auth failed message and go close. {}", message.getMsg());
log.error("[Auth Failed]receive client auth failed message and go close. {}", message.getMsg());
}
this.timerDispatch.goOffline();
this.collectServer.shutdown();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public ClusterMsg.Message handle(ChannelHandlerContext ctx, ClusterMsg.Message m
log.info("receive offline message and handle success");
message.getMsg();
if (message.getMsg().contains(CommonConstants.COLLECTOR_AUTH_FAILED)) {
log.error("receive client auth failed message and go offline. {}", message.getMsg());
log.error("[Auth Failed]receive client auth failed message and go offline. {}", message.getMsg());
return null;
}
return ClusterMsg.Message.newBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void run(String... args) throws Exception {
.build();
collectorScheduling.collectorGoOnline(CommonConstants.MAIN_COLLECTOR_NODE, collectorInfo);
// init jobs
List<Monitor> monitors = monitorDao.findMonitorsByStatusNotInAndAndJobIdNotNull(Arrays.asList((byte) 0, (byte) 4));
List<Monitor> monitors = monitorDao.findMonitorsByStatusNotInAndAndJobIdNotNull(List.of((byte) 0));
List<CollectorMonitorBind> monitorBinds = collectorMonitorBindDao.findAll();
Map<Long, String> monitorIdCollectorMap = monitorBinds.stream().collect(
Collectors.toMap(CollectorMonitorBind::getMonitorId, CollectorMonitorBind::getCollector));
Expand Down
33 changes: 25 additions & 8 deletions manager/src/main/resources/define/app-api_code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@

# The monitoring type category:service-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: custom
category: service
# 监控应用类型名称(与文件名保持一致) eg: linux windows tomcat mysql aws...
app: api_code
# The app api i18n name
# app api国际化名称
name:
zh-CN: API Code
en-US: API Code
en-US: API业务状态码
# The description and help of this monitoring type
# 监控类型的帮助描述信息
help:
zh-CN: Hertzbeat 对 api 返回的状态码进行监控。<br>您可以点击 “<i>新建 API Code</i>” 并进行配置,或者选择“<i>更多操作</i>”,导入已有配置。
en-US: Hertzbeat monitors the status codes which returned by the API. You could click the "<i>New API Codes</i>" button and proceed with the configuration or import an existing setup through the "<i>More Actions</i>" menu.
zh-TW: Hertzbeat對api返回的狀態碼進行監控。<br>您可以點擊“<i>新建API Code</i>”並進行配寘,或者選擇“<i>更多操作</i>”,導入已有配寘。
zh-CN: 监控 HTTP API 接口,对 API 返回的业务自定义状态码(非 Http 状态码)进行监控。此需通过配置 JsonPath 来解析您 API 的业务状态码路径。<br>您可以点击 “<i>新建 API Code</i>” 并进行配置,或者选择“<i>更多操作</i>”,导入已有配置。
en-US: Monitor HTTP API to monitor business-defined status codes (non-HTTP status codes) returned by API. To do this, you need to configure JsonPath to resolve the business status code path of your API. <br>You could click the "<i>New API Codes</i>" button and proceed with the configuration or import an existing setup through the "<i>More Actions</i>" menu.
zh-TW: 監控 HTTP API 接口,對 API 返回的業務自定義狀態碼(非 Http 狀態碼)進行監控。此需通過配置 JsonPath 來解析您 API 的業務狀態碼路徑。<br>您可以點擊“<i>新建API Code</i>”並進行配寘,或者選擇“<i>更多操作</i>”,導入已有配寘。
helpLink:
zh-CN: https://hertzbeat.com/zh-cn/docs/help/api_code
en-US: https://hertzbeat.com/docs/help/api_code
Expand Down Expand Up @@ -151,8 +151,8 @@ params:
# name-param field display i18n name
# name-参数字段显示名称
name:
zh-CN: JsonPath解析路径
en-US: JsonPath
zh-CN: JsonPath解析状态码路径
en-US: JsonPath Parse Code
# type-param field type(most mapping the html input type)
# type-字段类型,样式(大部分映射input标签type属性)
type: text
Expand Down Expand Up @@ -351,14 +351,31 @@ params:
hide: true

metrics:
# metrics - status
# 监控指标 - status
- name: status
i18n:
zh-CN: 状态
en-US: Status
# 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
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-指标名称, type-指标类型(0-number数字,1-string字符串), unit-指标单位('%','ms','MB'), label-是否是指标标签字段
- field: responseTime
type: 0
unit: ms
i18n:
zh-CN: 响应时间
en-US: ResponseTime
- field: code
type: 0
type: 1
i18n:
zh-CN: 业务状态码
en-US: Status Code
aliasFields:
- ^_^jsonPath^_^
- responseTime
Expand Down
66 changes: 61 additions & 5 deletions manager/src/main/resources/define/app-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.


# The monitoring type category:service-application service monitoring db-database monitoring mid-middleware custom-custom monitoring os-operating system monitoring
# 监控类型所属类别:service-应用服务 program-应用程序 db-数据库 custom-自定义 os-操作系统 bigdata-大数据 mid-中间件 webserver-web服务器 cache-缓存 cn-云原生 network-网络监控等等
category: os
# The monitoring type eg: linux windows tomcat mysql aws...
# 监控类型 eg: linux windows tomcat mysql aws...
app: windows
# The monitoring i18n name
# 监控类型国际化名称
name:
zh-CN: Windows操作系统
en-US: OS Windows

# The description and help of this monitoring type
# 监控类型的帮助描述信息
help:
Expand All @@ -34,49 +36,103 @@ helpLink:
# 监控所需输入参数定义(根据定义渲染页面UI)
# Input params define for monitoring(render web ui by the definition)
params:
# field-param field key
# field-变量字段标识符
- field: host
# name-param field display i18n name
# name-参数字段显示名称
name:
zh-CN: 主机Host
en-US: Host
zh-CN: 目标Host
en-US: Target Host
# type-param field type(most mapping the html input type)
# type-字段类型,样式(大部分映射input标签type属性)
type: host
# required-true or false
# required-是否是必输项 true-必填 false-可选
required: true
# field-param field key
# field-变量字段标识符
- field: port
# name-param field display i18n name
# name-参数字段显示名称
name:
zh-CN: 端口
en-US: Port
# type-param field type(most mapping the html input type)
# type-字段类型,样式(大部分映射input标签type属性)
type: number
# when type is number, range is required
# 当type为number时,用range表示范围
range: '[0,65535]'
# required-true or false
# required-是否是必输项 true-必填 false-可选
required: true
# default value
# 默认值
defaultValue: 161
# field-param field key
# field-变量字段标识符
- field: version
# name-param field display i18n name
# name-参数字段显示名称
name:
zh-CN: SNMP 版本
en-US: SNMP Version
# type-param field type(radio mapping the html radio tag)
# type-当type为radio时,前端用radio展示开关
type: radio
# required-true or false
# required-是否是必输项 true-必填 false-可选
required: true
# when type is radio checkbox, use option to show optional values {name1:value1,name2:value2}
# 当type为radio单选框, checkbox复选框时, option表示可选项值列表 {name1:value1,name2:value2}
options:
- label: SNMPv1
value: 0
- label: SNMPv2c
value: 1
# field-param field key
# field-变量字段标识符
- field: community
# name-param field display i18n name
# name-参数字段显示名称
name:
zh-CN: SNMP 团体字
en-US: SNMP Community
# type-param field type(most mapping the html input type)
# type-字段类型,样式(大部分映射input标签type属性)
type: text
# when type is text, use limit to limit string length
# 当type为text时,用limit表示字符串限制大小
limit: 100
# required-true or false
# required-是否是必输项 true-必填 false-可选
required: true
# 参数输入框提示信息
# param field input placeholder
placeholder: 'Snmp community for v1 v2c'
# field-param field key
# field-变量字段标识符
- field: timeout
# name-param field display i18n name
# name-参数字段显示名称
name:
zh-CN: 超时时间(ms)
en-US: Timeout(ms)
# type-param field type(most mapping the html input type)
# type-字段类型,样式(大部分映射input标签type属性)
type: number
# when type is number, range is required
# 当type为number时,用range表示范围
range: '[0,100000]'
# required-true or false
# required-是否是必输项 true-必填 false-可选
required: false
# hide-is hide this field and put it in advanced layout
# hide-是否隐藏此参数将其放入高级设置中
hide: true
# default value
# 默认值
defaultValue: 6000
# collect metrics config list
# 采集指标配置列表
Expand Down Expand Up @@ -460,4 +516,4 @@ metrics:
oids:
hrDeviceIndex: 1.3.6.1.2.1.25.3.2.1.1
hrDeviceDescr: 1.3.6.1.2.1.25.3.2.1.3
hrDeviceStatus: 1.3.6.1.2.1.25.3.2.1.5
hrDeviceStatus: 1.3.6.1.2.1.25.3.2.1.5
Original file line number Diff line number Diff line change
Expand Up @@ -343,16 +343,24 @@
id="collector"
[nzCustomTemplate]="collectorTemplate"
>
<nz-option nzCustomContent [nzValue]="''" [nzLabel]="'monitor.collector.system.default' | i18n">
<nz-option
nzCustomContent
[nzValue]="0"
[nzLabel]="('monitor.collector.system.default' | i18n) + '-' + ('collector.mode.public' | i18n)"
>
<nz-tag nzColor="processing">{{ 'monitor.collector.system.default' | i18n }}</nz-tag>
<nz-tag nzColor="success">{{ 'collector.mode.public' | i18n }}</nz-tag>
</nz-option>
<nz-option nzCustomContent *ngFor="let item of collectors" [nzValue]="item.name" [nzLabel]="item.name">
<nz-tag [nzColor]="item.status == 0 ? 'processing' : 'error'">{{
item.status == 0 ? ('monitor.collector.status.online' | i18n) : ('monitor.collector.status.offline' | i18n)
}}</nz-tag>
<span nz-icon nzType="bug" nzTheme="outline" style="margin-right: 8px"></span>
<nz-tag nzColor="processing">{{ item.name }}</nz-tag>
<nz-tag nzColor="success">{{ item.ip }}</nz-tag>
<nz-tag nzColor="processing">{{ item.ip }}</nz-tag>
<nz-tag [nzColor]="item.mode == 'private' ? 'warning' : 'success'">
{{ item.mode == 'private' ? ('collector.mode.private' | i18n) : ('collector.mode.public' | i18n) }}
</nz-tag>
</nz-option>
</nz-select>
<ng-template #collectorTemplate let-selected>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,16 +352,24 @@
id="collector"
[nzCustomTemplate]="collectorTemplate"
>
<nz-option nzCustomContent [nzValue]="''" [nzLabel]="'monitor.collector.system.default' | i18n">
<nz-option
nzCustomContent
[nzValue]="0"
[nzLabel]="('monitor.collector.system.default' | i18n) + '-' + ('collector.mode.public' | i18n)"
>
<nz-tag nzColor="processing">{{ 'monitor.collector.system.default' | i18n }}</nz-tag>
<nz-tag nzColor="success">{{ 'collector.mode.public' | i18n }}</nz-tag>
</nz-option>
<nz-option nzCustomContent *ngFor="let item of collectors" [nzValue]="item.name" [nzLabel]="item.name">
<nz-tag [nzColor]="item.status == 0 ? 'processing' : 'error'">{{
item.status == 0 ? ('monitor.collector.status.online' | i18n) : ('monitor.collector.status.offline' | i18n)
}}</nz-tag>
<span nz-icon nzType="bug" nzTheme="outline" style="margin-right: 8px"></span>
<nz-tag nzColor="processing">{{ item.name }}</nz-tag>
<nz-tag nzColor="success">{{ item.ip }}</nz-tag>
<nz-tag nzColor="processing">{{ item.ip }}</nz-tag>
<nz-tag [nzColor]="item.mode == 'private' ? 'warning' : 'success'">
{{ item.mode == 'private' ? ('collector.mode.private' | i18n) : ('collector.mode.public' | i18n) }}
</nz-tag>
</nz-option>
</nz-select>
<ng-template #collectorTemplate let-selected>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ export class MonitorNewComponent implements OnInit {

onHostChange(hostValue: string) {
if (this.monitor.app != 'prometheus') {
this.monitor.name = `${this.monitor.app.toUpperCase()}_${hostValue}`;
let autoName = `${this.monitor.app.toUpperCase()}_${hostValue}`;
if (this.monitor.name == undefined || this.monitor.name == '' || this.monitor.name.startsWith(this.monitor.app.toUpperCase())) {
this.monitor.name = autoName;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@

.help_massage_nav {
float: left;
border-right: 1px solid white;
height: 28.8px;
padding-left: 23px;
padding-right: 23px;
Expand Down
Loading