Compare commits
22 Commits
fix_tanClo
...
feature_En
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5abbea10ba | ||
|
|
2bb8cee087 | ||
|
|
d660879cc9 | ||
|
|
9d8106fcdf | ||
|
|
c8d2b1ed48 | ||
|
|
b7eaabad1d | ||
|
|
08a70092ee | ||
|
|
4f13875e01 | ||
|
|
c79f66dd9f | ||
|
|
835df039e8 | ||
|
|
f23ea9ffd5 | ||
|
|
7994d7ef15 | ||
|
|
323e5f8981 | ||
|
|
e1916b937e | ||
|
|
2ecf40e873 | ||
|
|
63ea0a87f7 | ||
|
|
a3f4e42034 | ||
|
|
018db2a14f | ||
|
|
f238a1d4ea | ||
|
|
709d51d4d5 | ||
|
|
ce528808c7 | ||
|
|
51266aab87 |
6
.gitignore
vendored
6
.gitignore
vendored
@@ -37,4 +37,10 @@ nbdist/
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
# dependencies
|
||||
node_modules
|
||||
.docusaurus
|
||||
yarn.lock
|
||||
|
||||
# debug env
|
||||
application-dev.yml
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
[comment]: <> (<img alt="sureness" src="https://cdn.jsdelivr.net/gh/dromara/hertzbeat/home/static/img/hertzbeat-brand.svg" width="300">)
|
||||
|
||||
## HertzBeat 赫兹跳动
|
||||
## HertzBeat 赫兹跳动 | [English Documentation](README_EN.md)
|
||||
|
||||
> 易用友好的监控告警系统。
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
----
|
||||
|
||||
[](https://www.bilibili.com/video/BV1Vi4y1f7i8)
|
||||
[](https://www.bilibili.com/video/BV1DY4y1i7ts)
|
||||
|
||||
----
|
||||
|
||||
@@ -76,7 +76,7 @@
|
||||
|
||||
##### 安装TDengine
|
||||
1. docker安装TDengine
|
||||
`docker run -d -p 6030-6049:6030-6049 -p 6030-6049:6030-6049/tcp -p 6030-6049:6030-6049/udp --name tdengine tdengine/tdengine:2.4.0.12`
|
||||
`docker run -d -p 6030-6049:6030-6049 -p 6030-6049:6030-6049/udp --name tdengine tdengine/tdengine:2.4.0.12`
|
||||
2. 创建名称为hertzbeat的数据库
|
||||
|
||||
详细步骤参考 [依赖服务TDengine安装初始化](https://hertzbeat.com/docs/start/tdengine-init)
|
||||
@@ -93,6 +93,7 @@
|
||||
1. 下载您系统环境对应的安装包 [GITEE Release](https://gitee.com/dromara/hertzbeat/releases) [GITHUB Release](https://github.com/dromara/hertzbeat/releases)
|
||||
2. 配置HertzBeat的配置文件 hertzbeat/config/application.yml
|
||||
3. 部署启动 `$ ./startup.sh `
|
||||
4. 浏览器访问 localhost:1157 即可开始,默认账号密码 admin/admin
|
||||
|
||||
详细步骤参考 [通过安装包安装HertzBeat](https://hertzbeat.com/docs/start/package-deploy)
|
||||
|
||||
|
||||
148
README_EN.md
Normal file
148
README_EN.md
Normal file
@@ -0,0 +1,148 @@
|
||||
<p align="center">
|
||||
<a href="https://hertzbeat.com">
|
||||
<img alt="hertzbeat" src="https://cdn.jsdelivr.net/gh/dromara/hertzbeat/home/static/img/hertzbeat-brand.svg" width="260">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
[comment]: <> (<img alt="sureness" src="https://cdn.jsdelivr.net/gh/dromara/hertzbeat/home/static/img/hertzbeat-brand.svg" width="300">)
|
||||
|
||||
## HertzBeat | [中文文档](README.md)
|
||||
|
||||
> Friendly cloud monitoring system.
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
**Home: [hertzbeat.com](https://hertzbeat.com) | [tancloud.cn](https://tancloud.cn)**
|
||||
|
||||
## 🎡 <font color="green">Introduction</font>
|
||||
|
||||
> [HertzBeat](https://github.com/dromara/hertzbeat) is an opensource monitoring and alarm project incubated by [Dromara](https://dromara.org) and open sourced by [TanCloud](https://tancloud.cn), which supports Website, API, PING, Port, Database, OS Monitor etc.
|
||||
> We also provide **[Monitoring Cloud For Saas](https://console.tancloud.cn)**, people no longer need to deploy a cumbersome monitoring system in order to monitor their website resources. **[Sign in to get started for free](https://console.tancloud.cn)**.
|
||||
> HertzBeat supports more liberal threshold alarm configuration (calculation expression), supports alarm notification, alarm template, email, DingDing, WeChat FeiShu and WebHook.
|
||||
> Most important is HertzBeat supports [Custom Monitoring](https://hertzbeat.com/docs/advanced/extend-point), just by configuring the YML file, we can customize the monitoring types and metrics what we need.
|
||||
> HertzBeat is modular, `manager, collector, scheduler, warehouse, alerter` modules are decoupled for easy understanding and custom development.
|
||||
> Welcome to HertzBeat's [Cloud Environment TanCloud](https://console.tancloud.cn) to try and discover more.
|
||||
> Welcome to join us to build hertzbeat together.
|
||||
|
||||
> `HertzBeat`'s multi-type support, easy expansion, low coupling, hope to help developers and micro teams to quickly build their own monitoring system.
|
||||
|
||||
----
|
||||
|
||||
[](https://www.bilibili.com/video/BV1DY4y1i7ts)
|
||||
|
||||
----
|
||||
|
||||
## 🥐 Architecture
|
||||
|
||||
- **[manager](https://github.com/dromara/hertzbeat/tree/master/manager)** Provide monitoring management, system management basic services.
|
||||
> Provides monitoring management, monitoring configuration management, system user management, etc.
|
||||
- **[collector](https://github.com/dromara/hertzbeat/tree/master/collector)** Provide metrics data collection services.
|
||||
> Use common protocols to remotely collect and obtain peer-to-peer metrics data.
|
||||
- **[scheduler](https://github.com/dromara/hertzbeat/tree/master/scheduler)** Provide monitoring task scheduling service.
|
||||
> Collection task management, scheduling and distribution of one-time tasks and periodic tasks.
|
||||
- **[warehouse](https://github.com/dromara/hertzbeat/tree/master/warehouse)** Provide monitoring data warehousing services.
|
||||
> Metrics data management, data query, calculation and statistics.
|
||||
- **[alerter](https://github.com/dromara/hertzbeat/tree/master/alerter)** Provide alert service.
|
||||
> Alarm calculation trigger, monitoring status linkage, alarm configuration, and alarm notification.
|
||||
- **[web-app](https://github.com/dromara/hertzbeat/tree/master/web-app)** Provide web ui.
|
||||
> Angular Web UI.
|
||||
|
||||

|
||||
|
||||
|
||||
## 🐕 Quick Start
|
||||
|
||||
- If you don’t want to deploy but use it directly, we provide [SAAS Monitoring Cloud-TanCloud](https://console.tancloud.cn), **[Log In And Register For Free](https://console.tancloud.cn) **.
|
||||
- If you want to deploy HertzBeat local, please refer to the following [Deployment Documentation](https://hertzbeat.com/docs/start/quickstart) for operation.
|
||||
|
||||
### 🐵 Dependency Service Deployment
|
||||
|
||||
> HertzBeat depends at least on relational database [MYSQL5+](https://www.mysql.com/) and time series database [TDengine2+](https://www.taosdata.com/getting-started)
|
||||
|
||||
##### Install MYSQL
|
||||
1. Install mysql with docker
|
||||
`docker run -d --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql:5.7`
|
||||
2. Create database names `hertzbeat`
|
||||
3. Run the database sql script [schema.sql](https://gitee.com/dromara/hertzbeat/raw/master/script/sql/schema.sql) located in the project repository `/script/sql/` directory.
|
||||
|
||||
For detailed steps, refer to [MYSQL Installation And Initialization](https://hertzbeat.com/docs/start/mysql-init)
|
||||
|
||||
##### Install TDengine
|
||||
1. Install TDengine with docker
|
||||
`docker run -d -p 6030-6049:6030-6049 -p 6030-6049:6030-6049/udp --name tdengine tdengine/tdengine:2.4.0.12`
|
||||
2. Create database names `hertzbeat`
|
||||
|
||||
For detailed steps, refer to [TDengine Installation And Initialization](https://hertzbeat.com/docs/start/tdengine-init).
|
||||
|
||||
### 🍞 Install HertzBeat
|
||||
|
||||
> HertzBeat supports installation through source code, docker or package.
|
||||
|
||||
##### 1:Install quickly via docker
|
||||
`docker run -d -p 1157:1157 -v /opt/application.yml:/opt/hertzbeat/config/application.yml --name hertzbeat tancloud/hertzbeat:[版本tag]`
|
||||
|
||||
Detailed steps refer to [Install HertzBeat via Docker](https://hertzbeat.com/docs/start/docker-deploy)
|
||||
|
||||
##### 2:Install via package
|
||||
1. Download the installation package [GITEE Release](https://gitee.com/dromara/hertzbeat/releases) [GITHUB Release](https://github.com/dromara/hertzbeat/releases)
|
||||
2. Configure the HertzBeat configuration yml file `hertzbeat/config/application.yml`
|
||||
3. Run shell `$ ./startup.sh `
|
||||
4. Access `localhost:1157` to start, default account: `admin/admin`
|
||||
|
||||
Detailed steps refer to [Install HertzBeat via package](https://hertzbeat.com/docs/start/package-deploy)
|
||||
|
||||
##### 3:Start via source code
|
||||
1. Local source code debugging needs to start the back-end project manager and the front-end project web-app.
|
||||
2. Backend:need `maven3+`, `java8+`, start the manager service.
|
||||
3. Web:need `nodejs npm angular-cli` environment, Run `ng serve --open` in `web-app` directory after backend startup.
|
||||
4. Access `localhost:4200` to start, default account: `admin/admin`
|
||||
|
||||
Detailed steps refer to [CONTRIBUTING](CONTRIBUTING.md)
|
||||
|
||||
##### 4:Install All(mysql+tdengine+hertzbeat) via Docker-compose
|
||||
|
||||
Install and deploy the mysql database, tdengine database and hertzbeat at one time through [docker-compose deployment script](script/docker-compose).
|
||||
|
||||
Detailed steps refer to [docker-compose install](script/docker-compose/README.md)
|
||||
|
||||
**HAVE FUN**
|
||||
|
||||
## 💬 Join discussion
|
||||
|
||||
HertzBeat is an incubation project of [Dromara Open Source Community](https://dromara.org/).
|
||||
|
||||
##### WeChat Group
|
||||
|
||||
Add WeChat account `tan-cloud` or scan the QR code below to pull you into the WeChat group.
|
||||
|
||||
<img alt="tan-cloud" src="https://cdn.jsdelivr.net/gh/dromara/hertzbeat@gh-pages/img/docs/help/tan-cloud-wechat.jpg" width="200"/>
|
||||
|
||||
##### QQ Group
|
||||
|
||||
QQ group number `718618151` or scan the group QR code below, verify code: `tancloud`
|
||||
|
||||
<img alt="tan-cloud" src="https://cdn.jsdelivr.net/gh/dromara/hertzbeat@gh-pages/img/docs/help/qq-qr.jpg" width="200"/>
|
||||
|
||||
##### Github Discussion
|
||||
|
||||
Welcome to Discuss in [Github Discussion](https://github.com/dromara/hertzbeat/discussions)
|
||||
|
||||
##### Public WeChat
|
||||
|
||||
<img alt="tan-cloud" src="https://cdn.jsdelivr.net/gh/dromara/hertzbeat/home/static/img/wechat.png" width="400"/>
|
||||
|
||||
##### Sponsor
|
||||
|
||||
Thanks [吉实信息(构建全新的微波+光交易网络)](https://www.flarespeed.com) sponsored server node.
|
||||
Thanks [天上云计算(全新智慧上云)](https://www.tsyvps.com/aff/BZBEGYLX) sponsored server node.
|
||||
|
||||
## 🛡️ License
|
||||
[`Apache License, Version 2.0`](https://www.apache.org/licenses/LICENSE-2.0.html)
|
||||
@@ -110,7 +110,7 @@ public class CalculateAlarm {
|
||||
} else {
|
||||
// 其他异常
|
||||
alertBuilder.target(CommonConstants.AVAILABLE)
|
||||
.content("监控紧急可用性告警: " + metricsData.getCode().name());
|
||||
.content("监控可用性告警: " + metricsData.getCode().name() + " : " + metricsData.getMsg());
|
||||
triggeredMonitorStateAlertMap.put(monitorId, metricsData.getCode());
|
||||
dataQueue.addAlertData(alertBuilder.build());
|
||||
}
|
||||
|
||||
@@ -30,11 +30,12 @@ import java.util.List;
|
||||
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
|
||||
|
||||
/**
|
||||
* 告警管理API
|
||||
* Alarm Management API 告警管理API
|
||||
*
|
||||
* @author tom
|
||||
* @date 2021/12/9 10:32
|
||||
*/
|
||||
@Api(tags = "告警批量管理API")
|
||||
@Api(tags = "en: Alarm batch management API, zh:告警批量管理API")
|
||||
@RestController
|
||||
@RequestMapping(path = "/alerts", produces = {APPLICATION_JSON_VALUE})
|
||||
public class AlertsController {
|
||||
@@ -43,23 +44,23 @@ public class AlertsController {
|
||||
private AlertService alertService;
|
||||
|
||||
@GetMapping
|
||||
@ApiOperation(value = "查询告警列表", notes = "根据查询过滤项获取告警信息列表")
|
||||
@ApiOperation(value = "Get a list of alarm information based on query filter items", notes = "根据查询过滤项获取告警信息列表")
|
||||
public ResponseEntity<Message<Page<Alert>>> getAlerts(
|
||||
@ApiParam(value = "告警ID", example = "6565466456") @RequestParam(required = false) List<Long> ids,
|
||||
@ApiParam(value = "告警监控对象ID", example = "6565463543") @RequestParam(required = false) Long monitorId,
|
||||
@ApiParam(value = "告警级别", example = "6565463543") @RequestParam(required = false) Byte priority,
|
||||
@ApiParam(value = "告警状态", example = "6565463543") @RequestParam(required = false) Byte status,
|
||||
@ApiParam(value = "告警内容模糊查询", example = "linux") @RequestParam(required = false) String content,
|
||||
@ApiParam(value = "排序字段,默认id", example = "name") @RequestParam(defaultValue = "id") String sort,
|
||||
@ApiParam(value = "排序方式,asc:升序,desc:降序", example = "desc") @RequestParam(defaultValue = "desc") String order,
|
||||
@ApiParam(value = "列表当前分页", example = "0") @RequestParam(defaultValue = "0") int pageIndex,
|
||||
@ApiParam(value = "列表分页数量", example = "8") @RequestParam(defaultValue = "8") int pageSize) {
|
||||
@ApiParam(value = "en: Alarm ID List,zh: 告警IDS", example = "6565466456") @RequestParam(required = false) List<Long> ids,
|
||||
@ApiParam(value = "en: Alarm monitor object ID,zh: 告警监控对象ID", example = "6565463543") @RequestParam(required = false) Long monitorId,
|
||||
@ApiParam(value = "en: Alarm level,zh: 告警级别", example = "6565463543") @RequestParam(required = false) Byte priority,
|
||||
@ApiParam(value = "en: Alarm Status,zh: 告警状态", example = "6565463543") @RequestParam(required = false) Byte status,
|
||||
@ApiParam(value = "en: Alarm content fuzzy query,zh:告警内容模糊查询", example = "linux") @RequestParam(required = false) String content,
|
||||
@ApiParam(value = "en: Sort field, default id,zh: 排序字段,默认id", example = "name") @RequestParam(defaultValue = "id") String sort,
|
||||
@ApiParam(value = "en: Sort Type,zh: 排序方式,asc:升序,desc:降序", example = "desc") @RequestParam(defaultValue = "desc") String order,
|
||||
@ApiParam(value = "en: List current page,zh: 列表当前分页", example = "0") @RequestParam(defaultValue = "0") int pageIndex,
|
||||
@ApiParam(value = "en: Number of list pagination,zh: 列表分页数量", example = "8") @RequestParam(defaultValue = "8") int pageSize) {
|
||||
|
||||
Specification<Alert> specification = (root, query, criteriaBuilder) -> {
|
||||
List<Predicate> andList = new ArrayList<>();
|
||||
|
||||
if (ids != null && !ids.isEmpty()) {
|
||||
CriteriaBuilder.In<Long> inPredicate= criteriaBuilder.in(root.get("id"));
|
||||
CriteriaBuilder.In<Long> inPredicate = criteriaBuilder.in(root.get("id"));
|
||||
for (long id : ids) {
|
||||
inPredicate.value(id);
|
||||
}
|
||||
@@ -92,10 +93,9 @@ public class AlertsController {
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@ApiOperation(value = "批量删除告警", notes = "根据告警ID列表批量删除告警")
|
||||
@ApiOperation(value = "Delete alarms in batches", notes = "根据告警ID列表批量删除告警")
|
||||
public ResponseEntity<Message<Void>> deleteAlertDefines(
|
||||
@ApiParam(value = "告警IDs", example = "6565463543") @RequestParam(required = false) List<Long> ids
|
||||
) {
|
||||
@ApiParam(value = "en:Alarm List ID,zh: 告警IDs", example = "6565463543") @RequestParam(required = false) List<Long> ids) {
|
||||
if (ids != null && !ids.isEmpty()) {
|
||||
alertService.deleteAlerts(new HashSet<>(ids));
|
||||
}
|
||||
@@ -104,10 +104,10 @@ public class AlertsController {
|
||||
}
|
||||
|
||||
@PutMapping(path = "/status/{status}")
|
||||
@ApiOperation(value = "批量修改告警状态", notes = "批量修改告警状态,设置已读未读")
|
||||
@ApiOperation(value = "Batch modify alarm status, set read and unread", notes = "批量修改告警状态,设置已读未读")
|
||||
public ResponseEntity<Message<Void>> applyAlertDefinesStatus(
|
||||
@ApiParam(value = "告警状态值", example = "0") @PathVariable Byte status,
|
||||
@ApiParam(value = "告警IDs", example = "6565463543") @RequestParam(required = false) List<Long> ids) {
|
||||
@ApiParam(value = "en:Alarm status value,zh: 告警状态值", example = "0") @PathVariable Byte status,
|
||||
@ApiParam(value = "en:Alarm List IDS,zh: 告警IDS", example = "6565463543") @RequestParam(required = false) List<Long> ids) {
|
||||
if (ids != null && status != null && !ids.isEmpty()) {
|
||||
alertService.editAlertStatus(status, ids);
|
||||
}
|
||||
@@ -116,7 +116,7 @@ public class AlertsController {
|
||||
}
|
||||
|
||||
@GetMapping(path = "/summary")
|
||||
@ApiOperation(value = "获取告警统计信息", notes = "获取告警统计信息")
|
||||
@ApiOperation(value = "Get alarm statistics", notes = "获取告警统计信息")
|
||||
public ResponseEntity<Message<AlertSummary>> getAlertsSummary() {
|
||||
AlertSummary alertSummary = alertService.getAlertsSummary();
|
||||
Message<AlertSummary> message = new Message<>(alertSummary);
|
||||
|
||||
@@ -12,30 +12,35 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Alert 数据库操作
|
||||
* Alert Database Operations Alert数据库表操作
|
||||
*
|
||||
* @author tom
|
||||
* @date 2021/12/9 10:03
|
||||
*/
|
||||
public interface AlertDao extends JpaRepository<Alert, Long>, JpaSpecificationExecutor<Alert> {
|
||||
|
||||
/**
|
||||
* 根据ID列表删除告警
|
||||
* @param alertIds 告警ID列表
|
||||
* Delete alerts based on ID list 根据ID列表删除告警
|
||||
*
|
||||
* @param alertIds Alert ID List 告警ID列表
|
||||
*/
|
||||
void deleteAlertsByIdIn(Set<Long> alertIds);
|
||||
|
||||
/**
|
||||
* 根据告警ID-状态值 更新告警状态
|
||||
*
|
||||
* @param status 状态值
|
||||
* @param ids 告警ID列表
|
||||
* @param ids 告警ID列表
|
||||
*/
|
||||
@Modifying
|
||||
@Query("update Alert set status = :status where id in :ids")
|
||||
void updateAlertsStatus(@Param(value = "status") Byte status, @Param(value = "ids") List<Long> ids);
|
||||
|
||||
/**
|
||||
* Query the number of unhandled alarms of each alarm severity
|
||||
* 查询各个告警级别的未处理告警数量
|
||||
* @return 告警数量
|
||||
*
|
||||
* @return Number of alerts 告警数量
|
||||
*/
|
||||
@Query("select new com.usthe.alert.dto.AlertPriorityNum(mo.priority, count(mo.id)) from Alert mo where mo.status = 0 group by mo.priority")
|
||||
List<AlertPriorityNum> findAlertPriorityNum();
|
||||
|
||||
@@ -7,34 +7,43 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* AlertDefineBind 数据库操作
|
||||
* AlertDefineBind database operations 数据库操作
|
||||
*
|
||||
* @author tom
|
||||
* @date 2021/12/9 10:03
|
||||
*/
|
||||
public interface AlertDefineBindDao extends JpaRepository<AlertDefineMonitorBind, Long>, JpaSpecificationExecutor<AlertDefineMonitorBind> {
|
||||
|
||||
/**
|
||||
* Delete the alarm definition and monitor association based on the alarm definition ID
|
||||
* 根据告警定义ID删除告警定义与监控关联
|
||||
* @param alertDefineId 告警定义ID
|
||||
*
|
||||
* @param alertDefineId Alarm Definition ID 告警定义ID
|
||||
*/
|
||||
void deleteAlertDefineBindsByAlertDefineIdEquals(Long alertDefineId);
|
||||
|
||||
/**
|
||||
* Deleting alarms based on monitoring IDs defines monitoring associations
|
||||
* 根据监控ID删除告警定义监控关联
|
||||
* @param monitorId 监控ID
|
||||
*
|
||||
* @param monitorId Monitor Id 监控ID
|
||||
*/
|
||||
void deleteAlertDefineMonitorBindsByMonitorIdEquals(Long monitorId);
|
||||
|
||||
/**
|
||||
* Delete alarm definition monitoring association based on monitoring ID list
|
||||
* 根据监控ID列表删除告警定义监控关联
|
||||
* @param monitorIds 监控ID列表
|
||||
*
|
||||
* @param monitorIds Monitoring ID List 监控ID列表
|
||||
*/
|
||||
void deleteAlertDefineMonitorBindsByMonitorIdIn(List<Long> monitorIds);
|
||||
|
||||
/**
|
||||
* Query monitoring related information based on alarm definition ID
|
||||
* 根据告警定义ID查询监控关联信息
|
||||
* @param alertDefineId 告警定义ID
|
||||
* @return 关联监控信息
|
||||
*
|
||||
* @param alertDefineId Alarm Definition ID 告警定义ID
|
||||
* @return Associated monitoring information 关联监控信息
|
||||
*/
|
||||
List<AlertDefineMonitorBind> getAlertDefineBindsByAlertDefineIdEquals(Long alertDefineId);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,8 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 监控级别告警数量
|
||||
* Number of monitoring level alarms 监控级别告警数量
|
||||
*
|
||||
* @author tom
|
||||
* @date 2022/3/6 19:52
|
||||
*/
|
||||
@@ -12,7 +13,13 @@ import lombok.Data;
|
||||
@AllArgsConstructor
|
||||
public class AlertPriorityNum {
|
||||
|
||||
/**
|
||||
* Alarm level 告警级别
|
||||
*/
|
||||
private byte priority;
|
||||
|
||||
/**
|
||||
* count 数量
|
||||
*/
|
||||
private long num;
|
||||
}
|
||||
|
||||
@@ -9,31 +9,43 @@ import lombok.NoArgsConstructor;
|
||||
import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_ONLY;
|
||||
|
||||
/**
|
||||
* 告警统计信息
|
||||
* Alarm Statistics Information 告警统计信息
|
||||
*
|
||||
* @author tom
|
||||
* @date 2022/3/6 19:25
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ApiModel(description = "告警统计信息")
|
||||
@ApiModel(description = "en:Alarm Statistics Information,zh: 告警统计信息")
|
||||
public class AlertSummary {
|
||||
|
||||
@ApiModelProperty(value = "告警总数量(包括已处理未处理告警)", example = "134", accessMode = READ_ONLY, position = 0)
|
||||
@ApiModelProperty(value = "Total number of alerts (including processed and unprocessed alerts)",
|
||||
notes = "告警总数量(包括已处理未处理告警)",
|
||||
example = "134", accessMode = READ_ONLY, position = 0)
|
||||
private long total;
|
||||
|
||||
@ApiModelProperty(value = "已处理告警数量", example = "34", accessMode = READ_ONLY, position = 1)
|
||||
@ApiModelProperty(value = "Number of alerts handled",
|
||||
notes = "已处理告警数量",
|
||||
example = "34", accessMode = READ_ONLY, position = 1)
|
||||
private long dealNum;
|
||||
|
||||
@ApiModelProperty(value = "告警处理率", example = "39.34", accessMode = READ_ONLY, position = 2)
|
||||
@ApiModelProperty(value = "Alarm handling rate",
|
||||
notes = "告警处理率",
|
||||
example = "39.34", accessMode = READ_ONLY, position = 2)
|
||||
private float rate;
|
||||
|
||||
@ApiModelProperty(value = "告警级别为警告告警的告警数量(指未处理告警)", example = "43", accessMode = READ_ONLY, position = 3)
|
||||
@ApiModelProperty(value = "Number of alarms whose alarm severity is warning alarms (referring to unhandled alarms)",
|
||||
notes = "告警级别为警告告警的告警数量(指未处理告警)",
|
||||
example = "43", accessMode = READ_ONLY, position = 3)
|
||||
private long priorityWarningNum;
|
||||
|
||||
@ApiModelProperty(value = "告警级别为严重告警的告警数量(指未处理告警)", example = "56", accessMode = READ_ONLY, position = 4)
|
||||
@ApiModelProperty(value = "Number of alarms whose alarm severity is critical alarms (referring to unhandled alarms)",
|
||||
notes = "告警级别为严重告警的告警数量(指未处理告警)",
|
||||
example = "56", accessMode = READ_ONLY, position = 4)
|
||||
private long priorityCriticalNum;
|
||||
|
||||
@ApiModelProperty(value = "告警级别为紧急告警的告警数量(指未处理告警)", example = "23", accessMode = READ_ONLY, position = 5)
|
||||
@ApiModelProperty(value = "Number of alarms whose alarm severity is urgent alarms (referring to unhandled alarms)",
|
||||
notes = "告警级别为紧急告警的告警数量(指未处理告警)", example = "23", accessMode = READ_ONLY, position = 5)
|
||||
private long priorityEmergencyNum;
|
||||
}
|
||||
|
||||
@@ -10,43 +10,54 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Alarm information management interface
|
||||
* 告警信息管理接口
|
||||
*
|
||||
* @author tom
|
||||
* @date 2021/12/9 10:06
|
||||
*/
|
||||
public interface AlertService {
|
||||
|
||||
/**
|
||||
* 新增告警
|
||||
* @param alert 告警实体
|
||||
* @throws RuntimeException 新增过程异常抛出
|
||||
* Add alarm record
|
||||
* 新增告警记录
|
||||
*
|
||||
* @param alert Alert entity 告警实体
|
||||
* @throws RuntimeException Add process exception throw 新增过程异常抛出
|
||||
*/
|
||||
void addAlert(Alert alert) throws RuntimeException;
|
||||
|
||||
/**
|
||||
* Dynamic conditional query
|
||||
* 动态条件查询
|
||||
* @param specification 查询条件
|
||||
* @param pageRequest 分页参数
|
||||
* @return 查询结果
|
||||
*
|
||||
* @param specification Query conditions 查询条件
|
||||
* @param pageRequest pagination parameters 分页参数
|
||||
* @return search result 查询结果
|
||||
*/
|
||||
Page<Alert> getAlerts(Specification<Alert> specification, PageRequest pageRequest);
|
||||
|
||||
/**
|
||||
* Delete alarms in batches according to the alarm ID list
|
||||
* 根据告警ID列表批量删除告警
|
||||
* @param ids 告警IDs
|
||||
*
|
||||
* @param ids Alarm ID List 告警IDS
|
||||
*/
|
||||
void deleteAlerts(HashSet<Long> ids);
|
||||
|
||||
/**
|
||||
* Update the alarm status according to the alarm ID-status value
|
||||
* 根据告警ID-状态值 更新告警状态
|
||||
* @param status 待修改为的告警状态
|
||||
* @param ids 待修改的告警IDs
|
||||
*
|
||||
* @param status Alarm status to be modified 待修改为的告警状态
|
||||
* @param ids Alarm ID List to be modified 待修改的告警ID集合
|
||||
*/
|
||||
void editAlertStatus(Byte status, List<Long> ids);
|
||||
|
||||
/**
|
||||
* 获取告警统计信息
|
||||
* @return 告警统计
|
||||
* Get alarm statistics information 获取告警统计信息
|
||||
*
|
||||
* @return Alarm statistics information 告警统计
|
||||
*/
|
||||
AlertSummary getAlertsSummary();
|
||||
|
||||
|
||||
@@ -20,7 +20,8 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 告警信息服务实现
|
||||
* Realization of Alarm Information Service 告警信息服务实现
|
||||
*
|
||||
* @author tom
|
||||
* @date 2021/12/10 15:39
|
||||
*/
|
||||
@@ -55,18 +56,24 @@ public class AlertServiceImpl implements AlertService {
|
||||
@Override
|
||||
public AlertSummary getAlertsSummary() {
|
||||
AlertSummary alertSummary = new AlertSummary();
|
||||
//Statistics on the alarm information in the alarm state
|
||||
//统计正在告警状态下的告警信息
|
||||
List<AlertPriorityNum> priorityNums = alertDao.findAlertPriorityNum();
|
||||
if (priorityNums != null) {
|
||||
for (AlertPriorityNum priorityNum : priorityNums) {
|
||||
switch (priorityNum.getPriority()) {
|
||||
case CommonConstants
|
||||
.ALERT_PRIORITY_CODE_WARNING:
|
||||
alertSummary.setPriorityWarningNum(priorityNum.getNum());break;
|
||||
alertSummary.setPriorityWarningNum(priorityNum.getNum());
|
||||
break;
|
||||
case CommonConstants.ALERT_PRIORITY_CODE_CRITICAL:
|
||||
alertSummary.setPriorityCriticalNum(priorityNum.getNum());break;
|
||||
alertSummary.setPriorityCriticalNum(priorityNum.getNum());
|
||||
break;
|
||||
case CommonConstants.ALERT_PRIORITY_CODE_EMERGENCY:
|
||||
alertSummary.setPriorityEmergencyNum(priorityNum.getNum());break;
|
||||
default: break;
|
||||
alertSummary.setPriorityEmergencyNum(priorityNum.getNum());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,6 +115,11 @@
|
||||
<artifactId>ojdbc8</artifactId>
|
||||
<version>21.5.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.oracle.database.nls</groupId>
|
||||
<artifactId>orai18n</artifactId>
|
||||
<version>21.5.0.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -108,8 +108,8 @@ public class CommonHttpClient {
|
||||
.setConnectTimeout(CONNECT_TIMEOUT)
|
||||
// 数据传输最大响应间隔时间
|
||||
.setSocketTimeout(SOCKET_TIMEOUT)
|
||||
// 遇到301 302不自动重定向跳转
|
||||
.setRedirectsEnabled(false)
|
||||
// 遇到301 302自动重定向跳转
|
||||
.setRedirectsEnabled(true)
|
||||
.build();
|
||||
// 连接池
|
||||
connectionManager = new PoolingHttpClientConnectionManager(registry);
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.google.gson.JsonParser;
|
||||
import com.usthe.collector.collect.AbstractCollect;
|
||||
import com.usthe.collector.collect.common.http.CommonHttpClient;
|
||||
import com.usthe.collector.dispatch.DispatchConstants;
|
||||
import com.usthe.collector.util.CollectUtil;
|
||||
import com.usthe.collector.util.CollectorConstants;
|
||||
import com.usthe.collector.util.JsonPathParser;
|
||||
import com.usthe.common.entity.job.Metrics;
|
||||
@@ -100,7 +101,7 @@ public class HttpCollectImpl extends AbstractCollect {
|
||||
String parseType = metrics.getHttp().getParseType();
|
||||
try {
|
||||
if (DispatchConstants.PARSE_DEFAULT.equals(parseType)) {
|
||||
parseResponseByDefault(resp, metrics.getAliasFields(), builder, responseTime);
|
||||
parseResponseByDefault(resp, metrics.getAliasFields(), metrics.getHttp(), builder, responseTime);
|
||||
} else if (DispatchConstants.PARSE_JSON_PATH.equals(parseType)) {
|
||||
parseResponseByJsonPath(resp, metrics.getAliasFields(), metrics.getHttp(), builder, responseTime);
|
||||
} else if (DispatchConstants.PARSE_PROMETHEUS.equals(parseType)) {
|
||||
@@ -108,11 +109,11 @@ public class HttpCollectImpl extends AbstractCollect {
|
||||
} else if (DispatchConstants.PARSE_XML_PATH.equals(parseType)) {
|
||||
parseResponseByXmlPath(resp, metrics.getAliasFields(), metrics.getHttp(), builder);
|
||||
} else if (DispatchConstants.PARSE_WEBSITE.equals(parseType)){
|
||||
parseResponseByWebsite(resp, metrics.getAliasFields(), builder, responseTime);
|
||||
parseResponseByWebsite(resp, metrics.getAliasFields(), metrics.getHttp(), builder, responseTime);
|
||||
} else if (DispatchConstants.PARSE_SITE_MAP.equals(parseType)) {
|
||||
parseResponseBySiteMap(resp, metrics.getAliasFields(), builder);
|
||||
} else {
|
||||
parseResponseByDefault(resp, metrics.getAliasFields(), builder, responseTime);
|
||||
parseResponseByDefault(resp, metrics.getAliasFields(), metrics.getHttp(), builder, responseTime);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.info("parse error: {}.", e.getMessage(), e);
|
||||
@@ -169,13 +170,16 @@ public class HttpCollectImpl extends AbstractCollect {
|
||||
}
|
||||
}
|
||||
|
||||
private void parseResponseByWebsite(String resp, List<String> aliasFields,
|
||||
private void parseResponseByWebsite(String resp, List<String> aliasFields, HttpProtocol http,
|
||||
CollectRep.MetricsData.Builder builder, Long responseTime) {
|
||||
CollectRep.ValueRow.Builder valueRowBuilder = CollectRep.ValueRow.newBuilder();
|
||||
// todo resp 网站关键字监测
|
||||
// 网站关键词数量监测
|
||||
int keywordNum = CollectUtil.countMatchKeyword(resp, http.getKeyword());
|
||||
for (String alias : aliasFields) {
|
||||
if (CollectorConstants.RESPONSE_TIME.equalsIgnoreCase(alias)) {
|
||||
valueRowBuilder.addColumns(responseTime.toString());
|
||||
} else if (CollectorConstants.KEYWORD.equalsIgnoreCase(alias)) {
|
||||
valueRowBuilder.addColumns(Integer.toString(keywordNum));
|
||||
} else {
|
||||
valueRowBuilder.addColumns(CommonConstants.NULL_VALUE);
|
||||
}
|
||||
@@ -277,6 +281,7 @@ public class HttpCollectImpl extends AbstractCollect {
|
||||
private void parseResponseByJsonPath(String resp, List<String> aliasFields, HttpProtocol http,
|
||||
CollectRep.MetricsData.Builder builder, Long responseTime) {
|
||||
List<Map<String, Object>> results = JsonPathParser.parseContentWithJsonPath(resp, http.getParseScript());
|
||||
int keywordNum = CollectUtil.countMatchKeyword(resp, http.getKeyword());
|
||||
for (Map<String, Object> stringMap : results) {
|
||||
CollectRep.ValueRow.Builder valueRowBuilder = CollectRep.ValueRow.newBuilder();
|
||||
for (String alias : aliasFields) {
|
||||
@@ -286,6 +291,8 @@ public class HttpCollectImpl extends AbstractCollect {
|
||||
} else {
|
||||
if (CollectorConstants.RESPONSE_TIME.equalsIgnoreCase(alias)) {
|
||||
valueRowBuilder.addColumns(responseTime.toString());
|
||||
} else if (CollectorConstants.KEYWORD.equalsIgnoreCase(alias)) {
|
||||
valueRowBuilder.addColumns(Integer.toString(keywordNum));
|
||||
} else {
|
||||
valueRowBuilder.addColumns(CommonConstants.NULL_VALUE);
|
||||
}
|
||||
@@ -300,9 +307,10 @@ public class HttpCollectImpl extends AbstractCollect {
|
||||
|
||||
}
|
||||
|
||||
private void parseResponseByDefault(String resp, List<String> aliasFields,
|
||||
private void parseResponseByDefault(String resp, List<String> aliasFields, HttpProtocol http,
|
||||
CollectRep.MetricsData.Builder builder, Long responseTime) {
|
||||
JsonElement element = JsonParser.parseString(resp);
|
||||
int keywordNum = CollectUtil.countMatchKeyword(resp, http.getKeyword());
|
||||
if (element.isJsonArray()) {
|
||||
JsonArray array = element.getAsJsonArray();
|
||||
for (JsonElement jsonElement : array) {
|
||||
@@ -317,6 +325,8 @@ public class HttpCollectImpl extends AbstractCollect {
|
||||
} else {
|
||||
if (CollectorConstants.RESPONSE_TIME.equalsIgnoreCase(alias)) {
|
||||
valueRowBuilder.addColumns(responseTime.toString());
|
||||
} else if (CollectorConstants.KEYWORD.equalsIgnoreCase(alias)) {
|
||||
valueRowBuilder.addColumns(Integer.toString(keywordNum));
|
||||
} else {
|
||||
valueRowBuilder.addColumns(CommonConstants.NULL_VALUE);
|
||||
}
|
||||
|
||||
@@ -105,9 +105,13 @@ public class CommonDispatcher implements MetricsTaskDispatch, CollectDataDispatc
|
||||
.setId(timerJob.getJob().getMonitorId())
|
||||
.setApp(timerJob.getJob().getApp())
|
||||
.setMetrics(metricsTime.getMetrics().getName())
|
||||
.setPriority(metricsTime.getMetrics().getPriority())
|
||||
.setTime(System.currentTimeMillis())
|
||||
.setCode(CollectRep.Code.TIMEOUT).setMsg("collect timeout").build();
|
||||
dispatchCollectData(metricsTime.timeout, metricsTime.getMetrics(), metricsData);
|
||||
log.error("[Collect Timeout]: \n{}", metricsData);
|
||||
if (metricsData.getPriority() == 0) {
|
||||
dispatchCollectData(metricsTime.timeout, metricsTime.getMetrics(), metricsData);
|
||||
}
|
||||
metricsTimeoutMonitorMap.remove(entry.getKey());
|
||||
}
|
||||
}
|
||||
@@ -165,8 +169,8 @@ public class CommonDispatcher implements MetricsTaskDispatch, CollectDataDispatc
|
||||
metricsSet.forEach(metricItem -> {
|
||||
MetricsCollect metricsCollect = new MetricsCollect(metricItem, timeout, this);
|
||||
jobRequestQueue.addJob(metricsCollect);
|
||||
metricsTimeoutMonitorMap.put(job.getId() + "-" + metrics.getName(),
|
||||
new MetricsTime(System.currentTimeMillis(), metrics, timeout));
|
||||
metricsTimeoutMonitorMap.put(job.getId() + "-" + metricItem.getName(),
|
||||
new MetricsTime(System.currentTimeMillis(), metricItem, timeout));
|
||||
});
|
||||
} else {
|
||||
// 当前执行级别的指标组列表未全执行完成,
|
||||
@@ -185,8 +189,8 @@ public class CommonDispatcher implements MetricsTaskDispatch, CollectDataDispatc
|
||||
metricsSet.forEach(metricItem -> {
|
||||
MetricsCollect metricsCollect = new MetricsCollect(metricItem, timeout, this);
|
||||
jobRequestQueue.addJob(metricsCollect);
|
||||
metricsTimeoutMonitorMap.put(job.getId() + "-" + metrics.getName(),
|
||||
new MetricsTime(System.currentTimeMillis(), metrics, timeout));
|
||||
metricsTimeoutMonitorMap.put(job.getId() + "-" + metricItem.getName(),
|
||||
new MetricsTime(System.currentTimeMillis(), metricItem, timeout));
|
||||
});
|
||||
} else {
|
||||
// 当前执行级别的指标组列表未全执行完成,
|
||||
|
||||
@@ -34,6 +34,10 @@ import java.util.stream.Collectors;
|
||||
@Slf4j
|
||||
@Data
|
||||
public class MetricsCollect implements Runnable, Comparable<MetricsCollect> {
|
||||
/**
|
||||
* 调度告警阈值时间 100ms
|
||||
*/
|
||||
private static final long WARN_DISPATCH_TIME = 100;
|
||||
/**
|
||||
* 监控ID
|
||||
*/
|
||||
@@ -243,6 +247,10 @@ public class MetricsCollect implements Runnable, Comparable<MetricsCollect> {
|
||||
value = aliasFieldValueMap.get(realField);
|
||||
}
|
||||
}
|
||||
// 处理可能带单位的指标数值 比如 34%, 34Mb,并将数值小数点限制到4位
|
||||
if (CommonConstants.TYPE_NUMBER == field.getType()) {
|
||||
value = CommonUtil.parseDoubleStr(value, field.getUnit());
|
||||
}
|
||||
if (value == null) {
|
||||
value = CommonConstants.NULL_VALUE;
|
||||
}
|
||||
@@ -267,11 +275,15 @@ public class MetricsCollect implements Runnable, Comparable<MetricsCollect> {
|
||||
private CollectRep.MetricsData validateResponse(CollectRep.MetricsData.Builder builder) {
|
||||
long endTime = System.currentTimeMillis();
|
||||
builder.setTime(endTime);
|
||||
log.debug("[Collect]: newTime: {}, startTime: {}, spendTime: {}.", newTime, startTime, endTime - startTime);
|
||||
long runningTime = endTime - startTime;
|
||||
long allTime = endTime - newTime;
|
||||
if (startTime - newTime >= WARN_DISPATCH_TIME) {
|
||||
log.warn("[Collector Dispatch Warn, Dispatch Use {}ms.", startTime - newTime);
|
||||
}
|
||||
if (builder.getCode() != CollectRep.Code.SUCCESS) {
|
||||
log.info("[Collect Fail] Reason: {}", builder.getMsg());
|
||||
log.info("[Collect Failed, Run {}ms, All {}ms] Reason: {}", runningTime, allTime, builder.getMsg());
|
||||
} else {
|
||||
log.info("[Collect Success].");
|
||||
log.info("[Collect Success, Run {}ms, All {}ms].", runningTime, allTime);
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 采集job管理提供api接口
|
||||
*
|
||||
* @author tomsun28
|
||||
* @date 2021/11/6 13:58
|
||||
*/
|
||||
@@ -26,9 +27,11 @@ public class CollectJobService {
|
||||
private TimerDispatch timerDispatch;
|
||||
|
||||
/**
|
||||
* Execute a one-time collection task and get the collected data response
|
||||
* 执行一次性采集任务,获取采集数据响应
|
||||
* @param job 采集任务详情
|
||||
* @return 采集结果
|
||||
*
|
||||
* @param job Collect task details 采集任务详情
|
||||
* @return Collection results 采集结果
|
||||
*/
|
||||
public List<CollectRep.MetricsData> collectSyncJobData(Job job) {
|
||||
final List<CollectRep.MetricsData> metricsData = new LinkedList<>();
|
||||
@@ -52,9 +55,11 @@ public class CollectJobService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Issue periodic asynchronous collection tasks
|
||||
* 下发周期性异步采集任务
|
||||
* @param job 采集任务详情
|
||||
* @return long 任务ID
|
||||
*
|
||||
* @param job Collect task details 采集任务详情
|
||||
* @return long Job ID 任务ID
|
||||
*/
|
||||
public long addAsyncCollectJob(Job job) {
|
||||
if (job.getId() == 0L) {
|
||||
@@ -66,8 +71,10 @@ public class CollectJobService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the periodic asynchronous collection tasks that have been delivered
|
||||
* 更新已经下发的周期性异步采集任务
|
||||
* @param modifyJob 采集任务详情
|
||||
*
|
||||
* @param modifyJob Collect task details 采集任务详情
|
||||
*/
|
||||
public void updateAsyncCollectJob(Job modifyJob) {
|
||||
timerDispatch.deleteJob(modifyJob.getId(), true);
|
||||
@@ -75,8 +82,10 @@ public class CollectJobService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel periodic asynchronous collection tasks
|
||||
* 取消周期性异步采集任务
|
||||
* @param jobId 任务ID
|
||||
*
|
||||
* @param jobId Job ID 任务ID
|
||||
*/
|
||||
public void cancelAsyncCollectJob(Long jobId) {
|
||||
timerDispatch.deleteJob(jobId, true);
|
||||
|
||||
@@ -10,36 +10,44 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 时间轮调度接口
|
||||
*
|
||||
* @author tomsun28
|
||||
* @date 2021/10/17 22:14
|
||||
*/
|
||||
public interface TimerDispatch {
|
||||
|
||||
/**
|
||||
* Add new job
|
||||
* 增加新的job
|
||||
* @param addJob job
|
||||
* @param eventListener 一次性同步任务监听器,异步任务不需要listener
|
||||
*
|
||||
* @param addJob job
|
||||
* @param eventListener One-time synchronous task listener, asynchronous task does not need listener一次性同步任务监听器,异步任务不需要listener
|
||||
*/
|
||||
void addJob(Job addJob, CollectResponseEventListener eventListener);
|
||||
|
||||
/**
|
||||
* 调度循环周期性job
|
||||
*
|
||||
* @param timerTask timerTask
|
||||
* @param interval 开始调度的间隔时间
|
||||
* @param timeUnit 时间单位
|
||||
* @param interval 开始调度的间隔时间
|
||||
* @param timeUnit 时间单位
|
||||
*/
|
||||
void cyclicJob(WheelTimerTask timerTask, long interval, TimeUnit timeUnit);
|
||||
|
||||
/**
|
||||
* Delete existing job
|
||||
* 删除存在的job
|
||||
* @param jobId jobId
|
||||
* @param isCyclic 是否是周期性任务,true是, false为临时性任务
|
||||
*
|
||||
* @param jobId jobId
|
||||
* @param isCyclic Whether it is a periodic task, true is, false is a temporary task
|
||||
* 是否是周期性任务,true是, false为临时性任务
|
||||
*/
|
||||
void deleteJob(long jobId, boolean isCyclic);
|
||||
|
||||
/**
|
||||
* 一次性同步采集任务采集结果通知监听器
|
||||
* @param jobId jobId
|
||||
*
|
||||
* @param jobId jobId
|
||||
* @param metricsDataTemps 采集结果数据
|
||||
*/
|
||||
void responseSyncJobData(long jobId, List<CollectRep.MetricsData> metricsDataTemps);
|
||||
|
||||
@@ -18,18 +18,22 @@ import java.util.concurrent.TimeUnit;
|
||||
public class TimerDispatcher implements TimerDispatch {
|
||||
|
||||
/**
|
||||
* time round schedule
|
||||
* 时间轮调度
|
||||
*/
|
||||
private Timer wheelTimer;
|
||||
/**
|
||||
* Existing periodic scheduled tasks
|
||||
* 已存在的周期性调度任务
|
||||
*/
|
||||
private Map<Long, Timeout> currentCyclicTaskMap;
|
||||
/**
|
||||
* Existing temporary scheduled tasks
|
||||
* 已存在的临时性调度任务
|
||||
*/
|
||||
private Map<Long, Timeout> currentTempTaskMap;
|
||||
/**
|
||||
* One-time task response listener holds
|
||||
* 一次性任务响应监听器持有
|
||||
* jobId - listener
|
||||
*/
|
||||
|
||||
@@ -22,7 +22,9 @@ import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Timer Task implementation
|
||||
* TimerTask实现
|
||||
*
|
||||
* @author tomsun28
|
||||
* @date 2021/11/1 17:18
|
||||
*/
|
||||
@@ -36,12 +38,15 @@ public class WheelTimerTask implements TimerTask {
|
||||
public WheelTimerTask(Job job) {
|
||||
this.metricsTaskDispatch = SpringContextHolder.getBean(MetricsTaskDispatch.class);
|
||||
this.job = job;
|
||||
// The initialization job will monitor the actual parameter value and replace the collection field
|
||||
// 初始化job 将监控实际参数值对采集字段进行替换
|
||||
initJobMetrics(job);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize job fill information
|
||||
* 初始化job填充信息
|
||||
*
|
||||
* @param job job
|
||||
*/
|
||||
private void initJobMetrics(Job job) {
|
||||
@@ -73,9 +78,10 @@ public class WheelTimerTask implements TimerTask {
|
||||
}
|
||||
|
||||
/**
|
||||
* json参数替换
|
||||
* json parameter replacement json参数替换
|
||||
*
|
||||
* @param jsonElement json
|
||||
* @param configmap 参数map
|
||||
* @param configmap parameter map 参数map
|
||||
* @return json
|
||||
*/
|
||||
private JsonElement replaceSpecialValue(JsonElement jsonElement, Map<String, Configmap> configmap) {
|
||||
@@ -86,26 +92,29 @@ public class WheelTimerTask implements TimerTask {
|
||||
Map.Entry<String, JsonElement> entry = iterator.next();
|
||||
JsonElement element = entry.getValue();
|
||||
String key = entry.getKey();
|
||||
// Replace the attributes of the KEY-VALUE case such as http headers params
|
||||
// 替换KEY-VALUE情况的属性 比如http headers params
|
||||
if (key != null && key.startsWith("^_^") && key.endsWith("^_^")) {
|
||||
key = key.replaceAll("\\^_\\^", "");
|
||||
Configmap param = configmap.get(key);
|
||||
if (param != null && param.getType() == (byte) 3) {
|
||||
String jsonValue = (String) param.getValue();
|
||||
Map<String, String> map = GsonUtil.fromJson(jsonValue, Map.class);
|
||||
if (map != null) {
|
||||
map.forEach((name, value) -> {
|
||||
if (name != null && !"".equals(name.trim())) {
|
||||
jsonObject.addProperty(name, value);
|
||||
}
|
||||
});
|
||||
}
|
||||
Map<String, String> map = GsonUtil.fromJson(jsonValue, Map.class);
|
||||
if (map != null) {
|
||||
map.forEach((name, value) -> {
|
||||
if (name != null && !"".equals(name.trim())) {
|
||||
jsonObject.addProperty(name, value);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
// Replace normal VALUE value
|
||||
// 替换正常的VALUE值
|
||||
if (element.isJsonPrimitive()) {
|
||||
// Check if there are special characters Replace
|
||||
// 判断是否含有特殊字符 替换
|
||||
String value = element.getAsString();
|
||||
if (value.startsWith("^_^") && value.endsWith("^_^")) {
|
||||
@@ -129,6 +138,7 @@ public class WheelTimerTask implements TimerTask {
|
||||
while (iterator.hasNext()) {
|
||||
JsonElement element = iterator.next();
|
||||
if (element.isJsonPrimitive()) {
|
||||
// Check if there are special characters Replace
|
||||
// 判断是否含有特殊字符 替换
|
||||
String value = element.getAsString();
|
||||
if (value.startsWith("^_^") && value.endsWith("^_^")) {
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.usthe.collector.util;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* 采集器工具类
|
||||
* @author tom
|
||||
* @date 2022/4/6 09:35
|
||||
*/
|
||||
public class CollectUtil {
|
||||
|
||||
/**
|
||||
* 关键字匹配计数
|
||||
* @param content 内容
|
||||
* @param keyword 关键字
|
||||
* @return 匹配次数
|
||||
*/
|
||||
public static int countMatchKeyword(String content, String keyword) {
|
||||
if (content == null || "".equals(content) || keyword == null || "".equals(keyword.trim())) {
|
||||
return 0;
|
||||
}
|
||||
try {
|
||||
Pattern pattern = Pattern.compile(keyword);
|
||||
Matcher matcher = pattern.matcher(content);
|
||||
int count = 0;
|
||||
while (matcher.find()) {
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
} catch (Exception e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,8 @@ public interface CollectorConstants {
|
||||
|
||||
String RESPONSE_TIME = "responseTime";
|
||||
|
||||
String KEYWORD = "keyword";
|
||||
|
||||
String STATUS_CODE = "statusCode";
|
||||
|
||||
String ERROR_MSG = "errorMsg";
|
||||
|
||||
@@ -4,6 +4,7 @@ import org.apache.commons.net.telnet.TelnetClient;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.ConnectException;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@@ -20,7 +21,7 @@ class TelnetCollectImplTest {
|
||||
telnetClient = new TelnetClient("vt200");
|
||||
telnetClient.setConnectTimeout(5000);
|
||||
TelnetClient finalTelnetClient = telnetClient;
|
||||
assertDoesNotThrow(() -> finalTelnetClient.connect("baidu.com",80));
|
||||
assertThrows(ConnectException.class,() -> finalTelnetClient.connect("127.0.0.1",0));
|
||||
telnetClient.disconnect();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -23,7 +23,8 @@ import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_ONLY;
|
||||
import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_WRITE;
|
||||
|
||||
/**
|
||||
* 告警记录
|
||||
* Alarm record entity 告警记录实体
|
||||
*
|
||||
* @author tom
|
||||
* @date 2021/12/9 15:37
|
||||
*/
|
||||
@@ -33,52 +34,68 @@ import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_WRITE;
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ApiModel(description = "告警记录实体")
|
||||
@ApiModel(description = "en: Alarm record entity zh: 告警记录实体")
|
||||
public class Alert {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@ApiModelProperty(value = "告警记录实体主键索引ID", example = "87584674384", accessMode = READ_ONLY, position = 0)
|
||||
@ApiModelProperty(value = "Alarm record entity primary key index ID",
|
||||
notes = "告警记录实体主键索引ID",
|
||||
example = "87584674384", accessMode = READ_ONLY, position = 0)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "告警目标对象: 监控可用性-available 指标-app.metrics.field",
|
||||
@ApiModelProperty(value = "Alert target object: monitor availability-available metrics-app.metrics.field",
|
||||
notes = "告警目标对象: 监控可用性-available 指标-app.metrics.field",
|
||||
example = "1", accessMode = READ_WRITE, position = 1)
|
||||
@Length(max = 255)
|
||||
private String target;
|
||||
|
||||
@ApiModelProperty(value = "告警对象关联的监控ID", example = "87432674336", accessMode = READ_WRITE, position = 2)
|
||||
@ApiModelProperty(value = "Monitoring ID associated with the alarm object",
|
||||
notes = "告警对象关联的监控ID",
|
||||
example = "87432674336", accessMode = READ_WRITE, position = 2)
|
||||
private Long monitorId;
|
||||
|
||||
@ApiModelProperty(value = "告警对象关联的监控名称", example = "Linux_192.132.23.1",
|
||||
accessMode = READ_WRITE, position = 3)
|
||||
@ApiModelProperty(value = "Monitoring name associated with the alarm object",
|
||||
notes = "告警对象关联的监控名称",
|
||||
example = "Linux_192.132.23.1", accessMode = READ_WRITE, position = 3)
|
||||
private String monitorName;
|
||||
|
||||
@ApiModelProperty(value = "告警关联的告警定义ID", example = "8743267443543", accessMode = READ_WRITE, position = 4)
|
||||
@ApiModelProperty(value = "Alarm definition ID associated with the alarm",
|
||||
notes = "告警关联的告警定义ID",
|
||||
example = "8743267443543", accessMode = READ_WRITE, position = 4)
|
||||
private Long alertDefineId;
|
||||
|
||||
@ApiModelProperty(value = "告警级别 0:高-emergency-紧急告警-红色 1:中-critical-严重告警-橙色 2:低-warning-警告告警-黄色",
|
||||
@ApiModelProperty(value = "Alarm level 0: high-emergency-critical alarm-red 1: medium-critical-critical alarm-orange 2: low-warning-warning alarm-yellow",
|
||||
notes = "告警级别 0:高-emergency-紧急告警-红色 1:中-critical-严重告警-橙色 2:低-warning-警告告警-黄色",
|
||||
example = "1", accessMode = READ_WRITE, position = 5)
|
||||
@Min(0)
|
||||
@Max(2)
|
||||
private byte priority;
|
||||
|
||||
@ApiModelProperty(value = "告警通知实际内容", example = "linux_192.134.32.1: 534543534 cpu usage high",
|
||||
@ApiModelProperty(value = "The actual content of the alarm notification",
|
||||
notes = "告警通知实际内容",
|
||||
example = "linux_192.134.32.1: 534543534 cpu usage high",
|
||||
accessMode = READ_WRITE, position = 6)
|
||||
@Length(max = 1024)
|
||||
private String content;
|
||||
|
||||
@ApiModelProperty(value = "告警状态: 0-正常告警(待处理) 1-阈值触发但未达到告警次数 2-恢复告警 3-已处理",
|
||||
@ApiModelProperty(value = "Alarm status: 0-normal alarm (to be processed) 1-threshold triggered but not reached the number of alarms 2-recovered alarm 3-processed",
|
||||
notes = "告警状态: 0-正常告警(待处理) 1-阈值触发但未达到告警次数 2-恢复告警 3-已处理",
|
||||
example = "1", accessMode = READ_WRITE, position = 7)
|
||||
@Min(0)
|
||||
@Max(2)
|
||||
private byte status;
|
||||
|
||||
@ApiModelProperty(value = "告警阈值触发次数", example = "3", accessMode = READ_WRITE, position = 8)
|
||||
@ApiModelProperty(value = "Alarm threshold trigger times",
|
||||
notes = "告警阈值触发次数",
|
||||
example = "3", accessMode = READ_WRITE, position = 8)
|
||||
@Min(0)
|
||||
@Max(10)
|
||||
private int times;
|
||||
|
||||
@ApiModelProperty(value = "告警触发时间(毫秒时间戳)", example = "1612198922000", accessMode = READ_ONLY, position = 9)
|
||||
@ApiModelProperty(value = "Alarm trigger time (timestamp in milliseconds)",
|
||||
notes = "告警触发时间(毫秒时间戳)",
|
||||
example = "1612198922000", accessMode = READ_ONLY, position = 9)
|
||||
@Column(insertable = false, updatable = false)
|
||||
private LocalDateTime gmtCreate;
|
||||
|
||||
|
||||
@@ -6,8 +6,12 @@ import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* Monitoring configuration parameter properties and values
|
||||
* 监控配置参数属性及值
|
||||
* During the process, you need to replace the content with the identifier ^_^key^_^
|
||||
* in the protocol configuration parameter with the real value in the configuration parameter
|
||||
* 过程中需要将协议配置参数里面的标识符为^_^key^_^的内容替换为配置参数里的真实值
|
||||
*
|
||||
* @author tomsun28
|
||||
* @date 2021/10/29 22:04
|
||||
*/
|
||||
@@ -18,16 +22,20 @@ import lombok.NoArgsConstructor;
|
||||
public class Configmap {
|
||||
|
||||
/**
|
||||
* Parameter key, replace the content with the identifier ^^_key_^^ in the protocol
|
||||
* configuration parameter with the real value in the configuration parameter
|
||||
* <p>
|
||||
* 参数key,将协议配置参数里面的标识符为^^_key_^^的内容替换为配置参数里的真实值
|
||||
*/
|
||||
private String key;
|
||||
|
||||
/**
|
||||
* 参数value
|
||||
* parameter value 参数value
|
||||
*/
|
||||
private Object value;
|
||||
|
||||
/**
|
||||
* Parameter type 0: number 1: string 2: encrypted string 3: json string mapped by map
|
||||
* 参数类型 0:数字 1:字符串 2:加密串 3:map映射的json串
|
||||
* number,string,secret
|
||||
* 数字,非加密字符串,加密字符串
|
||||
|
||||
@@ -21,7 +21,9 @@ import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Collect task details
|
||||
* 采集任务详情
|
||||
*
|
||||
* @author tomsun28
|
||||
* @date 2021/10/17 21:19
|
||||
*/
|
||||
@@ -35,61 +37,72 @@ public class Job {
|
||||
private static final String AVAILABILITY = "availability";
|
||||
|
||||
/**
|
||||
* 任务ID
|
||||
* Task id 任务ID
|
||||
*/
|
||||
private long id;
|
||||
/**
|
||||
* Monitoring ID Application ID
|
||||
* 监控ID 应用ID
|
||||
*/
|
||||
private long monitorId;
|
||||
/**
|
||||
* 监控的大类别
|
||||
* Large categories of monitoring 监控的大类别
|
||||
* service-application service monitoring db-database monitoring custom-custom monitoring os-operating system monitoring
|
||||
* service-应用服务监控 db-数据库监控 custom-自定义监控 os-操作系统监控
|
||||
*/
|
||||
private String category;
|
||||
/**
|
||||
* Type of monitoring eg: linux | mysql | jvm
|
||||
* 监控的类型 eg: linux | mysql | jvm
|
||||
*/
|
||||
private String app;
|
||||
/**
|
||||
* 监控类型的国际化名称
|
||||
* The internationalized name of the monitoring type 监控类型的国际化名称
|
||||
* zh-CN: PING连通性
|
||||
* en-US: PING CONNECT
|
||||
*/
|
||||
private Map<String, String> name;
|
||||
/**
|
||||
* Task dispatch start timestamp
|
||||
* 任务派发开始时间戳
|
||||
*/
|
||||
private long timestamp;
|
||||
/**
|
||||
* Task collection time interval (unit: second) eg: 30,60,600
|
||||
* 任务采集时间间隔(单位秒) eg: 30,60,600
|
||||
*/
|
||||
private long interval = 600L;
|
||||
/**
|
||||
* Whether it is a recurring periodic task true is yes, false is no
|
||||
* 是否是循环周期性任务 true为是,false为否
|
||||
*/
|
||||
private boolean isCyclic = false;
|
||||
/**
|
||||
* Indicator group configuration eg: cpu memory
|
||||
* 指标组配置 eg: cpu memory
|
||||
*/
|
||||
private List<Metrics> metrics;
|
||||
/**
|
||||
* Monitoring configuration parameter properties and values eg: username password timeout host
|
||||
* 监控配置参数属性及值 eg: username password timeout host
|
||||
*/
|
||||
private List<Configmap> configmap;
|
||||
|
||||
/**
|
||||
* collector use - timestamp when the task was scheduled by the time wheel
|
||||
* collector使用 - 任务被时间轮开始调度的时间戳
|
||||
*/
|
||||
@JsonIgnore
|
||||
private transient long dispatchTime;
|
||||
|
||||
/**
|
||||
* collector use - task version, this field is not stored in etcd
|
||||
* collector使用 - 任务版本,此字段不存储于etcd
|
||||
*/
|
||||
@JsonIgnore
|
||||
private transient long version;
|
||||
/**
|
||||
* collector usage - metric group task execution priority view
|
||||
* collector使用 - 指标组任务执行优先级视图
|
||||
* 0 - availability
|
||||
* 1 - cpu | memory
|
||||
@@ -103,27 +116,32 @@ public class Job {
|
||||
private transient List<Set<Metrics>> priorMetrics;
|
||||
|
||||
/**
|
||||
* collector use - Temporarily store one-time task indicator group response data
|
||||
* collector使用 - 临时存储一次性任务指标组响应数据
|
||||
*/
|
||||
@JsonIgnore
|
||||
private transient List<CollectRep.MetricsData> responseDataTemp;
|
||||
|
||||
/**
|
||||
* collector uses - construct to initialize metrics group execution view
|
||||
* collector使用 - 构造初始化指标组执行视图
|
||||
*/
|
||||
public synchronized void constructPriorMetrics() {
|
||||
Map<Byte, List<Metrics>> map = metrics.stream()
|
||||
.peek(metric -> {
|
||||
// Determine whether to configure aliasFields If not, configure the default
|
||||
// 判断是否配置aliasFields 没有则配置默认
|
||||
if (metric.getAliasFields() == null || metric.getAliasFields().isEmpty()) {
|
||||
metric.setAliasFields(metric.getFields().stream().map(Metrics.Field::getField).collect(Collectors.toList()));
|
||||
}
|
||||
// Set the default indicator group execution priority, if not filled, the default last priority
|
||||
// 设置默认的指标组执行优先级,不填则默认最后优先级
|
||||
if (metric.getPriority() == null) {
|
||||
metric.setPriority(Byte.MAX_VALUE);
|
||||
}
|
||||
})
|
||||
.collect(Collectors.groupingBy(Metrics::getPriority));
|
||||
// Construct a linked list of task execution order of the indicator group
|
||||
// 构造指标组任务执行顺序链表
|
||||
priorMetrics = new LinkedList<>();
|
||||
map.values().forEach(metric -> {
|
||||
@@ -141,12 +159,18 @@ public class Job {
|
||||
}
|
||||
|
||||
/**
|
||||
* collector use - to get the next set of priority metric group tasks
|
||||
* collector使用 - 获取下一组优先级的指标组任务
|
||||
* @param metrics 当前指标组
|
||||
* @param first 是否是第一次获取
|
||||
* @return 指标组任务
|
||||
*
|
||||
* @param metrics Current indicator group 当前指标组
|
||||
* @param first Is it the first time to get 是否是第一次获取
|
||||
* @return Metric Group Tasks 指标组任务
|
||||
* Returning null means: the job has been completed, and the collection of all indicator groups has ended
|
||||
* 返回null表示:job已完成,所有指标组采集结束
|
||||
* Returning the empty set indicates that there are still indicator group collection tasks at the current
|
||||
* level that have not been completed,and the next level indicator group task collection cannot be performed.
|
||||
* 返回empty的集合表示:当前级别下还有指标组采集任务未结束,无法进行下一级别的指标组任务采集
|
||||
* Returns a set of data representation: get the next set of priority index group tasks
|
||||
* 返回有数据集合表示:获取到下一组优先级的指标组任务
|
||||
*/
|
||||
public synchronized Set<Metrics> getNextCollectMetrics(Metrics metrics, boolean first) {
|
||||
@@ -189,7 +213,7 @@ public class Job {
|
||||
|
||||
@Override
|
||||
public Job clone() {
|
||||
// 深度克隆
|
||||
// deep clone 深度克隆
|
||||
return GsonUtil.fromJson(GsonUtil.toJson(this), Job.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,10 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Details of the collection of indicators collected by monitoring
|
||||
* eg: cpu | memory | health
|
||||
* 监控采集的指标集合详情 eg: cpu | memory | health
|
||||
*
|
||||
* @author tomsun28
|
||||
* @date 2021/10/17 21:24
|
||||
*/
|
||||
@@ -26,6 +29,7 @@ import java.util.Objects;
|
||||
public class Metrics {
|
||||
|
||||
/**
|
||||
* public property-name eg: cpu | memory | health
|
||||
* 公共属性-名称 eg: cpu | memory | health
|
||||
*/
|
||||
private String name;
|
||||
@@ -34,20 +38,27 @@ public class Metrics {
|
||||
*/
|
||||
private String protocol;
|
||||
/**
|
||||
* Range (0-127) indicator group scheduling priority, the smaller the value, the higher the priority
|
||||
* The collection task of the next priority indicator group will be scheduled only after the scheduled collection with the higher priority is completed.
|
||||
* The default priority of the availability indicator group is 0, and the range of other common indicator groups is 1-127, that is,
|
||||
* the subsequent indicator group tasks will only be scheduled after the availability is collected successfully.
|
||||
* 范围(0-127)指标组调度优先级,数值越小优先级越高
|
||||
* 优先级高的调度采集完成后才会调度下一优先级的指标组采集任务
|
||||
* 可用性指标组(availability)默认优先级为0,其它普通指标组范围为1-127,即需要等availability采集成功后才会调度后面的指标组任务
|
||||
*/
|
||||
private Byte priority;
|
||||
/**
|
||||
* Public attribute - collection and monitoring final result attribute set eg: speed | times | size
|
||||
* 公共属性-采集监控的最终结果属性集合 eg: speed | times | size
|
||||
*/
|
||||
private List<Field> fields;
|
||||
/**
|
||||
* Public attribute - collection and monitoring pre-query attribute set eg: size1 | size2 | speedSize
|
||||
* 公共属性-采集监控的前置查询属性集合 eg: size1 | size2 | speedSize
|
||||
*/
|
||||
private List<String> aliasFields;
|
||||
/**
|
||||
* Public attribute - expression calculation, map the pre-query attribute (pre Fields) with the final attribute (fields), and calculate the final attribute (fields) value
|
||||
* 公共属性-表达式计算,将前置查询属性(preFields)与最终属性(fields)映射,计算出最终属性(fields)值
|
||||
* eg: size = size1 + size2, speed = speedSize
|
||||
* https://www.yuque.com/boyan-avfmj/aviatorscript/ban32m
|
||||
@@ -55,26 +66,32 @@ public class Metrics {
|
||||
private List<String> calculates;
|
||||
|
||||
/**
|
||||
* Monitoring configuration information using the http protocol
|
||||
* 使用http协议的监控配置信息
|
||||
*/
|
||||
private HttpProtocol http;
|
||||
/**
|
||||
* Monitoring configuration information for ping using the icmp protocol
|
||||
* 使用icmp协议进行ping的监控配置信息
|
||||
*/
|
||||
private IcmpProtocol icmp;
|
||||
/**
|
||||
* Monitoring configuration information using the telnet protocol
|
||||
* 使用telnet协议的监控配置信息
|
||||
*/
|
||||
private TelnetProtocol telnet;
|
||||
/**
|
||||
* Use tcp or ucp implemented by socket for service port detection configuration information
|
||||
* 使用socket实现的tcp或ucp进行服务端口探测配置信息
|
||||
*/
|
||||
private TcpUdpProtocol tcpUdp;
|
||||
/**
|
||||
* Database configuration information implemented using the public jdbc specification
|
||||
* 使用公共的jdbc规范实现的数据库配置信息
|
||||
*/
|
||||
private JdbcProtocol jdbc;
|
||||
/**
|
||||
* Monitoring configuration information using the public ssh protocol
|
||||
* 使用公共的ssh协议的监控配置信息
|
||||
*/
|
||||
private SshProtocol ssh;
|
||||
@@ -101,18 +118,22 @@ public class Metrics {
|
||||
@NoArgsConstructor
|
||||
public static class Field {
|
||||
/**
|
||||
* Indicator name
|
||||
* 指标名称
|
||||
*/
|
||||
private String field;
|
||||
/**
|
||||
* Indicator type 0-number: number 1-string: string
|
||||
* 指标类型 0-number:数字 1-string:字符串
|
||||
*/
|
||||
private byte type = 1;
|
||||
/**
|
||||
* Whether this field is the instance primary key
|
||||
* 此字段是否为实例主键
|
||||
*/
|
||||
private boolean instance = false;
|
||||
/**
|
||||
* Indicator unit
|
||||
* 指标单位
|
||||
*/
|
||||
private String unit;
|
||||
|
||||
@@ -49,7 +49,6 @@ public class HttpProtocol {
|
||||
* http请求携带的请求体
|
||||
*/
|
||||
private String payload;
|
||||
|
||||
/**
|
||||
* 认证信息
|
||||
*/
|
||||
@@ -66,6 +65,10 @@ public class HttpProtocol {
|
||||
* 数据解析脚本 当解析方式为 jsonPath or xmlPath时存在
|
||||
*/
|
||||
private String parseScript;
|
||||
/**
|
||||
* 内容关键字
|
||||
*/
|
||||
private String keyword;
|
||||
|
||||
/**
|
||||
* 认证信息
|
||||
|
||||
@@ -22,7 +22,9 @@ import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_ONLY;
|
||||
import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_WRITE;
|
||||
|
||||
/**
|
||||
* Monitor Entity
|
||||
* 监控实体
|
||||
*
|
||||
* @author tomsun28
|
||||
* @date 2021/11/14 9:53
|
||||
*/
|
||||
@@ -32,10 +34,11 @@ import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_WRITE;
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ApiModel(description = "监控实体")
|
||||
@ApiModel(description = "en: Monitor Entity,zh: 监控实体")
|
||||
public class Monitor {
|
||||
|
||||
/**
|
||||
* Monitor ID
|
||||
* 主键ID
|
||||
*/
|
||||
@Id
|
||||
@@ -43,12 +46,14 @@ public class Monitor {
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* Job ID
|
||||
* 监控对应下发的任务ID
|
||||
*/
|
||||
@ApiModelProperty(value = "任务ID", example = "43243543543", accessMode = READ_ONLY, position = 1)
|
||||
private Long jobId;
|
||||
|
||||
/**
|
||||
* Monitor Name
|
||||
* 监控的名称
|
||||
*/
|
||||
@ApiModelProperty(value = "监控名称", example = "Api-TanCloud.cn", accessMode = READ_WRITE, position = 2)
|
||||
@@ -56,6 +61,7 @@ public class Monitor {
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* Type of monitoring: linux, mysql, jvm...
|
||||
* 监控的类型:linux,mysql,jvm...
|
||||
*/
|
||||
@ApiModelProperty(value = "监控类型", example = "TanCloud", accessMode = READ_WRITE, position = 3)
|
||||
@@ -63,6 +69,7 @@ public class Monitor {
|
||||
private String app;
|
||||
|
||||
/**
|
||||
* Monitored peer host: ipv4, ipv6, domain name
|
||||
* 监控的对端host:ipv4,ipv6,域名
|
||||
*/
|
||||
@ApiModelProperty(value = "监控的对端host", example = "192.167.25.11", accessMode = READ_WRITE, position = 4)
|
||||
@@ -71,6 +78,7 @@ public class Monitor {
|
||||
private String host;
|
||||
|
||||
/**
|
||||
* Monitoring collection interval time, in seconds
|
||||
* 监控的采集间隔时间,单位秒
|
||||
*/
|
||||
@ApiModelProperty(value = "监控的采集间隔时间,单位秒", example = "600", accessMode = READ_WRITE, position = 5)
|
||||
@@ -78,6 +86,7 @@ public class Monitor {
|
||||
private Integer intervals;
|
||||
|
||||
/**
|
||||
* Monitoring status 0: Unmonitored, 1: Available, 2: Unavailable, 3: Unreachable, 4: Suspended
|
||||
* 监控状态 0:未监控,1:可用,2:不可用,3:不可达,4:挂起
|
||||
*/
|
||||
@ApiModelProperty(value = "监控状态 0:未监控,1:可用,2:不可用,3:不可达,4:挂起", accessMode = READ_WRITE, position = 6)
|
||||
@@ -86,6 +95,7 @@ public class Monitor {
|
||||
private byte status;
|
||||
|
||||
/**
|
||||
* Monitoring note description
|
||||
* 监控备注描述
|
||||
*/
|
||||
@ApiModelProperty(value = "监控备注描述", example = "对SAAS网站TanCloud的可用性监控", accessMode = READ_WRITE, position = 7)
|
||||
@@ -93,18 +103,21 @@ public class Monitor {
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* The creator of this record
|
||||
* 此条记录创建者
|
||||
*/
|
||||
@ApiModelProperty(value = "此条记录创建者", example = "tom", accessMode = READ_ONLY, position = 8)
|
||||
private String creator;
|
||||
|
||||
/**
|
||||
* This record was last modified by
|
||||
* 此条记录最新修改者
|
||||
*/
|
||||
@ApiModelProperty(value = "此条记录最新修改者", example = "tom", accessMode = READ_ONLY, position = 9)
|
||||
private String modifier;
|
||||
|
||||
/**
|
||||
* record creation time (millisecond timestamp)
|
||||
* 记录创建时间
|
||||
*/
|
||||
@ApiModelProperty(value = "记录创建时间(毫秒时间戳)", example = "1612198922000", accessMode = READ_ONLY, position = 10)
|
||||
@@ -112,6 +125,7 @@ public class Monitor {
|
||||
private LocalDateTime gmtCreate;
|
||||
|
||||
/**
|
||||
* Record the latest modification time (timestamp in milliseconds)
|
||||
* 记录最新修改时间
|
||||
*/
|
||||
@ApiModelProperty(value = "记录最新修改时间(毫秒时间戳)", example = "1612198444000", accessMode = READ_ONLY, position = 11)
|
||||
|
||||
@@ -23,7 +23,9 @@ import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_ONLY;
|
||||
import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_WRITE;
|
||||
|
||||
/**
|
||||
* Message notification recipient entity
|
||||
* 消息通知接收人实体
|
||||
*
|
||||
* @author tomsun28
|
||||
* @date 2021/11/13 22:19
|
||||
*/
|
||||
@@ -33,56 +35,80 @@ import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_WRITE;
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ApiModel(description = "消息通知接收人实体")
|
||||
@ApiModel(description = "en: Message notification recipient entity,zh:消息通知接收人实体")
|
||||
public class NoticeReceiver {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@ApiModelProperty(value = "接收人实体主键索引ID", example = "87584674384", accessMode = READ_ONLY, position = 0)
|
||||
@ApiModelProperty(value = "Recipient entity primary key index ID",
|
||||
notes = "接收人实体主键索引ID",
|
||||
example = "87584674384", accessMode = READ_ONLY, position = 0)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "接收人名称", example = "tom", accessMode = READ_WRITE, position = 1)
|
||||
@ApiModelProperty(value = "Recipient name",
|
||||
notes = "接收人名称",
|
||||
example = "tom", accessMode = READ_WRITE, position = 1)
|
||||
@Length(max = 100)
|
||||
@NotNull
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "通知信息方式: 0-手机短信 1-邮箱 2-webhook 3-微信公众号 4-企业微信机器人 5-钉钉机器人 6-飞书机器人", accessMode = READ_WRITE, position = 2)
|
||||
@ApiModelProperty(value = "Notification information method: 0-SMS 1-Email 2-webhook 3-WeChat Official Account 4-Enterprise WeChat Robot 5-DingTalk Robot 6-FeiShu Robot",
|
||||
notes = "通知信息方式: 0-手机短信 1-邮箱 2-webhook 3-微信公众号 4-企业微信机器人 5-钉钉机器人 6-飞书机器人",
|
||||
accessMode = READ_WRITE, position = 2)
|
||||
@Min(0)
|
||||
@Max(8)
|
||||
@NotNull
|
||||
private Byte type;
|
||||
|
||||
@ApiModelProperty(value = "手机号, 通知方式为手机短信时有效", example = "18923435643", accessMode = READ_WRITE, position = 3)
|
||||
@ApiModelProperty(value = "Mobile number: Valid when the notification method is SMS",
|
||||
notes = "手机号 : 通知方式为手机短信时有效",
|
||||
example = "18923435643", accessMode = READ_WRITE, position = 3)
|
||||
@Length(max = 100)
|
||||
private String phone;
|
||||
|
||||
@ApiModelProperty(value = "邮箱账号, 通知方式为邮箱时有效", example = "tom@qq.com", accessMode = READ_WRITE, position = 4)
|
||||
@ApiModelProperty(value = "Email account: Valid when the notification method is email",
|
||||
notes = "邮箱账号 : 通知方式为邮箱时有效",
|
||||
example = "tom@qq.com", accessMode = READ_WRITE, position = 4)
|
||||
@Length(max = 100)
|
||||
private String email;
|
||||
|
||||
@ApiModelProperty(value = "URL地址, 通知方式为webhook有效", example = "https://www.tancloud.cn", accessMode = READ_WRITE, position = 5)
|
||||
@ApiModelProperty(value = "URL address: The notification method is valid for webhook",
|
||||
notes = "URL地址 : 通知方式为webhook有效",
|
||||
example = "https://www.tancloud.cn", accessMode = READ_WRITE, position = 5)
|
||||
@Length(max = 300)
|
||||
private String hookUrl;
|
||||
|
||||
@ApiModelProperty(value = "openId, 通知方式为微信公众号或企业微信机器人有效", example = "343432", accessMode = READ_WRITE, position = 6)
|
||||
@ApiModelProperty(value = "openId : The notification method is valid for WeChat official account or enterprise WeChat robot",
|
||||
notes = "openId : 通知方式为微信公众号或企业微信机器人有效",
|
||||
example = "343432", accessMode = READ_WRITE, position = 6)
|
||||
@Length(max = 300)
|
||||
private String wechatId;
|
||||
|
||||
@ApiModelProperty(value = "访问token, 通知方式为钉钉机器人有效", example = "34823984635647", accessMode = READ_WRITE, position = 7)
|
||||
@ApiModelProperty(value = "Access token : The notification method is valid for DingTalk robot",
|
||||
notes = "访问token : 通知方式为钉钉机器人有效",
|
||||
example = "34823984635647", accessMode = READ_WRITE, position = 7)
|
||||
@Length(max = 300)
|
||||
private String accessToken;
|
||||
|
||||
@ApiModelProperty(value = "此条记录创建者", example = "tom", accessMode = READ_ONLY, position = 7)
|
||||
@ApiModelProperty(value = "The creator of this record",
|
||||
notes = "此条记录创建者",
|
||||
example = "tom", accessMode = READ_ONLY, position = 7)
|
||||
private String creator;
|
||||
|
||||
@ApiModelProperty(value = "此条记录最新修改者", example = "tom", accessMode = READ_ONLY, position = 8)
|
||||
@ApiModelProperty(value = "This record was last modified by",
|
||||
notes = "此条记录最新修改者",
|
||||
example = "tom", accessMode = READ_ONLY, position = 8)
|
||||
private String modifier;
|
||||
|
||||
@ApiModelProperty(value = "记录创建时间(毫秒时间戳)", example = "1612198922000", accessMode = READ_ONLY, position = 9)
|
||||
@ApiModelProperty(value = "Record creation time (millisecond timestamp)",
|
||||
notes = "记录创建时间(毫秒时间戳)",
|
||||
example = "1612198922000", accessMode = READ_ONLY, position = 9)
|
||||
@Column(insertable = false, updatable = false)
|
||||
private LocalDateTime gmtCreate;
|
||||
|
||||
@ApiModelProperty(value = "记录最新修改时间(毫秒时间戳)", example = "1612198444000", accessMode = READ_ONLY, position = 10)
|
||||
@ApiModelProperty(value = "Record the latest modification time (timestamp in milliseconds)",
|
||||
notes = "记录最新修改时间(毫秒时间戳)",
|
||||
example = "1612198444000", accessMode = READ_ONLY, position = 10)
|
||||
@Column(insertable = false, updatable = false)
|
||||
private LocalDateTime gmtUpdate;
|
||||
|
||||
|
||||
@@ -21,7 +21,9 @@ import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_ONLY;
|
||||
import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_WRITE;
|
||||
|
||||
/**
|
||||
* Notification strategy entity
|
||||
* 通知策略
|
||||
*
|
||||
* @author tomsun28
|
||||
* @date 2021/11/13 22:19
|
||||
*/
|
||||
@@ -31,45 +33,65 @@ import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_WRITE;
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ApiModel(description = "通知策略实体")
|
||||
@ApiModel(description = "en: Notify Policy Entity,zh: 通知策略实体")
|
||||
public class NoticeRule {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@ApiModelProperty(value = "通知策略实体主键索引ID", example = "87584674384", accessMode = READ_ONLY, position = 0)
|
||||
@ApiModelProperty(value = "Notification Policy Entity Primary Key Index ID",
|
||||
notes = "通知策略实体主键索引ID",
|
||||
example = "87584674384", accessMode = READ_ONLY, position = 0)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "策略名称", example = "dispatch-1", accessMode = READ_WRITE, position = 1)
|
||||
@ApiModelProperty(value = "Policy name",
|
||||
notes = "策略名称",
|
||||
example = "dispatch-1", accessMode = READ_WRITE, position = 1)
|
||||
@Length(max = 100)
|
||||
@NotNull
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "接收人ID", example = "4324324", accessMode = READ_WRITE, position = 2)
|
||||
@ApiModelProperty(value = "Recipient ID",
|
||||
notes = "接收人ID",
|
||||
example = "4324324", accessMode = READ_WRITE, position = 2)
|
||||
@NotNull
|
||||
private Long receiverId;
|
||||
|
||||
@ApiModelProperty(value = "接收人标识", example = "tom", accessMode = READ_WRITE, position = 3)
|
||||
@ApiModelProperty(value = "Recipient identification",
|
||||
notes = "接收人标识",
|
||||
example = "tom", accessMode = READ_WRITE, position = 3)
|
||||
@Length(max = 100)
|
||||
@NotNull
|
||||
private String receiverName;
|
||||
|
||||
@ApiModelProperty(value = "是否启用此策略", example = "true", accessMode = READ_WRITE, position = 4)
|
||||
@ApiModelProperty(value = "Whether to enable this policy",
|
||||
notes = "是否启用此策略",
|
||||
example = "true", accessMode = READ_WRITE, position = 4)
|
||||
private boolean enable = true;
|
||||
|
||||
@ApiModelProperty(value = "是否转发所有", example = "false", accessMode = READ_WRITE, position = 5)
|
||||
@ApiModelProperty(value = "Whether to forward all",
|
||||
notes = "是否转发所有",
|
||||
example = "false", accessMode = READ_WRITE, position = 5)
|
||||
private boolean filterAll = true;
|
||||
|
||||
@ApiModelProperty(value = "此条记录创建者", example = "tom", accessMode = READ_ONLY, position = 7)
|
||||
@ApiModelProperty(value = "The creator of this record",
|
||||
notes = "此条记录创建者",
|
||||
example = "tom", accessMode = READ_ONLY, position = 7)
|
||||
private String creator;
|
||||
|
||||
@ApiModelProperty(value = "此条记录最新修改者", example = "tom", accessMode = READ_ONLY, position = 8)
|
||||
@ApiModelProperty(value = "This record was last modified by",
|
||||
notes = "此条记录最新修改者",
|
||||
example = "tom", accessMode = READ_ONLY, position = 8)
|
||||
private String modifier;
|
||||
|
||||
@ApiModelProperty(value = "记录创建时间(毫秒时间戳)", example = "1612198922000", accessMode = READ_ONLY, position = 9)
|
||||
@ApiModelProperty(value = "This record creation time (millisecond timestamp)",
|
||||
notes = "记录创建时间(毫秒时间戳)",
|
||||
example = "1612198922000", accessMode = READ_ONLY, position = 9)
|
||||
@Column(insertable = false, updatable = false)
|
||||
private LocalDateTime gmtCreate;
|
||||
|
||||
@ApiModelProperty(value = "记录最新修改时间(毫秒时间戳)", example = "1612198444000", accessMode = READ_ONLY, position = 10)
|
||||
@ApiModelProperty(value = "Record the latest modification time (timestamp in milliseconds)",
|
||||
notes = "记录最新修改时间(毫秒时间戳)",
|
||||
example = "1612198444000", accessMode = READ_ONLY, position = 10)
|
||||
@Column(insertable = false, updatable = false)
|
||||
private LocalDateTime gmtUpdate;
|
||||
|
||||
|
||||
@@ -23,7 +23,9 @@ import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_ONLY;
|
||||
import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_WRITE;
|
||||
|
||||
/**
|
||||
* Monitor parameter values
|
||||
* 监控参数值
|
||||
*
|
||||
* @author tomsun28
|
||||
* @date 2021/11/13 22:19
|
||||
*/
|
||||
@@ -33,21 +35,26 @@ import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_WRITE;
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ApiModel(description = "参数实体")
|
||||
@ApiModel(description = "嗯: Parameter Entity,zh: 参数实体")
|
||||
public class Param {
|
||||
|
||||
/**
|
||||
* Parameter primary key index ID
|
||||
*/
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@ApiModelProperty(value = "参数主键索引ID", example = "87584674384", accessMode = READ_ONLY, position = 0)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* Monitor ID
|
||||
* 监控ID
|
||||
*/
|
||||
@ApiModelProperty(value = "监控ID", example = "875846754543", accessMode = READ_WRITE, position = 1)
|
||||
private Long monitorId;
|
||||
|
||||
/**
|
||||
* Parameter Field Identifier
|
||||
* 参数字段标识符
|
||||
*/
|
||||
@ApiModelProperty(value = "参数标识符字段", example = "port", accessMode = READ_WRITE, position = 2)
|
||||
@@ -56,6 +63,7 @@ public class Param {
|
||||
private String field;
|
||||
|
||||
/**
|
||||
* Param Value
|
||||
* 参数值
|
||||
*/
|
||||
@ApiModelProperty(value = "参数值", example = "8080", accessMode = READ_WRITE, position = 3)
|
||||
@@ -63,6 +71,7 @@ public class Param {
|
||||
private String value;
|
||||
|
||||
/**
|
||||
* Parameter type 0: number 1: string 2: encrypted string 3: json string mapped by map
|
||||
* 参数类型 0:数字 1:字符串 2:加密串 3:map映射的json串
|
||||
*/
|
||||
@ApiModelProperty(value = "参数类型 0:数字 1:字符串 2:加密串 3:map映射的json串", accessMode = READ_WRITE, position = 4)
|
||||
@@ -71,6 +80,7 @@ public class Param {
|
||||
private byte type;
|
||||
|
||||
/**
|
||||
* Record Creation Time
|
||||
* 记录创建时间
|
||||
*/
|
||||
@ApiModelProperty(value = "记录创建时间(毫秒时间戳)", example = "1612198922000", accessMode = READ_ONLY, position = 5)
|
||||
@@ -78,6 +88,7 @@ public class Param {
|
||||
private LocalDateTime gmtCreate;
|
||||
|
||||
/**
|
||||
* Record the latest modification time
|
||||
* 记录最新修改时间
|
||||
*/
|
||||
@ApiModelProperty(value = "记录最新修改时间(毫秒时间戳)", example = "1612198444000", accessMode = READ_ONLY, position = 6)
|
||||
|
||||
@@ -22,7 +22,9 @@ import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_WRITE;
|
||||
|
||||
/**
|
||||
* todo 字段默认值
|
||||
* Monitoring parameter definitions
|
||||
* 监控参数定义
|
||||
*
|
||||
* @author tomsun28
|
||||
* @date 2021/11/13 21:49
|
||||
*/
|
||||
@@ -32,57 +34,68 @@ import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_WRITE;
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ApiModel(description = "参数结构定义实体")
|
||||
@ApiModel(description = "en: Parameter structure definition entity,zh: 参数结构定义实体")
|
||||
public class ParamDefine {
|
||||
|
||||
/**
|
||||
* Parameter Structure ID
|
||||
*/
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@ApiModelProperty(value = "参数结构ID", example = "87584674384", accessMode = READ_ONLY, position = 0)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* Monitoring application type name
|
||||
* 监控应用类型名称
|
||||
*/
|
||||
@ApiModelProperty(value = "监控类型", example = "TanCloud", accessMode = READ_WRITE, position = 1)
|
||||
private String app;
|
||||
|
||||
/**
|
||||
* Parameter field external display name
|
||||
* 参数字段对外显示名称
|
||||
*/
|
||||
@ApiModelProperty(value = "参数字段显示名称", example = "端口", accessMode = READ_WRITE, position = 2)
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* Parameter Field Identifier
|
||||
* 参数字段标识符
|
||||
*/
|
||||
@ApiModelProperty(value = "参数字段标识符", example = "port", accessMode = READ_WRITE, position = 3)
|
||||
private String field;
|
||||
|
||||
/**
|
||||
* Field type, style (mostly map the input tag type attribute)
|
||||
* 字段类型,样式(大部分映射input标签type属性)
|
||||
*/
|
||||
@ApiModelProperty(value = "字段类型,样式(大部分映射input标签type属性)", example = "number", accessMode = READ_WRITE, position = 4)
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* Is it mandatory true-required false-optional
|
||||
* 是否是必输项 true-必填 false-可选
|
||||
*/
|
||||
@ApiModelProperty(value = "是否是必输项 true-必填 false-可选", example = "true", accessMode = READ_WRITE, position = 5)
|
||||
private boolean required = false;
|
||||
|
||||
/**
|
||||
* Parameter Default Value
|
||||
* 参数默认值
|
||||
*/
|
||||
@ApiModelProperty(value = "参数默认值", example = "12", accessMode = READ_WRITE, position = 6)
|
||||
private String defaultValue;
|
||||
|
||||
/**
|
||||
* Parameter input box prompt information
|
||||
* 参数输入框提示信息
|
||||
*/
|
||||
@ApiModelProperty(value = "参数输入框提示信息", example = "请输入密码", accessMode = READ_WRITE, position = 7)
|
||||
private String placeholder;
|
||||
|
||||
/**
|
||||
* When type is number, use range to represent the range eg: 0-233
|
||||
* 当type为number时,用range表示范围 eg: 0-233
|
||||
*/
|
||||
@ApiModelProperty(value = "当type为number时,用range区间表示范围", example = "[0,233]", accessMode = READ_WRITE, position = 6)
|
||||
@@ -90,6 +103,7 @@ public class ParamDefine {
|
||||
private String range;
|
||||
|
||||
/**
|
||||
* When type is text, use limit to indicate the limit size of the string. The maximum is 255
|
||||
* 当type为text时,用limit表示字符串限制大小.最大255
|
||||
*/
|
||||
@ApiModelProperty(value = "当type为text时,用limit表示字符串限制大小.最大255", example = "30", accessMode = READ_WRITE, position = 7)
|
||||
@@ -97,10 +111,11 @@ public class ParamDefine {
|
||||
private Short limit;
|
||||
|
||||
/**
|
||||
* When the type is radio radio box, checkbox checkbox, options represents a list of optional values
|
||||
* 当type为radio单选框,checkbox复选框时,options表示可选项值列表
|
||||
* eg: {
|
||||
* "key1":"value1",
|
||||
* "key2":"value2"
|
||||
* "key1":"value1",
|
||||
* "key2":"value2"
|
||||
* }
|
||||
* key-值显示标签
|
||||
* value-真正值
|
||||
@@ -111,30 +126,42 @@ public class ParamDefine {
|
||||
private List<Option> options;
|
||||
|
||||
/**
|
||||
* Valid when type is key-value, indicating the alias description of the key
|
||||
* 当type为key-value时有效,表示key的别名描述
|
||||
*/
|
||||
@ApiModelProperty(value = "当type为key-value时有效,表示key的别名描述", example = "Name", accessMode = READ_WRITE, position = 9)
|
||||
private String keyAlias;
|
||||
|
||||
/**
|
||||
* Valid when type is key-value, indicating the alias description of value type
|
||||
* 当type为key-value时有效,表示value的别名描述
|
||||
*/
|
||||
@ApiModelProperty(value = "当type为key-value时有效,表示value的别名描述", example = "Value", accessMode = READ_WRITE, position = 10)
|
||||
private String valueAlias;
|
||||
|
||||
/**
|
||||
* Is it an advanced hidden parameter true-yes false-no
|
||||
* 是否是高级隐藏参数 true-是 false-否
|
||||
*/
|
||||
@ApiModelProperty(value = "是否是高级隐藏参数 true-是 false-否", example = "true", accessMode = READ_WRITE, position = 11)
|
||||
private boolean hide = false;
|
||||
|
||||
/**
|
||||
* The creator of this record
|
||||
* 此条记录创建者
|
||||
*/
|
||||
@ApiModelProperty(value = "此条记录创建者", example = "tom", accessMode = READ_ONLY, position = 11)
|
||||
private String creator;
|
||||
|
||||
/**
|
||||
* This record was last modified by
|
||||
* 此条记录最新修改者
|
||||
*/
|
||||
@ApiModelProperty(value = "此条记录最新修改者", example = "tom", accessMode = READ_ONLY, position = 12)
|
||||
private String modifier;
|
||||
|
||||
/**
|
||||
* record creation time
|
||||
* 记录创建时间
|
||||
*/
|
||||
@ApiModelProperty(value = "记录创建时间(毫秒时间戳)", example = "1612198922000", accessMode = READ_ONLY, position = 13)
|
||||
@@ -142,6 +169,7 @@ public class ParamDefine {
|
||||
private LocalDateTime gmtCreate;
|
||||
|
||||
/**
|
||||
* Record the latest modification time
|
||||
* 记录最新修改时间
|
||||
*/
|
||||
@ApiModelProperty(value = "记录最新修改时间(毫秒时间戳)", example = "1612198444000", accessMode = READ_ONLY, position = 14)
|
||||
@@ -153,10 +181,12 @@ public class ParamDefine {
|
||||
@NoArgsConstructor
|
||||
public static final class Option {
|
||||
/**
|
||||
* value display label
|
||||
* 值显示标签
|
||||
*/
|
||||
private String label;
|
||||
/**
|
||||
* optional value
|
||||
* 可选值
|
||||
*/
|
||||
private String value;
|
||||
|
||||
@@ -1,175 +1,208 @@
|
||||
package com.usthe.common.util;
|
||||
|
||||
/**
|
||||
* Public Constant
|
||||
* 公共常量
|
||||
*
|
||||
* @author tomsun28
|
||||
* @date 2021/11/14 12:06
|
||||
*/
|
||||
public interface CommonConstants {
|
||||
|
||||
/**
|
||||
* Response status code: generic success
|
||||
* 响应状态码: 通用成功
|
||||
*/
|
||||
byte SUCCESS_CODE = 0x00;
|
||||
|
||||
/**
|
||||
* Response status code: generic failure
|
||||
* 响应状态码: 通用失败
|
||||
*/
|
||||
byte FAIL_CODE = 0x0F;
|
||||
|
||||
/**
|
||||
* Response status code: Parameter verification failed
|
||||
* 响应状态码: 参数校验失败
|
||||
*/
|
||||
byte PARAM_INVALID_CODE = 0x01;
|
||||
|
||||
/**
|
||||
* Response Status Code: Probe Failed
|
||||
* 响应状态码: 探测失败
|
||||
*/
|
||||
byte DETECT_FAILED_CODE = 0x02;
|
||||
|
||||
/**
|
||||
* Response status code: monitoring does not exist
|
||||
* 响应状态码: 监控不存在
|
||||
*/
|
||||
byte MONITOR_NOT_EXIST_CODE = 0x03;
|
||||
|
||||
/**
|
||||
* Response Status Code: Monitor Service Conflict
|
||||
* 响应状态码: 监控服务冲突
|
||||
*/
|
||||
byte MONITOR_CONFLICT_CODE = 0x04;
|
||||
|
||||
/**
|
||||
* Response status code: Incorrect login account password
|
||||
* 响应状态码: 登录账户密码错误
|
||||
*/
|
||||
byte MONITOR_LOGIN_FAILED_CODE = 0x05;
|
||||
|
||||
/**
|
||||
* Response status code: Registration failed exception
|
||||
* 响应状态码: 注册失败异常
|
||||
*/
|
||||
byte MONITOR_REGISTER_FAILED_CODE = 0x06;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Monitoring Status Code: Unmanaged
|
||||
* 监控状态码: 未管理
|
||||
*/
|
||||
byte UN_MANAGE_CODE = 0x00;
|
||||
|
||||
/**
|
||||
* Monitoring Status Code: Available
|
||||
* 监控状态码: 可用
|
||||
*/
|
||||
byte AVAILABLE_CODE = 0x01;
|
||||
|
||||
/**
|
||||
* Monitoring Status Code: Not Available
|
||||
* 监控状态码: 不可用
|
||||
*/
|
||||
byte UN_AVAILABLE_CODE = 0x02;
|
||||
|
||||
/**
|
||||
* Monitoring Status Code: Unreachable
|
||||
* 监控状态码: 不可达
|
||||
*/
|
||||
byte UN_REACHABLE_CODE = 0x03;
|
||||
|
||||
/**
|
||||
* Monitoring Status Code: Pending
|
||||
* 监控状态码: 挂起
|
||||
*/
|
||||
byte SUSPENDING_CODE = 0x04;
|
||||
|
||||
/**
|
||||
* Alarm status: 0 - normal alarm (to be processed)
|
||||
* 告警状态: 0-正常告警(待处理)
|
||||
*/
|
||||
byte ALERT_STATUS_CODE_PENDING = 0x00;
|
||||
|
||||
/**
|
||||
* Alarm Status: 1 - Threshold triggered but not reached the number of alarms
|
||||
* 告警状态: 1-阈值触发但未达到告警次数
|
||||
*/
|
||||
byte ALERT_STATUS_CODE_NOT_REACH = 0x01;
|
||||
|
||||
/**
|
||||
* Alarm Status: 2-Restore Alarm
|
||||
* 告警状态: 2-恢复告警
|
||||
*/
|
||||
byte ALERT_STATUS_CODE_RESTORED = 0x02;
|
||||
|
||||
/**
|
||||
* Alert Status: 3-Handled
|
||||
* 告警状态: 3-已处理
|
||||
*/
|
||||
byte ALERT_STATUS_CODE_SOLVED = 0x03;
|
||||
|
||||
/**
|
||||
* Alarm level: 0: high-emergency-emergency-red
|
||||
* 告警级别: 0:高-emergency-紧急告警-红色
|
||||
*/
|
||||
byte ALERT_PRIORITY_CODE_EMERGENCY = 0x00;
|
||||
|
||||
/**
|
||||
* Alarm severity: 1: medium-critical-critical alarm-orange
|
||||
* 告警级别: 1:中-critical-严重告警-橙色
|
||||
*/
|
||||
byte ALERT_PRIORITY_CODE_CRITICAL = 0x01;
|
||||
|
||||
/**
|
||||
* Warning level: 2: low-warning-warning warning-yellow
|
||||
* 告警级别: 2:低-warning-警告告警-黄色
|
||||
*/
|
||||
byte ALERT_PRIORITY_CODE_WARNING = 0x02;
|
||||
|
||||
/**
|
||||
* Field parameter type: number
|
||||
* 字段参数类型: 数字
|
||||
*/
|
||||
byte TYPE_NUMBER = 0;
|
||||
|
||||
/**
|
||||
* Field parameter type: String
|
||||
* 字段参数类型: 字符串
|
||||
*/
|
||||
byte TYPE_STRING = 1;
|
||||
|
||||
/**
|
||||
* Field parameter type: encrypted string
|
||||
* 字段参数类型: 加密字符串
|
||||
*/
|
||||
byte TYPE_SECRET = 2;
|
||||
|
||||
/**
|
||||
* Collection indicator value: null placeholder for empty value
|
||||
* 采集指标值:null空值占位符
|
||||
*/
|
||||
String NULL_VALUE = " ";
|
||||
|
||||
/**
|
||||
* Availability Object
|
||||
* 可用性对象
|
||||
*/
|
||||
String AVAILABLE = "available";
|
||||
|
||||
/**
|
||||
* 可达性对象
|
||||
* Reachability Object可达性对象
|
||||
*/
|
||||
String REACHABLE = "reachable";
|
||||
|
||||
/**
|
||||
* Parameter Type Number
|
||||
* 参数类型 数字
|
||||
*/
|
||||
byte PARAM_TYPE_NUMBER = 0;
|
||||
|
||||
/**
|
||||
* Parameter Type String
|
||||
* 参数类型 字符串
|
||||
*/
|
||||
byte PARAM_TYPE_STRING = 1;
|
||||
|
||||
/**
|
||||
* Parameter Type Password
|
||||
* 参数类型 密码
|
||||
*/
|
||||
byte PARAM_TYPE_PASSWORD = 2;
|
||||
|
||||
/**
|
||||
* Authentication type Account password
|
||||
* 认证类型 账户密码
|
||||
*/
|
||||
byte AUTH_TYPE_PASSWORD = 1;
|
||||
|
||||
/**
|
||||
* Authentication type GITHUB three-party login
|
||||
* 认证类型 GITHUB三方登录
|
||||
*/
|
||||
byte AUTH_TYPE_GITHUB = 2;
|
||||
|
||||
/**
|
||||
* Authentication type WeChat three-party login
|
||||
* 认证类型 微信三方登录
|
||||
*/
|
||||
byte AUTH_TYPE_WEIXIN = 3;
|
||||
|
||||
/**
|
||||
* Authentication type GITEE three-party login
|
||||
* 认证类型 GITEE三方登录
|
||||
*/
|
||||
byte AUTH_TYPE_GITEE = 5;
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.usthe.common.util;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -15,7 +17,7 @@ public class CommonUtil {
|
||||
|
||||
private static final Pattern EMAIL_PATTERN = Pattern.compile("\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");
|
||||
|
||||
private static final Pattern PHONE_PATTERN = Pattern.compile("^(((13[0-9])|(15[0-9])|(18[0-9])|(17[0-9]))+\\d{8})?$");
|
||||
private static final Pattern PHONE_PATTERN = Pattern.compile("^(((13[0-9])|(14[0-9])|(15[0-9])|(16[0-9])|(19[0-9])|(18[0-9])|(17[0-9]))+\\d{8})?$");
|
||||
|
||||
private static final int PHONE_LENGTH = 11;
|
||||
|
||||
@@ -36,6 +38,30 @@ public class CommonUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将字符串str,此字符串可能带单位,转换为double数字类型
|
||||
* 将数值小数点限制到4位
|
||||
* @param str string
|
||||
* @param unit 字符串单位
|
||||
* @return string格式的 double 数字 小数点最大到4位
|
||||
*/
|
||||
public static String parseDoubleStr(String str, String unit) {
|
||||
if (str == null || "".equals(str)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
if (unit != null && str.endsWith(unit)) {
|
||||
str = str.substring(0, str.length() - unit.length());
|
||||
}
|
||||
BigDecimal bigDecimal = new BigDecimal(str);
|
||||
double value = bigDecimal.setScale(4, RoundingMode.HALF_UP).doubleValue();
|
||||
return String.valueOf(value);
|
||||
} catch (Exception e) {
|
||||
log.debug(e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 邮箱格式校验
|
||||
* @param email 邮箱
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.usthe.common.util;
|
||||
|
||||
/**
|
||||
* Snowflake Algorithm Generator Tool
|
||||
* 雪花算法生成器工具
|
||||
*
|
||||
* @author tomsun28
|
||||
* @date 2021/11/10 11:04
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.usthe.common.util;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* @author tom
|
||||
* @date 2022/4/7 17:18
|
||||
*/
|
||||
class CommonUtilTest {
|
||||
|
||||
@Test
|
||||
void testParseDoubleStr() {
|
||||
assertEquals("9.3454",CommonUtil.parseDoubleStr("9.345435345", null));
|
||||
assertEquals("9.3454",CommonUtil.parseDoubleStr("9.345435345%", "%"));
|
||||
assertEquals("10.0",CommonUtil.parseDoubleStr("10%", "%"));
|
||||
assertEquals("588.0",CommonUtil.parseDoubleStr("588Mb", "Mb"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void validateEmail() {
|
||||
assertTrue(CommonUtil.validateEmail("tom@usthe.com"));
|
||||
assertTrue(CommonUtil.validateEmail("demo@qq.com"));
|
||||
assertFalse(CommonUtil.validateEmail("tom.usthe.com"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void validatePhoneNum() {
|
||||
assertTrue(CommonUtil.validatePhoneNum("19234554432"));
|
||||
assertTrue(CommonUtil.validatePhoneNum("13234554432"));
|
||||
assertTrue(CommonUtil.validatePhoneNum("14234554432"));
|
||||
assertTrue(CommonUtil.validatePhoneNum("16234554432"));
|
||||
assertFalse(CommonUtil.validatePhoneNum("12234554432"));
|
||||
assertFalse(CommonUtil.validatePhoneNum("11234554432"));
|
||||
assertFalse(CommonUtil.validatePhoneNum("35234554432"));
|
||||
assertFalse(CommonUtil.validatePhoneNum("46234554432"));
|
||||
}
|
||||
|
||||
}
|
||||
92
home/blog/2022-04-08-hertzbeat-v1.0-beta.7.md
Normal file
92
home/blog/2022-04-08-hertzbeat-v1.0-beta.7.md
Normal file
@@ -0,0 +1,92 @@
|
||||
---
|
||||
title: HertzBeat入GVP啦,并 v1.0.beta.7 发布,易用友好的云监控系统
|
||||
author: tom
|
||||
author_title: tom
|
||||
author_url: https://github.com/tomsun28
|
||||
author_image_url: https://avatars.githubusercontent.com/u/24788200?s=400&v=4
|
||||
tags: [opensource]
|
||||
---
|
||||
|
||||
|
||||
HertzBeat赫兹跳动 是一个由Dromara孵化的支持网站,API,PING,端口,数据库,全站,操作系统等监控类型,支持阈值告警,告警通知(邮箱,webhook,钉钉,企业微信,飞书机器人),拥有易用友好的可视化操作界面的开源监控告警项目。
|
||||
|
||||
很高兴Hertzbeat被评定为GVP - Gitee最有价值开源项目!
|
||||
|
||||
|
||||

|
||||
|
||||
老哥们帮忙在Gitee STAR起来,冲!https://gitee.com/dromara/hertzbeat
|
||||
|
||||
官网:hertzbeat.com | tancloud.cn
|
||||
|
||||
然后来说说最新的版本,这个版本看这么多feature,其实简单来说主要是这几个
|
||||
|
||||
支持了ORACLE数据库的监控,包括ORACLE的基本信息,表空间,连接数,TPS,QPS等指标
|
||||
|
||||
支持了LINUX的CPU利用率,内存利用率,磁盘占用相关指标,使LINUX监控贴合实际业务
|
||||
|
||||
还有前端参数支持了KEY-VALUE,以后我们就可以在页面上配置HTTP Headers等类似参数了,还有就是参数配置那优化改版,把非常用告警参数隐藏起来了,稍微好看些,然后支持了windows下bat启动脚本,更多的就是稳定性的提升和一些其它的小修复小需求啦!
|
||||
|
||||
|
||||
|
||||
版本特性:
|
||||
|
||||
1. feature 支持oracle数据库监控类型-xgf 由 @gf-8 贡献 thanks
|
||||
2. feature oracle监控支持tablespace,连接数,qps,tps等指标
|
||||
3. feature linux监控支持设置超时时间 (#49)
|
||||
4. feature 检测网站SSL证书是否过期 (#50) 由 @weihongbin 提出 thanks
|
||||
5. feature 页面配置参数支持KEY-VALUE数组(#57)
|
||||
6. feature API和网站监控支持页面配置Headers和Params (#58)(#59)
|
||||
7. feature API和网站监控支持页面配置 basic auth, digest auth (#60)
|
||||
8. feature http 端口跟随SSL是否启用变更443或80 (#61)
|
||||
9. feature 修改默认超时时间3000毫秒为6000毫秒 (#55)
|
||||
10. feature:make tdengine optional, not required (#62)
|
||||
11. feature:support win bat service (#65)
|
||||
12. feature:support hide advanced params define (#68)
|
||||
13. feature:enable auto redirect when 301 302 http code (#69)
|
||||
14. feature:only collect available metrics when detect (#70)
|
||||
15. feature:[website api]monitor support keyword match (#72)
|
||||
16. feature:support linux cpu usage,memory usage,disk free (#76)
|
||||
|
||||
BUG修复
|
||||
1. 添加sqlserver关联文档,fix connection指标入库tdengine失败 (#41)
|
||||
2. 使用docker部署TDengine,开放tcp访问端口!16 由 @老姜bei 贡献 thanks
|
||||
3. 补充sureness配置文档 避免误配导致权限异常
|
||||
4. bugfix:monitors always timeout alert (#67)
|
||||
5. code format and optimization 由 @学习代码的小白 贡献 thanks
|
||||
6. bugfix: remove oracle field - database_type due 11g not support 由 @syongaaa 贡献 thanks
|
||||
7. bugfix:fix linux interface metrics no instance (#75)
|
||||
|
||||
欢迎在线试用 https://console.tancloud.cn.
|
||||
|
||||
-----------------------
|
||||
|
||||
> [HertzBeat赫兹跳动](https://github.com/dromara/hertzbeat) 是一个支持网站,API,PING,端口,数据库,操作系统等监控类型,拥有易用友好的可视化操作界面的开源监控告警项目。
|
||||
> 我们也提供了对应的 **[SAAS版本监控云](https://console.tancloud.cn)**,中小团队和个人无需再为了监控自己的网站资源,而去部署一套繁琐的监控系统,**[登录即可免费开始](https://console.tancloud.cn)**。
|
||||
> HertzBeat 支持[自定义监控](https://hertzbeat.com/docs/advanced/extend-point) ,只用通过配置YML文件我们就可以自定义需要的监控类型和指标,来满足常见的个性化需求。
|
||||
> HertzBeat 模块化,`manager, collector, scheduler, warehouse, alerter` 各个模块解耦合,方便理解与定制开发。
|
||||
> HertzBeat 支持更自由化的告警配置(计算表达式),支持告警通知,告警模版,邮件钉钉微信飞书等及时通知送达
|
||||
> 欢迎登录 HertzBeat 的 [云环境TanCloud](https://console.tancloud.cn) 试用发现更多。
|
||||
> 我们正在快速迭代中,欢迎参与加入一起共建项目开源生态。
|
||||
|
||||
> `HertzBeat`的多类型支持,易扩展,低耦合,希望能帮助开发者和中小团队快速搭建自有监控系统。
|
||||
|
||||
老铁们可以通过演示视频来直观了解功能: https://www.bilibili.com/video/BV1DY4y1i7ts
|
||||
|
||||
欢迎在线试用 [https://console.tancloud.cn](https://gitee.com/link?target=https%3A%2F%2Fconsole.tancloud.cn)
|
||||
|
||||
优化后的参数输入界面:
|
||||

|
||||
|
||||
Linux新增指标:
|
||||

|
||||
|
||||
ORACLE监控:
|
||||
哦豁!oracle环境不在了,之前没有截图,先脑补一张!
|
||||
|
||||
**仓库地址**
|
||||
|
||||
[Github](https://github.com/dromara/hertzbeat) https://github.com/dromara/hertzbeat
|
||||
[Gitee](https://gitee.com/dromara/hertzbeat) https://gitee.com/dromara/hertzbeat
|
||||
|
||||
看到这里不妨给个Star支持下哦,灰常感谢,弯腰!!
|
||||
@@ -38,6 +38,7 @@ sidebar_label: Linux操作系统
|
||||
| interrupt | 个数 | CPU中断数量 |
|
||||
| load | 无 | CPU最近1/5/15分钟的平均负载 |
|
||||
| context_switch | 个数 | 当前上下文切换数量 |
|
||||
| usage | % | CPU使用率 |
|
||||
|
||||
|
||||
#### 指标集合:memory
|
||||
@@ -49,6 +50,7 @@ sidebar_label: Linux操作系统
|
||||
| free | Mb | 空闲内存容量 |
|
||||
| buff_cache | Mb | 缓存占用内存 |
|
||||
| available | Mb | 剩余可用内存容 |
|
||||
| usage | % | 内存使用率 |
|
||||
|
||||
#### 指标集合:disk
|
||||
|
||||
@@ -68,3 +70,12 @@ sidebar_label: Linux操作系统
|
||||
| receive_bytes | byte | 入站数据流量(bytes) |
|
||||
| transmit_bytes | byte | 出站数据流量(bytes) |
|
||||
|
||||
#### 指标集合:disk_free
|
||||
|
||||
| 指标名称 | 指标单位 | 指标帮助描述 |
|
||||
| ----------- | ----------- | ----------- |
|
||||
| filesystem | 无 | 文件系统的名称 |
|
||||
| used | Mb | 已使用磁盘大小 |
|
||||
| available | Mb | 可用磁盘大小 |
|
||||
| usage | % | 使用率 |
|
||||
| mounted | 无 | 挂载点目录 |
|
||||
|
||||
@@ -18,10 +18,11 @@ TDengine是一款国产的开源物联网时序型数据库,我们使用其替
|
||||
```
|
||||
2. Docker安装TDengine
|
||||
```
|
||||
$ docker run -d -p 6030-6049:6030-6049 -p 6030-6049:6030-6049/udp -v /opt/taosdata:/var/lib/taos --name tdengine tdengine/tdengine:2.4.0.12
|
||||
$ docker run -d -p 6030-6049:6030-6049 -p 6030-6049:6030-6049/udp -v /opt/taosdata:/var/lib/taos --name tdengine -e TZ=Asia/Shanghai tdengine/tdengine:2.4.0.12
|
||||
526aa188da767ae94b244226a2b2eec2b5f17dd8eff594533d9ec0cd0f3a1ccd
|
||||
```
|
||||
`-v /opt/taosdata:/var/lib/taos` 为tdengine数据目录本地持久化挂载,需将`/opt/taosdata`替换为实际本地存在的目录
|
||||
`-v /opt/taosdata:/var/lib/taos` 为tdengine数据目录本地持久化挂载,需将`/opt/taosdata`替换为实际本地存在的目录
|
||||
`-e TZ="Asia/Shanghai"` 为tdengine设置时区,这里可选设置对应的时区
|
||||
使用```$ docker ps```查看数据库是否启动成功
|
||||
|
||||
### 创建数据库实例
|
||||
@@ -51,4 +52,4 @@ TDengine是一款国产的开源物联网时序型数据库,我们使用其替
|
||||
```
|
||||
|
||||
**注意⚠️若是安装包安装的TDengine2.3+版本**
|
||||
> 除了启动server外,还需执行 `systemctl start taosadapter` 启动 adapter
|
||||
> 除了启动server外,还需执行 `systemctl start taosadapter` 启动 adapter
|
||||
|
||||
@@ -28,7 +28,7 @@ function Home() {
|
||||
<h1 className="hero__title">
|
||||
<img style={{width: '500px', marginTop: '100px'}} src={cdnTransfer('img/hertzbeat-brand.svg')} alt={'#'}/>
|
||||
</h1>
|
||||
<p className="hero__subtitle"><Translate>易用友好的监控告警系统</Translate></p>
|
||||
<p className="hero__subtitle"><Translate>易用友好的云监控系统</Translate></p>
|
||||
<div className={styles.social}>
|
||||
<a href="https://console.tancloud.cn"><img src={cdnTransfer('img/badge/web-monitor.svg')} alt={''}/></a>
|
||||
<a href="https://console.tancloud.cn"><img src={cdnTransfer('img/badge/ping-connect.svg')} alt={''}/></a>
|
||||
|
||||
1
home/static/img/docs/hertzbeat-stru-en.svg
Normal file
1
home/static/img/docs/hertzbeat-stru-en.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 31 KiB |
@@ -30,7 +30,9 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Alarm information storage and distribution
|
||||
* 告警信息入库分发
|
||||
*
|
||||
* @author tom
|
||||
* @date 2021/12/10 12:58
|
||||
*/
|
||||
@@ -70,7 +72,7 @@ public class DispatchAlarm {
|
||||
try {
|
||||
Alert alert = dataQueue.pollAlertData();
|
||||
if (alert != null) {
|
||||
// 判断告警类型入库
|
||||
// Determining alarm type storage 判断告警类型入库
|
||||
storeAlertData(alert);
|
||||
// 通知分发
|
||||
sendAlertDataListener(alert);
|
||||
@@ -86,7 +88,7 @@ public class DispatchAlarm {
|
||||
}
|
||||
|
||||
private void storeAlertData(Alert alert) {
|
||||
// todo 使用缓存不直接操作库
|
||||
// todo Using the cache does not directly manipulate the library 使用缓存不直接操作库
|
||||
Monitor monitor = monitorService.getMonitor(alert.getMonitorId());
|
||||
if (monitor == null) {
|
||||
log.warn("Dispatch alarm the monitorId: {} not existed, ignored.", alert.getMonitorId());
|
||||
@@ -94,50 +96,70 @@ public class DispatchAlarm {
|
||||
}
|
||||
alert.setMonitorName(monitor.getName());
|
||||
if (monitor.getStatus() == CommonConstants.UN_MANAGE_CODE) {
|
||||
// When monitoring is not managed, ignore and silence its alarm messages
|
||||
// 当监控未管理时 忽略静默其告警信息
|
||||
return;
|
||||
}
|
||||
if (monitor.getStatus() == CommonConstants.AVAILABLE_CODE) {
|
||||
if (CommonConstants.AVAILABLE.equals(alert.getTarget())) {
|
||||
// Availability Alarm Need to change the monitoring status to unavailable
|
||||
// 可用性告警 需变更监控状态为不可用
|
||||
monitorService.updateMonitorStatus(monitor.getId(), CommonConstants.UN_AVAILABLE_CODE);
|
||||
} else if (CommonConstants.REACHABLE.equals(alert.getTarget())) {
|
||||
// Reachability alarm The monitoring status needs to be changed to unreachable
|
||||
// 可达性告警 需变更监控状态为不可达
|
||||
monitorService.updateMonitorStatus(monitor.getId(), CommonConstants.UN_REACHABLE_CODE);
|
||||
}
|
||||
} else {
|
||||
// If the alarm is restored, the monitoring state needs to be restored
|
||||
// 若是恢复告警 需对监控状态进行恢复
|
||||
if (alert.getStatus() == CommonConstants.ALERT_STATUS_CODE_RESTORED) {
|
||||
monitorService.updateMonitorStatus(alert.getMonitorId(), CommonConstants.AVAILABLE_CODE);
|
||||
}
|
||||
if (alert.getStatus() == CommonConstants.ALERT_STATUS_CODE_RESTORED) {
|
||||
monitorService.updateMonitorStatus(alert.getMonitorId(), CommonConstants.AVAILABLE_CODE);
|
||||
}
|
||||
}
|
||||
// 告警落库
|
||||
// Alarm drop library 告警落库
|
||||
alertService.addAlert(alert);
|
||||
}
|
||||
|
||||
private void sendAlertDataListener(Alert alert) {
|
||||
// todo 转发配置的邮件 微信 webhook
|
||||
// todo Forward configured email WeChat webhook 转发配置的邮件 微信 webhook
|
||||
List<NoticeReceiver> receivers = matchReceiverByNoticeRules(alert);
|
||||
// todo 发送通知这里暂时单线程
|
||||
// todo Send notification here temporarily single thread 发送通知这里暂时单线程
|
||||
for (NoticeReceiver receiver : receivers) {
|
||||
switch (receiver.getType()) {
|
||||
// todo 短信通知
|
||||
case 0: break;
|
||||
case 1: sendEmailAlert(receiver, alert); break;
|
||||
case 2: sendWebHookAlert(receiver, alert); break;
|
||||
case 3: sendWeChatAlert(receiver, alert); break;
|
||||
case 4: sendWeWorkRobotAlert(receiver, alert); break;
|
||||
case 5: sendDingTalkRobotAlert(receiver, alert); break;
|
||||
case 6: sendFlyBookAlert(receiver,alert); break;
|
||||
default: break;
|
||||
// todo SMS notification 短信通知
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
sendEmailAlert(receiver, alert);
|
||||
break;
|
||||
case 2:
|
||||
sendWebHookAlert(receiver, alert);
|
||||
break;
|
||||
case 3:
|
||||
sendWeChatAlert(receiver, alert);
|
||||
break;
|
||||
case 4:
|
||||
sendWeWorkRobotAlert(receiver, alert);
|
||||
break;
|
||||
case 5:
|
||||
sendDingTalkRobotAlert(receiver, alert);
|
||||
break;
|
||||
case 6:
|
||||
sendFlyBookAlert(receiver, alert);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send alert information through FeiShu
|
||||
* 通过飞书发送告警信息
|
||||
* @param receiver 接收人
|
||||
* @param alert 告警信息
|
||||
*
|
||||
* @param receiver Notification configuration information 通知配置信息
|
||||
* @param alert Alarm information 告警信息
|
||||
*/
|
||||
private void sendFlyBookAlert(NoticeReceiver receiver, Alert alert) {
|
||||
FlyBookWebHookDto flyBookWebHookDto = new FlyBookWebHookDto();
|
||||
@@ -183,9 +205,11 @@ public class DispatchAlarm {
|
||||
}
|
||||
|
||||
/**
|
||||
* Send alarm information through DingTalk robot
|
||||
* 通过钉钉机器人发送告警信息
|
||||
* @param receiver 通知配置信息
|
||||
* @param alert 告警信息
|
||||
*
|
||||
* @param receiver Notification configuration information 通知配置信息
|
||||
* @param alert Alarm information 告警信息
|
||||
*/
|
||||
private void sendDingTalkRobotAlert(NoticeReceiver receiver, Alert alert) {
|
||||
DingTalkWebHookDto dingTalkWebHookDto = new DingTalkWebHookDto();
|
||||
@@ -216,9 +240,11 @@ public class DispatchAlarm {
|
||||
}
|
||||
|
||||
/**
|
||||
* Send alarm information through enterprise WeChat
|
||||
* 通过企业微信发送告警信息
|
||||
* @param receiver 通知配置信息
|
||||
* @param alert 告警信息
|
||||
*
|
||||
* @param receiver Notification configuration information 通知配置信息
|
||||
* @param alert Alarm information 告警信息
|
||||
*/
|
||||
private void sendWeWorkRobotAlert(NoticeReceiver receiver, Alert alert) {
|
||||
WeWorkWebHookDto weWorkWebHookDTO = new WeWorkWebHookDto();
|
||||
@@ -231,7 +257,7 @@ public class DispatchAlarm {
|
||||
if (alert.getPriority() < CommonConstants.ALERT_PRIORITY_CODE_WARNING) {
|
||||
content.append("告警级别 : <font color=\"warning\">")
|
||||
.append(CommonUtil.transferAlertPriority(alert.getPriority())).append("</font>\n");
|
||||
}else {
|
||||
} else {
|
||||
content.append("告警级别 : <font color=\"comment\">")
|
||||
.append(CommonUtil.transferAlertPriority(alert.getPriority())).append("</font>\n");
|
||||
}
|
||||
@@ -273,28 +299,28 @@ public class DispatchAlarm {
|
||||
}
|
||||
|
||||
|
||||
private void sendEmailAlert(final NoticeReceiver receiver,final Alert alert){
|
||||
try{
|
||||
private void sendEmailAlert(final NoticeReceiver receiver, final Alert alert) {
|
||||
try {
|
||||
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
|
||||
MimeMessageHelper messageHelper = new MimeMessageHelper(mimeMessage,true,"UTF-8");
|
||||
MimeMessageHelper messageHelper = new MimeMessageHelper(mimeMessage, true, "UTF-8");
|
||||
messageHelper.setSubject("TanCloud探云-监控告警");
|
||||
//设置发件人Email
|
||||
//Set sender Email 设置发件人Email
|
||||
messageHelper.setFrom(emailFromUser);
|
||||
//设定收件人Email
|
||||
messageHelper.setTo(receiver.getEmail());
|
||||
//Set recipient Email 设定收件人Email
|
||||
messageHelper.setTo(receiver.getEmail());
|
||||
messageHelper.setSentDate(new Date());
|
||||
//构建邮件模版
|
||||
//Build email templates 构建邮件模版
|
||||
String process = mailService.buildAlertHtmlTemplate(alert);
|
||||
//设置邮件内容模版
|
||||
messageHelper.setText(process,true);
|
||||
//Set Email Content Template 设置邮件内容模版
|
||||
messageHelper.setText(process, true);
|
||||
javaMailSender.send(mimeMessage);
|
||||
}catch (Exception e){
|
||||
log.error("[邮箱告警] error,Exception information={}",e.getMessage());
|
||||
} catch (Exception e) {
|
||||
log.error("[Email Alert] Exception,Exception information={}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private List<NoticeReceiver> matchReceiverByNoticeRules(Alert alert) {
|
||||
// todo 使用缓存
|
||||
// todo use cache 使用缓存
|
||||
return noticeConfigService.getReceiverFilterRule(alert);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,17 +29,20 @@ import static com.usthe.common.util.CommonConstants.MONITOR_LOGIN_FAILED_CODE;
|
||||
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
|
||||
|
||||
/**
|
||||
* Authentication registration TOKEN management API
|
||||
* 认证注册TOKEN管理API
|
||||
*
|
||||
* @author tomsun28
|
||||
* @date 13:11 2019-05-26
|
||||
*/
|
||||
@Api(tags = "认证注册TOKEN管理API")
|
||||
@Api(tags = "en: Authentication registration TOKEN management API,zh: 认证注册TOKEN管理API")
|
||||
@RestController()
|
||||
@RequestMapping(value = "/account/auth", produces = {APPLICATION_JSON_VALUE})
|
||||
@Slf4j
|
||||
public class AccountController {
|
||||
|
||||
/**
|
||||
* Token validity time in seconds
|
||||
* TOKEN有效期时间 单位秒
|
||||
*/
|
||||
private static final long PERIOD_TIME = 3600L;
|
||||
@@ -50,7 +53,7 @@ public class AccountController {
|
||||
private SurenessAccountProvider accountProvider = new DocumentAccountProvider();
|
||||
|
||||
@PostMapping("/form")
|
||||
@ApiOperation(value = "账户登录", notes = "账户密码登录获取关联用户信息")
|
||||
@ApiOperation(value = "Account password login to obtain associated user information", notes = "账户密码登录获取关联用户信息")
|
||||
public ResponseEntity<Message<Map<String, String>>> authGetToken(@RequestBody LoginDto loginDto) {
|
||||
|
||||
SurenessAccount account = accountProvider.loadAccount(loginDto.getIdentifier());
|
||||
@@ -76,7 +79,7 @@ public class AccountController {
|
||||
}
|
||||
// Get the roles the user has - rbac
|
||||
List<String> roles = account.getOwnRoles();
|
||||
// 签发TOKEN
|
||||
// Issue TOKEN 签发TOKEN
|
||||
String issueToken = JsonWebTokenUtil.issueJwt(loginDto.getIdentifier(), PERIOD_TIME, roles);
|
||||
Map<String, Object> customClaimMap = new HashMap<>(1);
|
||||
customClaimMap.put("refresh", true);
|
||||
@@ -88,9 +91,9 @@ public class AccountController {
|
||||
}
|
||||
|
||||
@GetMapping("/refresh/{refreshToken}")
|
||||
@ApiOperation(value = "TOKEN刷新", notes = "使用刷新TOKEN重新获取TOKEN")
|
||||
@ApiOperation(value = "Use refresh TOKEN to re-acquire TOKEN", notes = "使用刷新TOKEN重新获取TOKEN")
|
||||
public ResponseEntity<Message<Map<String, String>>> refreshToken(
|
||||
@ApiParam(value = "刷新TOKEN", example = "xxx")
|
||||
@ApiParam(value = "en: Refresh TOKEN,zh: 刷新TOKEN", example = "xxx")
|
||||
@PathVariable("refreshToken") @NotNull final String refreshToken) {
|
||||
String userId;
|
||||
boolean isRefresh;
|
||||
@@ -116,7 +119,7 @@ public class AccountController {
|
||||
return ResponseEntity.ok(message);
|
||||
}
|
||||
List<String> roles = account.getOwnRoles();
|
||||
// 签发TOKEN
|
||||
// Issue TOKEN 签发TOKEN
|
||||
String issueToken = JsonWebTokenUtil.issueJwt(userId, PERIOD_TIME, roles);
|
||||
Map<String, Object> customClaimMap = new HashMap<>(1);
|
||||
customClaimMap.put("refresh", true);
|
||||
|
||||
@@ -21,11 +21,13 @@ import java.util.List;
|
||||
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
|
||||
|
||||
/**
|
||||
* Monitoring Type Management API
|
||||
* 监控类型管理API
|
||||
*
|
||||
* @author tomsun28
|
||||
* @date 2021/11/14 16:47
|
||||
*/
|
||||
@Api(tags = "监控类型管理API")
|
||||
@Api(tags = "en: Monitoring Type Management API,zh: 监控类型管理API")
|
||||
@RestController
|
||||
@RequestMapping(path = "/apps", produces = {APPLICATION_JSON_VALUE})
|
||||
public class AppController {
|
||||
@@ -34,31 +36,32 @@ public class AppController {
|
||||
private AppService appService;
|
||||
|
||||
@GetMapping(path = "/{app}/params")
|
||||
@ApiOperation(value = "查询监控类型的参数结构", notes = "根据app查询指定监控类型的需要输入参数的结构")
|
||||
@ApiOperation(value = "The structure of the input parameters required to specify the monitoring type according to the app query", notes = "根据app查询指定监控类型的需要输入参数的结构")
|
||||
public ResponseEntity<Message<List<ParamDefine>>> queryAppParamDefines(
|
||||
@ApiParam(value = "监控类型名称", example = "api") @PathVariable("app") final String app) {
|
||||
@ApiParam(value = "en: Monitoring type name,zh: 监控类型名称", example = "api") @PathVariable("app") final String app) {
|
||||
List<ParamDefine> paramDefines = appService.getAppParamDefines(app.toLowerCase());
|
||||
return ResponseEntity.ok(new Message<>(paramDefines));
|
||||
}
|
||||
|
||||
@GetMapping(path = "/{app}/define")
|
||||
@ApiOperation(value = "查询监控类型的结构定义", notes = "根据app查询指定监控类型的定义结构")
|
||||
@ApiOperation(value = "The definition structure of the specified monitoring type according to the app query", notes = "根据app查询指定监控类型的定义结构")
|
||||
public ResponseEntity<Message<Job>> queryAppDefine(
|
||||
@ApiParam(value = "监控类型名称", example = "api") @PathVariable("app") final String app) {
|
||||
@ApiParam(value = "en: Monitoring type name,zh: 监控类型名称", example = "api") @PathVariable("app") final String app) {
|
||||
Job define = appService.getAppDefine(app.toLowerCase());
|
||||
return ResponseEntity.ok(new Message<>(define));
|
||||
}
|
||||
|
||||
@GetMapping(path = "/hierarchy")
|
||||
@ApiOperation(value = "查询全部监控指标层级", notes = "查询所有监控的类型-指标组-指标层级,以层级结构输出")
|
||||
@ApiOperation(value = "Query all monitored types-indicator group-indicator level, output in a hierarchical structure", notes = "查询所有监控的类型-指标组-指标层级,以层级结构输出")
|
||||
public ResponseEntity<Message<List<Hierarchy>>> queryAppsHierarchy(
|
||||
@ApiParam(value = "语言类型", example = "zh-CN", defaultValue = "zh-CN")
|
||||
@ApiParam(value = "en: language type,zh: 语言类型",
|
||||
example = "zh-CN", defaultValue = "zh-CN")
|
||||
@RequestParam(name = "lang", required = false) String lang) {
|
||||
if (lang == null || "".equals(lang)) {
|
||||
lang = "zh-CN";
|
||||
}
|
||||
lang = "zh-cn".equalsIgnoreCase(lang)? "zh-CN" : lang;
|
||||
lang = "en-us".equalsIgnoreCase(lang)? "en-US" : lang;
|
||||
lang = "zh-cn".equalsIgnoreCase(lang) ? "zh-CN" : lang;
|
||||
lang = "en-us".equalsIgnoreCase(lang) ? "en-US" : lang;
|
||||
List<Hierarchy> appHierarchies = appService.getAllAppHierarchy(lang);
|
||||
return ResponseEntity.ok(new Message<>(appHierarchies));
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.usthe.manager.controller;
|
||||
|
||||
import com.usthe.common.entity.dto.Message;
|
||||
import com.usthe.common.entity.manager.Monitor;
|
||||
import com.usthe.manager.pojo.dto.MonitorDto;
|
||||
import com.usthe.manager.service.MonitorService;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -23,11 +24,13 @@ import static com.usthe.common.util.CommonConstants.MONITOR_NOT_EXIST_CODE;
|
||||
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
|
||||
|
||||
/**
|
||||
* Monitoring management API
|
||||
* 监控管理API
|
||||
*
|
||||
* @author tomsun28
|
||||
* @date 2021/11/14 10:57
|
||||
*/
|
||||
@Api(tags = "监控管理API")
|
||||
@Api(tags = "en: Monitoring management API,zh: 监控管理API")
|
||||
@RestController
|
||||
@RequestMapping(path = "/monitor", produces = {APPLICATION_JSON_VALUE})
|
||||
public class MonitorController {
|
||||
@@ -36,12 +39,12 @@ public class MonitorController {
|
||||
private MonitorService monitorService;
|
||||
|
||||
@PostMapping
|
||||
@ApiOperation(value = "新增监控", notes = "新增一个监控应用")
|
||||
@ApiOperation(value = "Add a monitoring application", notes = "新增一个监控应用")
|
||||
public ResponseEntity<Message<Void>> addNewMonitor(@Valid @RequestBody MonitorDto monitorDto) {
|
||||
// 校验请求数据
|
||||
// Verify request data 校验请求数据
|
||||
monitorService.validate(monitorDto, false);
|
||||
if (monitorDto.isDetected()) {
|
||||
// 进行探测
|
||||
// Probe 进行探测
|
||||
monitorService.detectMonitor(monitorDto.getMonitor(), monitorDto.getParams());
|
||||
}
|
||||
monitorService.addMonitor(monitorDto.getMonitor(), monitorDto.getParams());
|
||||
@@ -49,12 +52,12 @@ public class MonitorController {
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@ApiOperation(value = "修改监控", notes = "修改一个已存在监控应用")
|
||||
@ApiOperation(value = "Modify an existing monitoring application", notes = "修改一个已存在监控应用")
|
||||
public ResponseEntity<Message<Void>> modifyMonitor(@Valid @RequestBody MonitorDto monitorDto) {
|
||||
// 校验请求数据
|
||||
// Verify request data 校验请求数据
|
||||
monitorService.validate(monitorDto, true);
|
||||
if (monitorDto.isDetected()) {
|
||||
// 进行探测
|
||||
// Probe 进行探测
|
||||
monitorService.detectMonitor(monitorDto.getMonitor(), monitorDto.getParams());
|
||||
}
|
||||
monitorService.modifyMonitor(monitorDto.getMonitor(), monitorDto.getParams());
|
||||
@@ -62,9 +65,10 @@ public class MonitorController {
|
||||
}
|
||||
|
||||
@GetMapping(path = "/{id}")
|
||||
@ApiOperation(value = "查询监控", notes = "根据监控ID获取监控信息")
|
||||
@ApiOperation(value = "Obtain monitoring information based on monitoring ID", notes = "根据监控ID获取监控信息")
|
||||
public ResponseEntity<Message<MonitorDto>> getMonitor(
|
||||
@ApiParam(value = "监控ID", example = "6565463543") @PathVariable("id") final long id) {
|
||||
// Get monitoring information
|
||||
// 获取监控信息
|
||||
MonitorDto monitorDto = monitorService.getMonitorDto(id);
|
||||
Message.MessageBuilder<MonitorDto> messageBuilder = Message.builder();
|
||||
@@ -77,16 +81,20 @@ public class MonitorController {
|
||||
}
|
||||
|
||||
@DeleteMapping(path = "/{id}")
|
||||
@ApiOperation(value = "删除监控", notes = "根据监控ID删除监控应用,监控不存在也是删除成功")
|
||||
@ApiOperation(value = "Delete monitoring application based on monitoring ID", notes = "根据监控ID删除监控应用")
|
||||
public ResponseEntity<Message<Void>> deleteMonitor(
|
||||
@ApiParam(value = "监控ID", example = "6565463543") @PathVariable("id") final long id) {
|
||||
// 删除监控,监控不存在或删除成功都返回成功
|
||||
@ApiParam(value = "en: Monitor ID,zh: 监控ID", example = "6565463543") @PathVariable("id") final long id) {
|
||||
// delete monitor 删除监控
|
||||
Monitor monitor = monitorService.getMonitor(id);
|
||||
if (monitor == null) {
|
||||
return ResponseEntity.ok(new Message<>("The specified monitoring was not queried, please check whether the parameters are correct"));
|
||||
}
|
||||
monitorService.deleteMonitor(id);
|
||||
return ResponseEntity.ok(new Message<>("Delete success"));
|
||||
}
|
||||
|
||||
@PostMapping(path = "/detect")
|
||||
@ApiOperation(value = "探测监控", notes = "根据监控信息去对此监控进行可用性探测")
|
||||
@ApiOperation(value = "Perform availability detection on this monitoring based on monitoring information", notes = "根据监控信息去对此监控进行可用性探测")
|
||||
public ResponseEntity<Message<Void>> detectMonitor(@Valid @RequestBody MonitorDto monitorDto) {
|
||||
monitorService.validate(monitorDto, null);
|
||||
monitorService.detectMonitor(monitorDto.getMonitor(), monitorDto.getParams());
|
||||
|
||||
@@ -29,11 +29,13 @@ import java.util.List;
|
||||
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
|
||||
|
||||
/**
|
||||
* Monitor and manage batch API
|
||||
* 监控管理批量API
|
||||
*
|
||||
* @author tom
|
||||
* @date 2021/12/1 20:43
|
||||
*/
|
||||
@Api(tags = "监控列表API")
|
||||
@Api(tags = "en: Monitor and manage batch API,zh: 监控列表API")
|
||||
@RestController
|
||||
@RequestMapping(path = "/monitors", produces = {APPLICATION_JSON_VALUE})
|
||||
public class MonitorsController {
|
||||
@@ -44,22 +46,23 @@ public class MonitorsController {
|
||||
private MonitorService monitorService;
|
||||
|
||||
@GetMapping
|
||||
@ApiOperation(value = "查询监控列表", notes = "根据查询过滤项获取监控信息列表")
|
||||
@ApiOperation(value = "Obtain a list of monitoring information based on query filter items",
|
||||
notes = "根据查询过滤项获取监控信息列表")
|
||||
public ResponseEntity<Message<Page<Monitor>>> getMonitors(
|
||||
@ApiParam(value = "监控ID", example = "6565463543") @RequestParam(required = false) final List<Long> ids,
|
||||
@ApiParam(value = "监控类型", example = "linux") @RequestParam(required = false) final String app,
|
||||
@ApiParam(value = "监控名称,模糊查询", example = "linux-127.0.0.1") @RequestParam(required = false) final String name,
|
||||
@ApiParam(value = "监控Host,模糊查询", example = "127.0.0.1") @RequestParam(required = false) final String host,
|
||||
@ApiParam(value = "监控状态 0:未监控,1:可用,2:不可用,3:不可达,4:挂起,9:全部状态", example = "1") @RequestParam(required = false) final Byte status,
|
||||
@ApiParam(value = "排序字段,默认id", example = "name") @RequestParam(defaultValue = "id") final String sort,
|
||||
@ApiParam(value = "排序方式,asc:升序,desc:降序", example = "desc") @RequestParam(defaultValue = "desc") final String order,
|
||||
@ApiParam(value = "列表当前分页", example = "0") @RequestParam(defaultValue = "0") int pageIndex,
|
||||
@ApiParam(value = "列表分页数量", example = "8") @RequestParam(defaultValue = "8") int pageSize) {
|
||||
@ApiParam(value = "en: Monitor ID,zh: 监控ID", example = "6565463543") @RequestParam(required = false) final List<Long> ids,
|
||||
@ApiParam(value = "en: Monitor Type,zh: 监控类型", example = "linux") @RequestParam(required = false) final String app,
|
||||
@ApiParam(value = "en: Monitor Name,zh: 监控名称,模糊查询", example = "linux-127.0.0.1") @RequestParam(required = false) final String name,
|
||||
@ApiParam(value = "en: Monitor Host,zh: 监控Host,模糊查询", example = "127.0.0.1") @RequestParam(required = false) final String host,
|
||||
@ApiParam(value = "en: Monitor Status,zh: 监控状态 0:未监控,1:可用,2:不可用,3:不可达,4:挂起,9:全部状态", example = "1") @RequestParam(required = false) final Byte status,
|
||||
@ApiParam(value = "en: Sort Field,default id,zh: 排序字段,默认id", example = "name") @RequestParam(defaultValue = "id") final String sort,
|
||||
@ApiParam(value = "en: Sort by,zh: 排序方式,asc:升序,desc:降序", example = "desc") @RequestParam(defaultValue = "desc") final String order,
|
||||
@ApiParam(value = "en: List current page,zh: 列表当前分页", example = "0") @RequestParam(defaultValue = "0") int pageIndex,
|
||||
@ApiParam(value = "en: Number of list pagination,zh: 列表分页数量", example = "8") @RequestParam(defaultValue = "8") int pageSize) {
|
||||
|
||||
Specification<Monitor> specification = (root, query, criteriaBuilder) -> {
|
||||
List<Predicate> andList = new ArrayList<>();
|
||||
if (ids != null && !ids.isEmpty()) {
|
||||
CriteriaBuilder.In<Long> inPredicate= criteriaBuilder.in(root.get("id"));
|
||||
CriteriaBuilder.In<Long> inPredicate = criteriaBuilder.in(root.get("id"));
|
||||
for (long id : ids) {
|
||||
inPredicate.value(id);
|
||||
}
|
||||
@@ -95,10 +98,10 @@ public class MonitorsController {
|
||||
} else if (orPredicate.getExpressions().isEmpty()) {
|
||||
return query.where(andPredicate).getRestriction();
|
||||
} else {
|
||||
return query.where(andPredicate,orPredicate).getRestriction();
|
||||
return query.where(andPredicate, orPredicate).getRestriction();
|
||||
}
|
||||
};
|
||||
// 分页是必须的
|
||||
// Pagination is a must 分页是必须的
|
||||
Sort sortExp = Sort.by(new Sort.Order(Sort.Direction.fromString(order), sort));
|
||||
PageRequest pageRequest = PageRequest.of(pageIndex, pageSize, sortExp);
|
||||
Page<Monitor> monitorPage = monitorService.getMonitors(specification, pageRequest);
|
||||
@@ -107,18 +110,20 @@ public class MonitorsController {
|
||||
}
|
||||
|
||||
@GetMapping(path = "/{app}")
|
||||
@ApiOperation(value = "查询指定监控类型的监控列表", notes = "根据查询过滤指定监控类型的所有获取监控信息列表")
|
||||
@ApiOperation(value = "Filter all acquired monitoring information lists of the specified monitoring type according to the query",
|
||||
notes = "根据查询过滤指定监控类型的所有获取监控信息列表")
|
||||
public ResponseEntity<Message<List<Monitor>>> getAppMonitors(
|
||||
@ApiParam(value = "监控类型", example = "linux") @PathVariable(required = false) final String app) {
|
||||
@ApiParam(value = "en: Monitoring type,zh: 监控类型", example = "linux") @PathVariable(required = false) final String app) {
|
||||
List<Monitor> monitors = monitorService.getAppMonitors(app);
|
||||
Message<List<Monitor>> message = new Message<>(monitors);
|
||||
return ResponseEntity.ok(message);
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@ApiOperation(value = "批量删除监控", notes = "根据监控ID列表批量删除监控项")
|
||||
@ApiOperation(value = "Delete monitoring items in batches according to the monitoring ID list",
|
||||
notes = "根据监控ID列表批量删除监控项")
|
||||
public ResponseEntity<Message<Void>> deleteMonitors(
|
||||
@ApiParam(value = "监控IDs", example = "6565463543") @RequestParam(required = false) List<Long> ids
|
||||
@ApiParam(value = "en: Monitoring ID List,zh: 监控ID列表", example = "6565463543") @RequestParam(required = false) List<Long> ids
|
||||
) {
|
||||
if (ids != null && !ids.isEmpty()) {
|
||||
monitorService.deleteMonitors(new HashSet<>(ids));
|
||||
@@ -128,9 +133,10 @@ public class MonitorsController {
|
||||
}
|
||||
|
||||
@DeleteMapping("manage")
|
||||
@ApiOperation(value = "批量取消纳管监控", notes = "根据监控ID列表批量取消纳管监控项")
|
||||
@ApiOperation(value = "Unmanaged monitoring items in batches according to the monitoring ID list",
|
||||
notes = "根据监控ID列表批量取消纳管监控项")
|
||||
public ResponseEntity<Message<Void>> cancelManageMonitors(
|
||||
@ApiParam(value = "监控IDs", example = "6565463543") @RequestParam(required = false) List<Long> ids
|
||||
@ApiParam(value = "en: Monitoring ID List,zh: 监控ID列表", example = "6565463543") @RequestParam(required = false) List<Long> ids
|
||||
) {
|
||||
if (ids != null && !ids.isEmpty()) {
|
||||
monitorService.cancelManageMonitors(new HashSet<>(ids));
|
||||
@@ -140,9 +146,10 @@ public class MonitorsController {
|
||||
}
|
||||
|
||||
@GetMapping("manage")
|
||||
@ApiOperation(value = "批量启动纳管监控", notes = "根据监控ID列表批量启动纳管监控项")
|
||||
@ApiOperation(value = "Start the managed monitoring items in batches according to the monitoring ID list",
|
||||
notes = "根据监控ID列表批量启动纳管监控项")
|
||||
public ResponseEntity<Message<Void>> enableManageMonitors(
|
||||
@ApiParam(value = "监控IDs", example = "6565463543") @RequestParam(required = false) List<Long> ids
|
||||
@ApiParam(value = "en: Monitor ID List,zh: 监控ID列表", example = "6565463543") @RequestParam(required = false) List<Long> ids
|
||||
) {
|
||||
if (ids != null && !ids.isEmpty()) {
|
||||
monitorService.enableManageMonitors(new HashSet<>(ids));
|
||||
|
||||
@@ -28,11 +28,13 @@ import java.util.List;
|
||||
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
|
||||
|
||||
/**
|
||||
* Message Notification Configuration API
|
||||
* 消息通知配置API
|
||||
*
|
||||
* @author tom
|
||||
* @date 2021/12/16 16:18
|
||||
*/
|
||||
@Api(tags = "消息通知配置API")
|
||||
@Api(tags = "en: Message Notification Configuration API,zh: 消息通知配置API")
|
||||
@RestController()
|
||||
@RequestMapping(value = "/notice", produces = {APPLICATION_JSON_VALUE})
|
||||
public class NoticeConfigController {
|
||||
@@ -41,32 +43,36 @@ public class NoticeConfigController {
|
||||
private NoticeConfigService noticeConfigService;
|
||||
|
||||
@PostMapping(path = "/receiver")
|
||||
@ApiOperation(value = "新增接收人", notes = "新增一个接收人")
|
||||
@ApiOperation(value = "Add a recipient", notes = "新增一个接收人")
|
||||
public ResponseEntity<Message<Void>> addNewNoticeReceiver(@Valid @RequestBody NoticeReceiver noticeReceiver) {
|
||||
noticeConfigService.addReceiver(noticeReceiver);
|
||||
return ResponseEntity.ok(new Message<>("Add success"));
|
||||
}
|
||||
|
||||
@PutMapping(path = "/receiver")
|
||||
@ApiOperation(value = "修改接收人", notes = "修改已存在的接收人信息")
|
||||
@ApiOperation(value = "Modify existing recipient information", notes = "修改已存在的接收人信息")
|
||||
public ResponseEntity<Message<Void>> editNoticeReceiver(@Valid @RequestBody NoticeReceiver noticeReceiver) {
|
||||
noticeConfigService.editReceiver(noticeReceiver);
|
||||
return ResponseEntity.ok(new Message<>("Edit success"));
|
||||
}
|
||||
|
||||
@DeleteMapping(path = "/receiver/{id}")
|
||||
@ApiOperation(value = "删除指定接收人", notes = "删除已存在的接收人信息")
|
||||
@ApiOperation(value = "Delete existing recipient information", notes = "删除已存在的接收人信息")
|
||||
public ResponseEntity<Message<Void>> deleteNoticeReceiver(
|
||||
@ApiParam(value = "接收人ID", example = "6565463543") @PathVariable("id") final Long receiverId) {
|
||||
// 不存在或删除成功都返回成功
|
||||
@ApiParam(value = "en: Recipient ID,zh: 接收人ID", example = "6565463543") @PathVariable("id") final Long receiverId) {
|
||||
NoticeReceiver noticeReceiver = noticeConfigService.getReceiverById(receiverId);
|
||||
if (noticeReceiver == null) {
|
||||
return ResponseEntity.ok(new Message<>("The relevant information of the recipient could not be found, please check whether the parameters are correct"));
|
||||
}
|
||||
noticeConfigService.deleteReceiver(receiverId);
|
||||
return ResponseEntity.ok(new Message<>("Delete success"));
|
||||
}
|
||||
|
||||
@GetMapping(path = "/receivers")
|
||||
@ApiOperation(value = "查询消息通知接收人", notes = "根据查询过滤项获取消息通知接收人列表")
|
||||
@ApiOperation(value = "Get a list of message notification recipients based on query filter items",
|
||||
notes = "根据查询过滤项获取消息通知接收人列表")
|
||||
public ResponseEntity<Message<List<NoticeReceiver>>> getReceivers(
|
||||
@ApiParam(value = "接收人名称,模糊查询", example = "tom") @RequestParam(required = false) final String name) {
|
||||
@ApiParam(value = "en: Recipient name,zh: 接收人名称,模糊查询", example = "tom") @RequestParam(required = false) final String name) {
|
||||
|
||||
Specification<NoticeReceiver> specification = (root, query, criteriaBuilder) -> {
|
||||
Predicate predicate = criteriaBuilder.conjunction();
|
||||
@@ -83,32 +89,38 @@ public class NoticeConfigController {
|
||||
|
||||
|
||||
@PostMapping(path = "/rule")
|
||||
@ApiOperation(value = "新增通知策略", notes = "新增一个通知策略")
|
||||
@ApiOperation(value = "Add a notification policy", notes = "新增一个通知策略")
|
||||
public ResponseEntity<Message<Void>> addNewNoticeRule(@Valid @RequestBody NoticeRule noticeRule) {
|
||||
noticeConfigService.addNoticeRule(noticeRule);
|
||||
return ResponseEntity.ok(new Message<>("Add success"));
|
||||
}
|
||||
|
||||
@PutMapping(path = "/rule")
|
||||
@ApiOperation(value = "修改通知策略", notes = "修改已存在的通知策略信息")
|
||||
@ApiOperation(value = "Modify existing notification policy information", notes = "修改已存在的通知策略信息")
|
||||
public ResponseEntity<Message<Void>> editNoticeRule(@Valid @RequestBody NoticeRule noticeRule) {
|
||||
noticeConfigService.editNoticeRule(noticeRule);
|
||||
return ResponseEntity.ok(new Message<>("Edit success"));
|
||||
}
|
||||
|
||||
@DeleteMapping(path = "/rule/{id}")
|
||||
@ApiOperation(value = "删除指定通知策略", notes = "删除已存在的通知策略信息")
|
||||
@ApiOperation(value = "Delete existing notification policy information", notes = "删除已存在的通知策略信息")
|
||||
public ResponseEntity<Message<Void>> deleteNoticeRule(
|
||||
@ApiParam(value = "通知策略ID", example = "6565463543") @PathVariable("id") final Long ruleId) {
|
||||
// 不存在或删除成功都返回成功
|
||||
@ApiParam(value = "en: Notification Policy ID,zh: 通知策略ID", example = "6565463543") @PathVariable("id") final Long ruleId) {
|
||||
// Returns success if it does not exist or if the deletion is successful
|
||||
// todo 不存在或删除成功都返回成功
|
||||
NoticeRule noticeRule = noticeConfigService.getNoticeRulesById(ruleId);
|
||||
if (noticeRule == null) {
|
||||
return ResponseEntity.ok(new Message<>("The specified notification rule could not be queried, please check whether the parameters are correct"));
|
||||
}
|
||||
noticeConfigService.deleteNoticeRule(ruleId);
|
||||
return ResponseEntity.ok(new Message<>("Delete success"));
|
||||
}
|
||||
|
||||
@GetMapping(path = "/rules")
|
||||
@ApiOperation(value = "查询消息通知策略", notes = "根据查询过滤项获取消息通知策略列表")
|
||||
@ApiOperation(value = "Get a list of message notification policies based on query filter items",
|
||||
notes = "根据查询过滤项获取消息通知策略列表")
|
||||
public ResponseEntity<Message<List<NoticeRule>>> getRules(
|
||||
@ApiParam(value = "接收人名称,模糊查询", example = "rule1") @RequestParam(required = false) final String name) {
|
||||
@ApiParam(value = "en: Recipient name,zh: 接收人名称,模糊查询", example = "rule1") @RequestParam(required = false) final String name) {
|
||||
|
||||
Specification<NoticeRule> specification = (root, query, criteriaBuilder) -> {
|
||||
Predicate predicate = criteriaBuilder.conjunction();
|
||||
|
||||
@@ -18,11 +18,13 @@ import java.util.List;
|
||||
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
|
||||
|
||||
/**
|
||||
* System Summary Statistics API
|
||||
* 系统摘要统计API
|
||||
*
|
||||
* @author tom
|
||||
* @date 2021/12/7 15:57
|
||||
*/
|
||||
@Api(tags = "系统摘要统计API")
|
||||
@Api(tags = "en: System Summary Statistics API,zh: 系统摘要统计API")
|
||||
@RestController
|
||||
@RequestMapping(path = "/summary", produces = {APPLICATION_JSON_VALUE})
|
||||
public class SummaryController {
|
||||
@@ -31,7 +33,7 @@ public class SummaryController {
|
||||
private MonitorService monitorService;
|
||||
|
||||
@GetMapping
|
||||
@ApiOperation(value = "查询应用类别监控统计", notes = "查询所有应用类别监控统计信息")
|
||||
@ApiOperation(value = "Query all application category monitoring statistics", notes = "查询所有应用类别监控统计信息")
|
||||
public ResponseEntity<Message<Dashboard>> appMonitors() {
|
||||
List<AppCount> appsCount = monitorService.getAllAppMonitorsCount();
|
||||
Message<Dashboard> message = new Message<>(new Dashboard(appsCount));
|
||||
|
||||
@@ -14,6 +14,7 @@ import java.util.Set;
|
||||
|
||||
/**
|
||||
* AuthResources 数据库操作
|
||||
*
|
||||
* @author tomsun28
|
||||
* @date 2021/11/14 11:24
|
||||
*/
|
||||
@@ -21,50 +22,63 @@ public interface MonitorDao extends JpaRepository<Monitor, Long>, JpaSpecificati
|
||||
|
||||
|
||||
/**
|
||||
* Delete monitor based on monitor ID list
|
||||
* 根据监控ID列表删除监控
|
||||
* @param monitorIds 监控ID列表
|
||||
*
|
||||
* @param monitorIds Monitoring ID List 监控ID列表
|
||||
*/
|
||||
void deleteAllByIdIn(Set<Long> monitorIds);
|
||||
|
||||
/**
|
||||
* Query monitoring based on monitoring ID list
|
||||
* 根据监控ID列表查询监控
|
||||
* @param monitorIds 监控ID列表
|
||||
* @return 监控列表
|
||||
*
|
||||
* @param monitorIds Monitoring ID List 监控ID列表
|
||||
* @return Monitor List 监控列表
|
||||
*/
|
||||
List<Monitor> findMonitorsByIdIn(Set<Long> monitorIds);
|
||||
|
||||
/**
|
||||
* Query monitoring by monitoring type
|
||||
* 根据监控类型查询监控
|
||||
* @param app 监控类型
|
||||
* @return 监控列表
|
||||
*
|
||||
* @param app Monitor Type 监控类型
|
||||
* @return Monitor List 监控列表
|
||||
*/
|
||||
List<Monitor> findMonitorsByAppEquals(String app);
|
||||
|
||||
/**
|
||||
* Querying Monitoring of Sent Collection Tasks
|
||||
* 查询已下发采集任务的监控
|
||||
* @param status 监控状态
|
||||
* @return 监控列表
|
||||
*
|
||||
* @param status Monitor Status 监控状态
|
||||
* @return Monitor List 监控列表
|
||||
*/
|
||||
List<Monitor> findMonitorsByStatusNotInAndAndJobIdNotNull(List<Byte> status);
|
||||
|
||||
/**
|
||||
* 根据监控名称查询监控
|
||||
* @param name 监控名称
|
||||
* @return 监控列表
|
||||
* Query monitoring by monitoring name 根据监控名称查询监控
|
||||
*
|
||||
* @param name monitoring name 监控名称
|
||||
* @return monitoring list 监控列表
|
||||
*/
|
||||
Optional<Monitor> findMonitorByNameEquals(String name);
|
||||
|
||||
/**
|
||||
* Query the monitoring category - the number of monitoring corresponding to the status
|
||||
* 查询监控类别-状态对应的监控数量
|
||||
* @return 监控类别-状态与监控数量映射
|
||||
*
|
||||
* @return Monitoring Category-Status and Monitoring Quantity Mapping 监控类别-状态与监控数量映射
|
||||
*/
|
||||
@Query("select new com.usthe.manager.pojo.dto.AppCount(mo.app, mo.status, COUNT(mo.id)) from Monitor mo group by mo.app, mo.status")
|
||||
List<AppCount> findAppsStatusCount();
|
||||
|
||||
/**
|
||||
* Update the status of the specified monitor
|
||||
* 更新指定监控的状态
|
||||
* @param id 监控ID
|
||||
* @param status 监控状态
|
||||
*
|
||||
* @param id Monitor ID 监控ID
|
||||
* @param status 监控状态 Monitor Status
|
||||
*/
|
||||
@Modifying
|
||||
@Query("update Monitor set status = :status where id = :id")
|
||||
|
||||
@@ -8,27 +8,34 @@ import java.util.Set;
|
||||
|
||||
/**
|
||||
* ParamDao 数据库操作
|
||||
*
|
||||
* @author tomsun28
|
||||
* @date 2021/11/14 11:26
|
||||
*/
|
||||
public interface ParamDao extends JpaRepository<Param, Long> {
|
||||
|
||||
/**
|
||||
* Query the list of parameters associated with the monitoring ID'
|
||||
* 根据监控ID查询与之关联的参数列表
|
||||
* @param monitorId 监控ID
|
||||
* @return 参数值列表
|
||||
*
|
||||
* @param monitorId Monitor ID 监控ID
|
||||
* @return list of parameter values 参数值列表
|
||||
*/
|
||||
List<Param> findParamsByMonitorId(long monitorId);
|
||||
|
||||
/**
|
||||
* Remove the parameter list associated with the monitoring ID based on it
|
||||
* 根据监控ID删除与之关联的参数列表
|
||||
* @param monitorId 监控ID
|
||||
*
|
||||
* @param monitorId Monitor Id 监控ID
|
||||
*/
|
||||
void deleteParamsByMonitorId(long monitorId);
|
||||
|
||||
/**
|
||||
* Remove the parameter list associated with the monitoring ID list based on it
|
||||
* 根据监控ID列表删除与之关联的参数列表
|
||||
* @param monitorIds 监控ID列表
|
||||
*
|
||||
* @param monitorIds Monitoring ID List 监控ID列表
|
||||
*/
|
||||
void deleteParamsByMonitorIdIn(Set<Long> monitorIds);
|
||||
}
|
||||
|
||||
@@ -6,16 +6,20 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Param Define Database Operations
|
||||
* ParamDefine数据库操作
|
||||
*
|
||||
* @author tomsun28
|
||||
* @date 2021/11/14 11:27
|
||||
*/
|
||||
public interface ParamDefineDao extends JpaRepository<ParamDefine, Long> {
|
||||
|
||||
/**
|
||||
* Query the parameter definitions under it according to the monitoring type
|
||||
* 根据监控类型查询其下的参数定义
|
||||
* @param app 监控类型
|
||||
* @return 参数定义列表
|
||||
*
|
||||
* @param app Monitoring type 监控类型
|
||||
* @return parameter definition list 参数定义列表
|
||||
*/
|
||||
List<ParamDefine> findParamDefinesByApp(String app);
|
||||
}
|
||||
|
||||
@@ -11,8 +11,11 @@ import java.util.List;
|
||||
import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_WRITE;
|
||||
|
||||
/**
|
||||
* Hierarchical structure
|
||||
* 层级关系结构
|
||||
* eg: Monitoring Type Indicator Group Indicator Information Hierarchy Relationship
|
||||
* eg: 监控类型指标组指标信息层级关系
|
||||
*
|
||||
* @author tom
|
||||
* @date 2021/12/12 16:23
|
||||
*/
|
||||
@@ -21,18 +24,33 @@ import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_WRITE;
|
||||
@Data
|
||||
public class Hierarchy {
|
||||
|
||||
/**
|
||||
* Category value
|
||||
*/
|
||||
@ApiModelProperty(value = "类别值", example = "os", accessMode = READ_WRITE, position = 0)
|
||||
String category;
|
||||
|
||||
/**
|
||||
* Attribute value
|
||||
*/
|
||||
@ApiModelProperty(value = "属性值", example = "linux", accessMode = READ_WRITE, position = 1)
|
||||
String value;
|
||||
|
||||
/**
|
||||
* Attribute internationalization tag
|
||||
*/
|
||||
@ApiModelProperty(value = "属性国际化标签", example = "Linux系统", accessMode = READ_WRITE, position = 2)
|
||||
String label;
|
||||
|
||||
/**
|
||||
* Is it a leaf node
|
||||
*/
|
||||
@ApiModelProperty(value = "是否是叶子节点", example = "true", accessMode = READ_WRITE, position = 3)
|
||||
Boolean isLeaf = false;
|
||||
|
||||
/**
|
||||
* Next level of association
|
||||
*/
|
||||
@ApiModelProperty(value = "下一关联层级", accessMode = READ_WRITE, position = 4)
|
||||
private List<Hierarchy> children;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,9 @@ import javax.validation.constraints.NotBlank;
|
||||
import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_ONLY;
|
||||
|
||||
/**
|
||||
* Login registered account information transfer body username phone email
|
||||
* 登录注册账户信息传输体 username phone email
|
||||
*
|
||||
* @author tomsun28
|
||||
* @date 20:36 2019-08-01
|
||||
*/
|
||||
@@ -21,17 +23,27 @@ import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_ONLY;
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ApiModel(description = "账户信息传输体")
|
||||
@ApiModel(description = "en: Account information transfer body,zh: 账户信息传输体")
|
||||
public class LoginDto {
|
||||
|
||||
/**
|
||||
* type
|
||||
* 1. Account (email username and mobile phone number) password login 2. github login 3. WeChat login
|
||||
*/
|
||||
@ApiModelProperty(value = "类型", example = "1", accessMode = READ_ONLY, position = 0)
|
||||
@Range(min = 0, max = 4, message = "1.账户(邮箱用户名手机号)密码登录 2.github登录 3.微信登录")
|
||||
private Byte type;
|
||||
|
||||
/**
|
||||
* User ID
|
||||
*/
|
||||
@ApiModelProperty(value = "用户标识", example = "1", accessMode = READ_ONLY, position = 0)
|
||||
@NotBlank(message = "Identifier can not null")
|
||||
private String identifier;
|
||||
|
||||
/**
|
||||
* key
|
||||
*/
|
||||
@ApiModelProperty(value = "密钥", example = "1", accessMode = READ_ONLY, position = 0)
|
||||
@NotBlank(message = "Credential can not null")
|
||||
private String credential;
|
||||
|
||||
@@ -14,15 +14,18 @@ import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_ONLY;
|
||||
import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_WRITE;
|
||||
|
||||
/**
|
||||
* Monitoring Information External Interaction Entities
|
||||
* 监控信息对外交互实体
|
||||
*
|
||||
* @author tomsun28
|
||||
* @date 2021/11/14 10:13
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(description = "监控信息实体")
|
||||
@ApiModel(description = "en: Monitoring information entities,zh: 监控信息实体")
|
||||
public class MonitorDto {
|
||||
|
||||
/**
|
||||
* Monitoring entity
|
||||
* 监控实体
|
||||
*/
|
||||
@ApiModelProperty(value = "监控实体", accessMode = READ_WRITE, position = 0)
|
||||
@@ -31,17 +34,22 @@ public class MonitorDto {
|
||||
private Monitor monitor;
|
||||
|
||||
/**
|
||||
* 参数
|
||||
* Params 参数
|
||||
*/
|
||||
@ApiModelProperty(value = "监控参数", accessMode = READ_WRITE, position = 1)
|
||||
@NotNull
|
||||
@Valid
|
||||
private List<Param> params;
|
||||
|
||||
/**
|
||||
* List of indicator groups
|
||||
* 指标组列表
|
||||
*/
|
||||
@ApiModelProperty(value = "指标组列表", accessMode = READ_ONLY, position = 2)
|
||||
private List<String> metrics;
|
||||
|
||||
/**
|
||||
* Whether to detect
|
||||
* 是否探测
|
||||
*/
|
||||
@ApiModelProperty(value = "是否进行探测", accessMode = READ_WRITE, position = 3)
|
||||
|
||||
@@ -7,6 +7,7 @@ import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 企业微信机器人请求消息体
|
||||
*
|
||||
* @author 花城
|
||||
* @version 1.0
|
||||
* @date 2022/2/21 6:55 下午
|
||||
@@ -18,7 +19,14 @@ import lombok.NoArgsConstructor;
|
||||
public class WeWorkWebHookDto {
|
||||
|
||||
public static final String WEBHOOK_URL = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=";
|
||||
/**
|
||||
* markdown格式
|
||||
*/
|
||||
private static final String MARKDOWN = "markdown";
|
||||
/**
|
||||
* 文本格式
|
||||
*/
|
||||
private static final String TEXT = "TEXT";
|
||||
|
||||
/**
|
||||
* 消息类型
|
||||
|
||||
@@ -8,38 +8,49 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Monitoring Type Management Interface
|
||||
* 监控类型管理接口
|
||||
*
|
||||
* @author tomsun28
|
||||
* @date 2021/11/14 17:12
|
||||
*/
|
||||
public interface AppService {
|
||||
|
||||
/**
|
||||
* Query the defined parameter structure based on the monitoring type
|
||||
* 根据监控类型查询定义的参数结构
|
||||
* @param app 监控类型
|
||||
* @return 参数结构列表
|
||||
*
|
||||
* @param app Monitoring type 监控类型
|
||||
* @return list of parameter structures 参数结构列表
|
||||
*/
|
||||
List<ParamDefine> getAppParamDefines(String app);
|
||||
|
||||
/**
|
||||
* Get monitor structure definition based on monitor type name
|
||||
* 根据监控类型名称获取监控结构定义
|
||||
* @param app 监控类型名称
|
||||
* @return 监控结构定义
|
||||
* @throws IllegalArgumentException 当不存在即不支持对应名称的监控类型时抛出
|
||||
*
|
||||
* @param app Monitoring type name 监控类型名称
|
||||
* @return Monitoring Structure Definition 监控结构定义
|
||||
* @throws IllegalArgumentException Thrown when there is no monitoring type with the corresponding name that is not supported
|
||||
* 当不存在即不支持对应名称的监控类型时抛出
|
||||
*/
|
||||
Job getAppDefine(String app) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Get defined monitoring I 18 N resources
|
||||
* 获取定义的监控I18N资源
|
||||
* @param lang 语言类型
|
||||
* @return I18N资源
|
||||
*
|
||||
* @param lang Language type 语言类型
|
||||
* @return I18N Resources I18N资源
|
||||
*/
|
||||
Map<String, String> getI18nResources(String lang);
|
||||
|
||||
/**
|
||||
* Query all types of monitoring - indicator group - indicator level
|
||||
* 查询所有监控的类型-指标组-指标层级
|
||||
* @param lang 语言
|
||||
* @return 层级信息
|
||||
*
|
||||
* @param lang language 语言
|
||||
* @return level information 层级信息
|
||||
*/
|
||||
List<Hierarchy> getAllAppHierarchy(String lang);
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 邮箱发送服务
|
||||
* Email delivery service 邮箱发送服务
|
||||
*
|
||||
* @author 花城
|
||||
* @version 1.0
|
||||
@@ -15,9 +15,11 @@ import org.springframework.stereotype.Service;
|
||||
public interface MailService {
|
||||
|
||||
/**
|
||||
* Build an alert email template
|
||||
* 构建告警邮件模版
|
||||
* @param alert 告警信息
|
||||
* @return 邮件内容
|
||||
*
|
||||
* @param alert Alarm data element information 告警数据元信息
|
||||
* @return content of email 邮件内容
|
||||
*/
|
||||
String buildAlertHtmlTemplate(Alert alert);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import java.util.Set;
|
||||
|
||||
/**
|
||||
* 监控管理服务
|
||||
*
|
||||
* @author tomsun28
|
||||
* @date 2021/11/14 11:28
|
||||
*/
|
||||
@@ -22,103 +23,130 @@ public interface MonitorService {
|
||||
|
||||
|
||||
/**
|
||||
* Monitoring Availability Probes
|
||||
* 监控可用性探测
|
||||
* @param monitor 监控实体信息
|
||||
* @param params 参数信息
|
||||
* @throws MonitorDetectException 探测失败抛出
|
||||
*
|
||||
* @param monitor Monitoring entity information 监控实体信息
|
||||
* @param params Parameter information 参数信息
|
||||
* @throws MonitorDetectException Probe failure throws 探测失败抛出
|
||||
*/
|
||||
void detectMonitor(Monitor monitor, List<Param> params) throws MonitorDetectException;
|
||||
|
||||
/**
|
||||
* 新增监控
|
||||
* @param monitor 监控实体
|
||||
* @param params 参数信息
|
||||
* @throws RuntimeException 新增过程异常抛出
|
||||
* Add monitoring 新增监控
|
||||
*
|
||||
* @param monitor Monitoring Entity 监控实体
|
||||
* @param params Parameter information 参数信息
|
||||
* @throws RuntimeException Add process exception throw 新增过程异常抛出
|
||||
*/
|
||||
void addMonitor(Monitor monitor, List<Param> params) throws RuntimeException;
|
||||
|
||||
/**
|
||||
* Verify the correctness of request data parameters
|
||||
* 校验请求数据参数正确性
|
||||
*
|
||||
* @param monitorDto monitorDto
|
||||
* @param isModify 是否是修改监控
|
||||
* @throws IllegalArgumentException 校验参数错误抛出
|
||||
* @param isModify Whether it is a modification monitoring 是否是修改监控
|
||||
* @throws IllegalArgumentException Validation parameter error thrown 校验参数错误抛出
|
||||
*/
|
||||
void validate(MonitorDto monitorDto, Boolean isModify) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Modify update monitoring
|
||||
* 修改更新监控
|
||||
* @param monitor 监控实体
|
||||
* @param params 参数信息
|
||||
* @throws RuntimeException 修改过程中异常抛出
|
||||
*
|
||||
* @param monitor Monitor Entity 监控实体
|
||||
* @param params Parameter information 参数信息
|
||||
* @throws RuntimeException Exception thrown during modification 修改过程中异常抛出
|
||||
*/
|
||||
void modifyMonitor(Monitor monitor, List<Param> params) throws RuntimeException;
|
||||
|
||||
/**
|
||||
* Delete Monitor
|
||||
* 删除监控
|
||||
* @param id 监控ID
|
||||
* @throws RuntimeException 删除过程中异常抛出
|
||||
*
|
||||
* @param id Monitor ID 监控ID
|
||||
* @throws RuntimeException Exception thrown during deletion 删除过程中异常抛出
|
||||
*/
|
||||
void deleteMonitor(long id) throws RuntimeException;
|
||||
|
||||
/**
|
||||
* Batch delete monitoring
|
||||
* 批量删除监控
|
||||
* @param ids 监控ID
|
||||
* @throws RuntimeException 删除过程中异常抛出
|
||||
*
|
||||
* @param ids Monitoring ID List 监控ID列表
|
||||
* @throws RuntimeException Exception thrown during deletion 删除过程中异常抛出
|
||||
*/
|
||||
void deleteMonitors(Set<Long> ids) throws RuntimeException;
|
||||
|
||||
/**
|
||||
* Get monitoring information
|
||||
* 获取监控信息
|
||||
* @param id 监控ID
|
||||
* @return MonitorDto
|
||||
* @throws RuntimeException 查询过程中异常抛出
|
||||
*
|
||||
* @param id Monitor ID 监控ID
|
||||
* @return MonitorDto Monitor Entity 監控实体
|
||||
* @throws RuntimeException Exception thrown during query 查询过程中异常抛出
|
||||
*/
|
||||
MonitorDto getMonitorDto(long id) throws RuntimeException;
|
||||
|
||||
/**
|
||||
* Dynamic conditional query
|
||||
* 动态条件查询
|
||||
* @param specification 查询条件
|
||||
* @param pageRequest 分页参数
|
||||
* @return 查询结果
|
||||
*
|
||||
* @param specification Query conditions 查询条件
|
||||
* @param pageRequest Pagination parameters 分页参数
|
||||
* @return Search Result 查询结果
|
||||
*/
|
||||
Page<Monitor> getMonitors(Specification<Monitor> specification, PageRequest pageRequest);
|
||||
|
||||
/**
|
||||
* Unmanaged monitoring items in batches according to the monitoring ID list
|
||||
* 根据监控ID列表批量取消纳管监控项
|
||||
* @param ids 监控IDs
|
||||
*
|
||||
* @param ids Monitoring ID List 监控ID列表
|
||||
*/
|
||||
void cancelManageMonitors(HashSet<Long> ids);
|
||||
|
||||
/**
|
||||
* Start the managed monitoring items in batches according to the monitoring ID list
|
||||
* 根据监控ID列表批量启动纳管监控项
|
||||
* @param ids 监控IDs
|
||||
*
|
||||
* @param ids Monitoring ID List 监控ID列表
|
||||
*/
|
||||
void enableManageMonitors(HashSet<Long> ids);
|
||||
|
||||
/**
|
||||
* Query the monitoring category and its corresponding monitoring quantity
|
||||
* 查询监控类别及其对应的监控数量
|
||||
* @return 监控类别与监控数量映射
|
||||
*
|
||||
* @return Monitoring Category and Monitoring Quantity Mapping 监控类别与监控数量映射
|
||||
*/
|
||||
List<AppCount> getAllAppMonitorsCount();
|
||||
|
||||
/**
|
||||
* Query monitoring
|
||||
* 查询监控
|
||||
* @param monitorId 监控ID
|
||||
* @return 监控信息
|
||||
*
|
||||
* @param monitorId Monitor ID 监控ID
|
||||
* @return Monitor information 监控信息
|
||||
*/
|
||||
Monitor getMonitor(Long monitorId);
|
||||
|
||||
/**
|
||||
* Update the status of the specified monitor
|
||||
* 更新指定监控的状态
|
||||
* @param monitorId 监控ID
|
||||
* @param status 监控状态
|
||||
*
|
||||
* @param monitorId monitorId 监控ID
|
||||
* @param status monitor status 监控状态
|
||||
*/
|
||||
void updateMonitorStatus(Long monitorId, byte status);
|
||||
|
||||
/**
|
||||
* Query the list of all monitoring information under the specified monitoring type
|
||||
* 查询指定监控类型下的所有监控信息列表
|
||||
* @param app 监控类型
|
||||
* @return 监控列表
|
||||
*
|
||||
* @param app Monitor Type 监控类型
|
||||
* @return Monitor Entity List 监控列表
|
||||
*/
|
||||
List<Monitor> getAppMonitors(String app);
|
||||
}
|
||||
|
||||
@@ -8,66 +8,104 @@ import org.springframework.data.jpa.domain.Specification;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Message notification configuration interface
|
||||
* 消息通知配置接口
|
||||
*
|
||||
* @author tom
|
||||
* @date 2021/12/16 16:14
|
||||
*/
|
||||
public interface NoticeConfigService {
|
||||
|
||||
/**
|
||||
* Dynamic conditional query
|
||||
* 动态条件查询
|
||||
* @param specification 查询条件
|
||||
* @return 查询结果
|
||||
*
|
||||
* @param specification Query conditions 查询条件
|
||||
* @return Search result 查询结果
|
||||
*/
|
||||
List<NoticeReceiver> getNoticeReceivers(Specification<NoticeReceiver> specification);
|
||||
|
||||
/**
|
||||
* Dynamic conditional query
|
||||
* 动态条件查询
|
||||
* @param specification 查询条件
|
||||
* @return 查询结果
|
||||
*
|
||||
* @param specification Query conditions 查询条件
|
||||
* @return Search result 查询结果
|
||||
*/
|
||||
List<NoticeRule> getNoticeRules(Specification<NoticeRule> specification);
|
||||
|
||||
/**
|
||||
* Add a notification recipient
|
||||
* 新增一个通知接收人
|
||||
* @param noticeReceiver 接收人信息
|
||||
*
|
||||
* @param noticeReceiver recipient information 接收人信息
|
||||
*/
|
||||
void addReceiver(NoticeReceiver noticeReceiver);
|
||||
|
||||
/**
|
||||
* Modify notification recipients
|
||||
* 修改通知接收人
|
||||
* @param noticeReceiver 接收人信息
|
||||
*
|
||||
* @param noticeReceiver recipient information 接收人信息
|
||||
*/
|
||||
void editReceiver(NoticeReceiver noticeReceiver);
|
||||
|
||||
/**
|
||||
* Delete recipient information based on recipient ID
|
||||
* 根据接收人ID删除接收人信息
|
||||
* @param receiverId 接收人ID
|
||||
*
|
||||
* @param receiverId Recipient ID 接收人ID
|
||||
*/
|
||||
void deleteReceiver(Long receiverId);
|
||||
|
||||
/**
|
||||
* Added notification policy
|
||||
* 新增通知策略
|
||||
* @param noticeRule 通知策略
|
||||
*
|
||||
* @param noticeRule Notification strategy 通知策略
|
||||
*/
|
||||
void addNoticeRule(NoticeRule noticeRule);
|
||||
|
||||
/**
|
||||
* Modify Notification Policy
|
||||
* 修改通知策略
|
||||
* @param noticeRule 通知策略
|
||||
*
|
||||
* @param noticeRule Notification strategy 通知策略
|
||||
*/
|
||||
void editNoticeRule(NoticeRule noticeRule);
|
||||
|
||||
/**
|
||||
* Delete the specified notification policy
|
||||
* 删除指定的通知策略
|
||||
* @param ruleId 通知策略ID
|
||||
*
|
||||
* @param ruleId Notification Policy ID 通知策略ID
|
||||
*/
|
||||
void deleteNoticeRule(Long ruleId);
|
||||
|
||||
/**
|
||||
* According to the alarm information matching all notification policies, filter out the recipients who need to be notified
|
||||
* 根据告警信息与所有通知策略匹配,过滤出需要通知的接收人
|
||||
* @param alert 告警信息
|
||||
* @return 接收人
|
||||
*
|
||||
* @param alert Alarm information 告警信息
|
||||
* @return Receiver 接收人
|
||||
*/
|
||||
List<NoticeReceiver> getReceiverFilterRule(Alert alert);
|
||||
|
||||
/**
|
||||
* Query recipient information based on recipient ID (primary key Id)
|
||||
* 根据接收人ID(主键Id)查询接收人信息
|
||||
*
|
||||
* @param receiverId Receiver ID (primary key ID) 接收人ID(主键ID)
|
||||
* @return Recipient Entity 接收人实体
|
||||
*/
|
||||
NoticeReceiver getReceiverById(Long receiverId);
|
||||
|
||||
/**
|
||||
* Query specific notification rules according to the rule ID (primary key ID)
|
||||
* 根据规则ID(主键ID)查询具体通知规则
|
||||
*
|
||||
* @param ruleId Rule ID 规则ID(主键ID)
|
||||
* @return Notification Rule Entity 通知规则实体
|
||||
*/
|
||||
NoticeRule getNoticeRulesById(Long ruleId);
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 监控管理服务实现
|
||||
*
|
||||
* @author tomsun28
|
||||
* @date 2021/11/14 13:06
|
||||
*/
|
||||
@@ -79,7 +80,13 @@ public class MonitorServiceImpl implements MonitorService {
|
||||
List<Configmap> configmaps = params.stream().map(param ->
|
||||
new Configmap(param.getField(), param.getValue(), param.getType())).collect(Collectors.toList());
|
||||
appDefine.setConfigmap(configmaps);
|
||||
// To detect availability, you only need to collect the set of availability indicators with a priority of 0.
|
||||
// 探测可用性只需要采集优先级为0的可用性指标集合
|
||||
List<Metrics> availableMetrics = appDefine.getMetrics().stream()
|
||||
.filter(item -> item.getPriority() == 0).collect(Collectors.toList());
|
||||
appDefine.setMetrics(availableMetrics);
|
||||
List<CollectRep.MetricsData> collectRep = collectJobService.collectSyncJobData(appDefine);
|
||||
// If the detection result fails, a detection exception is thrown
|
||||
// 判断探测结果 失败则抛出探测异常
|
||||
if (collectRep == null || collectRep.isEmpty()) {
|
||||
throw new MonitorDetectException("No collector response");
|
||||
@@ -92,9 +99,9 @@ public class MonitorServiceImpl implements MonitorService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void addMonitor(Monitor monitor, List<Param> params) throws RuntimeException {
|
||||
// 申请 monitor id
|
||||
// Apply for monitor id 申请 monitor id
|
||||
long monitorId = SnowFlakeIdGenerator.generateId();
|
||||
// 构造采集任务Job实体
|
||||
// Construct the collection task Job entity 构造采集任务Job实体
|
||||
Job appDefine = appService.getAppDefine(monitor.getApp());
|
||||
appDefine.setMonitorId(monitorId);
|
||||
appDefine.setInterval(monitor.getIntervals());
|
||||
@@ -105,8 +112,10 @@ public class MonitorServiceImpl implements MonitorService {
|
||||
return new Configmap(param.getField(), param.getValue(), param.getType());
|
||||
}).collect(Collectors.toList());
|
||||
appDefine.setConfigmap(configmaps);
|
||||
// Send the collection task to get the job ID
|
||||
// 下发采集任务得到jobId
|
||||
long jobId = collectJobService.addAsyncCollectJob(appDefine);
|
||||
// Brush the library after the download is successful
|
||||
// 下发成功后刷库
|
||||
try {
|
||||
monitor.setId(monitorId);
|
||||
@@ -116,6 +125,7 @@ public class MonitorServiceImpl implements MonitorService {
|
||||
paramDao.saveAll(params);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
// Repository brushing abnormally cancels the previously delivered task
|
||||
// 刷库异常取消之前的下发任务
|
||||
collectJobService.cancelAsyncCollectJob(jobId);
|
||||
throw new MonitorDatabaseException(e.getMessage());
|
||||
@@ -125,6 +135,7 @@ public class MonitorServiceImpl implements MonitorService {
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public void validate(MonitorDto monitorDto, Boolean isModify) throws IllegalArgumentException {
|
||||
// The request monitoring parameter matches the monitoring parameter definition mapping check
|
||||
// 请求监控参数与监控参数定义映射校验匹配
|
||||
Monitor monitor = monitorDto.getMonitor();
|
||||
monitor.setHost(monitor.getHost().trim());
|
||||
@@ -137,7 +148,7 @@ public class MonitorServiceImpl implements MonitorService {
|
||||
param.setValue(value);
|
||||
})
|
||||
.collect(Collectors.toMap(Param::getField, param -> param));
|
||||
// 校验名称唯一性
|
||||
// Check name uniqueness 校验名称唯一性
|
||||
if (isModify != null) {
|
||||
Optional<Monitor> monitorOptional = monitorDao.findMonitorByNameEquals(monitor.getName());
|
||||
if (monitorOptional.isPresent()) {
|
||||
@@ -152,7 +163,7 @@ public class MonitorServiceImpl implements MonitorService {
|
||||
}
|
||||
}
|
||||
|
||||
// 参数定义结构校验
|
||||
// Parameter definition structure verification 参数定义结构校验
|
||||
List<ParamDefine> paramDefines = appService.getAppParamDefines(monitorDto.getMonitor().getApp());
|
||||
if (paramDefines != null) {
|
||||
for (ParamDefine paramDefine : paramDefines) {
|
||||
@@ -198,6 +209,7 @@ public class MonitorServiceImpl implements MonitorService {
|
||||
}
|
||||
break;
|
||||
case "password":
|
||||
// The plaintext password needs to be encrypted for transmission and storage
|
||||
// 明文密码需加密传输存储
|
||||
String passwordValue = param.getValue();
|
||||
if (!AesUtil.isCiphertext(passwordValue)) {
|
||||
@@ -207,7 +219,7 @@ public class MonitorServiceImpl implements MonitorService {
|
||||
param.setType(CommonConstants.PARAM_TYPE_PASSWORD);
|
||||
break;
|
||||
case "boolean":
|
||||
// boolean校验
|
||||
// boolean check
|
||||
String booleanValue = param.getValue();
|
||||
try {
|
||||
Boolean.parseBoolean(booleanValue);
|
||||
@@ -217,7 +229,7 @@ public class MonitorServiceImpl implements MonitorService {
|
||||
}
|
||||
break;
|
||||
case "radio":
|
||||
// radio单选值校验
|
||||
// radio single value check radio单选值校验
|
||||
List<ParamDefine.Option> options = paramDefine.getOptions();
|
||||
boolean invalid = true;
|
||||
if (options != null) {
|
||||
@@ -239,7 +251,8 @@ public class MonitorServiceImpl implements MonitorService {
|
||||
case "key-value":
|
||||
// todo key-value校验
|
||||
break;
|
||||
// todo 更多参数定义与实际值格式校验
|
||||
// todo More parameter definitions and actual value format verification
|
||||
// 更多参数定义与实际值格式校验
|
||||
default:
|
||||
throw new IllegalArgumentException("ParamDefine type " + paramDefine.getType() + " is invalid.");
|
||||
}
|
||||
@@ -249,8 +262,10 @@ public class MonitorServiceImpl implements MonitorService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void modifyMonitor(Monitor monitor, List<Param> params) throws RuntimeException {
|
||||
long monitorId = monitor.getId();
|
||||
// Check to determine whether the monitor corresponding to the monitor Id exists
|
||||
// 查判断monitorId对应的此监控是否存在
|
||||
Optional<Monitor> queryOption = monitorDao.findById(monitorId);
|
||||
if (!queryOption.isPresent()) {
|
||||
@@ -258,9 +273,11 @@ public class MonitorServiceImpl implements MonitorService {
|
||||
}
|
||||
Monitor preMonitor = queryOption.get();
|
||||
if (!preMonitor.getApp().equals(monitor.getApp())) {
|
||||
// The type of monitoring cannot be modified
|
||||
// 监控的类型不能修改
|
||||
throw new IllegalArgumentException("Can not modify monitor's app type");
|
||||
}
|
||||
// Construct the collection task Job entity
|
||||
// 构造采集任务Job实体
|
||||
Job appDefine = appService.getAppDefine(monitor.getApp());
|
||||
appDefine.setId(preMonitor.getJobId());
|
||||
@@ -271,14 +288,16 @@ public class MonitorServiceImpl implements MonitorService {
|
||||
List<Configmap> configmaps = params.stream().map(param ->
|
||||
new Configmap(param.getField(), param.getValue(), param.getType())).collect(Collectors.toList());
|
||||
appDefine.setConfigmap(configmaps);
|
||||
// 更新采集任务
|
||||
collectJobService.updateAsyncCollectJob(appDefine);
|
||||
// After the update is successfully released, refresh the library
|
||||
// 下发更新成功后刷库
|
||||
try {
|
||||
monitor.setJobId(preMonitor.getJobId());
|
||||
monitor.setStatus(preMonitor.getStatus());
|
||||
monitorDao.save(monitor);
|
||||
paramDao.saveAll(params);
|
||||
// Update the collection task after the storage is completed
|
||||
// 入库完成后更新采集任务
|
||||
collectJobService.updateAsyncCollectJob(appDefine);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new MonitorDatabaseException(e.getMessage());
|
||||
@@ -339,7 +358,9 @@ public class MonitorServiceImpl implements MonitorService {
|
||||
|
||||
@Override
|
||||
public void cancelManageMonitors(HashSet<Long> ids) {
|
||||
// Update monitoring status Delete corresponding monitoring periodic task
|
||||
// 更新监控状态 删除对应的监控周期性任务
|
||||
// The jobId is not deleted, and the jobId is reused again after the management is started.
|
||||
// jobId不删除 待启动纳管之后再次复用jobId
|
||||
List<Monitor> managedMonitors = monitorDao.findMonitorsByIdIn(ids)
|
||||
.stream().filter(monitor ->
|
||||
@@ -356,6 +377,7 @@ public class MonitorServiceImpl implements MonitorService {
|
||||
|
||||
@Override
|
||||
public void enableManageMonitors(HashSet<Long> ids) {
|
||||
// Update monitoring status Add corresponding monitoring periodic task
|
||||
// 更新监控状态 新增对应的监控周期性任务
|
||||
List<Monitor> unManagedMonitors = monitorDao.findMonitorsByIdIn(ids)
|
||||
.stream().filter(monitor ->
|
||||
@@ -365,6 +387,7 @@ public class MonitorServiceImpl implements MonitorService {
|
||||
if (!unManagedMonitors.isEmpty()) {
|
||||
monitorDao.saveAll(unManagedMonitors);
|
||||
for (Monitor monitor : unManagedMonitors) {
|
||||
// Construct the collection task Job entity
|
||||
// 构造采集任务Job实体
|
||||
Job appDefine = appService.getAppDefine(monitor.getApp());
|
||||
appDefine.setMonitorId(monitor.getId());
|
||||
@@ -375,7 +398,7 @@ public class MonitorServiceImpl implements MonitorService {
|
||||
List<Configmap> configmaps = params.stream().map(param ->
|
||||
new Configmap(param.getField(), param.getValue(), param.getType())).collect(Collectors.toList());
|
||||
appDefine.setConfigmap(configmaps);
|
||||
// 下发采集任务
|
||||
// Issue collection tasks 下发采集任务
|
||||
collectJobService.addAsyncCollectJob(appDefine);
|
||||
}
|
||||
}
|
||||
@@ -387,7 +410,8 @@ public class MonitorServiceImpl implements MonitorService {
|
||||
if (appCounts == null) {
|
||||
return null;
|
||||
}
|
||||
// 关联大类别信息 计算每个状态对应数量
|
||||
//Statistical category information, calculate the number of corresponding states for each monitor
|
||||
//统计类别信息,计算每个监控分别对应状态的数量
|
||||
Map<String, AppCount> appCountMap = new HashMap<>(appCounts.size());
|
||||
for (AppCount item : appCounts) {
|
||||
AppCount appCount = appCountMap.getOrDefault(item.getApp(), new AppCount());
|
||||
@@ -405,10 +429,13 @@ public class MonitorServiceImpl implements MonitorService {
|
||||
case CommonConstants.UN_REACHABLE_CODE:
|
||||
appCount.setUnReachableSize(appCount.getUnReachableSize() + item.getSize());
|
||||
break;
|
||||
default: break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
appCountMap.put(item.getApp(), appCount);
|
||||
}
|
||||
//Traverse the map obtained by statistics and convert it into a List<App Count> result set
|
||||
//遍历统计得到的map,转换成List<App Count>结果集
|
||||
return appCountMap.values().stream().peek(item -> {
|
||||
item.setSize(item.getAvailableSize() + item.getUnManageSize()
|
||||
+ item.getUnReachableSize() + item.getUnAvailableSize());
|
||||
|
||||
@@ -18,6 +18,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 消息通知配置实现
|
||||
*
|
||||
* @author tom
|
||||
* @date 2021/12/16 16:16
|
||||
*/
|
||||
@@ -74,13 +75,24 @@ public class NoticeConfigServiceImpl implements NoticeConfigService {
|
||||
|
||||
@Override
|
||||
public List<NoticeReceiver> getReceiverFilterRule(Alert alert) {
|
||||
// todo 使用缓存
|
||||
// todo use cache 使用缓存
|
||||
List<NoticeRule> rules = noticeRuleDao.findNoticeRulesByEnableTrue();
|
||||
// todo 暂时规则是全部转发 后面实现更多匹配规则:告警状态选择 监控类型选择等
|
||||
// todo The temporary rule is to forward all, and then implement more matching rules: alarm status selection, monitoring type selection, etc.
|
||||
// 暂时规则是全部转发 后面实现更多匹配规则:告警状态选择 监控类型选择等
|
||||
Set<Long> receiverIds = rules.stream()
|
||||
.filter(NoticeRule::isFilterAll)
|
||||
.map(NoticeRule::getReceiverId)
|
||||
.collect(Collectors.toSet());
|
||||
return noticeReceiverDao.findAllById(receiverIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NoticeReceiver getReceiverById(Long receiverId) {
|
||||
return noticeReceiverDao.getOne(receiverId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NoticeRule getNoticeRulesById(Long ruleId) {
|
||||
return noticeRuleDao.getOne(ruleId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ category: custom
|
||||
app: example
|
||||
name:
|
||||
zh-CN: 模拟应用类型
|
||||
en-US: EXAMPLE APP
|
||||
en-US: EXAMPLE
|
||||
# 参数映射map. type是参数类型: 0-number数字, 1-string明文字符串, 2-secret加密字符串, 3-map映射的json串
|
||||
# 强制固定必须参数 - host
|
||||
configmap:
|
||||
|
||||
@@ -32,6 +32,8 @@ configmap:
|
||||
type: 3
|
||||
- key: params
|
||||
type: 3
|
||||
- key: keyword
|
||||
type: 1
|
||||
# 指标组列表
|
||||
metrics:
|
||||
# 第一个监控指标组 cpu
|
||||
@@ -46,6 +48,9 @@ metrics:
|
||||
- field: responseTime
|
||||
type: 0
|
||||
unit: ms
|
||||
- field: keyword
|
||||
type: 0
|
||||
unit: 次数
|
||||
# 监控采集使用协议 eg: sql, ssh, http, telnet, wmi, snmp, sdk
|
||||
protocol: http
|
||||
# 当protocol为http协议时具体的采集配置
|
||||
@@ -78,4 +83,5 @@ metrics:
|
||||
digestAuthPassword: ^_^password^_^
|
||||
# 响应数据解析方式: default-系统规则,jsonPath-jsonPath脚本,website-网站可用性指标监控
|
||||
# todo xmlPath-xmlPath脚本,prometheus-Prometheus数据规则
|
||||
parseType: website
|
||||
parseType: website
|
||||
keyword: ^_^keyword^_^
|
||||
@@ -2,7 +2,7 @@ category: service
|
||||
app: fullsite
|
||||
name:
|
||||
zh-CN: 全站监控
|
||||
en-US: FULL WEBSITE MONITOR
|
||||
en-US: SITE MAP
|
||||
configmap:
|
||||
- key: host
|
||||
type: 1
|
||||
|
||||
@@ -68,6 +68,26 @@ metrics:
|
||||
- field: context_switch
|
||||
type: 0
|
||||
unit: 个数
|
||||
- field: usage
|
||||
type: 0
|
||||
unit: '%'
|
||||
# (非必须)监控指标别名,与上面的指标名映射。用于采集接口数据字段不直接是最终指标名称,需要此别名做映射转换
|
||||
aliasFields:
|
||||
- info
|
||||
- cores
|
||||
- interrupt
|
||||
- load
|
||||
- context_switch
|
||||
- idle
|
||||
# (非必须)指标计算表达式,与上面的别名一起作用,计算出最终需要的指标值
|
||||
# eg: cores=core1+core2, usage=usage, waitTime=allTime-runningTime
|
||||
calculates:
|
||||
- info=info
|
||||
- cores=cores
|
||||
- interrupt=interrupt
|
||||
- load=load
|
||||
- context_switch=context_switch
|
||||
- usage=100-idle
|
||||
# 监控采集使用协议 eg: sql, ssh, http, telnet, wmi, snmp, sdk
|
||||
protocol: ssh
|
||||
# 当protocol为http协议时具体的采集配置
|
||||
@@ -79,7 +99,7 @@ metrics:
|
||||
username: ^_^username^_^
|
||||
password: ^_^password^_^
|
||||
timeout: ^_^timeout^_^
|
||||
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}'"
|
||||
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}';vmstat 1 1 | awk 'NR==3{print $15}'"
|
||||
parseType: oneRow
|
||||
|
||||
- name: memory
|
||||
@@ -101,6 +121,25 @@ metrics:
|
||||
- field: available
|
||||
type: 0
|
||||
unit: Mb
|
||||
- field: usage
|
||||
type: 0
|
||||
unit: '%'
|
||||
# (非必须)监控指标别名,与上面的指标名映射。用于采集接口数据字段不直接是最终指标名称,需要此别名做映射转换
|
||||
aliasFields:
|
||||
- total
|
||||
- used
|
||||
- free
|
||||
- buff_cache
|
||||
- available
|
||||
# (非必须)指标计算表达式,与上面的别名一起作用,计算出最终需要的指标值
|
||||
# eg: cores=core1+core2, usage=usage, waitTime=allTime-runningTime
|
||||
calculates:
|
||||
- total=total
|
||||
- used=used
|
||||
- free=free
|
||||
- buff_cache=buff_cache
|
||||
- available=available
|
||||
- usage=(used / total) * 100
|
||||
# 监控采集使用协议 eg: sql, ssh, http, telnet, wmi, snmp, sdk
|
||||
protocol: ssh
|
||||
# 当protocol为http协议时具体的采集配置
|
||||
@@ -154,6 +193,7 @@ metrics:
|
||||
# 指标信息 包括 field名称 type字段类型:0-number数字,1-string字符串 instance是否为实例主键 unit:指标单位
|
||||
- field: interface_name
|
||||
type: 1
|
||||
instance: true
|
||||
- field: receive_bytes
|
||||
type: 0
|
||||
unit: byte
|
||||
@@ -172,4 +212,36 @@ metrics:
|
||||
password: ^_^password^_^
|
||||
timeout: ^_^timeout^_^
|
||||
script: cat /proc/net/dev | tail -n +3 | awk 'BEGIN{ print "interface_name receive_bytes transmit_bytes"} {print $1,$2,$10}'
|
||||
parseType: multiRow
|
||||
|
||||
- name: disk_free
|
||||
priority: 5
|
||||
fields:
|
||||
# 指标信息 包括 field名称 type字段类型:0-number数字,1-string字符串 instance是否为实例主键 unit:指标单位
|
||||
- field: filesystem
|
||||
type: 1
|
||||
- field: used
|
||||
type: 0
|
||||
unit: Mb
|
||||
- field: available
|
||||
type: 0
|
||||
unit: Mb
|
||||
- field: usage
|
||||
type: 0
|
||||
unit: '%'
|
||||
- field: mounted
|
||||
type: 1
|
||||
instance: true
|
||||
# 监控采集使用协议 eg: sql, ssh, http, telnet, wmi, snmp, sdk
|
||||
protocol: ssh
|
||||
# 当protocol为http协议时具体的采集配置
|
||||
ssh:
|
||||
# 主机host: ipv4 ipv6 域名
|
||||
host: ^_^host^_^
|
||||
# 端口
|
||||
port: ^_^port^_^
|
||||
username: ^_^username^_^
|
||||
password: ^_^password^_^
|
||||
timeout: ^_^timeout^_^
|
||||
script: df -m | tail -n +2 | awk 'BEGIN{ print "filesystem used available usage mounted"} {print $1,$3,$4,$5,$6}'
|
||||
parseType: multiRow
|
||||
@@ -32,8 +32,6 @@ metrics:
|
||||
- field: database_version
|
||||
type: 1
|
||||
instance: true
|
||||
- field: database_type
|
||||
type: 1
|
||||
- field: hostname
|
||||
type: 1
|
||||
- field: instance_name
|
||||
@@ -45,7 +43,6 @@ metrics:
|
||||
# (非必须)监控指标别名,与上面的指标名映射。用于采集接口数据字段不直接是最终指标名称,需要此别名做映射转换
|
||||
aliasFields:
|
||||
- VERSION
|
||||
- DATABASE_TYPE
|
||||
- HOST_NAME
|
||||
- INSTANCE_NAME
|
||||
- STARTUP_TIME
|
||||
@@ -54,7 +51,6 @@ metrics:
|
||||
# eg: cores=core1+core2, usage=usage, waitTime=allTime-runningTime
|
||||
calculates:
|
||||
- database_version=VERSION
|
||||
- database_type=DATABASE_TYPE
|
||||
- hostname=HOST_NAME
|
||||
- instance_name=INSTANCE_NAME
|
||||
- startup_time=STARTUP_TIME
|
||||
@@ -179,4 +175,4 @@ metrics:
|
||||
queryType: columns
|
||||
# sql
|
||||
sql: select metric_name, value from gv$sysmetric where metric_name = 'I/O Megabytes per Second' or metric_name = 'User Transaction Per Sec' or metric_name = 'I/O Requests per Second'
|
||||
url: ^_^url^_^
|
||||
url: ^_^url^_^
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
category: service
|
||||
app: telnet
|
||||
name:
|
||||
zh-CN: TELNET端口可用性
|
||||
en-US: PORT TELNET
|
||||
configmap:
|
||||
- key: host
|
||||
type: 1
|
||||
- key: port
|
||||
type: 0
|
||||
- key: timeout
|
||||
type: 0
|
||||
metrics:
|
||||
- name: summary
|
||||
priority: 0
|
||||
fields:
|
||||
- field: responseTime
|
||||
type: 0
|
||||
unit: ms
|
||||
protocol: telnet
|
||||
# 当protocol为telnet协议时具体的采集配置
|
||||
telnet:
|
||||
host: ^_^host^_^
|
||||
port: ^_^port^_^
|
||||
timeout: ^_^timeout^_^
|
||||
@@ -2,7 +2,7 @@ category: service
|
||||
app: website
|
||||
name:
|
||||
zh-CN: 网站监测
|
||||
en-US: WEBSITE MONITOR
|
||||
en-US: WEBSITE
|
||||
configmap:
|
||||
- key: host
|
||||
type: 1
|
||||
@@ -18,10 +18,12 @@ configmap:
|
||||
type: 1
|
||||
- key: password
|
||||
type: 2
|
||||
- key: keyword
|
||||
type: 1
|
||||
# 指标组列表
|
||||
metrics:
|
||||
# 第一个监控指标组 cpu
|
||||
# 注意:内置监控指标有 (responseTime - 响应时间)
|
||||
# 注意:内置监控指标有 (responseTime - 响应时间, keyword - 关键字数量)
|
||||
- name: summary
|
||||
# 指标组调度优先级(0-127)越小优先级越高,优先级低的指标组会等优先级高的指标组采集完成后才会被调度,相同优先级的指标组会并行调度采集
|
||||
# 优先级为0的指标组为可用性指标组,即它会被首先调度,采集成功才会继续调度其它指标组,采集失败则中断调度
|
||||
@@ -32,6 +34,9 @@ metrics:
|
||||
- field: responseTime
|
||||
type: 0
|
||||
unit: ms
|
||||
- field: keyword
|
||||
type: 0
|
||||
unit: 次数
|
||||
# 监控采集使用协议 eg: sql, ssh, http, telnet, wmi, snmp, sdk
|
||||
protocol: http
|
||||
# 当protocol为http协议时具体的采集配置
|
||||
@@ -55,4 +60,5 @@ metrics:
|
||||
digestAuthPassword: ^_^password^_^
|
||||
# 响应数据解析方式: default-系统规则,jsonPath-jsonPath脚本,website-网站可用性指标监控
|
||||
# todo xmlPath-xmlPath脚本,prometheus-Prometheus数据规则
|
||||
parseType: website
|
||||
parseType: website
|
||||
keyword: ^_^keyword^_^
|
||||
@@ -26,10 +26,12 @@ param:
|
||||
# 当type为text时,用limit表示字符串限制大小
|
||||
limit: 20
|
||||
required: false
|
||||
hide: true
|
||||
- field: password
|
||||
name: 密码
|
||||
type: password
|
||||
required: false
|
||||
hide: true
|
||||
- field: ssl
|
||||
name: 启动SSL
|
||||
# 当type为boolean时,前端用switch展示开关
|
||||
|
||||
@@ -60,15 +60,18 @@ param:
|
||||
type: text
|
||||
placeholder: '请求BODY资源类型'
|
||||
required: false
|
||||
hide: true
|
||||
- field: payload
|
||||
name: 请求BODY
|
||||
type: textarea
|
||||
placeholder: 'POST PUT请求时有效'
|
||||
required: false
|
||||
hide: true
|
||||
- field: authType
|
||||
name: 认证方式
|
||||
type: radio
|
||||
required: false
|
||||
hide: true
|
||||
# 当type为radio单选框,checkbox复选框时,option表示可选项值列表 {name1:value1,name2:value2}
|
||||
options:
|
||||
- label: Basic Auth
|
||||
@@ -81,7 +84,14 @@ param:
|
||||
# 当type为text时,用limit表示字符串限制大小
|
||||
limit: 20
|
||||
required: false
|
||||
hide: true
|
||||
- field: password
|
||||
name: 密码
|
||||
type: password
|
||||
required: false
|
||||
hide: true
|
||||
- field: keyword
|
||||
name: 关键字
|
||||
type: text
|
||||
required: false
|
||||
hide: true
|
||||
|
||||
@@ -17,6 +17,7 @@ param:
|
||||
required: false
|
||||
defaultValue: 6000
|
||||
placeholder: '查询超时时间'
|
||||
hide: true
|
||||
- field: database
|
||||
name: 数据库名称
|
||||
type: text
|
||||
@@ -33,4 +34,5 @@ param:
|
||||
- field: url
|
||||
name: URL
|
||||
type: text
|
||||
required: false
|
||||
required: false
|
||||
hide: true
|
||||
@@ -15,6 +15,7 @@ param:
|
||||
name: 查询超时时间
|
||||
type: number
|
||||
required: false
|
||||
hide: true
|
||||
defaultValue: 6000
|
||||
placeholder: '查询超时时间'
|
||||
- field: database
|
||||
@@ -33,4 +34,5 @@ param:
|
||||
- field: url
|
||||
name: URL
|
||||
type: text
|
||||
required: false
|
||||
required: false
|
||||
hide: true
|
||||
@@ -15,6 +15,7 @@ param:
|
||||
name: 查询超时时间
|
||||
type: number
|
||||
required: false
|
||||
hide: true
|
||||
defaultValue: 6000
|
||||
placeholder: '查询超时时间'
|
||||
- field: database
|
||||
@@ -33,4 +34,5 @@ param:
|
||||
- field: url
|
||||
name: URL
|
||||
type: text
|
||||
required: false
|
||||
required: false
|
||||
hide: true
|
||||
@@ -15,6 +15,7 @@ param:
|
||||
name: 查询超时时间
|
||||
type: number
|
||||
required: false
|
||||
hide: true
|
||||
defaultValue: 6000
|
||||
placeholder: '查询超时时间'
|
||||
- field: database
|
||||
@@ -33,4 +34,5 @@ param:
|
||||
- field: url
|
||||
name: URL
|
||||
type: text
|
||||
required: false
|
||||
required: false
|
||||
hide: true
|
||||
@@ -15,6 +15,7 @@ param:
|
||||
name: 查询超时时间
|
||||
type: number
|
||||
required: false
|
||||
hide: true
|
||||
defaultValue: 6000
|
||||
placeholder: '查询超时时间'
|
||||
- field: database
|
||||
@@ -33,4 +34,5 @@ param:
|
||||
- field: url
|
||||
name: URL
|
||||
type: text
|
||||
required: false
|
||||
required: false
|
||||
hide: true
|
||||
@@ -1,27 +0,0 @@
|
||||
# 监控应用类型名称(与文件名保持一致) eg: linux windows tomcat mysql aws...
|
||||
app: telnet
|
||||
# 强制固定必须参数 - host(ipv4,ipv6,域名)
|
||||
param:
|
||||
# field-字段名称标识符
|
||||
- field: host
|
||||
# name-参数字段显示名称
|
||||
name: 主机Host
|
||||
# type-字段类型,样式(大部分映射input标签type属性)
|
||||
type: host
|
||||
# 是否是必输项 true-必填 false-可选
|
||||
required: true
|
||||
- field: port
|
||||
name: 端口
|
||||
type: number
|
||||
# 当type为number时,用range表示范围
|
||||
range: '[0,65535]'
|
||||
required: true
|
||||
defaultValue: 80
|
||||
- field: timeout
|
||||
name: Telnet超时时间
|
||||
type: number
|
||||
# 当type为number时,用range表示范围
|
||||
range: '[0,100000]'
|
||||
required: true
|
||||
placeholder: '请输入超时时间,单位毫秒'
|
||||
defaultValue: 6000
|
||||
@@ -33,6 +33,7 @@ param:
|
||||
name: 认证方式
|
||||
type: radio
|
||||
required: false
|
||||
hide: true
|
||||
# 当type为radio单选框,checkbox复选框时,option表示可选项值列表 {name1:value1,name2:value2}
|
||||
options:
|
||||
- label: Basic Auth
|
||||
@@ -45,7 +46,14 @@ param:
|
||||
# 当type为text时,用limit表示字符串限制大小
|
||||
limit: 20
|
||||
required: false
|
||||
hide: true
|
||||
- field: password
|
||||
name: 密码
|
||||
type: password
|
||||
required: false
|
||||
required: false
|
||||
hide: true
|
||||
- field: keyword
|
||||
name: 关键字
|
||||
type: text
|
||||
required: false
|
||||
hide: true
|
||||
@@ -3,7 +3,7 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd
|
||||
http://maven.apache.org/ASSEMBLY/2.0.0 ">
|
||||
<!--必填,会追加到打包文件名称的末尾-->
|
||||
<id>1.0-beta.6</id>
|
||||
<id>1.0-beta.7</id>
|
||||
<!--打包类型,可以设置多种类型,打包的时候不同的类型都会打包打出来-->
|
||||
<formats>
|
||||
<format>tar</format>
|
||||
|
||||
@@ -28,9 +28,7 @@ if [ ! -d $LOGS_DIR ]; then
|
||||
fi
|
||||
|
||||
# JVM Configuration
|
||||
JAVA_OPTS=" -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true "
|
||||
|
||||
JAVA_MEM_OPTS=" -server -Xms256m -Xmx1024m -XX:SurvivorRatio=2 -XX:+UseParallelGC "
|
||||
JAVA_MEM_OPTS=" -server -XX:SurvivorRatio=6 -XX:+UseParallelGC "
|
||||
|
||||
# 加载外部log文件的配置
|
||||
LOG_IMPL_FILE=logback-spring.xml
|
||||
@@ -41,4 +39,4 @@ then
|
||||
fi
|
||||
CONFIG_FILES=" -Dlogging.path=$LOGS_DIR $LOGGING_CONFIG -Dspring.config.location=$CONF_DIR/ "
|
||||
echo -e "Starting the $SERVER_NAME ..."
|
||||
java $JAVA_OPTS $JAVA_MEM_OPTS $CONFIG_FILES -jar $DEPLOY_DIR/$JAR_NAME --spring.profiles.active=prod
|
||||
java $JAVA_MEM_OPTS $CONFIG_FILES -jar $DEPLOY_DIR/$JAR_NAME --spring.profiles.active=prod
|
||||
@@ -2,11 +2,9 @@
|
||||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
rem 项目名称
|
||||
set SERVER_NAME="${project.artifactId}"
|
||||
|
||||
|
||||
rem 应用的端口号
|
||||
set SERVER_PORT=1157
|
||||
|
||||
echo Start shutdown HertzBeat %SERVER_NAME%
|
||||
|
||||
@@ -2,25 +2,21 @@
|
||||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
rem 项目名称
|
||||
set SERVER_NAME=${project.artifactId}
|
||||
|
||||
rem jar名称
|
||||
set JAR_NAME=${project.build.finalName}.jar
|
||||
|
||||
rem 进入bin目录
|
||||
rem enter the bin directory
|
||||
cd /d %~dp0
|
||||
rem 返回到上一级项目根目录路径
|
||||
|
||||
cd ..
|
||||
rem 打印项目安装根目录绝对路径
|
||||
|
||||
set DEPLOY_DIR=%~dp0..
|
||||
echo %DEPLOY_DIR%
|
||||
rem 外部配置文件绝对目录,如果是目录需要/结尾,也可以直接指定文件
|
||||
rem 如果指定的是目录,spring则会读取目录中的所有配置文件
|
||||
|
||||
set CONF_DIR=%DEPLOY_DIR%\config
|
||||
echo %CONF_DIR%
|
||||
|
||||
rem 应用的端口号
|
||||
set SERVER_PORT=1157
|
||||
|
||||
for /f "tokens=1-5" %%i in ('netstat -ano^|findstr "0.0.0.0:%SERVER_PORT%"') do (
|
||||
@@ -29,18 +25,16 @@ for /f "tokens=1-5" %%i in ('netstat -ano^|findstr "0.0.0.0:%SERVER_PORT%"') do
|
||||
goto q
|
||||
)
|
||||
|
||||
|
||||
rem 项目日志输出绝对路径
|
||||
set LOGS_DIR=%DEPLOY_DIR%\logs
|
||||
|
||||
rem JVM Configuration
|
||||
set JAVA_OPTS= -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -Duser.timezone=Asia/Shanghai
|
||||
set JAVA_OPTS= -Duser.timezone=Asia/Shanghai
|
||||
|
||||
set JAVA_MEM_OPTS= -server -XX:SurvivorRatio=6 -XX:+UseParallelGC
|
||||
|
||||
set JAVA_MEM_OPTS= -server -Xms256m -Xmx1024m -XX:SurvivorRatio=2 -XX:+UseParallelGC
|
||||
|
||||
rem 加载外部log文件的配置
|
||||
set LOGGING_CONFIG=-Dlogging.config=%CONF_DIR%\logback-spring.xml
|
||||
rem 注意配置文件目录最后的后缀需为 / 而不是 windows \
|
||||
|
||||
set CONFIG_FILES= -Dlogging.path=%LOGS_DIR% %LOGGING_CONFIG% -Dspring.config.location=%CONF_DIR%/
|
||||
echo Starting the %SERVER_NAME% ...
|
||||
|
||||
|
||||
@@ -66,9 +66,9 @@ if [ ! -d $LOGS_DIR ]; then
|
||||
fi
|
||||
|
||||
# JVM Configuration
|
||||
JAVA_OPTS=" -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -Duser.timezone=Asia/Shanghai"
|
||||
JAVA_OPTS=" -Duser.timezone=Asia/Shanghai"
|
||||
|
||||
JAVA_MEM_OPTS=" -server -Xms256m -Xmx1024m -XX:SurvivorRatio=2 -XX:+UseParallelGC "
|
||||
JAVA_MEM_OPTS=" -server -XX:SurvivorRatio=6 -XX:+UseParallelGC "
|
||||
|
||||
# 加载外部log文件的配置
|
||||
LOG_IMPL_FILE=logback-spring.xml
|
||||
|
||||
@@ -35,7 +35,7 @@ services:
|
||||
- heartzbeat
|
||||
|
||||
hertzbeat:
|
||||
image: "tancloud/hertzbeat:1.0-beta.6"
|
||||
image: "tancloud/hertzbeat:1.0-beta.7"
|
||||
container_name: hertzbeat
|
||||
hostname: hertzbeat
|
||||
restart: always
|
||||
|
||||
@@ -2,7 +2,7 @@ FROM openjdk:8-alpine
|
||||
|
||||
MAINTAINER tomsun28 "tomsun28@outlook.com"
|
||||
|
||||
ADD hertzbeat-1.0-beta.6.tar /opt/
|
||||
ADD hertzbeat-1.0-beta.7.tar /opt/
|
||||
|
||||
RUN apk add --no-cache tzdata
|
||||
|
||||
|
||||
BIN
tancloud.gif
BIN
tancloud.gif
Binary file not shown.
|
Before Width: | Height: | Size: 30 MiB After Width: | Height: | Size: 15 MiB |
@@ -71,9 +71,9 @@ import { environment } from '@env/environment';
|
||||
<setting-drawer *ngIf="showSettingDrawer"></setting-drawer>
|
||||
<theme-btn
|
||||
[types]="[
|
||||
{ key: 'default', text: '浅色主题' },
|
||||
{ key: 'dark', text: '深色主题' },
|
||||
{ key: 'compact', text: '紧凑主题' }
|
||||
{ key: 'default', text: 'app.theme.default' | i18n },
|
||||
{ key: 'dark', text: 'app.theme.dark' | i18n },
|
||||
{ key: 'compact', text: 'app.theme.compact' | i18n }
|
||||
]"
|
||||
></theme-btn>
|
||||
`
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { ChangeDetectionStrategy, Component, HostListener } from '@angular/core';
|
||||
import { ChangeDetectionStrategy, Component, HostListener, Inject } from '@angular/core';
|
||||
import { I18NService } from '@core';
|
||||
import { ALAIN_I18N_TOKEN } from '@delon/theme';
|
||||
import { NzMessageService } from 'ng-zorro-antd/message';
|
||||
import { NzModalService } from 'ng-zorro-antd/modal';
|
||||
|
||||
@@ -14,15 +16,19 @@ import { NzModalService } from 'ng-zorro-antd/modal';
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
})
|
||||
export class HeaderClearStorageComponent {
|
||||
constructor(private modalSrv: NzModalService, private messageSrv: NzMessageService) {}
|
||||
constructor(
|
||||
private modalSrv: NzModalService,
|
||||
private messageSrv: NzMessageService,
|
||||
@Inject(ALAIN_I18N_TOKEN) private i18nSvc: I18NService
|
||||
) {}
|
||||
|
||||
@HostListener('click')
|
||||
_click(): void {
|
||||
this.modalSrv.confirm({
|
||||
nzTitle: '请确认是否清理缓存?',
|
||||
nzTitle: this.i18nSvc.fanyi('common.confirm.clear-cache'),
|
||||
nzOnOk: () => {
|
||||
localStorage.clear();
|
||||
this.messageSrv.success('清理成功!');
|
||||
this.messageSrv.success(this.i18nSvc.fanyi('common.notify.clear-success'));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -26,11 +26,11 @@ import { AlertService } from '../../../service/alert.service';
|
||||
export class HeaderNotifyComponent implements OnInit {
|
||||
data: NoticeItem[] = [
|
||||
{
|
||||
title: '近期未处理告警',
|
||||
title: this.i18nSvc.fanyi('dashboard.alerts.title-no'),
|
||||
list: [],
|
||||
emptyText: '暂无未处理告警',
|
||||
emptyText: this.i18nSvc.fanyi('dashboard.alerts.no'),
|
||||
emptyImage: 'https://gw.alipayobjects.com/zos/rmsportal/wAhyIChODzsoKIOBHcBk.svg',
|
||||
clearText: '进入告警中心'
|
||||
clearText: this.i18nSvc.fanyi('dashboard.alerts.enter')
|
||||
}
|
||||
];
|
||||
count = 0;
|
||||
@@ -69,10 +69,10 @@ export class HeaderNotifyComponent implements OnInit {
|
||||
let item = {
|
||||
id: alert.id,
|
||||
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png',
|
||||
title: `监控-${alert.monitorName}-发出${this.i18nSvc.fanyi(`alert.priority.${alert.priority}`)}`,
|
||||
title: `${alert.monitorName}--${this.i18nSvc.fanyi(`alert.priority.${alert.priority}`)}`,
|
||||
datetime: alert.gmtCreate,
|
||||
color: 'blue',
|
||||
type: '近期未处理告警'
|
||||
type: this.i18nSvc.fanyi('dashboard.alerts.title-no')
|
||||
};
|
||||
this.data[0].list.push(item);
|
||||
});
|
||||
|
||||
@@ -40,8 +40,8 @@ import { MonitorService } from '../../../service/monitor.service';
|
||||
<nz-autocomplete nzBackfill="false" nzDefaultActiveFirstOption #auto>
|
||||
<nz-auto-option *ngFor="let option of options" [nzValue]="option.id" [nzLabel]="option.name">
|
||||
<a [routerLink]="['/monitors/' + option.id]">
|
||||
监控名称: {{ option.name }}
|
||||
<span style="left:50% ; position: absolute;">监控Host: {{ option.host }}</span>
|
||||
{{ 'monitor.name' | i18n }} : {{ option.name }}
|
||||
<span style="left:50% ; position: absolute;">{{ 'monitor.host' | i18n }} : {{ option.host }}</span>
|
||||
<span style="right: 10px; position: absolute;"><i nz-icon nzType="arrow-right" nzTheme="outline"></i></span>
|
||||
</a>
|
||||
</nz-auto-option>
|
||||
|
||||
@@ -6,15 +6,15 @@
|
||||
<img class="logo" src="./assets/logo.svg" alt="" />
|
||||
<span class="title">HertzBeat</span>
|
||||
</div>
|
||||
<div class="desc">TanCloud-易用友好的高性能监控云服务</div>
|
||||
<div class="desc">{{ 'app.passport.desc' | i18n }}</div>
|
||||
</div>
|
||||
<router-outlet></router-outlet>
|
||||
<global-footer [links]="links">
|
||||
Copyright
|
||||
<i nz-icon nzType="copyright" nzTheme="outline"></i>
|
||||
2022
|
||||
<a href="https://tancloud.cn" target="_blank">探云 tancloud.cn | </a>
|
||||
<a href="https://hertzbeat.com" target="_blank">赫兹跳动 hertzbeat.com</a>
|
||||
<a href="https://tancloud.cn" target="_blank">TanCloud tancloud.cn | </a>
|
||||
<a href="https://hertzbeat.com" target="_blank">HertzBeat hertzbeat.com</a>
|
||||
</global-footer>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { Component, Inject, OnInit } from '@angular/core';
|
||||
import { I18NService } from '@core';
|
||||
import { DA_SERVICE_TOKEN, ITokenService } from '@delon/auth';
|
||||
import { ALAIN_I18N_TOKEN } from '@delon/theme';
|
||||
|
||||
@Component({
|
||||
selector: 'layout-passport',
|
||||
@@ -9,12 +11,12 @@ import { DA_SERVICE_TOKEN, ITokenService } from '@delon/auth';
|
||||
export class LayoutPassportComponent implements OnInit {
|
||||
links = [
|
||||
{
|
||||
title: '欢迎使用TanCloud探云-监控云服务-tancloud.cn',
|
||||
title: this.i18nSvc.fanyi('app.passport.welcome'),
|
||||
href: 'https://tancloud.cn'
|
||||
}
|
||||
];
|
||||
|
||||
constructor(@Inject(DA_SERVICE_TOKEN) private tokenService: ITokenService) {}
|
||||
constructor(@Inject(DA_SERVICE_TOKEN) private tokenService: ITokenService, @Inject(ALAIN_I18N_TOKEN) private i18nSvc: I18NService) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.tokenService.clear();
|
||||
|
||||
@@ -12,4 +12,6 @@ export class ParamDefine {
|
||||
// 当type为key-value时有效,表示别名描述
|
||||
keyAlias!: string;
|
||||
valueAlias!: string;
|
||||
// 此参数是否隐藏 即默认不显示, 在高级设置区显示
|
||||
hide: boolean = false;
|
||||
}
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
<nz-breadcrumb-item>
|
||||
<a [routerLink]="['/']">
|
||||
<i nz-icon nzType="home"></i>
|
||||
<span>仪表盘</span>
|
||||
<span>{{ 'menu.dashboard' | i18n }}</span>
|
||||
</a>
|
||||
</nz-breadcrumb-item>
|
||||
<nz-breadcrumb-item>
|
||||
<i nz-icon nzType="alert"></i>
|
||||
<span>告警中心</span>
|
||||
<span>{{ 'menu.alert.center' | i18n }}</span>
|
||||
</nz-breadcrumb-item>
|
||||
</nz-breadcrumb>
|
||||
<nz-divider></nz-divider>
|
||||
@@ -16,26 +16,28 @@
|
||||
<div>
|
||||
<button nz-button nzType="primary" (click)="onDeleteAlerts()">
|
||||
<i nz-icon nzType="delete" nzTheme="outline"></i>
|
||||
删除告警
|
||||
{{ 'alert.center.delete' | i18n }}
|
||||
</button>
|
||||
<button nz-button nzType="primary" (click)="onMarkReadAlerts()">
|
||||
<i nz-icon nzType="down-circle" nzTheme="outline"></i>
|
||||
标记已处理
|
||||
{{ 'alert.center.deal' | i18n }}
|
||||
</button>
|
||||
<button nz-button nzType="primary" (click)="onMarkUnReadAlerts()">
|
||||
<i nz-icon nzType="up-circle" nzTheme="outline"></i>
|
||||
标记未处理
|
||||
{{ 'alert.center.no-deal' | i18n }}
|
||||
</button>
|
||||
<button nz-button nzType="primary" (click)="sync()" nz-tooltip nzTooltipTitle="刷新">
|
||||
<button nz-button nzType="primary" (click)="sync()" nz-tooltip [nzTooltipTitle]="'common.refresh' | i18n">
|
||||
<i nz-icon nzType="sync" nzTheme="outline"></i>
|
||||
</button>
|
||||
|
||||
<button style="margin-right: 25px; float: right" nz-button nzType="primary" (click)="onFilterSearchAlerts()"> 搜索 </button>
|
||||
<button style="margin-right: 25px; float: right" nz-button nzType="primary" (click)="onFilterSearchAlerts()">
|
||||
{{ 'common.search' | i18n }}
|
||||
</button>
|
||||
<input
|
||||
style="margin-right: 5px; float: right; width: 150px; border-radius: 9px; text-align: center"
|
||||
nz-input
|
||||
type="text"
|
||||
placeholder="搜索告警内容"
|
||||
[placeholder]="'alert.center.search' | i18n"
|
||||
nzSize="default"
|
||||
(keyup.enter)="onFilterSearchAlerts()"
|
||||
[(ngModel)]="filterContent"
|
||||
@@ -43,23 +45,24 @@
|
||||
<nz-select
|
||||
style="margin-right: 10px; float: right; width: 120px"
|
||||
nzAllowClear
|
||||
[nzPlaceHolder]="'告警状态过滤'"
|
||||
[nzPlaceHolder]="'alert.center.filter-status' | i18n"
|
||||
[(ngModel)]="filterStatus"
|
||||
>
|
||||
<nz-option nzLabel="全部状态" nzValue="9"></nz-option>
|
||||
<nz-option nzLabel="未处理" nzValue="0"></nz-option>
|
||||
<nz-option nzLabel="已处理" nzValue="3"></nz-option>
|
||||
<nz-option [nzLabel]="'alert.status.all' | i18n" nzValue="9"></nz-option>
|
||||
<nz-option [nzLabel]="'alert.status.0' | i18n" nzValue="0"></nz-option>
|
||||
<nz-option [nzLabel]="'alert.status.2' | i18n" nzValue="2"></nz-option>
|
||||
<nz-option [nzLabel]="'alert.status.3' | i18n" nzValue="3"></nz-option>
|
||||
</nz-select>
|
||||
<nz-select
|
||||
style="margin-right: 10px; float: right; width: 120px"
|
||||
nzAllowClear
|
||||
[nzPlaceHolder]="'告警级别过滤'"
|
||||
[nzPlaceHolder]="'alert.center.filter-priority' | i18n"
|
||||
[(ngModel)]="filterPriority"
|
||||
>
|
||||
<nz-option nzLabel="全部级别" nzValue="9"></nz-option>
|
||||
<nz-option nzLabel="警告级别" nzValue="2"></nz-option>
|
||||
<nz-option nzLabel="严重级别" nzValue="1"></nz-option>
|
||||
<nz-option nzLabel="紧急级别" nzValue="0"></nz-option>
|
||||
<nz-option [nzLabel]="'alert.priority.all' | i18n" nzValue="9"></nz-option>
|
||||
<nz-option [nzLabel]="'alert.priority.2' | i18n" nzValue="2"></nz-option>
|
||||
<nz-option [nzLabel]="'alert.priority.1' | i18n" nzValue="1"></nz-option>
|
||||
<nz-option [nzLabel]="'alert.priority.0' | i18n" nzValue="0"></nz-option>
|
||||
</nz-select>
|
||||
</div>
|
||||
|
||||
@@ -81,13 +84,13 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th nzAlign="center" nzLeft nzWidth="4%" [(nzChecked)]="checkedAll" (nzCheckedChange)="onAllChecked($event)"></th>
|
||||
<th nzAlign="center" nzLeft>告警指标</th>
|
||||
<th nzAlign="center">所属监控</th>
|
||||
<th nzAlign="center">级别</th>
|
||||
<th nzAlign="center">告警内容</th>
|
||||
<th nzAlign="center">状态</th>
|
||||
<th nzAlign="center">告警时间</th>
|
||||
<th nzAlign="center">操作</th>
|
||||
<th nzAlign="center" nzLeft>{{ 'alert.center.target' | i18n }}</th>
|
||||
<th nzAlign="center">{{ 'alert.center.monitor' | i18n }}</th>
|
||||
<th nzAlign="center">{{ 'alert.center.priority' | i18n }}</th>
|
||||
<th nzAlign="center">{{ 'alert.center.content' | i18n }}</th>
|
||||
<th nzAlign="center">{{ 'alert.center.status' | i18n }}</th>
|
||||
<th nzAlign="center">{{ 'alert.center.time' | i18n }}</th>
|
||||
<th nzAlign="center">{{ 'common.edit' | i18n }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -102,30 +105,36 @@
|
||||
<td nzAlign="center">
|
||||
<nz-tag *ngIf="data.priority == 0" nzColor="red">
|
||||
<i nz-icon nzType="bell" nzTheme="outline"></i>
|
||||
<span>紧急告警</span>
|
||||
<span>{{ 'alert.priority.0' | i18n }}</span>
|
||||
</nz-tag>
|
||||
<nz-tag *ngIf="data.priority == 1" nzColor="orange">
|
||||
<i nz-icon nzType="bell" nzTheme="outline"></i>
|
||||
<span>严重告警</span>
|
||||
<span>{{ 'alert.priority.1' | i18n }}</span>
|
||||
</nz-tag>
|
||||
<nz-tag *ngIf="data.priority == 2" nzColor="yellow">
|
||||
<i nz-icon nzType="bell" nzTheme="outline"></i>
|
||||
<span>警告告警</span>
|
||||
<span>{{ 'alert.priority.2' | i18n }}</span>
|
||||
</nz-tag>
|
||||
</td>
|
||||
<td nzAlign="center">{{ data.content }}</td>
|
||||
<td nzAlign="center">
|
||||
{{ data.status === 0 ? '未处理' : '已处理' }}
|
||||
{{ 'alert.status.' + data.status | i18n }}
|
||||
</td>
|
||||
<td nzAlign="center">{{ data.gmtCreate | date: 'YYYY-MM-dd HH:mm:ss' }}</td>
|
||||
<td nzAlign="center">
|
||||
<button nz-button nzType="primary" (click)="onDeleteOneAlert(data.id)" nz-tooltip nzTooltipTitle="删除告警">
|
||||
<button nz-button nzType="primary" (click)="onDeleteOneAlert(data.id)" nz-tooltip [nzTooltipTitle]="'alert.center.delete' | i18n">
|
||||
<i nz-icon nzType="delete" nzTheme="outline"></i>
|
||||
</button>
|
||||
<button nz-button nzType="primary" (click)="onMarkReadOneAlert(data.id)" nz-tooltip nzTooltipTitle="标记已处理">
|
||||
<button nz-button nzType="primary" (click)="onMarkReadOneAlert(data.id)" nz-tooltip [nzTooltipTitle]="'alert.center.deal' | i18n">
|
||||
<i nz-icon nzType="down-circle" nzTheme="outline"></i>
|
||||
</button>
|
||||
<button nz-button nzType="primary" (click)="onMarkUnReadOneAlert(data.id)" nz-tooltip nzTooltipTitle="标记未处理">
|
||||
<button
|
||||
nz-button
|
||||
nzType="primary"
|
||||
(click)="onMarkUnReadOneAlert(data.id)"
|
||||
nz-tooltip
|
||||
[nzTooltipTitle]="'alert.center.no-deal' | i18n"
|
||||
>
|
||||
<i nz-icon nzType="up-circle" nzTheme="outline"></i>
|
||||
</button>
|
||||
</td>
|
||||
@@ -133,4 +142,4 @@
|
||||
</tbody>
|
||||
</nz-table>
|
||||
|
||||
<ng-template #rangeTemplate> 总量 {{ total }} </ng-template>
|
||||
<ng-template #rangeTemplate> {{ 'common.total' | i18n }} {{ total }} </ng-template>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component, Inject, OnInit } from '@angular/core';
|
||||
import { I18NService } from '@core';
|
||||
import { ALAIN_I18N_TOKEN } from '@delon/theme';
|
||||
import { NzModalService } from 'ng-zorro-antd/modal';
|
||||
import { NzNotificationService } from 'ng-zorro-antd/notification';
|
||||
import { NzTableQueryParams } from 'ng-zorro-antd/table';
|
||||
@@ -12,7 +14,12 @@ import { AlertService } from '../../../service/alert.service';
|
||||
styles: []
|
||||
})
|
||||
export class AlertCenterComponent implements OnInit {
|
||||
constructor(private notifySvc: NzNotificationService, private modal: NzModalService, private alertSvc: AlertService) {}
|
||||
constructor(
|
||||
private notifySvc: NzNotificationService,
|
||||
private modal: NzModalService,
|
||||
private alertSvc: AlertService,
|
||||
@Inject(ALAIN_I18N_TOKEN) private i18nSvc: I18NService
|
||||
) {}
|
||||
|
||||
pageIndex: number = 1;
|
||||
pageSize: number = 8;
|
||||
@@ -87,13 +94,13 @@ export class AlertCenterComponent implements OnInit {
|
||||
|
||||
onDeleteAlerts() {
|
||||
if (this.checkedAlertIds == null || this.checkedAlertIds.size === 0) {
|
||||
this.notifySvc.warning('未选中任何待删除项!', '');
|
||||
this.notifySvc.warning(this.i18nSvc.fanyi('alert.center.notify.no-delete'), '');
|
||||
return;
|
||||
}
|
||||
this.modal.confirm({
|
||||
nzTitle: '请确认是否批量删除!',
|
||||
nzOkText: '确定',
|
||||
nzCancelText: '取消',
|
||||
nzTitle: this.i18nSvc.fanyi('alert.center.confirm.delete-batch'),
|
||||
nzOkText: this.i18nSvc.fanyi('common.button.ok'),
|
||||
nzCancelText: this.i18nSvc.fanyi('common.button.cancel'),
|
||||
nzOkDanger: true,
|
||||
nzOkType: 'primary',
|
||||
nzOnOk: () => this.deleteAlerts(this.checkedAlertIds)
|
||||
@@ -102,13 +109,13 @@ export class AlertCenterComponent implements OnInit {
|
||||
|
||||
onMarkReadAlerts() {
|
||||
if (this.checkedAlertIds == null || this.checkedAlertIds.size === 0) {
|
||||
this.notifySvc.warning('未选中任何待标记项!', '');
|
||||
this.notifySvc.warning(this.i18nSvc.fanyi('alert.center.notify.no-mark'), '');
|
||||
return;
|
||||
}
|
||||
this.modal.confirm({
|
||||
nzTitle: '请确认是否批量标记已处理!',
|
||||
nzOkText: '确定',
|
||||
nzCancelText: '取消',
|
||||
nzTitle: this.i18nSvc.fanyi('alert.center.confirm.mark-done-batch'),
|
||||
nzOkText: this.i18nSvc.fanyi('common.button.ok'),
|
||||
nzCancelText: this.i18nSvc.fanyi('common.button.cancel'),
|
||||
nzOkDanger: true,
|
||||
nzOkType: 'primary',
|
||||
nzOnOk: () => this.updateAlertsStatus(this.checkedAlertIds, 3)
|
||||
@@ -116,13 +123,13 @@ export class AlertCenterComponent implements OnInit {
|
||||
}
|
||||
onMarkUnReadAlerts() {
|
||||
if (this.checkedAlertIds == null || this.checkedAlertIds.size === 0) {
|
||||
this.notifySvc.warning('未选中任何待标记项!', '');
|
||||
this.notifySvc.warning(this.i18nSvc.fanyi('alert.center.notify.no-mark'), '');
|
||||
return;
|
||||
}
|
||||
this.modal.confirm({
|
||||
nzTitle: '请确认是否批量标记未处理!',
|
||||
nzOkText: '确定',
|
||||
nzCancelText: '取消',
|
||||
nzTitle: this.i18nSvc.fanyi('alert.center.confirm.mark-no-batch'),
|
||||
nzOkText: this.i18nSvc.fanyi('common.button.ok'),
|
||||
nzCancelText: this.i18nSvc.fanyi('common.button.cancel'),
|
||||
nzOkDanger: true,
|
||||
nzOkType: 'primary',
|
||||
nzOnOk: () => this.updateAlertsStatus(this.checkedAlertIds, 0)
|
||||
@@ -133,9 +140,9 @@ export class AlertCenterComponent implements OnInit {
|
||||
let alerts = new Set<number>();
|
||||
alerts.add(alertId);
|
||||
this.modal.confirm({
|
||||
nzTitle: '请确认是否删除!',
|
||||
nzOkText: '确定',
|
||||
nzCancelText: '取消',
|
||||
nzTitle: this.i18nSvc.fanyi('common.confirm.delete'),
|
||||
nzOkText: this.i18nSvc.fanyi('common.button.ok'),
|
||||
nzCancelText: this.i18nSvc.fanyi('common.button.cancel'),
|
||||
nzOkDanger: true,
|
||||
nzOkType: 'primary',
|
||||
nzOnOk: () => this.deleteAlerts(alerts)
|
||||
@@ -146,9 +153,9 @@ export class AlertCenterComponent implements OnInit {
|
||||
let alerts = new Set<number>();
|
||||
alerts.add(alertId);
|
||||
this.modal.confirm({
|
||||
nzTitle: '请确认是否标记已处理!',
|
||||
nzOkText: '确定',
|
||||
nzCancelText: '取消',
|
||||
nzTitle: this.i18nSvc.fanyi('alert.center.confirm.mark-done'),
|
||||
nzOkText: this.i18nSvc.fanyi('common.button.ok'),
|
||||
nzCancelText: this.i18nSvc.fanyi('common.button.cancel'),
|
||||
nzOkDanger: true,
|
||||
nzOkType: 'primary',
|
||||
nzOnOk: () => this.updateAlertsStatus(alerts, 3)
|
||||
@@ -159,9 +166,9 @@ export class AlertCenterComponent implements OnInit {
|
||||
let alerts = new Set<number>();
|
||||
alerts.add(alertId);
|
||||
this.modal.confirm({
|
||||
nzTitle: '请确认是否标记未处理!',
|
||||
nzOkText: '确定',
|
||||
nzCancelText: '取消',
|
||||
nzTitle: this.i18nSvc.fanyi('alert.center.confirm.mark-no'),
|
||||
nzOkText: this.i18nSvc.fanyi('common.button.ok'),
|
||||
nzCancelText: this.i18nSvc.fanyi('common.button.cancel'),
|
||||
nzOkDanger: true,
|
||||
nzOkType: 'primary',
|
||||
nzOnOk: () => this.updateAlertsStatus(alerts, 0)
|
||||
@@ -174,17 +181,17 @@ export class AlertCenterComponent implements OnInit {
|
||||
message => {
|
||||
deleteAlerts$.unsubscribe();
|
||||
if (message.code === 0) {
|
||||
this.notifySvc.success('删除成功!', '');
|
||||
this.notifySvc.success(this.i18nSvc.fanyi('common.notify.delete-success'), '');
|
||||
this.loadAlertsTable();
|
||||
} else {
|
||||
this.tableLoading = false;
|
||||
this.notifySvc.error('删除失败!', message.msg);
|
||||
this.notifySvc.error(this.i18nSvc.fanyi('common.notify.delete-fail'), message.msg);
|
||||
}
|
||||
},
|
||||
error => {
|
||||
this.tableLoading = false;
|
||||
deleteAlerts$.unsubscribe();
|
||||
this.notifySvc.error('删除失败!', error.msg);
|
||||
this.notifySvc.error(this.i18nSvc.fanyi('common.notify.delete-fail'), error.msg);
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -195,17 +202,17 @@ export class AlertCenterComponent implements OnInit {
|
||||
message => {
|
||||
markAlertsStatus$.unsubscribe();
|
||||
if (message.code === 0) {
|
||||
this.notifySvc.success('标记成功!', '');
|
||||
this.notifySvc.success(this.i18nSvc.fanyi('common.notify.mark-success'), '');
|
||||
this.loadAlertsTable();
|
||||
} else {
|
||||
this.tableLoading = false;
|
||||
this.notifySvc.error('标记失败!', message.msg);
|
||||
this.notifySvc.error(this.i18nSvc.fanyi('common.notify.mark-fail'), message.msg);
|
||||
}
|
||||
},
|
||||
error => {
|
||||
this.tableLoading = false;
|
||||
markAlertsStatus$.unsubscribe();
|
||||
this.notifySvc.error('标记失败!', error.msg);
|
||||
this.notifySvc.error(this.i18nSvc.fanyi('common.notify.mark-fail'), error.msg);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
<nz-breadcrumb-item>
|
||||
<a [routerLink]="['/']">
|
||||
<i nz-icon nzType="home"></i>
|
||||
<span>仪表盘</span>
|
||||
<span>{{ 'menu.dashboard' | i18n }}</span>
|
||||
</a>
|
||||
</nz-breadcrumb-item>
|
||||
<nz-breadcrumb-item>
|
||||
<i nz-icon nzType="alert"></i>
|
||||
<span>告警通知配置</span>
|
||||
<span>{{ 'menu.alert.dispatch' | i18n }}</span>
|
||||
<a href="https://tancloud.cn/docs/help/alert_email" target="_blank" style="float: right; margin-right: 5%">
|
||||
<span>帮助 </span>
|
||||
<span>{{ 'common.button.help' | i18n }} </span>
|
||||
<i nz-icon nzType="question-circle" nzTheme="outline"></i>
|
||||
</a>
|
||||
</nz-breadcrumb-item>
|
||||
@@ -18,12 +18,12 @@
|
||||
<nz-divider></nz-divider>
|
||||
|
||||
<nz-tabset nzSize="large">
|
||||
<nz-tab nzTitle="告警接收人">
|
||||
<nz-tab [nzTitle]="'alert.notice.receiver' | i18n">
|
||||
<button nz-button nzType="primary" (click)="onNewNoticeReceiver()">
|
||||
<i nz-icon nzType="appstore-add" nzTheme="outline"></i>
|
||||
新增接收人
|
||||
{{ 'alert.notice.receiver.new' | i18n }}
|
||||
</button>
|
||||
<button nz-button nzType="primary" (click)="syncReceiver()" nz-tooltip nzTooltipTitle="刷新">
|
||||
<button nz-button nzType="primary" (click)="syncReceiver()" nz-tooltip [nzTooltipTitle]="'common.refresh' | i18n">
|
||||
<i nz-icon nzType="sync" nzTheme="outline"></i>
|
||||
</button>
|
||||
<nz-table
|
||||
@@ -35,11 +35,11 @@
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th nzAlign="center" nzWidth="10%">接收人</th>
|
||||
<th nzAlign="center" nzWidth="20%">通知方式</th>
|
||||
<th nzAlign="center" nzWidth="20%">配置</th>
|
||||
<th nzAlign="center" nzWidth="20%">最新修改时间</th>
|
||||
<th nzAlign="center" nzWidth="30%">操作</th>
|
||||
<th nzAlign="center" nzWidth="10%">{{ 'alert.notice.receiver.people' | i18n }}</th>
|
||||
<th nzAlign="center" nzWidth="20%">{{ 'alert.notice.receiver.type' | i18n }}</th>
|
||||
<th nzAlign="center" nzWidth="20%">{{ 'alert.notice.receiver.setting' | i18n }}</th>
|
||||
<th nzAlign="center" nzWidth="20%">{{ 'common.edit-time' | i18n }}</th>
|
||||
<th nzAlign="center" nzWidth="30%">{{ 'common.edit' | i18n }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -50,11 +50,11 @@
|
||||
<td nzAlign="center">
|
||||
<nz-tag *ngIf="data.type == 0" nzColor="orange">
|
||||
<i nz-icon nzType="notification" nzTheme="outline"></i>
|
||||
<span>短信</span>
|
||||
<span>{{ 'alert.notice.type.sms' | i18n }}</span>
|
||||
</nz-tag>
|
||||
<nz-tag *ngIf="data.type == 1" nzColor="orange">
|
||||
<i nz-icon nzType="notification" nzTheme="outline"></i>
|
||||
<span>邮件</span>
|
||||
<span>{{ 'alert.notice.type.email' | i18n }}</span>
|
||||
</nz-tag>
|
||||
<nz-tag *ngIf="data.type == 2" nzColor="orange">
|
||||
<i nz-icon nzType="notification" nzTheme="outline"></i>
|
||||
@@ -62,19 +62,19 @@
|
||||
</nz-tag>
|
||||
<nz-tag *ngIf="data.type == 3" nzColor="orange">
|
||||
<i nz-icon nzType="notification" nzTheme="outline"></i>
|
||||
<span>微信公众号</span>
|
||||
<span>{{ 'alert.notice.type.wechat' | i18n }}</span>
|
||||
</nz-tag>
|
||||
<nz-tag *ngIf="data.type == 4" nzColor="orange">
|
||||
<i nz-icon nzType="notification" nzTheme="outline"></i>
|
||||
<span>企业微信机器人</span>
|
||||
<span>{{ 'alert.notice.type.wework' | i18n }}</span>
|
||||
</nz-tag>
|
||||
<nz-tag *ngIf="data.type == 5" nzColor="orange">
|
||||
<i nz-icon nzType="notification" nzTheme="outline"></i>
|
||||
<span>钉钉机器人</span>
|
||||
<span>{{ 'alert.notice.type.ding' | i18n }}</span>
|
||||
</nz-tag>
|
||||
<nz-tag *ngIf="data.type == 6" nzColor="orange">
|
||||
<i nz-icon nzType="notification" nzTheme="outline"></i>
|
||||
<span>飞书机器人</span>
|
||||
<span>{{ 'alert.notice.type.fei-shu' | i18n }}</span>
|
||||
</nz-tag>
|
||||
</td>
|
||||
<td nzAlign="center">
|
||||
@@ -88,10 +88,22 @@
|
||||
</td>
|
||||
<td nzAlign="center">{{ (data.gmtUpdate ? data.gmtUpdate : data.gmtCreate) | date: 'YYYY-MM-dd HH:mm:ss' }}</td>
|
||||
<td nzAlign="center">
|
||||
<button nz-button nzType="primary" (click)="onEditOneNoticeReceiver(data)" nz-tooltip nzTooltipTitle="修改接收人">
|
||||
<button
|
||||
nz-button
|
||||
nzType="primary"
|
||||
(click)="onEditOneNoticeReceiver(data)"
|
||||
nz-tooltip
|
||||
[nzTooltipTitle]="'alert.notice.receiver.edit' | i18n"
|
||||
>
|
||||
<i nz-icon nzType="edit" nzTheme="outline"></i>
|
||||
</button>
|
||||
<button nz-button nzType="primary" (click)="onDeleteOneNoticeReceiver(data.id)" nz-tooltip nzTooltipTitle="删除接收人">
|
||||
<button
|
||||
nz-button
|
||||
nzType="primary"
|
||||
(click)="onDeleteOneNoticeReceiver(data.id)"
|
||||
nz-tooltip
|
||||
[nzTooltipTitle]="'alert.notice.receiver.delete' | i18n"
|
||||
>
|
||||
<i nz-icon nzType="delete" nzTheme="outline"></i>
|
||||
</button>
|
||||
</td>
|
||||
@@ -99,12 +111,12 @@
|
||||
</tbody>
|
||||
</nz-table>
|
||||
</nz-tab>
|
||||
<nz-tab nzTitle="告警通知策略">
|
||||
<nz-tab [nzTitle]="'alert.notice.rule' | i18n">
|
||||
<button nz-button nzType="primary" (click)="onNewNoticeRule()">
|
||||
<i nz-icon nzType="appstore-add" nzTheme="outline"></i>
|
||||
新增通知策略
|
||||
{{ 'alert.notice.rule.new' | i18n }}
|
||||
</button>
|
||||
<button nz-button nzType="primary" (click)="syncRule()" nz-tooltip nzTooltipTitle="刷新">
|
||||
<button nz-button nzType="primary" (click)="syncRule()" nz-tooltip [nzTooltipTitle]="'common.refresh' | i18n">
|
||||
<i nz-icon nzType="sync" nzTheme="outline"></i>
|
||||
</button>
|
||||
<nz-table
|
||||
@@ -116,12 +128,12 @@
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th nzAlign="center" nzWidth="15%">策略名称</th>
|
||||
<th nzAlign="center" nzWidth="12%">接收人</th>
|
||||
<th nzAlign="center" nzWidth="12%">转发所有</th>
|
||||
<th nzAlign="center" nzWidth="15%">是否启用</th>
|
||||
<th nzAlign="center" nzWidth="15%">最新修改时间</th>
|
||||
<th nzAlign="center" nzWidth="25%">操作</th>
|
||||
<th nzAlign="center" nzWidth="15%">{{ 'alert.notice.rule.name' | i18n }}</th>
|
||||
<th nzAlign="center" nzWidth="12%">{{ 'alert.notice.receiver.people' | i18n }}</th>
|
||||
<th nzAlign="center" nzWidth="12%">{{ 'alert.notice.rule.all' | i18n }}</th>
|
||||
<th nzAlign="center" nzWidth="15%">{{ 'alert.notice.rule.enable' | i18n }}</th>
|
||||
<th nzAlign="center" nzWidth="15%">{{ 'common.edit-time' | i18n }}</th>
|
||||
<th nzAlign="center" nzWidth="25%">{{ 'common.edit' | i18n }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -134,26 +146,38 @@
|
||||
</td>
|
||||
<td nzAlign="center">
|
||||
<nz-tag *ngIf="data.filterAll" nzColor="green">
|
||||
<span>是</span>
|
||||
<span>{{ 'common.yes' | i18n }}</span>
|
||||
</nz-tag>
|
||||
<nz-tag *ngIf="!data.filterAll" nzColor="orange">
|
||||
<span>否</span>
|
||||
<span>{{ 'common.no' | i18n }}</span>
|
||||
</nz-tag>
|
||||
</td>
|
||||
<td nzAlign="center">
|
||||
<nz-tag *ngIf="data.enable" nzColor="green">
|
||||
<span>开启</span>
|
||||
<span>{{ 'common.enable' | i18n }}</span>
|
||||
</nz-tag>
|
||||
<nz-tag *ngIf="!data.enable" nzColor="orange">
|
||||
<span>关闭</span>
|
||||
<span>{{ 'common.disable' | i18n }}</span>
|
||||
</nz-tag>
|
||||
</td>
|
||||
<td nzAlign="center">{{ (data.gmtUpdate ? data.gmtUpdate : data.gmtCreate) | date: 'YYYY-MM-dd HH:mm:ss' }}</td>
|
||||
<td nzAlign="center">
|
||||
<button nz-button nzType="primary" (click)="onEditOneNoticeRule(data)" nz-tooltip nzTooltipTitle="修改告警策略">
|
||||
<button
|
||||
nz-button
|
||||
nzType="primary"
|
||||
(click)="onEditOneNoticeRule(data)"
|
||||
nz-tooltip
|
||||
[nzTooltipTitle]="'alert.notice.rule.edit' | i18n"
|
||||
>
|
||||
<i nz-icon nzType="edit" nzTheme="outline"></i>
|
||||
</button>
|
||||
<button nz-button nzType="primary" (click)="onDeleteOneNoticeRule(data.id)" nz-tooltip nzTooltipTitle="删除告警策略">
|
||||
<button
|
||||
nz-button
|
||||
nzType="primary"
|
||||
(click)="onDeleteOneNoticeRule(data.id)"
|
||||
nz-tooltip
|
||||
[nzTooltipTitle]="'alert.notice.rule.delete' | i18n"
|
||||
>
|
||||
<i nz-icon nzType="delete" nzTheme="outline"></i>
|
||||
</button>
|
||||
</td>
|
||||
@@ -166,7 +190,7 @@
|
||||
<!-- 新增或修改通知接收人弹出框 -->
|
||||
<nz-modal
|
||||
[(nzVisible)]="isManageReceiverModalVisible"
|
||||
[nzTitle]="isManageReceiverModalAdd ? '新增接收人' : '修改接收人'"
|
||||
[nzTitle]="isManageReceiverModalAdd ? ('alert.notice.receiver.new' | i18n) : ('alert.notice.receiver.edit' | i18n)"
|
||||
(nzOnCancel)="onManageReceiverModalCancel()"
|
||||
(nzOnOk)="onManageReceiverModalOk()"
|
||||
nzMaskClosable="false"
|
||||
@@ -176,27 +200,27 @@
|
||||
<div *nzModalContent class="-inner-content">
|
||||
<form nz-form #receiverForm="ngForm">
|
||||
<nz-form-item>
|
||||
<nz-form-label [nzSpan]="7" nzFor="name" nzRequired="true">接收人名称</nz-form-label>
|
||||
<nz-form-label [nzSpan]="7" nzFor="name" nzRequired="true">{{ 'alert.notice.receiver.people.name' | i18n }}</nz-form-label>
|
||||
<nz-form-control [nzSpan]="12" [nzErrorTip]="'validation.required' | i18n">
|
||||
<input [(ngModel)]="receiver.name" nz-input required name="name" type="text" id="name" />
|
||||
</nz-form-control>
|
||||
</nz-form-item>
|
||||
<nz-form-item>
|
||||
<nz-form-label nzSpan="7" nzRequired="true" nzFor="type">通知方式 </nz-form-label>
|
||||
<nz-form-label nzSpan="7" nzRequired="true" nzFor="type">{{ 'alert.notice.receiver.type' | i18n }} </nz-form-label>
|
||||
<nz-form-control nzSpan="12" [nzErrorTip]="'validation.required' | i18n">
|
||||
<nz-select [(ngModel)]="receiver.type" nzPlaceHolder="Choose" required name="type" id="type">
|
||||
<nz-option [nzValue]="0" nzDisabled nzLabel="短信"></nz-option>
|
||||
<nz-option [nzValue]="1" nzLabel="邮箱"></nz-option>
|
||||
<nz-option [nzValue]="0" nzDisabled [nzLabel]="'alert.notice.type.sms' | i18n"></nz-option>
|
||||
<nz-option [nzValue]="1" [nzLabel]="'alert.notice.type.email' | i18n"></nz-option>
|
||||
<nz-option [nzValue]="2" nzLabel="WebHook"></nz-option>
|
||||
<nz-option [nzValue]="3" nzDisabled nzLabel="微信公众号"></nz-option>
|
||||
<nz-option [nzValue]="4" nzLabel="企业微信机器人"></nz-option>
|
||||
<nz-option [nzValue]="5" nzLabel="钉钉机器人"></nz-option>
|
||||
<nz-option [nzValue]="6" nzLabel="飞书机器人"></nz-option>
|
||||
<nz-option [nzValue]="3" nzDisabled [nzLabel]="'alert.notice.type.wechat' | i18n"></nz-option>
|
||||
<nz-option [nzValue]="4" [nzLabel]="'alert.notice.type.wework' | i18n"></nz-option>
|
||||
<nz-option [nzValue]="5" [nzLabel]="'alert.notice.type.ding' | i18n"></nz-option>
|
||||
<nz-option [nzValue]="6" [nzLabel]="'alert.notice.type.fei-shu' | i18n"></nz-option>
|
||||
</nz-select>
|
||||
</nz-form-control>
|
||||
</nz-form-item>
|
||||
<nz-form-item *ngIf="receiver.type === 0">
|
||||
<nz-form-label [nzSpan]="7" nzFor="phone" [nzRequired]="receiver.type === 0">手机号</nz-form-label>
|
||||
<nz-form-label [nzSpan]="7" nzFor="phone" [nzRequired]="receiver.type === 0">{{ 'alert.notice.type.phone' | i18n }}</nz-form-label>
|
||||
<nz-form-control [nzSpan]="12" [nzErrorTip]="'validation.phone.invalid' | i18n">
|
||||
<input
|
||||
[(ngModel)]="receiver.phone"
|
||||
@@ -210,37 +234,45 @@
|
||||
</nz-form-control>
|
||||
</nz-form-item>
|
||||
<nz-form-item *ngIf="receiver.type === 1">
|
||||
<nz-form-label [nzSpan]="7" nzFor="email" [nzRequired]="receiver.type === 1">邮箱</nz-form-label>
|
||||
<nz-form-label [nzSpan]="7" nzFor="email" [nzRequired]="receiver.type === 1">{{ 'alert.notice.type.email' | i18n }}</nz-form-label>
|
||||
<nz-form-control [nzSpan]="12" [nzErrorTip]="'validation.email.invalid' | i18n">
|
||||
<input [(ngModel)]="receiver.email" nz-input [required]="receiver.type === 1" email name="email" type="email" id="email" />
|
||||
</nz-form-control>
|
||||
</nz-form-item>
|
||||
<nz-form-item *ngIf="receiver.type === 2">
|
||||
<nz-form-label [nzSpan]="7" nzFor="hookUrl" [nzRequired]="receiver.type === 2">URL地址</nz-form-label>
|
||||
<nz-form-label [nzSpan]="7" nzFor="hookUrl" [nzRequired]="receiver.type === 2">{{ 'alert.notice.type.url' | i18n }}</nz-form-label>
|
||||
<nz-form-control [nzSpan]="12" [nzErrorTip]="'validation.required' | i18n">
|
||||
<input [(ngModel)]="receiver.hookUrl" nz-input [required]="receiver.type === 2" name="hookUrl" type="url" id="hookUrl" />
|
||||
</nz-form-control>
|
||||
</nz-form-item>
|
||||
<nz-form-item *ngIf="receiver.type === 3">
|
||||
<nz-form-label [nzSpan]="7" nzFor="wechatId" [nzRequired]="receiver.type === 3">微信OPENID</nz-form-label>
|
||||
<nz-form-label [nzSpan]="7" nzFor="wechatId" [nzRequired]="receiver.type === 3">{{
|
||||
'alert.notice.type.wechat-id' | i18n
|
||||
}}</nz-form-label>
|
||||
<nz-form-control [nzSpan]="12" [nzErrorTip]="'validation.required' | i18n">
|
||||
<input [(ngModel)]="receiver.wechatId" nz-input [required]="receiver.type === 3" name="wechatId" type="text" />
|
||||
</nz-form-control>
|
||||
</nz-form-item>
|
||||
<nz-form-item *ngIf="receiver.type === 4">
|
||||
<nz-form-label [nzSpan]="7" nzFor="wechatId" [nzRequired]="receiver.type === 4">企业微信机器人KEY</nz-form-label>
|
||||
<nz-form-label [nzSpan]="7" nzFor="wechatId" [nzRequired]="receiver.type === 4">{{
|
||||
'alert.notice.type.wework-key' | i18n
|
||||
}}</nz-form-label>
|
||||
<nz-form-control [nzSpan]="12" [nzErrorTip]="'validation.required' | i18n">
|
||||
<input [(ngModel)]="receiver.wechatId" nz-input [required]="receiver.type === 4" name="wechatId" type="text" />
|
||||
</nz-form-control>
|
||||
</nz-form-item>
|
||||
<nz-form-item *ngIf="receiver.type === 5">
|
||||
<nz-form-label [nzSpan]="7" nzFor="accessToken" [nzRequired]="receiver.type === 5">机器人ACCESS_TOKEN</nz-form-label>
|
||||
<nz-form-label [nzSpan]="7" nzFor="accessToken" [nzRequired]="receiver.type === 5">{{
|
||||
'alert.notice.type.access-token' | i18n
|
||||
}}</nz-form-label>
|
||||
<nz-form-control [nzSpan]="12" [nzErrorTip]="'validation.required' | i18n">
|
||||
<input [(ngModel)]="receiver.accessToken" nz-input [required]="receiver.type === 5" name="accessToken" type="text" />
|
||||
</nz-form-control>
|
||||
</nz-form-item>
|
||||
<nz-form-item *ngIf="receiver.type === 6">
|
||||
<nz-form-label [nzSpan]="7" nzFor="wechatId" [nzRequired]="receiver.type === 6">飞书机器人KEY</nz-form-label>
|
||||
<nz-form-label [nzSpan]="7" nzFor="wechatId" [nzRequired]="receiver.type === 6">{{
|
||||
'alert.notice.type.fei-shu-key' | i18n
|
||||
}}</nz-form-label>
|
||||
<nz-form-control [nzSpan]="12" [nzErrorTip]="'validation.required' | i18n">
|
||||
<input [(ngModel)]="receiver.wechatId" nz-input [required]="receiver.type === 6" name="wechatId" type="text" />
|
||||
</nz-form-control>
|
||||
@@ -252,7 +284,7 @@
|
||||
<!-- 新增或修改通知策略弹出框 -->
|
||||
<nz-modal
|
||||
[(nzVisible)]="isManageRuleModalVisible"
|
||||
[nzTitle]="isManageRuleModalAdd ? '新增策略' : '修改策略'"
|
||||
[nzTitle]="isManageRuleModalAdd ? ('alert.notice.rule.new' | i18n) : ('alert.notice.rule.edit' | i18n)"
|
||||
(nzOnCancel)="onManageRuleModalCancel()"
|
||||
(nzOnOk)="onManageRuleModalOk()"
|
||||
nzMaskClosable="false"
|
||||
@@ -262,19 +294,19 @@
|
||||
<div *nzModalContent class="-inner-content">
|
||||
<form nz-form #ruleForm="ngForm">
|
||||
<nz-form-item>
|
||||
<nz-form-label [nzSpan]="7" nzFor="rule_name" nzRequired="true">策略名称</nz-form-label>
|
||||
<nz-form-label [nzSpan]="7" nzFor="rule_name" nzRequired="true">{{ 'alert.notice.rule.name' | i18n }}</nz-form-label>
|
||||
<nz-form-control [nzSpan]="8" [nzErrorTip]="'validation.required' | i18n">
|
||||
<input [(ngModel)]="rule.name" nz-input required name="rule_name" type="text" id="rule_name" />
|
||||
</nz-form-control>
|
||||
</nz-form-item>
|
||||
<nz-form-item>
|
||||
<nz-form-label nzSpan="7" nzRequired="true" nzFor="filterAll">转发所有</nz-form-label>
|
||||
<nz-form-label nzSpan="7" nzRequired="true" nzFor="filterAll">{{ 'alert.notice.rule.all' | i18n }}</nz-form-label>
|
||||
<nz-form-control nzSpan="8">
|
||||
<nz-switch [(ngModel)]="rule.filterAll" disabled name="filterAll" id="filterAll"></nz-switch>
|
||||
</nz-form-control>
|
||||
</nz-form-item>
|
||||
<nz-form-item>
|
||||
<nz-form-label nzSpan="7" nzRequired="true" nzFor="receiver">接收人</nz-form-label>
|
||||
<nz-form-label nzSpan="7" nzRequired="true" nzFor="receiver">{{ 'alert.notice.receiver.people' | i18n }}</nz-form-label>
|
||||
<nz-form-control nzSpan="8" [nzErrorTip]="'validation.required' | i18n">
|
||||
<nz-select
|
||||
[(ngModel)]="rule.receiverId"
|
||||
@@ -291,7 +323,7 @@
|
||||
</nz-form-control>
|
||||
</nz-form-item>
|
||||
<nz-form-item>
|
||||
<nz-form-label nzSpan="7" nzRequired="true" nzFor="enable">是否启用</nz-form-label>
|
||||
<nz-form-label nzSpan="7" nzRequired="true" nzFor="enable">{{ 'alert.notice.rule.enable' | i18n }}</nz-form-label>
|
||||
<nz-form-control nzSpan="8">
|
||||
<nz-switch [(ngModel)]="rule.enable" name="enable" id="enable"></nz-switch>
|
||||
</nz-form-control>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component, Inject, OnInit } from '@angular/core';
|
||||
import { I18NService } from '@core';
|
||||
import { ALAIN_I18N_TOKEN } from '@delon/theme';
|
||||
import { NzModalService } from 'ng-zorro-antd/modal';
|
||||
import { NzNotificationService } from 'ng-zorro-antd/notification';
|
||||
import { finalize } from 'rxjs/operators';
|
||||
@@ -18,7 +20,8 @@ export class AlertNoticeComponent implements OnInit {
|
||||
private notifySvc: NzNotificationService,
|
||||
private noticeReceiverSvc: NoticeReceiverService,
|
||||
private modal: NzModalService,
|
||||
private noticeRuleSvc: NoticeRuleService
|
||||
private noticeRuleSvc: NoticeRuleService,
|
||||
@Inject(ALAIN_I18N_TOKEN) private i18nSvc: I18NService
|
||||
) {}
|
||||
|
||||
receivers!: NoticeReceiver[];
|
||||
@@ -78,9 +81,9 @@ export class AlertNoticeComponent implements OnInit {
|
||||
|
||||
onDeleteOneNoticeReceiver(receiveId: number) {
|
||||
this.modal.confirm({
|
||||
nzTitle: '请确认是否删除!',
|
||||
nzOkText: '确定',
|
||||
nzCancelText: '取消',
|
||||
nzTitle: this.i18nSvc.fanyi('common.confirm.delete'),
|
||||
nzOkText: this.i18nSvc.fanyi('common.button.ok'),
|
||||
nzCancelText: this.i18nSvc.fanyi('common.button.cancel'),
|
||||
nzOkDanger: true,
|
||||
nzOkType: 'primary',
|
||||
nzOnOk: () => this.deleteOneNoticeReceiver(receiveId)
|
||||
@@ -98,23 +101,23 @@ export class AlertNoticeComponent implements OnInit {
|
||||
.subscribe(
|
||||
message => {
|
||||
if (message.code === 0) {
|
||||
this.notifySvc.success('删除成功!', '');
|
||||
this.notifySvc.success(this.i18nSvc.fanyi('common.notify.delete-success'), '');
|
||||
this.loadReceiversTable();
|
||||
} else {
|
||||
this.notifySvc.error('删除失败!', message.msg);
|
||||
this.notifySvc.error(this.i18nSvc.fanyi('common.notify.delete-fail'), message.msg);
|
||||
}
|
||||
},
|
||||
error => {
|
||||
this.notifySvc.error('删除失败!', error.msg);
|
||||
this.notifySvc.error(this.i18nSvc.fanyi('common.notify.delete-fail'), error.msg);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
onDeleteOneNoticeRule(ruleId: number) {
|
||||
this.modal.confirm({
|
||||
nzTitle: '请确认是否删除!',
|
||||
nzOkText: '确定',
|
||||
nzCancelText: '取消',
|
||||
nzTitle: this.i18nSvc.fanyi('common.confirm.delete'),
|
||||
nzOkText: this.i18nSvc.fanyi('common.button.ok'),
|
||||
nzCancelText: this.i18nSvc.fanyi('common.button.cancel'),
|
||||
nzOkDanger: true,
|
||||
nzOkType: 'primary',
|
||||
nzOnOk: () => this.deleteOneNoticeRule(ruleId)
|
||||
@@ -132,14 +135,14 @@ export class AlertNoticeComponent implements OnInit {
|
||||
.subscribe(
|
||||
message => {
|
||||
if (message.code === 0) {
|
||||
this.notifySvc.success('删除成功!', '');
|
||||
this.notifySvc.success(this.i18nSvc.fanyi('common.notify.delete-success'), '');
|
||||
this.loadRulesTable();
|
||||
} else {
|
||||
this.notifySvc.error('删除失败!', message.msg);
|
||||
this.notifySvc.error(this.i18nSvc.fanyi('common.notify.delete-fail'), message.msg);
|
||||
}
|
||||
},
|
||||
error => {
|
||||
this.notifySvc.error('删除失败!', error.msg);
|
||||
this.notifySvc.error(this.i18nSvc.fanyi('common.notify.delete-fail'), error.msg);
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -179,14 +182,14 @@ export class AlertNoticeComponent implements OnInit {
|
||||
message => {
|
||||
if (message.code === 0) {
|
||||
this.isManageReceiverModalVisible = false;
|
||||
this.notifySvc.success('新增成功!', '');
|
||||
this.notifySvc.success(this.i18nSvc.fanyi('common.notify.new-success'), '');
|
||||
this.loadReceiversTable();
|
||||
} else {
|
||||
this.notifySvc.error('新增失败!', message.msg);
|
||||
this.notifySvc.error(this.i18nSvc.fanyi('common.notify.new-fail'), message.msg);
|
||||
}
|
||||
},
|
||||
error => {
|
||||
this.notifySvc.error('新增失败!', error.msg);
|
||||
this.notifySvc.error(this.i18nSvc.fanyi('common.notify.new-fail'), error.msg);
|
||||
}
|
||||
);
|
||||
} else {
|
||||
@@ -202,14 +205,14 @@ export class AlertNoticeComponent implements OnInit {
|
||||
message => {
|
||||
if (message.code === 0) {
|
||||
this.isManageReceiverModalVisible = false;
|
||||
this.notifySvc.success('修改成功!', '');
|
||||
this.notifySvc.success(this.i18nSvc.fanyi('common.notify.edit-success'), '');
|
||||
this.loadReceiversTable();
|
||||
} else {
|
||||
this.notifySvc.error('修改失败!', message.msg);
|
||||
this.notifySvc.error(this.i18nSvc.fanyi('common.notify.edit-fail'), message.msg);
|
||||
}
|
||||
},
|
||||
error => {
|
||||
this.notifySvc.error('修改失败!', error.msg);
|
||||
this.notifySvc.error(this.i18nSvc.fanyi('common.notify.edit-fail'), error.msg);
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -310,14 +313,14 @@ export class AlertNoticeComponent implements OnInit {
|
||||
message => {
|
||||
if (message.code === 0) {
|
||||
this.isManageRuleModalVisible = false;
|
||||
this.notifySvc.success('新增成功!', '');
|
||||
this.notifySvc.success(this.i18nSvc.fanyi('common.notify.new-success'), '');
|
||||
this.loadRulesTable();
|
||||
} else {
|
||||
this.notifySvc.error('新增失败!', message.msg);
|
||||
this.notifySvc.error(this.i18nSvc.fanyi('common.notify.new-fail'), message.msg);
|
||||
}
|
||||
},
|
||||
error => {
|
||||
this.notifySvc.error('新增失败!', error.msg);
|
||||
this.notifySvc.error(this.i18nSvc.fanyi('common.notify.new-fail'), error.msg);
|
||||
}
|
||||
);
|
||||
} else {
|
||||
@@ -333,14 +336,14 @@ export class AlertNoticeComponent implements OnInit {
|
||||
message => {
|
||||
if (message.code === 0) {
|
||||
this.isManageRuleModalVisible = false;
|
||||
this.notifySvc.success('修改成功!', '');
|
||||
this.notifySvc.success(this.i18nSvc.fanyi('common.notify.edit-success'), '');
|
||||
this.loadRulesTable();
|
||||
} else {
|
||||
this.notifySvc.error('修改失败!', message.msg);
|
||||
this.notifySvc.error(this.i18nSvc.fanyi('common.notify.edit-fail'), message.msg);
|
||||
}
|
||||
},
|
||||
error => {
|
||||
this.notifySvc.error('修改失败!', error.msg);
|
||||
this.notifySvc.error(this.i18nSvc.fanyi('common.notify.edit-fail'), error.msg);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
<nz-breadcrumb-item>
|
||||
<a [routerLink]="['/']">
|
||||
<i nz-icon nzType="home"></i>
|
||||
<span>仪表盘</span>
|
||||
<span>{{ 'menu.dashboard' | i18n }}</span>
|
||||
</a>
|
||||
</nz-breadcrumb-item>
|
||||
<nz-breadcrumb-item>
|
||||
<i nz-icon nzType="alert"></i>
|
||||
<span>告警阈值配置</span>
|
||||
<span>{{ 'menu.alert.setting' | i18n }}</span>
|
||||
<a href="https://tancloud.cn/docs/help/alert_threshold" target="_blank" style="float: right; margin-right: 5%">
|
||||
<span>帮助 </span>
|
||||
<span>{{ 'common.button.help' | i18n }} </span>
|
||||
<i nz-icon nzType="question-circle" nzTheme="outline"></i>
|
||||
</a>
|
||||
</nz-breadcrumb-item>
|
||||
@@ -19,17 +19,17 @@
|
||||
|
||||
<button nz-button nzType="primary" (click)="onNewAlertDefine()">
|
||||
<i nz-icon nzType="appstore-add" nzTheme="outline"></i>
|
||||
新增阈值
|
||||
{{ 'alert.setting.new' | i18n }}
|
||||
</button>
|
||||
<button nz-button nzType="primary" (click)="onEditAlertDefine()">
|
||||
<i nz-icon nzType="edit" nzTheme="outline"></i>
|
||||
编辑
|
||||
{{ 'common.button.edit' | i18n }}
|
||||
</button>
|
||||
<button nz-button nzType="primary" (click)="onDeleteAlertDefines()">
|
||||
<i nz-icon nzType="delete" nzTheme="outline"></i>
|
||||
删除
|
||||
{{ 'common.button.delete' | i18n }}
|
||||
</button>
|
||||
<button nz-button nzType="primary" (click)="sync()" nz-tooltip nzTooltipTitle="刷新">
|
||||
<button nz-button nzType="primary" (click)="sync()" nz-tooltip [nzTooltipTitle]="'common.refresh' | i18n">
|
||||
<i nz-icon nzType="sync" nzTheme="outline"></i>
|
||||
</button>
|
||||
|
||||
@@ -51,14 +51,14 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th nzAlign="center" nzLeft nzWidth="4%" [(nzChecked)]="checkedAll" (nzCheckedChange)="onAllChecked($event)"></th>
|
||||
<th nzAlign="center" nzLeft>指标对象</th>
|
||||
<th nzAlign="center">阈值触发表达式</th>
|
||||
<th nzAlign="center">告警级别</th>
|
||||
<th nzAlign="center">触发次数</th>
|
||||
<th nzAlign="center">通知模版</th>
|
||||
<th nzAlign="center">全局默认</th>
|
||||
<th nzAlign="center">最新修改时间</th>
|
||||
<th nzAlign="center">操作</th>
|
||||
<th nzAlign="center" nzLeft>{{ 'alert.setting.target' | i18n }}</th>
|
||||
<th nzAlign="center">{{ 'alert.setting.expr' | i18n }}</th>
|
||||
<th nzAlign="center">{{ 'alert.priority' | i18n }}</th>
|
||||
<th nzAlign="center">{{ 'alert.setting.times' | i18n }}</th>
|
||||
<th nzAlign="center">{{ 'alert.setting.template' | i18n }}</th>
|
||||
<th nzAlign="center">{{ 'alert.setting.default' | i18n }}</th>
|
||||
<th nzAlign="center">{{ 'common.edit-time' | i18n }}</th>
|
||||
<th nzAlign="center">{{ 'common.edit' | i18n }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -73,36 +73,54 @@
|
||||
<td nzAlign="center">
|
||||
<nz-tag *ngIf="data.priority == 0" nzColor="red">
|
||||
<i nz-icon nzType="bell" nzTheme="outline"></i>
|
||||
<span>紧急告警</span>
|
||||
<span>{{ 'alert.priority.0' | i18n }}</span>
|
||||
</nz-tag>
|
||||
<nz-tag *ngIf="data.priority == 1" nzColor="orange">
|
||||
<i nz-icon nzType="bell" nzTheme="outline"></i>
|
||||
<span>严重告警</span>
|
||||
<span>{{ 'alert.priority.1' | i18n }}</span>
|
||||
</nz-tag>
|
||||
<nz-tag *ngIf="data.priority == 2" nzColor="yellow">
|
||||
<i nz-icon nzType="bell" nzTheme="outline"></i>
|
||||
<span>警告告警</span>
|
||||
<span>{{ 'alert.priority.2' | i18n }}</span>
|
||||
</nz-tag>
|
||||
</td>
|
||||
<td nzAlign="center">{{ data.times }}</td>
|
||||
<td nzAlign="center">{{ data.template }}</td>
|
||||
<td nzAlign="center">
|
||||
<nz-tag *ngIf="data.preset" nzColor="green">
|
||||
<span>是</span>
|
||||
<span>{{ 'common.yes' | i18n }}</span>
|
||||
</nz-tag>
|
||||
<nz-tag *ngIf="!data.preset" nzColor="orange">
|
||||
<span>否</span>
|
||||
<span>{{ 'common.no' | i18n }}</span>
|
||||
</nz-tag>
|
||||
</td>
|
||||
<td nzAlign="center">{{ (data.gmtUpdate ? data.gmtUpdate : data.gmtCreate) | date: 'YYYY-MM-dd HH:mm:ss' }}</td>
|
||||
<td nzAlign="center">
|
||||
<button nz-button nzType="primary" (click)="onOpenConnectModal(data.id, data.app)" nz-tooltip nzTooltipTitle="配置关联监控">
|
||||
<button
|
||||
nz-button
|
||||
nzType="primary"
|
||||
(click)="onOpenConnectModal(data.id, data.app)"
|
||||
nz-tooltip
|
||||
[nzTooltipTitle]="'alert.setting.connect' | i18n"
|
||||
>
|
||||
<i nz-icon nzType="link" nzTheme="outline"></i>
|
||||
</button>
|
||||
<button nz-button nzType="primary" (click)="onEditOneAlertDefine(data.id)" nz-tooltip nzTooltipTitle="修改告警配置">
|
||||
<button
|
||||
nz-button
|
||||
nzType="primary"
|
||||
(click)="onEditOneAlertDefine(data.id)"
|
||||
nz-tooltip
|
||||
[nzTooltipTitle]="'alert.setting.edit' | i18n"
|
||||
>
|
||||
<i nz-icon nzType="edit" nzTheme="outline"></i>
|
||||
</button>
|
||||
<button nz-button nzType="primary" (click)="onDeleteOneAlertDefine(data.id)" nz-tooltip nzTooltipTitle="删除告警配置">
|
||||
<button
|
||||
nz-button
|
||||
nzType="primary"
|
||||
(click)="onDeleteOneAlertDefine(data.id)"
|
||||
nz-tooltip
|
||||
[nzTooltipTitle]="'alert.setting.delete' | i18n"
|
||||
>
|
||||
<i nz-icon nzType="delete" nzTheme="outline"></i>
|
||||
</button>
|
||||
</td>
|
||||
@@ -110,12 +128,12 @@
|
||||
</tbody>
|
||||
</nz-table>
|
||||
|
||||
<ng-template #rangeTemplate> 总量 {{ total }} </ng-template>
|
||||
<ng-template #rangeTemplate> {{ 'common.total' | i18n }} {{ total }} </ng-template>
|
||||
|
||||
<!-- 新增或修改告警定义弹出框 -->
|
||||
<nz-modal
|
||||
[(nzVisible)]="isManageModalVisible"
|
||||
[nzTitle]="isManageModalAdd ? '新增告警阈值' : '修改告警阈值'"
|
||||
[nzTitle]="isManageModalAdd ? ('alert.setting.new' | i18n) : ('alert.setting.edit' | i18n)"
|
||||
(nzOnCancel)="onManageModalCancel()"
|
||||
(nzOnOk)="onManageModalOk()"
|
||||
nzMaskClosable="false"
|
||||
@@ -125,7 +143,7 @@
|
||||
<div *nzModalContent class="-inner-content">
|
||||
<form nz-form #defineForm="ngForm">
|
||||
<nz-form-item>
|
||||
<nz-form-label [nzSpan]="7" nzFor="target" nzRequired="true">指标对象</nz-form-label>
|
||||
<nz-form-label [nzSpan]="7" nzFor="target" nzRequired="true">{{ 'alert.setting.target' | i18n }}</nz-form-label>
|
||||
<nz-form-control [nzSpan]="8" [nzErrorTip]="'validation.required' | i18n">
|
||||
<nz-cascader
|
||||
required
|
||||
@@ -140,19 +158,19 @@
|
||||
<nz-form-item>
|
||||
<nz-col [nzSpan]="8" nzOffset="7">
|
||||
<nz-collapse>
|
||||
<nz-collapse-panel [nzActive]="isManageModalAdd" nzHeader="支持的阈值触发表达式环境变量与操作符">
|
||||
<nz-collapse-panel [nzActive]="isManageModalAdd" [nzHeader]="'alert.setting.expr.tip' | i18n">
|
||||
<nz-list nzSize="small" nzSplit="false">
|
||||
<nz-list-item *ngIf="cascadeValues.length == 3">
|
||||
<code>{{ cascadeValues[2] }} : 选中的指标对象</code>
|
||||
<code>{{ cascadeValues[2] }} : {{ 'alert.setting.target.tip' | i18n }}</code>
|
||||
</nz-list-item>
|
||||
<nz-list-item *ngFor="let item of otherMetrics">
|
||||
<code>{{ item }} : 所属行其它指标对象</code>
|
||||
<code>{{ item }} : {{ 'alert.setting.target.other' | i18n }}</code>
|
||||
</nz-list-item>
|
||||
<nz-list-item *ngIf="otherMetrics.length != 0">
|
||||
<code>instance : 所属行实例</code>
|
||||
<code>instance : {{ 'alert.setting.target.instance' | i18n }}</code>
|
||||
</nz-list-item>
|
||||
<nz-list-item>
|
||||
<code>支持操作符函数 : equals(str1,str2), ==, <, <=, >, >=, !=, ( ), +, -, &&, ||</code>
|
||||
<code>{{ 'alert.setting.operator' | i18n }} : equals(str1,str2), ==, <, <=, >, >=, !=, ( ), +, -, &&, ||</code>
|
||||
</nz-list-item>
|
||||
</nz-list>
|
||||
</nz-collapse-panel>
|
||||
@@ -160,13 +178,8 @@
|
||||
</nz-col>
|
||||
</nz-form-item>
|
||||
<nz-form-item>
|
||||
<nz-form-label
|
||||
[nzSpan]="7"
|
||||
nzFor="expr"
|
||||
nzRequired="true"
|
||||
nzTooltipTitle="根据此表达式来计算判断是否触发阈值,表达式环境变量和操作符见上方"
|
||||
>
|
||||
阈值触发表达式
|
||||
<nz-form-label [nzSpan]="7" nzFor="expr" nzRequired="true" [nzTooltipTitle]="'alert.setting.expr.label' | i18n">
|
||||
{{ 'alert.setting.expr' | i18n }}
|
||||
</nz-form-label>
|
||||
<nz-form-control [nzSpan]="8" [nzErrorTip]="'validation.required' | i18n">
|
||||
<nz-textarea-count [nzMaxCharacterCount]="100">
|
||||
@@ -177,32 +190,27 @@
|
||||
nz-input
|
||||
name="expr"
|
||||
id="expr"
|
||||
placeholder="根据此表达式计算判断是否触发阈值. 示例: responseTime>40"
|
||||
[placeholder]="('alert.setting.expr.example' | i18n) + ': responseTime>40'"
|
||||
>
|
||||
</textarea>
|
||||
</nz-textarea-count>
|
||||
</nz-form-control>
|
||||
</nz-form-item>
|
||||
<nz-form-item>
|
||||
<nz-form-label
|
||||
nzSpan="7"
|
||||
nzRequired="true"
|
||||
nzFor="priority"
|
||||
nzTooltipTitle="触发阈值的告警级别,从低到高依次为:警告-warning,严重-critical,紧急-emergency"
|
||||
>
|
||||
告警级别
|
||||
<nz-form-label nzSpan="7" nzRequired="true" nzFor="priority" [nzTooltipTitle]="'alert.setting.priority.tip' | i18n">
|
||||
{{ 'alert.priority' | i18n }}
|
||||
</nz-form-label>
|
||||
<nz-form-control nzSpan="8" [nzErrorTip]="'validation.required' | i18n">
|
||||
<nz-select [(ngModel)]="define.priority" nzPlaceHolder="Choose" name="priority" id="priority">
|
||||
<nz-option [nzValue]="0" nzLabel="紧急告警"></nz-option>
|
||||
<nz-option [nzValue]="1" nzLabel="严重告警"></nz-option>
|
||||
<nz-option [nzValue]="2" nzLabel="警告告警"></nz-option>
|
||||
<nz-option [nzValue]="0" [nzLabel]="'alert.priority.0' | i18n"></nz-option>
|
||||
<nz-option [nzValue]="1" [nzLabel]="'alert.priority.1' | i18n"></nz-option>
|
||||
<nz-option [nzValue]="2" [nzLabel]="'alert.priority.2' | i18n"></nz-option>
|
||||
</nz-select>
|
||||
</nz-form-control>
|
||||
</nz-form-item>
|
||||
<nz-form-item>
|
||||
<nz-form-label nzSpan="7" nzRequired="true" nzFor="duration" nzTooltipTitle="设置触发阈值多少次之后才会发送告警">
|
||||
触发次数
|
||||
<nz-form-label nzSpan="7" nzRequired="true" nzFor="duration" [nzTooltipTitle]="'alert.setting.times.tip' | i18n">
|
||||
{{ 'alert.setting.times' | i18n }}
|
||||
</nz-form-label>
|
||||
<nz-form-control nzSpan="8" [nzErrorTip]="'validation.required' | i18n">
|
||||
<nz-input-number [(ngModel)]="define.times" [nzMin]="1" [nzMax]="10" [nzStep]="1" required name="duration" id="duration">
|
||||
@@ -212,25 +220,25 @@
|
||||
<nz-form-item>
|
||||
<nz-col [nzSpan]="8" nzOffset="7">
|
||||
<nz-collapse>
|
||||
<nz-collapse-panel [nzActive]="isManageModalAdd" nzHeader="支持的通知模版环境变量">
|
||||
<nz-collapse-panel [nzActive]="isManageModalAdd" [nzHeader]="'alert.setting.template.tip' | i18n">
|
||||
<nz-list nzSize="small" nzSplit="false">
|
||||
<nz-list-item>
|
||||
<code>${app} : 监控类型名称</code>
|
||||
<code>${app} : {{ 'alert.setting.template.monitor-type' | i18n }}</code>
|
||||
</nz-list-item>
|
||||
<nz-list-item>
|
||||
<code>${metrics} : 监控指标集合名称</code>
|
||||
<code>${metrics} : {{ 'alert.setting.template.metrics-name' | i18n }}</code>
|
||||
</nz-list-item>
|
||||
<nz-list-item *ngIf="cascadeValues.length == 3">
|
||||
<code>${metric} : 监控指标名称</code>
|
||||
<code>${metric} : {{ 'alert.setting.template.metric-name' | i18n }}</code>
|
||||
</nz-list-item>
|
||||
<nz-list-item *ngIf="cascadeValues.length == 3">
|
||||
<code>${{ '{' + cascadeValues[2] + '}' }} : 监控指标对象值</code>
|
||||
<code>${{ '{' + cascadeValues[2] + '}' }} : {{ 'alert.setting.template.metric-value' | i18n }}</code>
|
||||
</nz-list-item>
|
||||
<nz-list-item *ngFor="let item of otherMetrics">
|
||||
<code>${{ '{' + item + '}' }} : 所属行其它指标值</code>
|
||||
<code>${{ '{' + item + '}' }} : {{ 'alert.setting.template.other-value' | i18n }}</code>
|
||||
</nz-list-item>
|
||||
<nz-list-item>
|
||||
<code>${instance} : 所属行实例值</code>
|
||||
<code>${instance} : {{ 'alert.setting.template.instance-value' | i18n }}</code>
|
||||
</nz-list-item>
|
||||
</nz-list>
|
||||
</nz-collapse-panel>
|
||||
@@ -238,8 +246,8 @@
|
||||
</nz-col>
|
||||
</nz-form-item>
|
||||
<nz-form-item>
|
||||
<nz-form-label [nzSpan]="7" nzFor="template" nzRequired="true" nzTooltipTitle="告警触发后发送的通知信息模版,模版环境变量见上方">
|
||||
通知模版
|
||||
<nz-form-label [nzSpan]="7" nzFor="template" nzRequired="true" [nzTooltipTitle]="'alert.setting.template.label' | i18n">
|
||||
{{ 'alert.setting.template' | i18n }}
|
||||
</nz-form-label>
|
||||
<nz-form-control [nzSpan]="8" [nzErrorTip]="'validation.required' | i18n">
|
||||
<nz-textarea-count [nzMaxCharacterCount]="200">
|
||||
@@ -250,20 +258,24 @@
|
||||
required
|
||||
name="template"
|
||||
id="template"
|
||||
placeholder="请输入告警的通知模版. 示例: ${app}.${metrics}.${metric}'s value is too high"
|
||||
[placeholder]="'alert.setting.template.example' | i18n"
|
||||
>
|
||||
</textarea>
|
||||
</nz-textarea-count>
|
||||
</nz-form-control>
|
||||
</nz-form-item>
|
||||
<nz-form-item>
|
||||
<nz-form-label nzSpan="7" nzFor="preset" nzTooltipTitle="此告警阈值配置是否应用于全局所有此类型监控"> 全局默认 </nz-form-label>
|
||||
<nz-form-label nzSpan="7" nzFor="preset" [nzTooltipTitle]="'alert.setting.default.tip' | i18n">
|
||||
{{ 'alert.setting.default' | i18n }}
|
||||
</nz-form-label>
|
||||
<nz-form-control nzSpan="8">
|
||||
<nz-switch [(ngModel)]="define.preset" name="preset" id="preset"></nz-switch>
|
||||
</nz-form-control>
|
||||
</nz-form-item>
|
||||
<nz-form-item>
|
||||
<nz-form-label nzSpan="7" nzRequired="true" nzFor="enable" nzTooltipTitle="此告警阈值配置开启生效或关闭"> 启用告警 </nz-form-label>
|
||||
<nz-form-label nzSpan="7" nzRequired="true" nzFor="enable" [nzTooltipTitle]="'alert.setting.enable.tip' | i18n">
|
||||
{{ 'alert.setting.enable' | i18n }}
|
||||
</nz-form-label>
|
||||
<nz-form-control nzSpan="8">
|
||||
<nz-switch [(ngModel)]="define.enable" [ngModelOptions]="{ standalone: true }" name="enable" id="enable"></nz-switch>
|
||||
</nz-form-control>
|
||||
@@ -276,7 +288,7 @@
|
||||
|
||||
<nz-modal
|
||||
[(nzVisible)]="isConnectModalVisible"
|
||||
nzTitle="告警定义关联监控"
|
||||
[nzTitle]="'alert.setting.connect' | i18n"
|
||||
(nzOnCancel)="onConnectModalCancel()"
|
||||
(nzOnOk)="onConnectModalOk()"
|
||||
nzMaskClosable="false"
|
||||
@@ -303,8 +315,8 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th [nzChecked]="stat.checkAll" [nzIndeterminate]="stat.checkHalf" (nzCheckedChange)="onItemSelectAll($event)"></th>
|
||||
<th *ngIf="direction == 'left'">未关联监控</th>
|
||||
<th *ngIf="direction == 'right'">已关联监控</th>
|
||||
<th *ngIf="direction == 'left'">{{ 'alert.setting.connect.left' | i18n }}</th>
|
||||
<th *ngIf="direction == 'right'">{{ 'alert.setting.connect.right' | i18n }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component, Inject, OnInit } from '@angular/core';
|
||||
import { I18NService } from '@core';
|
||||
import { ALAIN_I18N_TOKEN } from '@delon/theme';
|
||||
import { NzModalService } from 'ng-zorro-antd/modal';
|
||||
import { NzNotificationService } from 'ng-zorro-antd/notification';
|
||||
import { NzTableQueryParams } from 'ng-zorro-antd/table';
|
||||
@@ -25,7 +27,8 @@ export class AlertSettingComponent implements OnInit {
|
||||
private notifySvc: NzNotificationService,
|
||||
private appDefineSvc: AppDefineService,
|
||||
private monitorSvc: MonitorService,
|
||||
private alertDefineSvc: AlertDefineService
|
||||
private alertDefineSvc: AlertDefineService,
|
||||
@Inject(ALAIN_I18N_TOKEN) private i18nSvc: I18NService
|
||||
) {}
|
||||
|
||||
pageIndex: number = 1;
|
||||
@@ -98,7 +101,7 @@ export class AlertSettingComponent implements OnInit {
|
||||
|
||||
onEditOneAlertDefine(alertDefineId: number) {
|
||||
if (alertDefineId == null) {
|
||||
this.notifySvc.warning('未选中任何待编辑项!', '');
|
||||
this.notifySvc.warning(this.i18nSvc.fanyi('common.notify.no-select-edit'), '');
|
||||
return;
|
||||
}
|
||||
this.editAlertDefine(alertDefineId);
|
||||
@@ -107,11 +110,11 @@ export class AlertSettingComponent implements OnInit {
|
||||
onEditAlertDefine() {
|
||||
// 编辑时只能选中一个
|
||||
if (this.checkedDefineIds == null || this.checkedDefineIds.size === 0) {
|
||||
this.notifySvc.warning('未选中任何待编辑项!', '');
|
||||
this.notifySvc.warning(this.i18nSvc.fanyi('common.notify.no-select-edit'), '');
|
||||
return;
|
||||
}
|
||||
if (this.checkedDefineIds.size > 1) {
|
||||
this.notifySvc.warning('只能对一个选中项进行编辑!', '');
|
||||
this.notifySvc.warning(this.i18nSvc.fanyi('common.notify.one-select-edit'), '');
|
||||
return;
|
||||
}
|
||||
let alertDefineId = 0;
|
||||
@@ -138,24 +141,24 @@ export class AlertSettingComponent implements OnInit {
|
||||
this.cascadeValues = [this.define.app, this.define.metric, this.define.field];
|
||||
this.cascadeOnChange(this.cascadeValues);
|
||||
} else {
|
||||
this.notifySvc.error('查询此监控定义详情失败!', message.msg);
|
||||
this.notifySvc.error(this.i18nSvc.fanyi('common.notify.monitor-fail'), message.msg);
|
||||
}
|
||||
},
|
||||
error => {
|
||||
this.notifySvc.error('查询此监控定义详情失败!', error.msg);
|
||||
this.notifySvc.error(this.i18nSvc.fanyi('common.notify.monitor-fail'), error.msg);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
onDeleteAlertDefines() {
|
||||
if (this.checkedDefineIds == null || this.checkedDefineIds.size === 0) {
|
||||
this.notifySvc.warning('未选中任何待删除项!', '');
|
||||
this.notifySvc.warning(this.i18nSvc.fanyi('common.notify.no-select-delete'), '');
|
||||
return;
|
||||
}
|
||||
this.modal.confirm({
|
||||
nzTitle: '请确认是否批量删除!',
|
||||
nzOkText: '确定',
|
||||
nzCancelText: '取消',
|
||||
nzTitle: this.i18nSvc.fanyi('common.confirm.delete-batch'),
|
||||
nzOkText: this.i18nSvc.fanyi('common.button.ok'),
|
||||
nzCancelText: this.i18nSvc.fanyi('common.button.cancel'),
|
||||
nzOkDanger: true,
|
||||
nzOkType: 'primary',
|
||||
nzOnOk: () => this.deleteAlertDefines(this.checkedDefineIds)
|
||||
@@ -166,9 +169,9 @@ export class AlertSettingComponent implements OnInit {
|
||||
let defineIds = new Set<number>();
|
||||
defineIds.add(alertDefineId);
|
||||
this.modal.confirm({
|
||||
nzTitle: '请确认是否删除!',
|
||||
nzOkText: '确定',
|
||||
nzCancelText: '取消',
|
||||
nzTitle: this.i18nSvc.fanyi('common.confirm.delete'),
|
||||
nzOkText: this.i18nSvc.fanyi('common.button.ok'),
|
||||
nzCancelText: this.i18nSvc.fanyi('common.button.cancel'),
|
||||
nzOkDanger: true,
|
||||
nzOkType: 'primary',
|
||||
nzOnOk: () => this.deleteAlertDefines(defineIds)
|
||||
@@ -177,7 +180,7 @@ export class AlertSettingComponent implements OnInit {
|
||||
|
||||
deleteAlertDefines(defineIds: Set<number>) {
|
||||
if (defineIds == null || defineIds.size == 0) {
|
||||
this.notifySvc.warning('未选中任何待删除项!', '');
|
||||
this.notifySvc.warning(this.i18nSvc.fanyi('common.notify.no-select-delete'), '');
|
||||
return;
|
||||
}
|
||||
this.tableLoading = true;
|
||||
@@ -185,17 +188,17 @@ export class AlertSettingComponent implements OnInit {
|
||||
message => {
|
||||
deleteDefines$.unsubscribe();
|
||||
if (message.code === 0) {
|
||||
this.notifySvc.success('删除成功!', '');
|
||||
this.notifySvc.success(this.i18nSvc.fanyi('common.notify.delete-success'), '');
|
||||
this.loadAlertDefineTable();
|
||||
} else {
|
||||
this.tableLoading = false;
|
||||
this.notifySvc.error('删除失败!', message.msg);
|
||||
this.notifySvc.error(this.i18nSvc.fanyi('common.notify.delete-fail'), message.msg);
|
||||
}
|
||||
},
|
||||
error => {
|
||||
this.tableLoading = false;
|
||||
deleteDefines$.unsubscribe();
|
||||
this.notifySvc.error('删除失败!', error.msg);
|
||||
this.notifySvc.error(this.i18nSvc.fanyi('common.notify.delete-fail'), error.msg);
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -242,7 +245,7 @@ export class AlertSettingComponent implements OnInit {
|
||||
}
|
||||
this.appHierarchies.forEach(hierarchy => {
|
||||
if (hierarchy.value == values[0]) {
|
||||
hierarchy.children.forEach((metrics: { value: string; children: any[]}) => {
|
||||
hierarchy.children.forEach((metrics: { value: string; children: any[] }) => {
|
||||
if (metrics.value == values[1]) {
|
||||
this.otherMetrics = [];
|
||||
metrics.children.forEach(item => {
|
||||
@@ -276,14 +279,14 @@ export class AlertSettingComponent implements OnInit {
|
||||
message => {
|
||||
if (message.code === 0) {
|
||||
this.isManageModalVisible = false;
|
||||
this.notifySvc.success('新增成功!', '');
|
||||
this.notifySvc.success(this.i18nSvc.fanyi('common.notify.new-success'), '');
|
||||
this.loadAlertDefineTable();
|
||||
} else {
|
||||
this.notifySvc.error('新增失败!', message.msg);
|
||||
this.notifySvc.error(this.i18nSvc.fanyi('common.notify.new-fail'), message.msg);
|
||||
}
|
||||
},
|
||||
error => {
|
||||
this.notifySvc.error('新增失败!', error.msg);
|
||||
this.notifySvc.error(this.i18nSvc.fanyi('common.notify.new-fail'), error.msg);
|
||||
}
|
||||
);
|
||||
} else {
|
||||
@@ -299,14 +302,14 @@ export class AlertSettingComponent implements OnInit {
|
||||
message => {
|
||||
if (message.code === 0) {
|
||||
this.isManageModalVisible = false;
|
||||
this.notifySvc.success('修改成功!', '');
|
||||
this.notifySvc.success(this.i18nSvc.fanyi('common.notify.edit-success'), '');
|
||||
this.loadAlertDefineTable();
|
||||
} else {
|
||||
this.notifySvc.error('修改失败!', message.msg);
|
||||
this.notifySvc.error(this.i18nSvc.fanyi('common.notify.edit-fail'), message.msg);
|
||||
}
|
||||
},
|
||||
error => {
|
||||
this.notifySvc.error('修改失败!', error.msg);
|
||||
this.notifySvc.error(this.i18nSvc.fanyi('common.notify.edit-fail'), error.msg);
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -373,16 +376,16 @@ export class AlertSettingComponent implements OnInit {
|
||||
message => {
|
||||
this.isConnectModalOkLoading = false;
|
||||
if (message.code === 0) {
|
||||
this.notifySvc.success('应用成功!', '');
|
||||
this.notifySvc.success(this.i18nSvc.fanyi('common.notify.apply-success'), '');
|
||||
this.isConnectModalVisible = false;
|
||||
this.loadAlertDefineTable();
|
||||
} else {
|
||||
this.notifySvc.error('应用失败!', message.msg);
|
||||
this.notifySvc.error(this.i18nSvc.fanyi('common.notify.apply-fail'), message.msg);
|
||||
}
|
||||
},
|
||||
error => {
|
||||
this.isConnectModalOkLoading = false;
|
||||
this.notifySvc.error('应用失败!', error.msg);
|
||||
this.notifySvc.error(this.i18nSvc.fanyi('common.notify.apply-fail'), error.msg);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -10,16 +10,19 @@
|
||||
</div>
|
||||
<div nz-col nzSpan="14" class="p-md text-white">
|
||||
<nz-tag class="mb-xs">
|
||||
<span>正常 </span><span style="font-weight: bolder">{{ appCountService.availableSize }}</span>
|
||||
<span>{{ 'monitor.status.available' | i18n }} </span
|
||||
><span style="font-weight: bolder">{{ appCountService.availableSize }}</span>
|
||||
</nz-tag>
|
||||
<nz-tag class="mb-xs">
|
||||
<span>不可用 </span><span style="font-weight: bolder">{{ appCountService.unAvailableSize }}</span>
|
||||
<span>{{ 'monitor.status.unavailable' | i18n }} </span
|
||||
><span style="font-weight: bolder">{{ appCountService.unAvailableSize }}</span>
|
||||
</nz-tag>
|
||||
<nz-tag class="mb-xs">
|
||||
<span>不可达 </span><span style="font-weight: bolder">{{ appCountService.unReachableSize }}</span>
|
||||
<span>{{ 'monitor.status.unreachable' | i18n }} </span
|
||||
><span style="font-weight: bolder">{{ appCountService.unReachableSize }}</span>
|
||||
</nz-tag>
|
||||
<nz-tag class="mb-xs">
|
||||
<span>未监控 </span><span style="font-weight: bolder">{{ appCountService.unManageSize }}</span>
|
||||
<span>{{ 'monitor.status.un-manage' | i18n }} </span><span style="font-weight: bolder">{{ appCountService.unManageSize }}</span>
|
||||
</nz-tag>
|
||||
</div>
|
||||
</div>
|
||||
@@ -35,16 +38,16 @@
|
||||
</div>
|
||||
<div nz-col nzSpan="14">
|
||||
<nz-tag class="mb-xs">
|
||||
<span>正常 </span><span style="font-weight: bolder">{{ appCountDb.availableSize }}</span>
|
||||
<span>{{ 'monitor.status.available' | i18n }} </span><span style="font-weight: bolder">{{ appCountDb.availableSize }}</span>
|
||||
</nz-tag>
|
||||
<nz-tag class="mb-xs">
|
||||
<span>不可用 </span><span style="font-weight: bolder">{{ appCountDb.unAvailableSize }}</span>
|
||||
<span>{{ 'monitor.status.unavailable' | i18n }} </span><span style="font-weight: bolder">{{ appCountDb.unAvailableSize }}</span>
|
||||
</nz-tag>
|
||||
<nz-tag class="mb-xs">
|
||||
<span>不可达 </span><span style="font-weight: bolder">{{ appCountDb.unReachableSize }}</span>
|
||||
<span>{{ 'monitor.status.unreachable' | i18n }} </span><span style="font-weight: bolder">{{ appCountDb.unReachableSize }}</span>
|
||||
</nz-tag>
|
||||
<nz-tag class="mb-xs">
|
||||
<span>未监控 </span><span style="font-weight: bolder">{{ appCountDb.unManageSize }}</span>
|
||||
<span>{{ 'monitor.status.un-manage' | i18n }} </span><span style="font-weight: bolder">{{ appCountDb.unManageSize }}</span>
|
||||
</nz-tag>
|
||||
</div>
|
||||
</div>
|
||||
@@ -60,16 +63,16 @@
|
||||
</div>
|
||||
<div nz-col nzSpan="14">
|
||||
<nz-tag class="mb-xs">
|
||||
<span>正常 </span><span style="font-weight: bolder">{{ appCountOs.availableSize }}</span>
|
||||
<span>{{ 'monitor.status.available' | i18n }} </span><span style="font-weight: bolder">{{ appCountOs.availableSize }}</span>
|
||||
</nz-tag>
|
||||
<nz-tag class="mb-xs">
|
||||
<span>不可用 </span><span style="font-weight: bolder">{{ appCountOs.unAvailableSize }}</span>
|
||||
<span>{{ 'monitor.status.unavailable' | i18n }} </span><span style="font-weight: bolder">{{ appCountOs.unAvailableSize }}</span>
|
||||
</nz-tag>
|
||||
<nz-tag class="mb-xs">
|
||||
<span>不可达 </span><span style="font-weight: bolder">{{ appCountOs.unReachableSize }}</span>
|
||||
<span>{{ 'monitor.status.unreachable' | i18n }} </span><span style="font-weight: bolder">{{ appCountOs.unReachableSize }}</span>
|
||||
</nz-tag>
|
||||
<nz-tag class="mb-xs">
|
||||
<span>未监控 </span><span style="font-weight: bolder">{{ appCountOs.unManageSize }}</span>
|
||||
<span>{{ 'monitor.status.un-manage' | i18n }} </span><span style="font-weight: bolder">{{ appCountOs.unManageSize }}</span>
|
||||
</nz-tag>
|
||||
</div>
|
||||
</div>
|
||||
@@ -85,16 +88,16 @@
|
||||
</div>
|
||||
<div nz-col nzSpan="14">
|
||||
<nz-tag class="mb-xs">
|
||||
<span>正常 </span><span style="font-weight: bolder">{{ appCountCustom.availableSize }}</span>
|
||||
<span>{{ 'monitor.status.available' | i18n }} </span><span style="font-weight: bolder">{{ appCountCustom.availableSize }}</span>
|
||||
</nz-tag>
|
||||
<nz-tag class="mb-xs">
|
||||
<span>不可用 </span><span style="font-weight: bolder">{{ appCountCustom.unAvailableSize }}</span>
|
||||
<span>{{ 'monitor.status.unavailable' | i18n }} </span><span style="font-weight: bolder">{{ appCountCustom.unAvailableSize }}</span>
|
||||
</nz-tag>
|
||||
<nz-tag class="mb-xs">
|
||||
<span>不可达 </span><span style="font-weight: bolder">{{ appCountCustom.unReachableSize }}</span>
|
||||
<span>{{ 'monitor.status.unreachable' | i18n }} </span><span style="font-weight: bolder">{{ appCountCustom.unReachableSize }}</span>
|
||||
</nz-tag>
|
||||
<nz-tag class="mb-xs">
|
||||
<span>未监控 </span><span style="font-weight: bolder">{{ appCountCustom.unManageSize }}</span>
|
||||
<span>{{ 'monitor.status.un-manage' | i18n }} </span><span style="font-weight: bolder">{{ appCountCustom.unManageSize }}</span>
|
||||
</nz-tag>
|
||||
</div>
|
||||
</div>
|
||||
@@ -114,21 +117,21 @@
|
||||
|
||||
<div nz-row nzGutter="16" style="margin-top: 10px">
|
||||
<div nz-col nzXs="24" nzSm="24" nzMd="12" class="mb-md">
|
||||
<nz-card nzHoverable nzTitle="最近告警列表" [nzExtra]="extraTemplate">
|
||||
<nz-card nzHoverable [nzTitle]="'dashboard.alerts.title' | i18n" [nzExtra]="extraTemplate">
|
||||
<nz-timeline nzMode="left">
|
||||
<nz-timeline-item *ngFor="let alert of alerts; let i = index" [nzLabel]="(alert.gmtCreate | date: 'YYYY-MM-dd HH:mm:ss')?.trim()">
|
||||
<p style="font-weight: 400">
|
||||
<nz-tag *ngIf="alert.priority == 0" nzColor="red">
|
||||
<i nz-icon nzType="bell" nzTheme="outline"></i>
|
||||
<span>紧急告警</span>
|
||||
<span>{{ 'alert.priority.0' | i18n }}</span>
|
||||
</nz-tag>
|
||||
<nz-tag *ngIf="alert.priority == 1" nzColor="orange">
|
||||
<i nz-icon nzType="bell" nzTheme="outline"></i>
|
||||
<span>严重告警</span>
|
||||
<span>{{ 'alert.priority.1' | i18n }}</span>
|
||||
</nz-tag>
|
||||
<nz-tag *ngIf="alert.priority == 2" nzColor="yellow">
|
||||
<i nz-icon nzType="bell" nzTheme="outline"></i>
|
||||
<span>警告告警</span>
|
||||
<span>{{ 'alert.priority.2' | i18n }}</span>
|
||||
</nz-tag>
|
||||
<span>[{{ alert.monitorName }}] </span>
|
||||
{{ alert.content }}
|
||||
@@ -162,5 +165,5 @@
|
||||
</div>
|
||||
|
||||
<ng-template #extraTemplate>
|
||||
<a [routerLink]="['/alert/center']">进入告警中心</a>
|
||||
<a [routerLink]="['/alert/center']">{{ 'dashboard.alerts.enter' | i18n }}</a>
|
||||
</ng-template>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user