Compare commits

..

10 Commits

Author SHA1 Message Date
tomsun28
15aae19140 [web-app]bugfix: recently alerts in dashboard load error when go back (#105) 2022-04-24 22:39:59 +08:00
MaxKey
bcce79f9cc change theme 2022-04-24 19:10:53 +08:00
tomsun28
02ebca02cc [docs]api tags i18n, update readme (#103) 2022-04-21 22:04:15 +08:00
会编程的王学长
1c31b3ff0c feat: [manager]feature:App/Account Controller compatible with Chinese and English #wqh (#90) 2022-04-21 21:44:54 +08:00
tomsun28
0b82096ff7 [doc,manager,webapp]support deploy with osrc.com 2022-04-19 20:18:01 +08:00
tomsun28
81896f9ba1 [home]feature: support home docs i18n en (#94)
* [home]feature: support home docs i18n en

* [home]feature: i18n update introduce

* [web-app]i18n for zh-TW

* [home]feature: i18n update docs
2022-04-17 21:36:13 +08:00
tomsun28
630c571f28 [monitor]feature: support roles permission, admin-user-guest (#101) 2022-04-17 21:30:26 +08:00
观沧海
39d31ad196 [script]bugfix #96,TDengine timezone error when docker-compose (#98)
Co-authored-by: Musk.Chen <Musk.Chen@fanruan.com>
2022-04-17 12:39:13 +08:00
tomsun28
70c31f1db7 [docs]add hertzbeat deploy video link 2022-04-17 12:30:11 +08:00
tomsun28
589d178586 [web-app]bugfix: filter is missing when alert-center pageSize change (#97) 2022-04-16 22:16:55 +08:00
53 changed files with 648 additions and 374 deletions

View File

@@ -8,7 +8,7 @@
## HertzBeat 赫兹跳动 | [English Documentation](README_EN.md) ## HertzBeat 赫兹跳动 | [English Documentation](README_EN.md)
> 易用友好的监控告警系统。 > 易用友好的监控系统无需Agent强大自定义监控能力
![tan-cloud](https://cdn.jsdelivr.net/gh/dromara/hertzbeat@gh-pages/img/badge/web-monitor.svg) ![tan-cloud](https://cdn.jsdelivr.net/gh/dromara/hertzbeat@gh-pages/img/badge/web-monitor.svg)
![tan-cloud](https://cdn.jsdelivr.net/gh/dromara/hertzbeat@gh-pages/img/badge/ping-connect.svg) ![tan-cloud](https://cdn.jsdelivr.net/gh/dromara/hertzbeat@gh-pages/img/badge/ping-connect.svg)
@@ -21,12 +21,14 @@
**官网: [hertzbeat.com](https://hertzbeat.com) | [tancloud.cn](https://tancloud.cn)** **官网: [hertzbeat.com](https://hertzbeat.com) | [tancloud.cn](https://tancloud.cn)**
在开源运行时社区[OSCR.COM](https://osrc.com)快速运行HertzBeat - [部署流程](https://osrc.com/user/articles/wiki_776513931985080320)
## 🎡 <font color="green">介绍</font> ## 🎡 <font color="green">介绍</font>
> [HertzBeat赫兹跳动](https://github.com/dromara/hertzbeat) 是由[Dromara](https://dromara.org)孵化,[TanCloud](https://tancloud.cn)开源的一个支持网站APIPING端口数据库操作系统等监控类型拥有易用友好的可视化操作界面的开源监控告警项目。 > [HertzBeat赫兹跳动](https://github.com/dromara/hertzbeat) 是由[Dromara](https://dromara.org)孵化,[TanCloud](https://tancloud.cn)开源的一个支持网站APIPING端口数据库操作系统等监控类型拥有易用友好的可视化操作界面的开源监控告警项目。
> 我们也提供了对应的 **[SAAS版本监控云](https://console.tancloud.cn)**,中小团队和个人无需再为了监控自己的网站资源,而去部署一套繁琐的监控系统,**[登录即可免费开始](https://console.tancloud.cn)**。 > 我们也提供了对应的 **[SAAS版本监控云](https://console.tancloud.cn)**,中小团队和个人无需再为了监控自己的网站资源,而去部署一套繁琐的监控系统,**[登录即可免费开始](https://console.tancloud.cn)**。
> HertzBeat 支持[自定义监控](https://hertzbeat.com/docs/advanced/extend-point) ,只用通过配置YML文件我们就可以自定义需要的监控类型和指标来满足常见的个性化需求。 > HertzBeat 支持[自定义监控](https://hertzbeat.com/docs/advanced/extend-point) ,只用通过配置YML文件我们就可以自定义需要的监控类型和指标来满足常见的个性化需求。
> HertzBeat 模块化,`manager, collector, scheduler, warehouse, alerter` 各个模块解耦合,方便理解与定制开发。 > HertzBeat 模块化,`manager, collector, warehouse, alerter` 各个模块解耦合,方便理解与定制开发。
> HertzBeat 支持更自由化的告警配置(计算表达式),支持告警通知,告警模版,邮件钉钉微信飞书等及时通知送达 > HertzBeat 支持更自由化的告警配置(计算表达式),支持告警通知,告警模版,邮件钉钉微信飞书等及时通知送达
> 欢迎登录 HertzBeat 的 [云环境TanCloud](https://console.tancloud.cn) 试用发现更多。 > 欢迎登录 HertzBeat 的 [云环境TanCloud](https://console.tancloud.cn) 试用发现更多。
> 我们正在快速迭代中,欢迎参与加入一起共建项目开源生态。 > 我们正在快速迭代中,欢迎参与加入一起共建项目开源生态。
@@ -45,8 +47,6 @@
> 提供对监控的管理,监控应用配置的管理,系统用户租户后台管理等。 > 提供对监控的管理,监控应用配置的管理,系统用户租户后台管理等。
- **[collector](https://github.com/dromara/hertzbeat/tree/master/collector)** 提供监控数据采集服务 - **[collector](https://github.com/dromara/hertzbeat/tree/master/collector)** 提供监控数据采集服务
> 使用通用协议远程采集获取对端指标数据。 > 使用通用协议远程采集获取对端指标数据。
- **[scheduler](https://github.com/dromara/hertzbeat/tree/master/scheduler)** 提供监控任务调度服务
> 采集任务管理,一次性任务和周期性任务的调度分发。
- **[warehouse](https://github.com/dromara/hertzbeat/tree/master/warehouse)** 提供监控数据仓储服务 - **[warehouse](https://github.com/dromara/hertzbeat/tree/master/warehouse)** 提供监控数据仓储服务
> 采集指标结果数据管理,数据落盘,查询,计算统计。 > 采集指标结果数据管理,数据落盘,查询,计算统计。
- **[alerter](https://github.com/dromara/hertzbeat/tree/master/alerter)** 提供告警服务 - **[alerter](https://github.com/dromara/hertzbeat/tree/master/alerter)** 提供告警服务
@@ -62,6 +62,8 @@
- 如果您不想部署而是直接使用我们提供SAAS监控云-[TanCloud探云](https://console.tancloud.cn),即刻 **[登录注册](https://console.tancloud.cn)** 免费使用。 - 如果您不想部署而是直接使用我们提供SAAS监控云-[TanCloud探云](https://console.tancloud.cn),即刻 **[登录注册](https://console.tancloud.cn)** 免费使用。
- 如果您是想将HertzBeat部署到内网环境搭建监控系统请参考下面的 [部署文档](https://hertzbeat.com/docs/start/quickstart) 进行操作。 - 如果您是想将HertzBeat部署到内网环境搭建监控系统请参考下面的 [部署文档](https://hertzbeat.com/docs/start/quickstart) 进行操作。
安装部署视频教程: [HertzBeat安装部署-BiliBili](https://www.bilibili.com/video/BV1GY41177YL)
### 🐵 依赖服务部署 ### 🐵 依赖服务部署
> HertzBeat最少依赖于 关系型数据库[MYSQL5+](https://www.mysql.com/) 和 时序性数据库[TDengine2+](https://www.taosdata.com/getting-started) > HertzBeat最少依赖于 关系型数据库[MYSQL5+](https://www.mysql.com/) 和 时序性数据库[TDengine2+](https://www.taosdata.com/getting-started)

View File

@@ -22,6 +22,8 @@
**Home: [hertzbeat.com](https://hertzbeat.com) | [tancloud.cn](https://tancloud.cn)** **Home: [hertzbeat.com](https://hertzbeat.com) | [tancloud.cn](https://tancloud.cn)**
Running HertzBeat in [OSCR.COM](https://osrc.com) Open Source Runtime Community - [Doc](https://osrc.com/user/articles/wiki_776513931985080320)
## 🎡 <font color="green">Introduction</font> ## 🎡 <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. > [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.
@@ -45,9 +47,7 @@
- **[manager](https://github.com/dromara/hertzbeat/tree/master/manager)** Provide monitoring management, system management basic services. - **[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. > Provides monitoring management, monitoring configuration management, system user management, etc.
- **[collector](https://github.com/dromara/hertzbeat/tree/master/collector)** Provide metrics data collection services. - **[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. > 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. - **[warehouse](https://github.com/dromara/hertzbeat/tree/master/warehouse)** Provide monitoring data warehousing services.
> Metrics data management, data query, calculation and statistics. > Metrics data management, data query, calculation and statistics.
- **[alerter](https://github.com/dromara/hertzbeat/tree/master/alerter)** Provide alert service. - **[alerter](https://github.com/dromara/hertzbeat/tree/master/alerter)** Provide alert service.

View File

@@ -31,7 +31,7 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
* @author tom * @author tom
* @date 2021/12/9 10:32 * @date 2021/12/9 10:32
*/ */
@Api(tags = "告警定义管理API") @Api(tags = "Alert Define API | 告警定义管理API")
@RestController @RestController
@RequestMapping(path = "/alert/define", produces = {APPLICATION_JSON_VALUE}) @RequestMapping(path = "/alert/define", produces = {APPLICATION_JSON_VALUE})
public class AlertDefineController { public class AlertDefineController {

View File

@@ -31,7 +31,7 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
* @author tom * @author tom
* @date 2021/12/9 10:32 * @date 2021/12/9 10:32
*/ */
@Api(tags = "告警定义管理API") @Api(tags = "Alert Define Batch API | 告警定义管理API")
@RestController @RestController
@RequestMapping(path = "/alert/defines", produces = {APPLICATION_JSON_VALUE}) @RequestMapping(path = "/alert/defines", produces = {APPLICATION_JSON_VALUE})
public class AlertDefinesController { public class AlertDefinesController {

View File

@@ -35,7 +35,7 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
* @author tom * @author tom
* @date 2021/12/9 10:32 * @date 2021/12/9 10:32
*/ */
@Api(tags = "en: Alarm batch management API, zh:告警批量管理API") @Api(tags = "Alarm Manage Batch API | 告警批量管理API")
@RestController @RestController
@RequestMapping(path = "/alerts", produces = {APPLICATION_JSON_VALUE}) @RequestMapping(path = "/alerts", produces = {APPLICATION_JSON_VALUE})
public class AlertsController { public class AlertsController {

View File

@@ -22,7 +22,9 @@ import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_WRITE;
/** /**
* todo 字段默认值 * todo 字段默认值
* Monitoring parameter definitions
* 监控参数定义 * 监控参数定义
*
* @author tomsun28 * @author tomsun28
* @date 2021/11/13 21:49 * @date 2021/11/13 21:49
*/ */
@@ -32,57 +34,68 @@ import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_WRITE;
@Builder @Builder
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@ApiModel(description = "参数结构定义实体") @ApiModel(description = "en: Parameter structure definition entity,zh: 参数结构定义实体")
public class ParamDefine { public class ParamDefine {
/**
* Parameter Structure ID
*/
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
@ApiModelProperty(value = "参数结构ID", example = "87584674384", accessMode = READ_ONLY, position = 0) @ApiModelProperty(value = "参数结构ID", example = "87584674384", accessMode = READ_ONLY, position = 0)
private Long id; private Long id;
/** /**
* Monitoring application type name
* 监控应用类型名称 * 监控应用类型名称
*/ */
@ApiModelProperty(value = "监控类型", example = "TanCloud", accessMode = READ_WRITE, position = 1) @ApiModelProperty(value = "监控类型", example = "TanCloud", accessMode = READ_WRITE, position = 1)
private String app; private String app;
/** /**
* Parameter field external display name
* 参数字段对外显示名称 * 参数字段对外显示名称
*/ */
@ApiModelProperty(value = "参数字段显示名称", example = "端口", accessMode = READ_WRITE, position = 2) @ApiModelProperty(value = "参数字段显示名称", example = "端口", accessMode = READ_WRITE, position = 2)
private String name; private String name;
/** /**
* Parameter Field Identifier
* 参数字段标识符 * 参数字段标识符
*/ */
@ApiModelProperty(value = "参数字段标识符", example = "port", accessMode = READ_WRITE, position = 3) @ApiModelProperty(value = "参数字段标识符", example = "port", accessMode = READ_WRITE, position = 3)
private String field; private String field;
/** /**
* Field type, style (mostly map the input tag type attribute)
* 字段类型,样式(大部分映射input标签type属性) * 字段类型,样式(大部分映射input标签type属性)
*/ */
@ApiModelProperty(value = "字段类型,样式(大部分映射input标签type属性)", example = "number", accessMode = READ_WRITE, position = 4) @ApiModelProperty(value = "字段类型,样式(大部分映射input标签type属性)", example = "number", accessMode = READ_WRITE, position = 4)
private String type; private String type;
/** /**
* Is it mandatory true-required false-optional
* 是否是必输项 true-必填 false-可选 * 是否是必输项 true-必填 false-可选
*/ */
@ApiModelProperty(value = "是否是必输项 true-必填 false-可选", example = "true", accessMode = READ_WRITE, position = 5) @ApiModelProperty(value = "是否是必输项 true-必填 false-可选", example = "true", accessMode = READ_WRITE, position = 5)
private boolean required = false; private boolean required = false;
/** /**
* Parameter Default Value
* 参数默认值 * 参数默认值
*/ */
@ApiModelProperty(value = "参数默认值", example = "12", accessMode = READ_WRITE, position = 6) @ApiModelProperty(value = "参数默认值", example = "12", accessMode = READ_WRITE, position = 6)
private String defaultValue; private String defaultValue;
/** /**
* Parameter input box prompt information
* 参数输入框提示信息 * 参数输入框提示信息
*/ */
@ApiModelProperty(value = "参数输入框提示信息", example = "请输入密码", accessMode = READ_WRITE, position = 7) @ApiModelProperty(value = "参数输入框提示信息", example = "请输入密码", accessMode = READ_WRITE, position = 7)
private String placeholder; private String placeholder;
/** /**
* When type is number, use range to represent the range eg: 0-233
* 当type为number时,用range表示范围 eg: 0-233 * 当type为number时,用range表示范围 eg: 0-233
*/ */
@ApiModelProperty(value = "当type为number时,用range区间表示范围", example = "[0,233]", accessMode = READ_WRITE, position = 6) @ApiModelProperty(value = "当type为number时,用range区间表示范围", example = "[0,233]", accessMode = READ_WRITE, position = 6)
@@ -90,6 +103,7 @@ public class ParamDefine {
private String range; 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 * 当type为text时,用limit表示字符串限制大小.最大255
*/ */
@ApiModelProperty(value = "当type为text时,用limit表示字符串限制大小.最大255", example = "30", accessMode = READ_WRITE, position = 7) @ApiModelProperty(value = "当type为text时,用limit表示字符串限制大小.最大255", example = "30", accessMode = READ_WRITE, position = 7)
@@ -97,10 +111,11 @@ public class ParamDefine {
private Short limit; private Short limit;
/** /**
* When the type is radio radio box, checkbox checkbox, options represents a list of optional values
* 当type为radio单选框,checkbox复选框时,options表示可选项值列表 * 当type为radio单选框,checkbox复选框时,options表示可选项值列表
* eg: { * eg: {
* "key1":"value1", * "key1":"value1",
* "key2":"value2" * "key2":"value2"
* } * }
* key-值显示标签 * key-值显示标签
* value-真正值 * value-真正值
@@ -111,36 +126,42 @@ public class ParamDefine {
private List<Option> options; private List<Option> options;
/** /**
* Valid when type is key-value, indicating the alias description of the key
* 当type为key-value时有效,表示key的别名描述 * 当type为key-value时有效,表示key的别名描述
*/ */
@ApiModelProperty(value = "当type为key-value时有效,表示key的别名描述", example = "Name", accessMode = READ_WRITE, position = 9) @ApiModelProperty(value = "当type为key-value时有效,表示key的别名描述", example = "Name", accessMode = READ_WRITE, position = 9)
private String keyAlias; private String keyAlias;
/** /**
* Valid when type is key-value, indicating the alias description of value type
* 当type为key-value时有效,表示value的别名描述 * 当type为key-value时有效,表示value的别名描述
*/ */
@ApiModelProperty(value = "当type为key-value时有效,表示value的别名描述", example = "Value", accessMode = READ_WRITE, position = 10) @ApiModelProperty(value = "当type为key-value时有效,表示value的别名描述", example = "Value", accessMode = READ_WRITE, position = 10)
private String valueAlias; private String valueAlias;
/** /**
* Is it an advanced hidden parameter true-yes false-no
* 是否是高级隐藏参数 true-是 false-否 * 是否是高级隐藏参数 true-是 false-否
*/ */
@ApiModelProperty(value = "是否是高级隐藏参数 true-是 false-否", example = "true", accessMode = READ_WRITE, position = 11) @ApiModelProperty(value = "是否是高级隐藏参数 true-是 false-否", example = "true", accessMode = READ_WRITE, position = 11)
private boolean hide = false; private boolean hide = false;
/** /**
* The creator of this record
* 此条记录创建者 * 此条记录创建者
*/ */
@ApiModelProperty(value = "此条记录创建者", example = "tom", accessMode = READ_ONLY, position = 11) @ApiModelProperty(value = "此条记录创建者", example = "tom", accessMode = READ_ONLY, position = 11)
private String creator; private String creator;
/** /**
* This record was last modified by
* 此条记录最新修改者 * 此条记录最新修改者
*/ */
@ApiModelProperty(value = "此条记录最新修改者", example = "tom", accessMode = READ_ONLY, position = 12) @ApiModelProperty(value = "此条记录最新修改者", example = "tom", accessMode = READ_ONLY, position = 12)
private String modifier; private String modifier;
/** /**
* record creation time
* 记录创建时间 * 记录创建时间
*/ */
@ApiModelProperty(value = "记录创建时间(毫秒时间戳)", example = "1612198922000", accessMode = READ_ONLY, position = 13) @ApiModelProperty(value = "记录创建时间(毫秒时间戳)", example = "1612198922000", accessMode = READ_ONLY, position = 13)
@@ -148,6 +169,7 @@ public class ParamDefine {
private LocalDateTime gmtCreate; private LocalDateTime gmtCreate;
/** /**
* Record the latest modification time
* 记录最新修改时间 * 记录最新修改时间
*/ */
@ApiModelProperty(value = "记录最新修改时间(毫秒时间戳)", example = "1612198444000", accessMode = READ_ONLY, position = 14) @ApiModelProperty(value = "记录最新修改时间(毫秒时间戳)", example = "1612198444000", accessMode = READ_ONLY, position = 14)
@@ -159,10 +181,12 @@ public class ParamDefine {
@NoArgsConstructor @NoArgsConstructor
public static final class Option { public static final class Option {
/** /**
* value display label
* 值显示标签 * 值显示标签
*/ */
private String label; private String label;
/** /**
* optional value
* 可选值 * 可选值
*/ */
private String value; private String value;

View File

@@ -6,6 +6,8 @@ sidebar_label: Docker方式部署
> 推荐使用docker部署HertzBeat > 推荐使用docker部署HertzBeat
安装部署视频教程: [HertzBeat安装部署-BiliBili](https://www.bilibili.com/video/BV1GY41177YL)
1. 下载安装Docker环境 1. 下载安装Docker环境
Docker 工具自身的下载请参考 [Docker官网文档](https://docs.docker.com/get-docker/)。 Docker 工具自身的下载请参考 [Docker官网文档](https://docs.docker.com/get-docker/)。
安装完毕后终端查看Docker版本是否正常输出。 安装完毕后终端查看Docker版本是否正常输出。
@@ -45,74 +47,104 @@ sidebar_label: Docker方式部署
在主机目录下创建sureness.ymleg:/opt/sureness.yml 在主机目录下创建sureness.ymleg:/opt/sureness.yml
配置文件内容参考 项目仓库[/script/sureness.yml](https://gitee.com/dromara/hertzbeat/blob/master/script/sureness.yml) 配置文件内容参考 项目仓库[/script/sureness.yml](https://gitee.com/dromara/hertzbeat/blob/master/script/sureness.yml)
```yaml ```yaml
resourceRole: resourceRole:
- /account/auth/refresh===post===[role1,role2,role3,role4] - /account/auth/refresh===post===[admin,user,guest]
- /apps/**===get===[admin,user,guest]
excludedResource: - /monitor/**===get===[admin,user,guest]
- /account/auth/**===* - /monitor/**===post===[admin,user]
- /===get - /monitor/**===put===[admin,user]
- /i18n/**===get - /monitor/**===delete==[admin]
- /apps/hierarchy===get - /monitors/**===get===[admin,user,guest]
- /console/**===get - /monitors/**===post===[admin,user]
- /**/*.html===get - /monitors/**===put===[admin,user]
- /**/*.js===get - /monitors/**===delete===[admin]
- /**/*.css===get - /alert/**===get===[admin,user,guest]
- /**/*.ico===get - /alert/**===post===[admin,user]
- /**/*.ttf===get - /alert/**===put===[admin,user]
- /**/*.png===get - /alert/**===delete===[admin]
- /**/*.gif===get - /alerts/**===get===[admin,user,guest]
- /alerts/**===post===[admin,user]
- /alerts/**===put===[admin,user]
- /alerts/**===delete===[admin]
- /notice/**===get===[admin,user,guest]
- /notice/**===post===[admin,user]
- /notice/**===put===[admin,user]
- /notice/**===delete===[admin]
- /summary/**===get===[admin,user,guest]
- /summary/**===post===[admin,user]
- /summary/**===put===[admin,user]
- /summary/**===delete===[admin]
excludedResource:
- /account/auth/**===*
- /===get
- /i18n/**===get
- /apps/hierarchy===get
# web ui 静态资源
- /console/**===get
- /**/*.html===get
- /**/*.js===get
- /**/*.css===get
- /**/*.ico===get
- /**/*.ttf===get
- /**/*.png===get
- /**/*.gif===get
- /**/*.png===* - /**/*.png===*
- /swagger-resources/**===get # swagger ui 资源
- /v2/api-docs===get - /swagger-resources/**===get
- /v3/api-docs===get - /v2/api-docs===get
- /v3/api-docs===get
# 用户账户信息
# 下面有 admin tom lili 三个账户 account:
# eg: admin 拥有[role1,role2]角色,密码为admin - appId: admin
# eg: tom 拥有[role1,role2,role3],密码为tom@123 credential: admin
# eg: lili 拥有[role1,role2],明文密码为lili, 加盐密码为1A676730B0C7F54654B0E09184448289 role: [admin,user]
account: - appId: tom
- appId: admin credential: tom@123
credential: admin role: [user]
role: [role1,role2] - appId: guest
- appId: tom credential: guest
credential: tom@123 role: [guest]
role: [role1,role2,role3] - appId: lili
- appId: lili # 注意 Digest认证不支持加盐加密的密码账户
# 注意 Digest认证不支持加盐加密的密码账户 # 加盐加密的密码,通过 MD5(password+salt)计算
# 加盐加密的密码,通过 MD5(password+salt)计算 # 此账户的原始密码为 lili
# 此账户的原始密码为 lili credential: 1A676730B0C7F54654B0E09184448289
credential: 1A676730B0C7F54654B0E09184448289 salt: 123
salt: 123 role: [guest]
role: [role1,role2]
``` ```
修改sureness.yml的如下**部分参数****[注意⚠sureness配置的其它默认参数需保留]** 修改sureness.yml的如下**部分参数****[注意⚠sureness配置的其它默认参数需保留]**
```yaml ```yaml
# 用户账户信息 # 用户账户信息
# 下面有 admin tom lili 三个账户 # 下面有 admin tom lili 三个账户
# eg: admin 拥有[role1,role2]角色,密码为admin # eg: admin 拥有[admin,user]角色,密码为admin
# eg: tom 拥有[role1,role2,role3],密码为tom@123 # eg: tom 拥有[user],密码为tom@123
# eg: lili 拥有[role1,role2],明文密码为lili, 加盐密码为1A676730B0C7F54654B0E09184448289 # eg: lili 拥有[guest],明文密码为lili, 加盐密码为1A676730B0C7F54654B0E09184448289
account: account:
- appId: admin - appId: admin
credential: admin credential: admin
role: [role1,role2] role: [admin,user]
- appId: tom - appId: tom
credential: tom@123 credential: tom@123
role: [role1,role2,role3] role: [user]
- appId: lili - appId: guest
# 注意 Digest认证不支持加盐加密的密码账户 credential: guest
# 加盐加密的密码,通过 MD5(password+salt)计算 role: [guest]
# 此账户的原始密码为 lili - appId: lili
credential: 1A676730B0C7F54654B0E09184448289 # 注意 Digest认证不支持加盐加密的密码账户
salt: 123 # 加盐加密的密码,通过 MD5(password+salt)计算
role: [role1,role2] # 此账户的原始密码为 lili
``` credential: 1A676730B0C7F54654B0E09184448289
salt: 123
role: [guest]
```
6. 启动HertzBeat Docker容器 6. 启动HertzBeat Docker容器
``` ```

View File

@@ -5,6 +5,8 @@ sidebar_label: MYSQL安装初始化
--- ---
MYSQL是一款值得信赖的关系型数据库HertzBeat使用其存储监控信息告警信息配置信息等结构化关系数据。 MYSQL是一款值得信赖的关系型数据库HertzBeat使用其存储监控信息告警信息配置信息等结构化关系数据。
安装部署视频教程: [HertzBeat安装部署-BiliBili](https://www.bilibili.com/video/BV1GY41177YL)
> 如果您已有MYSQL环境可直接跳到SQL脚本执行那一步。 > 如果您已有MYSQL环境可直接跳到SQL脚本执行那一步。
### 通过Docker方式安装MYSQL ### 通过Docker方式安装MYSQL

View File

@@ -3,7 +3,9 @@ id: package-deploy
title: 通过安装包安装HertzBeat title: 通过安装包安装HertzBeat
sidebar_label: 安装包方式部署 sidebar_label: 安装包方式部署
--- ---
> HertzBeat支持在Linux Windows Mac系统安装运行CPU支持X64/ARM64。由于安装包自身不包含JAVA运行环境需您提前准备JAVA运行环境。 > HertzBeat支持在Linux Windows Mac系统安装运行CPU支持X86/ARM64。由于安装包自身不包含JAVA运行环境需您提前准备JAVA运行环境。
安装部署视频教程: [HertzBeat安装部署-BiliBili](https://www.bilibili.com/video/BV1GY41177YL)
1. 安装JAVA运行环境-可参考[官方网站](http://www.oracle.com/technetwork/java/javase/downloads/index.html) 1. 安装JAVA运行环境-可参考[官方网站](http://www.oracle.com/technetwork/java/javase/downloads/index.html)
要求JDK8+(已验证JDK8) 要求JDK8+(已验证JDK8)
@@ -48,27 +50,32 @@ sidebar_label: 安装包方式部署
若需要新增删除修改账户或密码,可以通过修改位于 `hertzbeat/config/sureness.yml` 的配置文件实现,若无此需求可忽略此步骤 若需要新增删除修改账户或密码,可以通过修改位于 `hertzbeat/config/sureness.yml` 的配置文件实现,若无此需求可忽略此步骤
修改sureness.yml的如下**部分参数****[注意⚠sureness配置的其它默认参数需保留]** 修改sureness.yml的如下**部分参数****[注意⚠sureness配置的其它默认参数需保留]**
```yaml ```yaml
# 用户账户信息
# 下面有 admin tom lili 三个账户 # 用户账户信息
# eg: admin 拥有[role1,role2]角色,密码为admin # 下面有 admin tom lili 三个账户
# eg: tom 拥有[role1,role2,role3],密码为tom@123 # eg: admin 拥有[admin,user]角色,密码为admin
# eg: lili 拥有[role1,role2],明文密码为lili, 加盐密码为1A676730B0C7F54654B0E09184448289 # eg: tom 拥有[user],密码为tom@123
account: # eg: lili 拥有[guest],明文密码为lili, 加盐密码为1A676730B0C7F54654B0E09184448289
- appId: admin account:
credential: admin - appId: admin
role: [role1,role2] credential: admin
- appId: tom role: [admin,user]
credential: tom@123 - appId: tom
role: [role1,role2,role3] credential: tom@123
- appId: lili role: [user]
# 注意 Digest认证不支持加盐加密的密码账户 - appId: guest
# 加盐加密的密码,通过 MD5(password+salt)计算 credential: guest
# 此账户的原始密码为 lili role: [guest]
credential: 1A676730B0C7F54654B0E09184448289 - appId: lili
salt: 123 # 注意 Digest认证不支持加盐加密的密码账户
role: [role1,role2] # 加盐加密的密码,通过 MD5(password+salt)计算
``` # 此账户的原始密码为 lili
credential: 1A676730B0C7F54654B0E09184448289
salt: 123
role: [guest]
```
5. 部署启动 5. 部署启动
执行位于安装目录hertzbeat/bin/下的启动脚本 startup.sh 执行位于安装目录hertzbeat/bin/下的启动脚本 startup.sh

View File

@@ -9,6 +9,8 @@ sidebar_label: 快速开始
- 如果您不想部署而是直接使用我们提供SAAS监控云-[TanCloud探云](https://console.tancloud.cn),即刻[登录注册](https://console.tancloud.cn)免费使用。 - 如果您不想部署而是直接使用我们提供SAAS监控云-[TanCloud探云](https://console.tancloud.cn),即刻[登录注册](https://console.tancloud.cn)免费使用。
- 如果您是想将HertzBeat部署到内网环境搭建监控系统请参考下面的部署文档进行操作。 - 如果您是想将HertzBeat部署到内网环境搭建监控系统请参考下面的部署文档进行操作。
安装部署视频教程: [HertzBeat安装部署-BiliBili](https://www.bilibili.com/video/BV1GY41177YL)
### 🐵 依赖服务部署 ### 🐵 依赖服务部署
> HertzBeat最少依赖于 关系型数据库[MYSQL5+](https://www.mysql.com/) 和 时序性数据库[TDengine2+](https://www.taosdata.com/getting-started) > HertzBeat最少依赖于 关系型数据库[MYSQL5+](https://www.mysql.com/) 和 时序性数据库[TDengine2+](https://www.taosdata.com/getting-started)

View File

@@ -5,8 +5,11 @@ sidebar_label: TDengine安装初始化
--- ---
TDengine是一款国产的开源物联网时序型数据库我们使用其替换了InfluxDb来存储采集到的监控指标数据。 TDengine是一款国产的开源物联网时序型数据库我们使用其替换了InfluxDb来存储采集到的监控指标数据。
安装部署视频教程: [HertzBeat安装部署-BiliBili](https://www.bilibili.com/video/BV1GY41177YL)
> 如果您已有TDengine环境可直接跳到创建数据库实例那一步。 > 如果您已有TDengine环境可直接跳到创建数据库实例那一步。
### 通过Docker方式安装TDengine ### 通过Docker方式安装TDengine
> 可参考官方网站[安装教程](https://www.taosdata.com/docs/cn/v2.0/getting-started/docker) > 可参考官方网站[安装教程](https://www.taosdata.com/docs/cn/v2.0/getting-started/docker)
1. 下载安装Docker环境 1. 下载安装Docker环境

View File

@@ -0,0 +1,14 @@
{
"title": {
"message": "Blog",
"description": "The title for the blog used in SEO"
},
"description": {
"message": "Blog",
"description": "The description for the blog used in SEO"
},
"sidebar.title": {
"message": "Recent posts",
"description": "The label for the left sidebar"
}
}

View File

@@ -1,38 +1,19 @@
--- ---
id: contact id: contact
title: 交流联系 title: Join discussion
sidebar_label: 交流联系 sidebar_label: Discussion
--- ---
> 如果您在使用过程有任何需要帮助或者想交流建议,可以通过 微信群、QQ群 社区网站 ISSUE 讨论交流。
## BUG问题报告功能建议相关建议通过仓库ISSUE > If you need any help or want to exchange suggestions during the use process, you can discuss and exchange through ISSUE or Github Discussion.
[GITEE仓库ISSUES](https://gitee.com/dromara/hertzbeat/issues) [GITHUB ISSUES](https://github.com/dromara/hertzbeat/issues)
[GITHUB仓库ISSUES](https://github.com/dromara/hertzbeat/issues) [GITEE ISSUES](https://gitee.com/dromara/hertzbeat/issues)
## 微信交流群 ##### Github Discussion
加微信号 tan-cloud 或 扫描下面账号二维码拉您进微信群。 Welcome to Discuss in [Github Discussion](https://github.com/dromara/hertzbeat/discussions)
<img alt="tan-cloud" src="https://cdn.jsdelivr.net/gh/dromara/hertzbeat@gh-pages/img/docs/help/tan-cloud-wechat.jpg" width="400"/>
## QQ交流群 ##### Public WeChat
加QQ群号 718618151 或 扫描下面的群二维码进群, 验证信息: tancloud
<img alt="tan-cloud" src="https://cdn.jsdelivr.net/gh/dromara/hertzbeat@gh-pages/img/docs/help/qq-qr.jpg" width="400"/>
## 交流网站
[Dromara社区网站](https://dromara.org/)
[HertzBeat用户网站](https://support.qq.com/products/379369)
## 微信公众号
<img alt="tan-cloud" src="https://cdn.jsdelivr.net/gh/dromara/hertzbeat/home/static/img/wechat.png" width="400"/> <img alt="tan-cloud" src="https://cdn.jsdelivr.net/gh/dromara/hertzbeat/home/static/img/wechat.png" width="400"/>
## 其它联系
其它工作联系联系电话18781603458 微信: tomsun28

View File

@@ -4,10 +4,10 @@ title: 设计文档
sidebar_label: 设计文档 sidebar_label: 设计文档
--- ---
### HertzBeat架构 ### HertzBeat Architecture
![architecture](https://cdn.jsdelivr.net/gh/dromara/hertzbeat@gh-pages/img/docs/hertzbeat-stru.svg) ![architecture](https://cdn.jsdelivr.net/gh/dromara/hertzbeat/home/static/img/docs/hertzbeat-stru-en.svg)
### TanCloud架构 ### TanCloud Architecture
TanCloud是基于HertzBeat的公网SAAS集群版本采用多集群多租户的架构模式。 TanCloud is a SAAS cluster version based on HertzBeat, which adopts a multi-cluster and multi-tenant architecture model.

View File

@@ -11,9 +11,9 @@ sidebar_label: 赞助
![wechat-alipay](https://cdn.jsdelivr.net/gh/dromara/hertzbeat@gh-pages/img/docs/pay.png) ![wechat-alipay](https://cdn.jsdelivr.net/gh/dromara/hertzbeat@gh-pages/img/docs/pay.png)
感谢[吉实信息(构建全新的微波+光交易网络)](https://www.flarespeed.com) 赞助服务器采集节点 Thanks [吉实信息(构建全新的微波+光交易网络)](https://www.flarespeed.com) sponsored server node.
感谢[天上云计算(全新智慧上云)](https://www.tsyvps.com/aff/BZBEGYLX) 赞助服务器采集节点 Thanks [天上云计算(全新智慧上云)](https://www.tsyvps.com/aff/BZBEGYLX) sponsored server node.

View File

@@ -1,60 +1,63 @@
--- ---
id: quickstart id: quickstart
title: 快速开始 title: Quick Start
sidebar_label: 快速开始 sidebar_label: Quick Start
--- ---
### 🐕 开始使用 ### 🐕 Quick Start
- 如果您不想部署而是直接使用我们提供SAAS监控云-[TanCloud探云](https://console.tancloud.cn),即刻[登录注册](https://console.tancloud.cn)免费使用。 - If you dont 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) **.
- 如果您是想将HertzBeat部署到内网环境搭建监控系统请参考下面的部署文档进行操作。 - 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最少依赖于 关系型数据库[MYSQL5+](https://www.mysql.com/) 和 时序性数据库[TDengine2+](https://www.taosdata.com/getting-started) > HertzBeat depends at least on relational database [MYSQL5+](https://www.mysql.com/) and time series database [TDengine2+](https://www.taosdata.com/getting-started)
##### 安装MYSQL
1. docker安装MYSQl
`docker run -d --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql:5.7`
2. 创建名称为hertzbeat的数据库
3. 执行位于项目仓库/script/sql/目录下的数据库脚本 [schema.sql](https://gitee.com/dromara/hertzbeat/raw/master/script/sql/schema.sql)
详细步骤参考 [依赖服务MYSQL安装初始化](mysql-init.md) ##### 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.
##### 安装TDengine For detailed steps, refer to [MYSQL Installation And Initialization](https://hertzbeat.com/docs/start/mysql-init)
1. docker安装TDengine
`docker run -d -p 6030-6049:6030-6049 -p 6030-6049:6030-6049/udp --name tdengine tdengine/tdengine:2.4.0.12`
2. 创建名称为hertzbeat的数据库
详细步骤参考 [依赖服务TDengine安装初始化](tdengine-init.md) ##### 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`
### 🍞 HertzBeat安装 For detailed steps, refer to [TDengine Installation And Initialization](https://hertzbeat.com/docs/start/tdengine-init).
> HertzBeat支持通过源码安装启动Docker容器运行和安装包方式安装部署。
#### 方式一Docker方式快速安装 ### 🍞 Install HertzBeat
`docker run -d -p 1157:1157 -v /opt/application.yml:/opt/hertzbeat/config/application.yml --name hertzbeat tancloud/hertzbeat:[版本tag]`
详细步骤参考 [通过Docker方式安装HertzBeat](docker-deploy.md) > HertzBeat supports installation through source code, docker or package.
#### 方式二:通过安装包安装 ##### 1Install quickly via docker
1. 下载您系统环境对应的安装包 [GITEE Release](https://gitee.com/dromara/hertzbeat/releases) [GITHUB Release](https://github.com/dromara/hertzbeat/releases) `docker run -d -p 1157:1157 -v /opt/application.yml:/opt/hertzbeat/config/application.yml --name hertzbeat tancloud/hertzbeat:[版本tag]`
2. 配置HertzBeat的配置文件 hertzbeat/config/application.yml
3. 部署启动 `$ ./startup.sh `
详细步骤参考 [通过安装包安装HertzBeat](package-deploy.md) Detailed steps refer to [Install HertzBeat via Docker](https://hertzbeat.com/docs/start/docker-deploy)
#### 方式三:本地代码启动 ##### 2Install via package
1. 此为前后端分离项目本地代码调试需要分别启动后端工程manager和前端工程web-app 1. Download the installation package [GITEE Release](https://gitee.com/dromara/hertzbeat/releases) [GITHUB Release](https://github.com/dromara/hertzbeat/releases)
2. 后端:需要`maven3+``java8+`环境修改YML配置信息并启动manager服务 2. Configure the HertzBeat configuration yml file `hertzbeat/config/application.yml`
3. 前端:需要`nodejs npm angular-cli`环境待本地后端启动后在web-app目录下启动 `ng serve --open` 3. Run shell `$ ./startup.sh `
4. 浏览器访问 localhost:4200 即可开始,默认账户密码 admin/admin 4. Access `localhost:1157` to start, default account: `admin/admin`
详细步骤参考 [参与贡献之本地代码启动](../others/contributing) Detailed steps refer to [Install HertzBeat via package](https://hertzbeat.com/docs/start/package-deploy)
#### 方式四Docker-Compose统一安装hertzbeat及其依赖服务 ##### 3Start via source code
1. Local source code debugging needs to start the back-end project manager and the front-end project web-app.
2. Backendneed `maven3+`, `java8+`, start the manager service.
3. Webneed `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`
通过 [docker-compose部署脚本](https://gitee.com/dromara/hertzbeat/tree/master/script/docker-compose) 一次性把mysql数据库,tdengine数据库和hertzbeat安装部署。 Detailed steps refer to [CONTRIBUTING](../others/contributing)
详细步骤参考 [docker-compose安装](https://gitee.com/dromara/hertzbeat/tree/master/script/docker-compose/README.md) ##### 4Install 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](https://github.com/dromara/hertzbeat/tree/master/script/docker-compose).
Detailed steps refer to [docker-compose install](https://github.com/dromara/hertzbeat/tree/master/script/docker-compose)
**HAVE FUN** **HAVE FUN**

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 30 KiB

View File

@@ -26,7 +26,7 @@ public class SwaggerConfig {
return new Docket(DocumentationType.OAS_30) return new Docket(DocumentationType.OAS_30)
.apiInfo(apiInfo()) .apiInfo(apiInfo())
.enable(true) .enable(true)
.groupName("TanCloud") .groupName("HertzBeat")
.select() .select()
.apis(RequestHandlerSelectors.any()) .apis(RequestHandlerSelectors.any())
.paths(PathSelectors.regex("(?!/error.*).*")) .paths(PathSelectors.regex("(?!/error.*).*"))
@@ -35,7 +35,7 @@ public class SwaggerConfig {
private ApiInfo apiInfo(){ private ApiInfo apiInfo(){
return new ApiInfo( return new ApiInfo(
"TanCloud", "HertzBeat",
null, null,
"v1.0", "v1.0",
null, null,

View File

@@ -29,17 +29,20 @@ import static com.usthe.common.util.CommonConstants.MONITOR_LOGIN_FAILED_CODE;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
/** /**
* Authentication registration TOKEN management API
* 认证注册TOKEN管理API * 认证注册TOKEN管理API
*
* @author tomsun28 * @author tomsun28
* @date 13:11 2019-05-26 * @date 13:11 2019-05-26
*/ */
@Api(tags = "认证注册TOKEN管理API") @Api(tags = "Auth Manage API | 认证注册TOKEN管理API")
@RestController() @RestController()
@RequestMapping(value = "/account/auth", produces = {APPLICATION_JSON_VALUE}) @RequestMapping(value = "/account/auth", produces = {APPLICATION_JSON_VALUE})
@Slf4j @Slf4j
public class AccountController { public class AccountController {
/** /**
* Token validity time in seconds
* TOKEN有效期时间 单位秒 * TOKEN有效期时间 单位秒
*/ */
private static final long PERIOD_TIME = 3600L; private static final long PERIOD_TIME = 3600L;
@@ -50,7 +53,7 @@ public class AccountController {
private SurenessAccountProvider accountProvider = new DocumentAccountProvider(); private SurenessAccountProvider accountProvider = new DocumentAccountProvider();
@PostMapping("/form") @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) { public ResponseEntity<Message<Map<String, String>>> authGetToken(@RequestBody LoginDto loginDto) {
SurenessAccount account = accountProvider.loadAccount(loginDto.getIdentifier()); SurenessAccount account = accountProvider.loadAccount(loginDto.getIdentifier());
@@ -76,7 +79,7 @@ public class AccountController {
} }
// Get the roles the user has - rbac // Get the roles the user has - rbac
List<String> roles = account.getOwnRoles(); List<String> roles = account.getOwnRoles();
// 签发TOKEN // Issue TOKEN 签发TOKEN
String issueToken = JsonWebTokenUtil.issueJwt(loginDto.getIdentifier(), PERIOD_TIME, roles); String issueToken = JsonWebTokenUtil.issueJwt(loginDto.getIdentifier(), PERIOD_TIME, roles);
Map<String, Object> customClaimMap = new HashMap<>(1); Map<String, Object> customClaimMap = new HashMap<>(1);
customClaimMap.put("refresh", true); customClaimMap.put("refresh", true);
@@ -88,9 +91,9 @@ public class AccountController {
} }
@GetMapping("/refresh/{refreshToken}") @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( 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) { @PathVariable("refreshToken") @NotNull final String refreshToken) {
String userId; String userId;
boolean isRefresh; boolean isRefresh;
@@ -116,7 +119,7 @@ public class AccountController {
return ResponseEntity.ok(message); return ResponseEntity.ok(message);
} }
List<String> roles = account.getOwnRoles(); List<String> roles = account.getOwnRoles();
// 签发TOKEN // Issue TOKEN 签发TOKEN
String issueToken = JsonWebTokenUtil.issueJwt(userId, PERIOD_TIME, roles); String issueToken = JsonWebTokenUtil.issueJwt(userId, PERIOD_TIME, roles);
Map<String, Object> customClaimMap = new HashMap<>(1); Map<String, Object> customClaimMap = new HashMap<>(1);
customClaimMap.put("refresh", true); customClaimMap.put("refresh", true);

View File

@@ -21,11 +21,13 @@ import java.util.List;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
/** /**
* Monitoring Type Management API
* 监控类型管理API * 监控类型管理API
*
* @author tomsun28 * @author tomsun28
* @date 2021/11/14 16:47 * @date 2021/11/14 16:47
*/ */
@Api(tags = "监控类型管理API") @Api(tags = "Monitor Type Manage API | 监控类型管理API")
@RestController @RestController
@RequestMapping(path = "/apps", produces = {APPLICATION_JSON_VALUE}) @RequestMapping(path = "/apps", produces = {APPLICATION_JSON_VALUE})
public class AppController { public class AppController {
@@ -34,31 +36,32 @@ public class AppController {
private AppService appService; private AppService appService;
@GetMapping(path = "/{app}/params") @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( 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()); List<ParamDefine> paramDefines = appService.getAppParamDefines(app.toLowerCase());
return ResponseEntity.ok(new Message<>(paramDefines)); return ResponseEntity.ok(new Message<>(paramDefines));
} }
@GetMapping(path = "/{app}/define") @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( 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()); Job define = appService.getAppDefine(app.toLowerCase());
return ResponseEntity.ok(new Message<>(define)); return ResponseEntity.ok(new Message<>(define));
} }
@GetMapping(path = "/hierarchy") @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( 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) { @RequestParam(name = "lang", required = false) String lang) {
if (lang == null || "".equals(lang)) { if (lang == null || "".equals(lang)) {
lang = "zh-CN"; lang = "zh-CN";
} }
lang = "zh-cn".equalsIgnoreCase(lang)? "zh-CN" : lang; lang = "zh-cn".equalsIgnoreCase(lang) ? "zh-CN" : lang;
lang = "en-us".equalsIgnoreCase(lang)? "en-US" : lang; lang = "en-us".equalsIgnoreCase(lang) ? "en-US" : lang;
List<Hierarchy> appHierarchies = appService.getAllAppHierarchy(lang); List<Hierarchy> appHierarchies = appService.getAllAppHierarchy(lang);
return ResponseEntity.ok(new Message<>(appHierarchies)); return ResponseEntity.ok(new Message<>(appHierarchies));
} }

View File

@@ -21,7 +21,7 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
* @author tom * @author tom
* @date 2021/12/4 21:40 * @date 2021/12/4 21:40
*/ */
@Api(tags = "I18N国际化资源API") @Api(tags = "I18N API | I18N国际化资源API")
@RestController @RestController
@RequestMapping(path = "/i18n", produces = {APPLICATION_JSON_VALUE}) @RequestMapping(path = "/i18n", produces = {APPLICATION_JSON_VALUE})
public class I18nController { public class I18nController {

View File

@@ -30,7 +30,7 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
* @author tomsun28 * @author tomsun28
* @date 2021/11/14 10:57 * @date 2021/11/14 10:57
*/ */
@Api(tags = "en: Monitoring management API,zh: 监控管理API") @Api(tags = "Monitor Manage API | 监控管理API")
@RestController @RestController
@RequestMapping(path = "/monitor", produces = {APPLICATION_JSON_VALUE}) @RequestMapping(path = "/monitor", produces = {APPLICATION_JSON_VALUE})
public class MonitorController { public class MonitorController {

View File

@@ -35,7 +35,7 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
* @author tom * @author tom
* @date 2021/12/1 20:43 * @date 2021/12/1 20:43
*/ */
@Api(tags = "en: Monitor and manage batch API,zh: 监控列表API") @Api(tags = "Monitor Manage Batch API | 监控列表API")
@RestController @RestController
@RequestMapping(path = "/monitors", produces = {APPLICATION_JSON_VALUE}) @RequestMapping(path = "/monitors", produces = {APPLICATION_JSON_VALUE})
public class MonitorsController { public class MonitorsController {

View File

@@ -34,7 +34,7 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
* @author tom * @author tom
* @date 2021/12/16 16:18 * @date 2021/12/16 16:18
*/ */
@Api(tags = "en: Message Notification Configuration API,zh: 消息通知配置API") @Api(tags = "Notification Config API | 消息通知配置API")
@RestController() @RestController()
@RequestMapping(value = "/notice", produces = {APPLICATION_JSON_VALUE}) @RequestMapping(value = "/notice", produces = {APPLICATION_JSON_VALUE})
public class NoticeConfigController { public class NoticeConfigController {

View File

@@ -24,7 +24,7 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
* @author tom * @author tom
* @date 2021/12/7 15:57 * @date 2021/12/7 15:57
*/ */
@Api(tags = "en: System Summary Statistics API,zh: 系统摘要统计API") @Api(tags = "Summary Statistics API | 系统摘要统计API")
@RestController @RestController
@RequestMapping(path = "/summary", produces = {APPLICATION_JSON_VALUE}) @RequestMapping(path = "/summary", produces = {APPLICATION_JSON_VALUE})
public class SummaryController { public class SummaryController {

View File

@@ -6,16 +6,20 @@ import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List; import java.util.List;
/** /**
* Param Define Database Operations
* ParamDefine数据库操作 * ParamDefine数据库操作
*
* @author tomsun28 * @author tomsun28
* @date 2021/11/14 11:27 * @date 2021/11/14 11:27
*/ */
public interface ParamDefineDao extends JpaRepository<ParamDefine, Long> { 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); List<ParamDefine> findParamDefinesByApp(String app);
} }

View File

@@ -11,8 +11,11 @@ import java.util.List;
import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_WRITE; import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_WRITE;
/** /**
* Hierarchical structure
* 层级关系结构 * 层级关系结构
* eg: Monitoring Type Indicator Group Indicator Information Hierarchy Relationship
* eg: 监控类型指标组指标信息层级关系 * eg: 监控类型指标组指标信息层级关系
*
* @author tom * @author tom
* @date 2021/12/12 16:23 * @date 2021/12/12 16:23
*/ */
@@ -21,18 +24,33 @@ import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_WRITE;
@Data @Data
public class Hierarchy { public class Hierarchy {
/**
* Category value
*/
@ApiModelProperty(value = "类别值", example = "os", accessMode = READ_WRITE, position = 0) @ApiModelProperty(value = "类别值", example = "os", accessMode = READ_WRITE, position = 0)
String category; String category;
/**
* Attribute value
*/
@ApiModelProperty(value = "属性值", example = "linux", accessMode = READ_WRITE, position = 1) @ApiModelProperty(value = "属性值", example = "linux", accessMode = READ_WRITE, position = 1)
String value; String value;
/**
* Attribute internationalization tag
*/
@ApiModelProperty(value = "属性国际化标签", example = "Linux系统", accessMode = READ_WRITE, position = 2) @ApiModelProperty(value = "属性国际化标签", example = "Linux系统", accessMode = READ_WRITE, position = 2)
String label; String label;
/**
* Is it a leaf node
*/
@ApiModelProperty(value = "是否是叶子节点", example = "true", accessMode = READ_WRITE, position = 3) @ApiModelProperty(value = "是否是叶子节点", example = "true", accessMode = READ_WRITE, position = 3)
Boolean isLeaf = false; Boolean isLeaf = false;
/**
* Next level of association
*/
@ApiModelProperty(value = "下一关联层级", accessMode = READ_WRITE, position = 4) @ApiModelProperty(value = "下一关联层级", accessMode = READ_WRITE, position = 4)
private List<Hierarchy> children; private List<Hierarchy> children;
} }

View File

@@ -13,7 +13,9 @@ import javax.validation.constraints.NotBlank;
import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_ONLY; import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_ONLY;
/** /**
* Login registered account information transfer body username phone email
* 登录注册账户信息传输体 username phone email * 登录注册账户信息传输体 username phone email
*
* @author tomsun28 * @author tomsun28
* @date 20:36 2019-08-01 * @date 20:36 2019-08-01
*/ */
@@ -21,17 +23,27 @@ import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_ONLY;
@Builder @Builder
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@ApiModel(description = "账户信息传输体") @ApiModel(description = "en: Account information transfer body,zh: 账户信息传输体")
public class LoginDto { 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) @ApiModelProperty(value = "类型", example = "1", accessMode = READ_ONLY, position = 0)
@Range(min = 0, max = 4, message = "1.账户(邮箱用户名手机号)密码登录 2.github登录 3.微信登录") @Range(min = 0, max = 4, message = "1.账户(邮箱用户名手机号)密码登录 2.github登录 3.微信登录")
private Byte type; private Byte type;
/**
* User ID
*/
@ApiModelProperty(value = "用户标识", example = "1", accessMode = READ_ONLY, position = 0) @ApiModelProperty(value = "用户标识", example = "1", accessMode = READ_ONLY, position = 0)
@NotBlank(message = "Identifier can not null") @NotBlank(message = "Identifier can not null")
private String identifier; private String identifier;
/**
* key
*/
@ApiModelProperty(value = "密钥", example = "1", accessMode = READ_ONLY, position = 0) @ApiModelProperty(value = "密钥", example = "1", accessMode = READ_ONLY, position = 0)
@NotBlank(message = "Credential can not null") @NotBlank(message = "Credential can not null")
private String credential; private String credential;

View File

@@ -8,6 +8,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
* Monitoring Type Management Interface
* 监控类型管理接口 * 监控类型管理接口
* *
* @author tomsun28 * @author tomsun28
@@ -16,10 +17,11 @@ import java.util.Map;
public interface AppService { public interface AppService {
/** /**
* Query the defined parameter structure based on the monitoring type
* 根据监控类型查询定义的参数结构 * 根据监控类型查询定义的参数结构
* *
* @param app 监控类型 * @param app Monitoring type 监控类型
* @return 参数结构列表 * @return list of parameter structures 参数结构列表
*/ */
List<ParamDefine> getAppParamDefines(String app); List<ParamDefine> getAppParamDefines(String app);
@@ -35,18 +37,20 @@ public interface AppService {
Job getAppDefine(String app) throws IllegalArgumentException; Job getAppDefine(String app) throws IllegalArgumentException;
/** /**
* Get defined monitoring I 18 N resources
* 获取定义的监控I18N资源 * 获取定义的监控I18N资源
* *
* @param lang 语言类型 * @param lang Language type 语言类型
* @return I18N资源 * @return I18N Resources I18N资源
*/ */
Map<String, String> getI18nResources(String lang); Map<String, String> getI18nResources(String lang);
/** /**
* Query all types of monitoring - indicator group - indicator level
* 查询所有监控的类型-指标组-指标层级 * 查询所有监控的类型-指标组-指标层级
* *
* @param lang 语言 * @param lang language 语言
* @return 层级信息 * @return level information 层级信息
*/ */
List<Hierarchy> getAllAppHierarchy(String lang); List<Hierarchy> getAllAppHierarchy(String lang);

View File

@@ -11,6 +11,9 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner; import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order; import org.springframework.core.annotation.Order;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.Yaml;
@@ -18,6 +21,7 @@ import org.yaml.snakeyaml.Yaml;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
@@ -122,6 +126,8 @@ public class AppServiceImpl implements AppService, CommandLineRunner {
@Override @Override
public void run(String... args) throws Exception { public void run(String... args) throws Exception {
boolean loadFromFile = true;
final List<InputStream> inputStreams = new LinkedList<>();
// 读取app定义配置加载到内存中 define/app/*.yml // 读取app定义配置加载到内存中 define/app/*.yml
Yaml yaml = new Yaml(); Yaml yaml = new Yaml();
String classpath = this.getClass().getClassLoader().getResource("").getPath(); String classpath = this.getClass().getClassLoader().getResource("").getPath();
@@ -132,37 +138,82 @@ public class AppServiceImpl implements AppService, CommandLineRunner {
defineAppPath = classpath + File.separator + "define" + File.separator + "app"; defineAppPath = classpath + File.separator + "define" + File.separator + "app";
directory = new File(defineAppPath); directory = new File(defineAppPath);
if (!directory.exists() || directory.listFiles() == null) { if (!directory.exists() || directory.listFiles() == null) {
throw new IllegalArgumentException("define app directory not exist: " + defineAppPath); // load define app yml in jar
} log.info("load define app yml in internal jar");
} loadFromFile = false;
log.info("query define path {}", defineAppPath); try {
for (File appFile : Objects.requireNonNull(directory.listFiles())) { ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
if (appFile.exists()) { Resource[] resources = resolver.getResources("classpath:define/app/*.yml");
try (FileInputStream fileInputStream = new FileInputStream(appFile)) { for (Resource resource : resources) {
Job app = yaml.loadAs(fileInputStream, Job.class); inputStreams.add(resource.getInputStream());
appDefines.put(app.getApp().toLowerCase(), app); }
} catch (IOException e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error("define app yml not exist");
throw new IOException(e); throw e;
} }
} }
} }
if (loadFromFile) {
log.info("load define path {}", defineAppPath);
for (File appFile : Objects.requireNonNull(directory.listFiles())) {
if (appFile.exists()) {
try (FileInputStream fileInputStream = new FileInputStream(appFile)) {
Job app = yaml.loadAs(fileInputStream, Job.class);
appDefines.put(app.getApp().toLowerCase(), app);
} catch (IOException e) {
log.error(e.getMessage(), e);
throw new IOException(e);
}
}
}
} else {
if (inputStreams.isEmpty()) {
throw new IllegalArgumentException("define app directory not exist");
} else {
inputStreams.forEach(stream -> {
try {
Job app = yaml.loadAs(stream, Job.class);
appDefines.put(app.getApp().toLowerCase(), app);
stream.close();
} catch (Exception e) {
log.error(e.getMessage(), e);
}
});
}
}
// 读取监控参数定义配置加载到数据库中 define/param/*.yml // 读取监控参数定义配置加载到数据库中 define/param/*.yml
String defineParamPath = classpath + File.separator + "define" + File.separator + "param"; if (loadFromFile) {
directory = new File(defineParamPath); String defineParamPath = classpath + File.separator + "define" + File.separator + "param";
if (!directory.exists() || directory.listFiles() == null) { directory = new File(defineParamPath);
throw new IllegalArgumentException("define param directory not exist: " + defineParamPath); if (!directory.exists() || directory.listFiles() == null) {
} throw new IllegalArgumentException("define param directory not exist: " + defineParamPath);
for (File appFile : Objects.requireNonNull(directory.listFiles())) { }
if (appFile.exists()) { for (File appFile : Objects.requireNonNull(directory.listFiles())) {
try (FileInputStream fileInputStream = new FileInputStream(appFile)) { if (appFile.exists()) {
ParamDefineDto paramDefine = yaml.loadAs(fileInputStream, ParamDefineDto.class); try (FileInputStream fileInputStream = new FileInputStream(appFile)) {
paramDefines.put(paramDefine.getApp().toLowerCase(), paramDefine.getParam()); ParamDefineDto paramDefine = yaml.loadAs(fileInputStream, ParamDefineDto.class);
} catch (IOException e) { paramDefines.put(paramDefine.getApp().toLowerCase(), paramDefine.getParam());
log.error(e.getMessage(), e); } catch (IOException e) {
throw new IOException(e); log.error(e.getMessage(), e);
throw new IOException(e);
}
} }
} }
} else {
try {
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
Resource[] resources = resolver.getResources("classpath:define/param/*.yml");
for (Resource resource : resources) {
InputStream stream = resource.getInputStream();
ParamDefineDto paramDefine = yaml.loadAs(stream, ParamDefineDto.class);
paramDefines.put(paramDefine.getApp().toLowerCase(), paramDefine.getParam());
stream.close();
}
} catch (Exception e) {
log.error("define param yml not exist");
throw e;
}
} }
} }
} }

View File

@@ -2,10 +2,35 @@
# 加载到匹配字典的资源,也就是需要被保护的,设置了所支持角色访问的资源 # 加载到匹配字典的资源,也就是需要被保护的,设置了所支持角色访问的资源
# 没有配置的资源也默认被认证保护,但不鉴权 # 没有配置的资源也默认被认证保护,但不鉴权
# eg: /api/v1/source1===get===[role2] 表示 /api/v2/host===post 这条资源支持 role2 这一种角色访问 # eg: /api/v1/source1===get===[admin] 表示 /api/v2/host===post 这条资源支持 admin 这一种角色访问
# eg: /api/v1/source2===get===[] 表示 /api/v1/source2===get 这条资源不支持任何角色访问 # eg: /api/v1/source2===get===[] 表示 /api/v1/source2===get 这条资源不支持任何角色访问
resourceRole: resourceRole:
- /account/auth/refresh===post===[role1,role2,role3,role4] - /account/auth/refresh===post===[admin,user,guest]
- /apps/**===get===[admin,user,guest]
- /monitor/**===get===[admin,user,guest]
- /monitor/**===post===[admin,user]
- /monitor/**===put===[admin,user]
- /monitor/**===delete==[admin]
- /monitors/**===get===[admin,user,guest]
- /monitors/**===post===[admin,user]
- /monitors/**===put===[admin,user]
- /monitors/**===delete===[admin]
- /alert/**===get===[admin,user,guest]
- /alert/**===post===[admin,user]
- /alert/**===put===[admin,user]
- /alert/**===delete===[admin]
- /alerts/**===get===[admin,user,guest]
- /alerts/**===post===[admin,user]
- /alerts/**===put===[admin,user]
- /alerts/**===delete===[admin]
- /notice/**===get===[admin,user,guest]
- /notice/**===post===[admin,user]
- /notice/**===put===[admin,user]
- /notice/**===delete===[admin]
- /summary/**===get===[admin,user,guest]
- /summary/**===post===[admin,user]
- /summary/**===put===[admin,user]
- /summary/**===delete===[admin]
# 需要被过滤保护的资源,不认证鉴权直接访问 # 需要被过滤保护的资源,不认证鉴权直接访问
# /api/v1/source3===get 表示 /api/v1/source3===get 可以被任何人访问 无需登录认证鉴权 # /api/v1/source3===get 表示 /api/v1/source3===get 可以被任何人访问 无需登录认证鉴权
@@ -31,20 +56,23 @@ excludedResource:
# 用户账户信息 # 用户账户信息
# 下面有 admin tom lili 三个账户 # 下面有 admin tom lili 三个账户
# eg: admin 拥有[role1,role2]角色,密码为admin # eg: admin 拥有[admin,user]角色,密码为admin
# eg: tom 拥有[role1,role2,role3],密码为tom@123 # eg: tom 拥有[user],密码为tom@123
# eg: lili 拥有[role1,role2],明文密码为lili, 加盐密码为1A676730B0C7F54654B0E09184448289 # eg: lili 拥有[guest],明文密码为lili, 加盐密码为1A676730B0C7F54654B0E09184448289
account: account:
- appId: admin - appId: admin
credential: admin credential: admin
role: [role1,role2] role: [admin,user]
- appId: tom - appId: tom
credential: tom@123 credential: tom@123
role: [role1,role2,role3] role: [user]
- appId: guest
credential: guest
role: [guest]
- appId: lili - appId: lili
# 注意 Digest认证不支持加盐加密的密码账户 # 注意 Digest认证不支持加盐加密的密码账户
# 加盐加密的密码,通过 MD5(password+salt)计算 # 加盐加密的密码,通过 MD5(password+salt)计算
# 此账户的原始密码为 lili # 此账户的原始密码为 lili
credential: 1A676730B0C7F54654B0E09184448289 credential: 1A676730B0C7F54654B0E09184448289
salt: 123 salt: 123
role: [role1,role2] role: [guest]

View File

@@ -2,10 +2,35 @@
# 加载到匹配字典的资源,也就是需要被保护的,设置了所支持角色访问的资源 # 加载到匹配字典的资源,也就是需要被保护的,设置了所支持角色访问的资源
# 没有配置的资源也默认被认证保护,但不鉴权 # 没有配置的资源也默认被认证保护,但不鉴权
# eg: /api/v1/source1===get===[role2] 表示 /api/v2/host===post 这条资源支持 role2 这一种角色访问 # eg: /api/v1/source1===get===[admin] 表示 /api/v2/host===post 这条资源支持 admin 这一种角色访问
# eg: /api/v1/source2===get===[] 表示 /api/v1/source2===get 这条资源不支持任何角色访问 # eg: /api/v1/source2===get===[] 表示 /api/v1/source2===get 这条资源不支持任何角色访问
resourceRole: resourceRole:
- /account/auth/refresh===post===[role1,role2,role3,role4] - /account/auth/refresh===post===[admin,user,guest]
- /apps/**===get===[admin,user,guest]
- /monitor/**===get===[admin,user,guest]
- /monitor/**===post===[admin,user]
- /monitor/**===put===[admin,user]
- /monitor/**===delete==[admin]
- /monitors/**===get===[admin,user,guest]
- /monitors/**===post===[admin,user]
- /monitors/**===put===[admin,user]
- /monitors/**===delete===[admin]
- /alert/**===get===[admin,user,guest]
- /alert/**===post===[admin,user]
- /alert/**===put===[admin,user]
- /alert/**===delete===[admin]
- /alerts/**===get===[admin,user,guest]
- /alerts/**===post===[admin,user]
- /alerts/**===put===[admin,user]
- /alerts/**===delete===[admin]
- /notice/**===get===[admin,user,guest]
- /notice/**===post===[admin,user]
- /notice/**===put===[admin,user]
- /notice/**===delete===[admin]
- /summary/**===get===[admin,user,guest]
- /summary/**===post===[admin,user]
- /summary/**===put===[admin,user]
- /summary/**===delete===[admin]
# 需要被过滤保护的资源,不认证鉴权直接访问 # 需要被过滤保护的资源,不认证鉴权直接访问
# /api/v1/source3===get 表示 /api/v1/source3===get 可以被任何人访问 无需登录认证鉴权 # /api/v1/source3===get 表示 /api/v1/source3===get 可以被任何人访问 无需登录认证鉴权
@@ -31,20 +56,23 @@ excludedResource:
# 用户账户信息 # 用户账户信息
# 下面有 admin tom lili 三个账户 # 下面有 admin tom lili 三个账户
# eg: admin 拥有[role1,role2]角色,密码为admin # eg: admin 拥有[admin,user]角色,密码为admin
# eg: tom 拥有[role1,role2,role3],密码为tom@123 # eg: tom 拥有[user],密码为tom@123
# eg: lili 拥有[role1,role2],明文密码为lili, 加盐密码为1A676730B0C7F54654B0E09184448289 # eg: lili 拥有[guest],明文密码为lili, 加盐密码为1A676730B0C7F54654B0E09184448289
account: account:
- appId: admin - appId: admin
credential: admin credential: admin
role: [role1,role2] role: [admin,user]
- appId: tom - appId: tom
credential: tom credential: tom@123
role: [role1,role2,role3] role: [user]
- appId: guest
credential: guest
role: [guest]
- appId: lili - appId: lili
# 注意 Digest认证不支持加盐加密的密码账户 # 注意 Digest认证不支持加盐加密的密码账户
# 加盐加密的密码,通过 MD5(password+salt)计算 # 加盐加密的密码,通过 MD5(password+salt)计算
# 此账户的原始密码为 lili # 此账户的原始密码为 lili
credential: 1A676730B0C7F54654B0E09194448289 credential: 1A676730B0C7F54654B0E09184448289
salt: 123 salt: 123
role: [role1,role2] role: [guest]

View File

@@ -26,6 +26,8 @@ services:
container_name: tdengine container_name: tdengine
hostname: tdengine hostname: tdengine
restart: always restart: always
environment:
TZ: Asia/Shanghai
ports: ports:
- "6030-6049:6030-6049" - "6030-6049:6030-6049"
- "6030-6049:6030-6049/udp" - "6030-6049:6030-6049/udp"

View File

@@ -2,10 +2,35 @@
# 加载到匹配字典的资源,也就是需要被保护的,设置了所支持角色访问的资源 # 加载到匹配字典的资源,也就是需要被保护的,设置了所支持角色访问的资源
# 没有配置的资源也默认被认证保护,但不鉴权 # 没有配置的资源也默认被认证保护,但不鉴权
# eg: /api/v1/source1===get===[role2] 表示 /api/v2/host===post 这条资源支持 role2 这一种角色访问 # eg: /api/v1/source1===get===[admin] 表示 /api/v2/host===post 这条资源支持 admin 这一种角色访问
# eg: /api/v1/source2===get===[] 表示 /api/v1/source2===get 这条资源不支持任何角色访问 # eg: /api/v1/source2===get===[] 表示 /api/v1/source2===get 这条资源不支持任何角色访问
resourceRole: resourceRole:
- /account/auth/refresh===post===[role1,role2,role3,role4] - /account/auth/refresh===post===[admin,user,guest]
- /apps/**===get===[admin,user,guest]
- /monitor/**===get===[admin,user,guest]
- /monitor/**===post===[admin,user]
- /monitor/**===put===[admin,user]
- /monitor/**===delete==[admin]
- /monitors/**===get===[admin,user,guest]
- /monitors/**===post===[admin,user]
- /monitors/**===put===[admin,user]
- /monitors/**===delete===[admin]
- /alert/**===get===[admin,user,guest]
- /alert/**===post===[admin,user]
- /alert/**===put===[admin,user]
- /alert/**===delete===[admin]
- /alerts/**===get===[admin,user,guest]
- /alerts/**===post===[admin,user]
- /alerts/**===put===[admin,user]
- /alerts/**===delete===[admin]
- /notice/**===get===[admin,user,guest]
- /notice/**===post===[admin,user]
- /notice/**===put===[admin,user]
- /notice/**===delete===[admin]
- /summary/**===get===[admin,user,guest]
- /summary/**===post===[admin,user]
- /summary/**===put===[admin,user]
- /summary/**===delete===[admin]
# 需要被过滤保护的资源,不认证鉴权直接访问 # 需要被过滤保护的资源,不认证鉴权直接访问
# /api/v1/source3===get 表示 /api/v1/source3===get 可以被任何人访问 无需登录认证鉴权 # /api/v1/source3===get 表示 /api/v1/source3===get 可以被任何人访问 无需登录认证鉴权
@@ -23,7 +48,7 @@ excludedResource:
- /**/*.ttf===get - /**/*.ttf===get
- /**/*.png===get - /**/*.png===get
- /**/*.gif===get - /**/*.gif===get
- /**/*.png===* - /**/*.png===*
# swagger ui 资源 # swagger ui 资源
- /swagger-resources/**===get - /swagger-resources/**===get
- /v2/api-docs===get - /v2/api-docs===get
@@ -31,20 +56,23 @@ excludedResource:
# 用户账户信息 # 用户账户信息
# 下面有 admin tom lili 三个账户 # 下面有 admin tom lili 三个账户
# eg: admin 拥有[role1,role2]角色,密码为admin # eg: admin 拥有[admin,user]角色,密码为admin
# eg: tom 拥有[role1,role2,role3],密码为tom@123 # eg: tom 拥有[user],密码为tom@123
# eg: lili 拥有[role1,role2],明文密码为lili, 加盐密码为1A676730B0C7F54654B0E09184448289 # eg: lili 拥有[guest],明文密码为lili, 加盐密码为1A676730B0C7F54654B0E09184448289
account: account:
- appId: admin - appId: admin
credential: admin credential: admin
role: [role1,role2] role: [admin,user]
- appId: tom - appId: tom
credential: tom@123 credential: tom@123
role: [role1,role2,role3] role: [user]
- appId: guest
credential: guest
role: [guest]
- appId: lili - appId: lili
# 注意 Digest认证不支持加盐加密的密码账户 # 注意 Digest认证不支持加盐加密的密码账户
# 加盐加密的密码,通过 MD5(password+salt)计算 # 加盐加密的密码,通过 MD5(password+salt)计算
# 此账户的原始密码为 lili # 此账户的原始密码为 lili
credential: 1A676730B0C7F54654B0E09184448289 credential: 1A676730B0C7F54654B0E09184448289
salt: 123 salt: 123
role: [role1,role2] role: [guest]

View File

@@ -34,7 +34,7 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
*/ */
@RestController @RestController
@RequestMapping(produces = {APPLICATION_JSON_VALUE}) @RequestMapping(produces = {APPLICATION_JSON_VALUE})
@Api(tags = "监控指标数据API") @Api(tags = "Metrics Data API | 监控指标数据API")
public class MetricsDataController { public class MetricsDataController {
private static final Integer METRIC_FULL_LENGTH = 3; private static final Integer METRIC_FULL_LENGTH = 3;

View File

@@ -1,5 +1,5 @@
{ {
"name": "web-app", "name": "hertzbeat-web-app",
"version": "0.0.0", "version": "0.0.0",
"scripts": { "scripts": {
"ng": "ng", "ng": "ng",

View File

@@ -26,8 +26,8 @@ const CODE_MESSAGE: { [key: number]: string } = {
202: '一个请求已经进入后台排队(异步任务)。', 202: '一个请求已经进入后台排队(异步任务)。',
204: '删除数据成功。', 204: '删除数据成功。',
400: '发出的请求有错误,服务器没有进行新建或修改数据的操作。', 400: '发出的请求有错误,服务器没有进行新建或修改数据的操作。',
401: '用户没有权限(令牌、用户名、密码错误)。', 401: '用户认证信息异常。',
403: '用户无权限访问此资源。', 403: '用户无此操作权限。',
404: '发出的请求针对的是不存在的记录,服务器没有进行操作。', 404: '发出的请求针对的是不存在的记录,服务器没有进行操作。',
406: '请求的格式不可得。', 406: '请求的格式不可得。',
409: '请求与服务器端目标资源的当前状态相冲突', 409: '请求与服务器端目标资源的当前状态相冲突',
@@ -65,7 +65,11 @@ export class DefaultInterceptor implements HttpInterceptor {
private checkStatus(ev: HttpResponseBase): void { private checkStatus(ev: HttpResponseBase): void {
const errorText = CODE_MESSAGE[ev.status] || ev.statusText; const errorText = CODE_MESSAGE[ev.status] || ev.statusText;
console.warn(` ${ev.status}: ${ev.url}`, errorText); console.warn(` ${ev.status}: ${ev.url}`, errorText);
this.notification.error(` ${ev.status}: ${ev.url}`, errorText); if (ev.status == 403) {
this.notification.error(` ${ev.status}: ${errorText}`, '');
} else {
this.notification.error(` ${ev.status}: ${ev.url}`, errorText);
}
} }
/** /**

View File

@@ -17,11 +17,7 @@ import { environment } from '@env/environment';
<i nz-icon nzIconfont="icon-gitee"></i> <i nz-icon nzIconfont="icon-gitee"></i>
</a> </a>
</layout-default-header-item> </layout-default-header-item>
<layout-default-header-item direction="left" hidden="mobile">
<a layout-default-header-item-trigger routerLink="/passport/lock">
<i nz-icon nzType="lock"></i>
</a>
</layout-default-header-item>
<layout-default-header-item direction="left" hidden="pc"> <layout-default-header-item direction="left" hidden="pc">
<div layout-default-header-item-trigger (click)="searchToggleStatus = !searchToggleStatus"> <div layout-default-header-item-trigger (click)="searchToggleStatus = !searchToggleStatus">
<i nz-icon nzType="search"></i> <i nz-icon nzType="search"></i>
@@ -33,6 +29,11 @@ import { environment } from '@env/environment';
<layout-default-header-item direction="right" hidden="mobile"> <layout-default-header-item direction="right" hidden="mobile">
<header-notify></header-notify> <header-notify></header-notify>
</layout-default-header-item> </layout-default-header-item>
<layout-default-header-item direction="right" hidden="mobile">
<a layout-default-header-item-trigger routerLink="/passport/lock">
<i nz-icon nzType="lock"></i>
</a>
</layout-default-header-item>
<layout-default-header-item direction="right" hidden="mobile"> <layout-default-header-item direction="right" hidden="mobile">
<div layout-default-header-item-trigger nz-dropdown [nzDropdownMenu]="settingsMenu" nzTrigger="click" nzPlacement="bottomRight"> <div layout-default-header-item-trigger nz-dropdown [nzDropdownMenu]="settingsMenu" nzTrigger="click" nzPlacement="bottomRight">
<i nz-icon nzType="setting"></i> <i nz-icon nzType="setting"></i>

View File

@@ -54,7 +54,7 @@ export class HeaderNotifyComponent implements OnInit {
return; return;
} }
this.loading = true; this.loading = true;
let loadAlerts$ = this.alertSvc.searchAlerts(0, undefined, undefined, 0, 5).subscribe( let loadAlerts$ = this.alertSvc.loadAlerts(0, undefined, undefined, 0, 5).subscribe(
message => { message => {
loadAlerts$.unsubscribe(); loadAlerts$.unsubscribe();
if (message.code === 0) { if (message.code === 0) {

View File

@@ -7,6 +7,11 @@ import { LocalStorageService } from '../../../service/local-storage.service';
@Component({ @Component({
selector: 'header-user', selector: 'header-user',
template: ` template: `
<div class="alain-default__nav-item d-flex align-items-center px-sm" (click)="logout()">
<i nz-icon nzType="logout" class="mr-sm"></i>
{{ 'menu.account.logout' | i18n }}
</div>
<!--
<div class="alain-default__nav-item d-flex align-items-center px-sm" nz-dropdown nzPlacement="bottomRight" [nzDropdownMenu]="userMenu"> <div class="alain-default__nav-item d-flex align-items-center px-sm" nz-dropdown nzPlacement="bottomRight" [nzDropdownMenu]="userMenu">
<nz-avatar [nzSrc]="user.avatar" nzSize="small" class="mr-sm"></nz-avatar> <nz-avatar [nzSrc]="user.avatar" nzSize="small" class="mr-sm"></nz-avatar>
{{ user.name }} {{ user.name }}
@@ -20,6 +25,7 @@ import { LocalStorageService } from '../../../service/local-storage.service';
</div> </div>
</div> </div>
</nz-dropdown-menu> </nz-dropdown-menu>
-->
`, `,
changeDetection: ChangeDetectionStrategy.OnPush changeDetection: ChangeDetectionStrategy.OnPush
}) })

View File

@@ -14,10 +14,10 @@
<nz-divider></nz-divider> <nz-divider></nz-divider>
<div> <div>
<button nz-button nzType="primary" (click)="onDeleteAlerts()"> <button nz-button nzType="primary" (click)="sync()" nz-tooltip [nzTooltipTitle]="'common.refresh' | i18n">
<i nz-icon nzType="delete" nzTheme="outline"></i> <i nz-icon nzType="sync" nzTheme="outline"></i>
{{ 'alert.center.delete' | i18n }}
</button> </button>
<button nz-button nzType="primary" (click)="onMarkReadAlerts()"> <button nz-button nzType="primary" (click)="onMarkReadAlerts()">
<i nz-icon nzType="down-circle" nzTheme="outline"></i> <i nz-icon nzType="down-circle" nzTheme="outline"></i>
{{ 'alert.center.deal' | i18n }} {{ 'alert.center.deal' | i18n }}
@@ -26,11 +26,12 @@
<i nz-icon nzType="up-circle" nzTheme="outline"></i> <i nz-icon nzType="up-circle" nzTheme="outline"></i>
{{ 'alert.center.no-deal' | i18n }} {{ 'alert.center.no-deal' | i18n }}
</button> </button>
<button nz-button nzType="primary" (click)="sync()" nz-tooltip [nzTooltipTitle]="'common.refresh' | i18n"> <button nz-button nzType="primary" nzDanger (click)="onDeleteAlerts()">
<i nz-icon nzType="sync" nzTheme="outline"></i> <i nz-icon nzType="delete" nzTheme="outline"></i>
{{ 'alert.center.delete' | i18n }}
</button> </button>
<button style="margin-right: 25px; float: right" nz-button nzType="primary" (click)="onFilterSearchAlerts()"> <button style="margin-right: 25px; float: right" nz-button nzType="primary" (click)="loadAlertsTable()">
{{ 'common.search' | i18n }} {{ 'common.search' | i18n }}
</button> </button>
<input <input
@@ -39,7 +40,7 @@
type="text" type="text"
[placeholder]="'alert.center.search' | i18n" [placeholder]="'alert.center.search' | i18n"
nzSize="default" nzSize="default"
(keyup.enter)="onFilterSearchAlerts()" (keyup.enter)="loadAlertsTable()"
[(ngModel)]="filterContent" [(ngModel)]="filterContent"
/> />
<nz-select <nz-select
@@ -122,9 +123,6 @@
</td> </td>
<td nzAlign="center">{{ data.gmtCreate | date: 'YYYY-MM-dd HH:mm:ss' }}</td> <td nzAlign="center">{{ data.gmtCreate | date: 'YYYY-MM-dd HH:mm:ss' }}</td>
<td nzAlign="center"> <td nzAlign="center">
<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]="'alert.center.deal' | i18n"> <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> <i nz-icon nzType="down-circle" nzTheme="outline"></i>
</button> </button>
@@ -137,6 +135,16 @@
> >
<i nz-icon nzType="up-circle" nzTheme="outline"></i> <i nz-icon nzType="up-circle" nzTheme="outline"></i>
</button> </button>
<button
nz-button
nzType="primary"
nzDanger
(click)="onDeleteOneAlert(data.id)"
nz-tooltip
[nzTooltipTitle]="'alert.center.delete' | i18n"
>
<i nz-icon nzType="delete" nzTheme="outline"></i>
</button>
</td> </td>
</tr> </tr>
</tbody> </tbody>

View File

@@ -36,13 +36,16 @@ export class AlertCenterComponent implements OnInit {
this.loadAlertsTable(); this.loadAlertsTable();
} }
onFilterSearchAlerts() { sync() {
this.loadAlertsTable();
}
loadAlertsTable() {
this.tableLoading = true; this.tableLoading = true;
let filterAlerts$ = this.alertSvc let alertsInit$ = this.alertSvc
.searchAlerts(this.filterStatus, this.filterPriority, this.filterContent, this.pageIndex - 1, this.pageSize) .loadAlerts(this.filterStatus, this.filterPriority, this.filterContent, this.pageIndex - 1, this.pageSize)
.subscribe( .subscribe(
message => { message => {
filterAlerts$.unsubscribe();
this.tableLoading = false; this.tableLoading = false;
this.checkedAll = false; this.checkedAll = false;
this.checkedAlertIds.clear(); this.checkedAlertIds.clear();
@@ -54,44 +57,16 @@ export class AlertCenterComponent implements OnInit {
} else { } else {
console.warn(message.msg); console.warn(message.msg);
} }
alertsInit$.unsubscribe();
}, },
error => { error => {
this.tableLoading = false; this.tableLoading = false;
filterAlerts$.unsubscribe(); alertsInit$.unsubscribe();
console.error(error.msg); console.error(error.msg);
} }
); );
} }
sync() {
this.loadAlertsTable();
}
loadAlertsTable() {
this.tableLoading = true;
let alertsInit$ = this.alertSvc.getAlerts(this.pageIndex - 1, this.pageSize).subscribe(
message => {
this.tableLoading = false;
this.checkedAll = false;
this.checkedAlertIds.clear();
if (message.code === 0) {
let page = message.data;
this.alerts = page.content;
this.pageIndex = page.number + 1;
this.total = page.totalElements;
} else {
console.warn(message.msg);
}
alertsInit$.unsubscribe();
},
error => {
this.tableLoading = false;
alertsInit$.unsubscribe();
console.error(error.msg);
}
);
}
onDeleteAlerts() { onDeleteAlerts() {
if (this.checkedAlertIds == null || this.checkedAlertIds.size === 0) { if (this.checkedAlertIds == null || this.checkedAlertIds.size === 0) {
this.notifySvc.warning(this.i18nSvc.fanyi('alert.center.notify.no-delete'), ''); this.notifySvc.warning(this.i18nSvc.fanyi('alert.center.notify.no-delete'), '');

View File

@@ -19,13 +19,16 @@
<nz-tabset nzSize="large"> <nz-tabset nzSize="large">
<nz-tab [nzTitle]="'alert.notice.receiver' | i18n"> <nz-tab [nzTitle]="'alert.notice.receiver' | i18n">
<button nz-button nzType="primary" (click)="syncReceiver()">
<i nz-icon nzType="sync" nzTheme="outline"></i>
{{ 'common.refresh' | i18n }}
</button>
<button nz-button nzType="primary" (click)="onNewNoticeReceiver()"> <button nz-button nzType="primary" (click)="onNewNoticeReceiver()">
<i nz-icon nzType="appstore-add" nzTheme="outline"></i> <i nz-icon nzType="appstore-add" nzTheme="outline"></i>
{{ 'alert.notice.receiver.new' | i18n }} {{ 'alert.notice.receiver.new' | i18n }}
</button> </button>
<button nz-button nzType="primary" (click)="syncReceiver()" nz-tooltip [nzTooltipTitle]="'common.refresh' | i18n">
<i nz-icon nzType="sync" nzTheme="outline"></i>
</button>
<nz-table <nz-table
#fixedTable #fixedTable
[nzData]="receivers" [nzData]="receivers"
@@ -100,6 +103,7 @@
<button <button
nz-button nz-button
nzType="primary" nzType="primary"
nzDanger
(click)="onDeleteOneNoticeReceiver(data.id)" (click)="onDeleteOneNoticeReceiver(data.id)"
nz-tooltip nz-tooltip
[nzTooltipTitle]="'alert.notice.receiver.delete' | i18n" [nzTooltipTitle]="'alert.notice.receiver.delete' | i18n"
@@ -112,13 +116,16 @@
</nz-table> </nz-table>
</nz-tab> </nz-tab>
<nz-tab [nzTitle]="'alert.notice.rule' | i18n"> <nz-tab [nzTitle]="'alert.notice.rule' | i18n">
<button nz-button nzType="primary" (click)="syncRule()">
<i nz-icon nzType="sync" nzTheme="outline"></i>
{{ 'common.refresh' | i18n }}
</button>
<button nz-button nzType="primary" (click)="onNewNoticeRule()"> <button nz-button nzType="primary" (click)="onNewNoticeRule()">
<i nz-icon nzType="appstore-add" nzTheme="outline"></i> <i nz-icon nzType="appstore-add" nzTheme="outline"></i>
{{ 'alert.notice.rule.new' | i18n }} {{ 'alert.notice.rule.new' | i18n }}
</button> </button>
<button nz-button nzType="primary" (click)="syncRule()" nz-tooltip [nzTooltipTitle]="'common.refresh' | i18n">
<i nz-icon nzType="sync" nzTheme="outline"></i>
</button>
<nz-table <nz-table
#ruleFixedTable #ruleFixedTable
[nzData]="rules" [nzData]="rules"
@@ -174,6 +181,7 @@
<button <button
nz-button nz-button
nzType="primary" nzType="primary"
nzDanger
(click)="onDeleteOneNoticeRule(data.id)" (click)="onDeleteOneNoticeRule(data.id)"
nz-tooltip nz-tooltip
[nzTooltipTitle]="'alert.notice.rule.delete' | i18n" [nzTooltipTitle]="'alert.notice.rule.delete' | i18n"

View File

@@ -17,21 +17,17 @@
</nz-breadcrumb> </nz-breadcrumb>
<nz-divider></nz-divider> <nz-divider></nz-divider>
<button nz-button nzType="primary" (click)="sync()" nz-tooltip [nzTooltipTitle]="'common.refresh' | i18n">
<i nz-icon nzType="sync" nzTheme="outline"></i>
</button>
<button nz-button nzType="primary" (click)="onNewAlertDefine()"> <button nz-button nzType="primary" (click)="onNewAlertDefine()">
<i nz-icon nzType="appstore-add" nzTheme="outline"></i> <i nz-icon nzType="appstore-add" nzTheme="outline"></i>
{{ 'alert.setting.new' | i18n }} {{ 'alert.setting.new' | i18n }}
</button> </button>
<button nz-button nzType="primary" (click)="onEditAlertDefine()"> <button nz-button nzType="primary" nzDanger (click)="onDeleteAlertDefines()">
<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> <i nz-icon nzType="delete" nzTheme="outline"></i>
{{ 'common.button.delete' | i18n }} {{ 'common.button.delete' | i18n }}
</button> </button>
<button nz-button nzType="primary" (click)="sync()" nz-tooltip [nzTooltipTitle]="'common.refresh' | i18n">
<i nz-icon nzType="sync" nzTheme="outline"></i>
</button>
<nz-table <nz-table
#fixedTable #fixedTable
@@ -116,6 +112,7 @@
</button> </button>
<button <button
nz-button nz-button
nzDanger
nzType="primary" nzType="primary"
(click)="onDeleteOneAlertDefine(data.id)" (click)="onDeleteOneAlertDefine(data.id)"
nz-tooltip nz-tooltip

View File

@@ -10,8 +10,7 @@
</div> </div>
<div nz-col nzSpan="14" class="p-md text-white"> <div nz-col nzSpan="14" class="p-md text-white">
<nz-tag class="mb-xs"> <nz-tag class="mb-xs">
<span>{{ 'monitor.status.available' | i18n }} </span <span>{{ 'monitor.status.available' | i18n }} </span><span style="font-weight: bolder">{{ appCountService.availableSize }}</span>
><span style="font-weight: bolder">{{ appCountService.availableSize }}</span>
</nz-tag> </nz-tag>
<nz-tag class="mb-xs"> <nz-tag class="mb-xs">
<span>{{ 'monitor.status.unavailable' | i18n }} </span <span>{{ 'monitor.status.unavailable' | i18n }} </span
@@ -91,10 +90,12 @@
<span>{{ 'monitor.status.available' | i18n }} </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>
<nz-tag class="mb-xs"> <nz-tag class="mb-xs">
<span>{{ 'monitor.status.unavailable' | i18n }} </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>
<nz-tag class="mb-xs"> <nz-tag class="mb-xs">
<span>{{ 'monitor.status.unreachable' | i18n }} </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>
<nz-tag class="mb-xs"> <nz-tag class="mb-xs">
<span>{{ 'monitor.status.un-manage' | i18n }} </span><span style="font-weight: bolder">{{ appCountCustom.unManageSize }}</span> <span>{{ 'monitor.status.un-manage' | i18n }} </span><span style="font-weight: bolder">{{ appCountCustom.unManageSize }}</span>

View File

@@ -347,11 +347,12 @@ export class DashboardComponent implements OnInit, OnDestroy {
alertsDealLoading: boolean = true; alertsDealLoading: boolean = true;
refreshAlertContentList(): void { refreshAlertContentList(): void {
let alertsInit$ = this.alertSvc.getAlerts(0, 4).subscribe( let alertsInit$ = this.alertSvc.loadAlerts(undefined, undefined, undefined, 0, 4).subscribe(
message => { message => {
if (message.code === 0) { if (message.code === 0) {
let page = message.data; let page = message.data;
this.alerts = page.content; this.alerts = page.content;
this.cdr.detectChanges();
} else { } else {
console.warn(message.msg); console.warn(message.msg);
} }

View File

@@ -14,30 +14,27 @@
<nz-divider></nz-divider> <nz-divider></nz-divider>
<div> <div>
<button nz-button nzType="primary" (click)="sync()" nz-tooltip [nzTooltipTitle]="'common.refresh' | i18n">
<i nz-icon nzType="sync" nzTheme="outline"></i>
</button>
<button nz-button nzType="primary"> <button nz-button nzType="primary">
<a routerLink="/monitors/new" [queryParams]="{ app: app }"> <a routerLink="/monitors/new" [queryParams]="{ app: app }">
<i nz-icon nzType="appstore-add" nzTheme="outline"></i> <i nz-icon nzType="appstore-add" nzTheme="outline"></i>
{{ 'monitors.new' | i18n }} {{ 'monitor.app.' + app | i18n }} {{ 'monitors.new' | i18n }} {{ 'monitor.app.' + app | i18n }}
</a> </a>
</button> </button>
<button nz-button nzType="primary" (click)="onEditMonitor()">
<i nz-icon nzType="edit" nzTheme="outline"></i>
{{ 'monitors.edit' | i18n }}
</button>
<button nz-button nzType="primary" (click)="onDeleteMonitors()">
<i nz-icon nzType="delete" nzTheme="outline"></i>
{{ 'monitors.delete' | i18n }}
</button>
<button nz-button nzType="primary" (click)="onEnableManageMonitors()"> <button nz-button nzType="primary" (click)="onEnableManageMonitors()">
<i nz-icon nzType="up-circle" nzTheme="outline"></i> <i nz-icon nzType="up-circle" nzTheme="outline"></i>
{{ 'monitors.enable' | i18n }} {{ 'monitors.enable' | i18n }}
</button> </button>
<button nz-button nzType="primary" (click)="onCancelManageMonitors()"> <button nz-button nzType="primary" nzDanger (click)="onCancelManageMonitors()">
<i nz-icon nzType="down-circle" nzTheme="outline"></i> <i nz-icon nzType="down-circle" nzTheme="outline"></i>
{{ 'monitors.cancel' | i18n }} {{ 'monitors.cancel' | i18n }}
</button> </button>
<button nz-button nzType="primary" (click)="sync()" nz-tooltip [nzTooltipTitle]="'common.refresh' | i18n"> <button nz-button nzType="primary" nzDanger (click)="onDeleteMonitors()">
<i nz-icon nzType="sync" nzTheme="outline"></i> <i nz-icon nzType="delete" nzTheme="outline"></i>
{{ 'monitors.delete' | i18n }}
</button> </button>
<button style="margin-right: 25px; float: right" nz-button nzType="primary" (click)="onFilterSearchMonitors()"> <button style="margin-right: 25px; float: right" nz-button nzType="primary" (click)="onFilterSearchMonitors()">
@@ -130,15 +127,6 @@
<button nz-button nzType="primary" (click)="onEditOneMonitor(data.id)" nz-tooltip [nzTooltipTitle]="'monitors.edit-monitor' | i18n"> <button nz-button nzType="primary" (click)="onEditOneMonitor(data.id)" nz-tooltip [nzTooltipTitle]="'monitors.edit-monitor' | i18n">
<i nz-icon nzType="edit" nzTheme="outline"></i> <i nz-icon nzType="edit" nzTheme="outline"></i>
</button> </button>
<button
nz-button
nzType="primary"
(click)="onDeleteOneMonitor(data.id)"
nz-tooltip
[nzTooltipTitle]="'monitors.delete-monitor' | i18n"
>
<i nz-icon nzType="delete" nzTheme="outline"></i>
</button>
<button <button
nz-button nz-button
nzType="primary" nzType="primary"
@@ -150,6 +138,7 @@
</button> </button>
<button <button
nz-button nz-button
nzDanger
nzType="primary" nzType="primary"
(click)="onCancelManageOneMonitor(data.id)" (click)="onCancelManageOneMonitor(data.id)"
nz-tooltip nz-tooltip
@@ -157,6 +146,16 @@
> >
<i nz-icon nzType="down-circle" nzTheme="outline"></i> <i nz-icon nzType="down-circle" nzTheme="outline"></i>
</button> </button>
<button
nz-button
nzDanger
nzType="primary"
(click)="onDeleteOneMonitor(data.id)"
nz-tooltip
[nzTooltipTitle]="'monitors.delete-monitor' | i18n"
>
<i nz-icon nzType="delete" nzTheme="outline"></i>
</button>
</td> </td>
</tr> </tr>
</tbody> </tbody>

View File

@@ -22,7 +22,7 @@ const routes: Routes = [
children: [ children: [
// todo 根据路由自动生成面包屑 // todo 根据路由自动生成面包屑
{ path: '', redirectTo: 'dashboard', pathMatch: 'full' }, { path: '', redirectTo: 'dashboard', pathMatch: 'full' },
{ path: 'dashboard', component: DashboardComponent, data: { title: '仪表盘' } }, { path: 'dashboard', component: DashboardComponent, data: { titleI18n: 'menu.dashboard' } },
{ path: 'exception', loadChildren: () => import('./exception/exception.module').then(m => m.ExceptionModule) }, { path: 'exception', loadChildren: () => import('./exception/exception.module').then(m => m.ExceptionModule) },
{ path: 'monitors', loadChildren: () => import('./monitor/monitor.module').then(m => m.MonitorModule) }, { path: 'monitors', loadChildren: () => import('./monitor/monitor.module').then(m => m.MonitorModule) },
{ path: 'alert', loadChildren: () => import('./alert/alert.module').then(m => m.AlertModule) } { path: 'alert', loadChildren: () => import('./alert/alert.module').then(m => m.AlertModule) }
@@ -40,8 +40,8 @@ const routes: Routes = [
path: 'passport', path: 'passport',
component: LayoutPassportComponent, component: LayoutPassportComponent,
children: [ children: [
{ path: 'login', component: UserLoginComponent, data: { title: '登录' } }, { path: 'login', component: UserLoginComponent, data: { titleI18n: 'app.login.login' } },
{ path: 'lock', component: UserLockComponent, data: { title: '锁屏' } } { path: 'lock', component: UserLockComponent, data: { titleI18n: 'app.lock' } }
] ]
}, },
{ path: '**', redirectTo: 'exception/404' } { path: '**', redirectTo: 'exception/404' }

View File

@@ -2,6 +2,8 @@ import { NgModule, Type } from '@angular/core';
import { SharedModule } from '@shared'; import { SharedModule } from '@shared';
// dashboard pages // dashboard pages
import { NzTagModule } from 'ng-zorro-antd/tag';
import { NzTimelineModule } from 'ng-zorro-antd/timeline';
import { NgxEchartsModule } from 'ngx-echarts'; import { NgxEchartsModule } from 'ngx-echarts';
import { DashboardComponent } from './dashboard/dashboard.component'; import { DashboardComponent } from './dashboard/dashboard.component';
@@ -10,8 +12,6 @@ import { UserLockComponent } from './passport/lock/lock.component';
// passport pages // passport pages
import { UserLoginComponent } from './passport/login/login.component'; import { UserLoginComponent } from './passport/login/login.component';
import { RouteRoutingModule } from './routes-routing.module'; import { RouteRoutingModule } from './routes-routing.module';
import { NzTagModule } from 'ng-zorro-antd/tag';
import { NzTimelineModule } from 'ng-zorro-antd/timeline';
const COMPONENTS: Array<Type<void>> = [ const COMPONENTS: Array<Type<void>> = [
DashboardComponent, DashboardComponent,

View File

@@ -16,22 +16,7 @@ const alerts_status_uri = '/alerts/status';
export class AlertService { export class AlertService {
constructor(private http: HttpClient) {} constructor(private http: HttpClient) {}
public getAlerts(pageIndex: number, pageSize: number): Observable<Message<Page<Alert>>> { public loadAlerts(
pageIndex = pageIndex ? pageIndex : 0;
pageSize = pageSize ? pageSize : 8;
// 注意HttpParams是不可变对象 需要保存set后返回的对象为最新对象
let httpParams = new HttpParams();
httpParams = httpParams.appendAll({
sort: 'id',
order: 'desc',
pageIndex: pageIndex,
pageSize: pageSize
});
const options = { params: httpParams };
return this.http.get<Message<Page<Alert>>>(alerts_uri, options);
}
public searchAlerts(
status: number | undefined, status: number | undefined,
priority: number | undefined, priority: number | undefined,
content: string | undefined, content: string | undefined,

View File

@@ -22,7 +22,7 @@
"security": "安全设置", "security": "安全设置",
"binding": "账号绑定", "binding": "账号绑定",
"trigger": "触发错误", "trigger": "触发错误",
"logout": "退出登录" "logout": "退出"
}, },
"alert": { "alert": {
"": "告警", "": "告警",

View File

@@ -22,7 +22,7 @@
"security": "安全設置", "security": "安全設置",
"binding": "賬號綁定", "binding": "賬號綁定",
"trigger": "觸發錯誤", "trigger": "觸發錯誤",
"logout": "退出登錄" "logout": "退出"
}, },
"alert": { "alert": {
"": "告警", "": "告警",

View File

@@ -7,12 +7,50 @@
// ==========The following is the custom theme variable area========== // ==========The following is the custom theme variable area==========
// The theme parameters can be generated at https://ng-alain.github.io/ng-alain/ // The theme parameters can be generated at https://ng-alain.github.io/ng-alain/
// @primary-color: #f50; // @primary-color: #f50;
@primary-color: #722ED1; @primary-color: #3f51b5;
@font-size-base: 12px; @font-size-base: 12px;
@nz-table-rep-padding-vertical: 2px; @nz-table-rep-padding-vertical: 2px;
@nz-table-rep-padding-horizontal: 2px; @nz-table-rep-padding-horizontal: 2px;
@alain-default-header-hg: 52px; @alain-default-header-hg: 52px;
@alain-default-header-bg: #722ED1; @alain-default-header-bg: #3f51b5;
@alain-default-header-padding: 8px; @alain-default-header-padding: 8px;
@alain-default-aside-nav-text-hover-color: #722ED1; @alain-default-aside-nav-text-hover-color: #3f51b5;
@alain-default-aside-nav-selected-text-color: #722ED1; @alain-default-aside-nav-selected-text-color: #3f51b5;
.ant-switch-checked{
background-color: #ff4081;
}
.ant-radio-group-solid .ant-radio-button-wrapper-checked:not(.ant-radio-button-wrapper-disabled) {
color: #fff;
background: #ff4081;
border-color: #ff4081;
}
.ant-radio-wrapper:hover .ant-radio,
.ant-radio:hover .ant-radio-inner,
.ant-radio-input:focus + .ant-radio-inner {
border-color: #ff4081;
background: #ff4081;
}
.sidebar-nav .sidebar-nav__selected{
background: rgba(63,81,181,.15);
color: #3f51b5;
}
.sidebar-nav__sub .sidebar-nav__item{
color: #000000a6;
}
.sidebar-nav__open > .sidebar-nav__sub {
background-color: #fafafa;
}
.sidebar-nav__sub .sidebar-nav__item:hover{
background: rgba(0,0,0,.04);
}
.ant-btn-dangerous.ant-btn-primary {
border-color: #ff4081;
background: #ff4081;
}