Skip to content

Commit

Permalink
feat(home): add notifyChannel metering (#767)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsy1001de authored Dec 25, 2023
1 parent 87db137 commit 16ea3c1
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
@Getter
public enum MonitorProductCode {
LOG("public_log_base_cn"), METRIC("public_index_spec_cn"), TRACE("public_link_spec_cn"), ALERT(
"public_warn_spec_cn"), API("software_api_base_cn");
"public_warn_spec_cn"), API("software_api_base_cn"), NOTIFY_SMS(
"public_message_base_cn"), NOTIFY_VOICE("public_voice_base_cn");

MonitorProductCode(String code) {
this.code = code;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,10 @@ public Map<String, Set<String>> productCtl(MonitorProductCode code, Map<String,
MonitorInstance instance = instances.get(0);
MonitorInstanceCfg cfg = J.fromJson(instance.getConfig(), MonitorInstanceCfg.class);
control(action, uniqueId, code.getCode(), cfg.getClosed(), productClosed);
log.info("[product_ctl] exec ctl, tenant={}, workspace={}, uniqueId={}, action={}",
instance.getTenant(), instance.getWorkspace(), uniqueId, action);
log.info(
"[product_ctl] exec ctl, tenant={}, tenantName={}, workspace={}, workspaceName={}, instance={}, uniqueId={}, action={}",
instance.getTenant(), instance.getTenantName(), instance.getWorkspace(),
instance.getWorkspaceName(), instance.getInstance(), uniqueId, action);
instance.setConfig(J.toJson(cfg));
monitorInstanceService.updateByInstance(instance);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Locale;
Expand Down Expand Up @@ -276,4 +277,24 @@ public static DateFormat getFormatFromThreadLocal(String format, String zoneId)
}
return df;
}


public static Date getFirstDayOfMonth() {
// 获取当前时间的Calendar实例
Calendar calendar = Calendar.getInstance();

// 将时间设置为本月的第一天
calendar.set(Calendar.DAY_OF_MONTH, 1);

// 将时分秒和毫秒清零
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);

// 获取本月第一天的时间戳(以毫秒为单位)
long firstDayOfMonthTimestamp = calendar.getTimeInMillis();

return new Date(firstDayOfMonthTimestamp);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0.
*/

-- ----------------------------
-- Table structure for alert_notify_record
-- ----------------------------
ALTER TABLE `alert_notify_record`
ADD INDEX `idx_sus_chanel_gmt` (`is_success` ASC, `notify_channel` ASC, `gmt_create` ASC) VISIBLE;
;

0 comments on commit 16ea3c1

Please sign in to comment.