-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[alerter, manager] use thymeleaf to render notify content (#583)
[web-app] fix history echarts chart tooltip only show one instance (#365) [workflow] upgrade issues-translator version 2.7 (#367) [manger] add mockito unit test [manger] add globalExceptionHandler mockito unit test (#368) [manager] impl appController unit test case (#370) 英文注释的补充 Supplement of English notes Supplementary English notes Supplement of English notes AppControllerTest Implementation of unit tests Co-authored-by: gaoxingcun <gxc01514416@alibaba-inc.com> [warehouse] support Iotdb metrics data storage (#372) add iotdb storage (saveData part) implement getHistoryMetricData save multiple instances at the same time implement getHistoryIntervalMetricData [warehouse] reformat code [warehouse] refactor code [warehouse] refactor code [warehouse] refactor code [warehouse] fix insert node path container ' parsed error [warehouse] fix insert node path container ' parsed error [warehouse] support iotdb rpc-port support iotdb version 0.12 fix save data and select bug replace Session with SessionPool rule fix, 修复魔法值问题 Co-authored-by: tomsun28 <tomsun28@outlook.com> Co-authored-by: hujiaofen <hujiaofen@2dfire.com> [webapp,warehouse] support historical interval aggregate data chart (#373) [manger] add mockito unit test [manger] impl unit test ParamDaoTest #360 [manager] fix NoticeRuleDaoTest [manger] impl unit test ParamDefineDaoTest #361 [manger] impl unit test TagDaoTest #362 [manger] add manger sql dao mockito unit test (#375) [manger] add mockito unit test [manger] add mockito unit test [manger] impl unit test ParamDaoTest #360 [manager] fix NoticeRuleDaoTest [manger] impl unit test ParamDefineDaoTest #361 [manger] impl unit test TagDaoTest #362 [manager] I18nControllerTest and MonitorControllerTest Unit tests are written (#376) I18ControllerTest Completion of the test class MonitorControllerTest Unit tests are written [manger] impl unit test AppServiceTest #355 [hertzbeat] update use PromQL to collect metrics from promethues server (#456) [manager] enhancement manager-monitors-page added gmtUpdate desc (#455) [manager-monitors](增强)应用服务检测-网站检测-分页:添加默认name升序 (enhancement)manager-monitors-page added name asc [manager-monitors](增强)应用服务检测-网站检测-分页:添加默认gmtUpdate降序 (enhancement)manager-monitors-page added gmtUpdate desc [webapp] support monitors list sort by name, date (#458) [manager] bugfix the gmtUpdate time not change when update monitor params (#459) [alerter,collector,common,warehouse] refactor auto import component [manager] Notification type supports telegram [web-app] Notification type supports telegram fix PMD Failure LowerCamelCaseVariableNamingRule fix PMD check fix ESLint Error [manager] remove useless judgment [manager] use thymeleaf to render notify content [alerter, manager] use thymeleaf to render notify content Co-authored-by: tomsun28 <tomsun28@outlook.com> Co-authored-by: 铁甲小宝 <85919258+TJxiaobao@users.noreply.github.com> Co-authored-by: gaoxingcun <gxc01514416@alibaba-inc.com> Co-authored-by: zcx <48920254+Ceilzcx@users.noreply.github.com> Co-authored-by: hujiaofen <hujiaofen@2dfire.com> Co-authored-by: luxx <58515565+luxx-lq@users.noreply.github.com>
- Loading branch information
1 parent
6491db7
commit 4405541
Showing
21 changed files
with
420 additions
and
502 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
...rc/main/java/com/usthe/manager/component/alerter/impl/AbstractAlertNotifyHandlerImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package com.usthe.manager.component.alerter.impl; | ||
|
||
import com.usthe.alert.AlerterProperties; | ||
import com.usthe.common.entity.alerter.Alert; | ||
import com.usthe.common.util.CommonUtil; | ||
import com.usthe.common.util.ResourceBundleUtil; | ||
import com.usthe.manager.component.alerter.AlertNotifyHandler; | ||
import org.springframework.web.client.RestTemplate; | ||
import org.thymeleaf.TemplateEngine; | ||
import org.thymeleaf.context.Context; | ||
|
||
import javax.annotation.Resource; | ||
import java.time.Instant; | ||
import java.time.ZoneId; | ||
import java.time.format.DateTimeFormatter; | ||
import java.util.ResourceBundle; | ||
|
||
/** | ||
* @author <a href="mailto:gcwm99@gmail.com">gcdd1993</a> | ||
* @version 2.1 | ||
* Created by Musk.Chen on 2023/1/16 | ||
*/ | ||
abstract class AbstractAlertNotifyHandlerImpl implements AlertNotifyHandler { | ||
|
||
protected final ResourceBundle bundle = ResourceBundleUtil.getBundle("alerter"); | ||
protected static final DateTimeFormatter DTF = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); | ||
|
||
@Resource | ||
protected TemplateEngine templateEngine; | ||
|
||
@Resource | ||
protected RestTemplate restTemplate; | ||
|
||
@Resource | ||
protected AlerterProperties alerterProperties; | ||
|
||
protected String renderContext(Alert alert) { | ||
Context context = new Context(); | ||
context.setVariable("title", "[" + bundle.getString("alerter.notify.title") + "]"); | ||
if (alert.getTags() != null) { | ||
alert.getTags().forEach(context::setVariable); | ||
} | ||
context.setVariable("monitorIdLabel", bundle.getString("alerter.notify.monitorId")); | ||
context.setVariable("monitorNameLabel", bundle.getString("alerter.notify.monitorName")); | ||
context.setVariable("targetLabel", bundle.getString("alerter.notify.target")); | ||
context.setVariable("target", alert.getTarget()); | ||
|
||
context.setVariable("priorityLabel", bundle.getString("alerter.notify.priority")); | ||
context.setVariable("priority", bundle.getString("alerter.priority." + alert.getPriority())); | ||
|
||
context.setVariable("triggerTimeLabel", bundle.getString("alerter.notify.triggerTime")); | ||
context.setVariable("triggerTime", DTF.format(Instant.ofEpochMilli(alert.getLastTriggerTime()).atZone(ZoneId.systemDefault()).toLocalDateTime())); | ||
|
||
context.setVariable("contentLabel", bundle.getString("alerter.notify.content")); | ||
context.setVariable("content", alert.getContent()); | ||
|
||
return CommonUtil.removeBlankLine(templateEngine.process(templateName(), context)); | ||
} | ||
|
||
/** | ||
* Get the Thymeleaf template name | ||
* 获取Thymeleaf模板名称 | ||
* | ||
* @return Thymeleaf模板名称 | ||
*/ | ||
protected abstract String templateName(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.