diff --git a/nezha-fronted/src/components/charts/chartDataFormat.js b/nezha-fronted/src/components/charts/chartDataFormat.js index c1e41c3f2..8dd99c54b 100644 --- a/nezha-fronted/src/components/charts/chartDataFormat.js +++ b/nezha-fronted/src/components/charts/chartDataFormat.js @@ -4,6 +4,7 @@ * type:自定义参数,用于区分是y轴调用还是tooltip调用,以设置不同精度 type =1 y轴调用 type=2 tooltip调用 * */ import {parse} from "echarts/extension-src/dataTool/gexf"; +import bus from "../../libs/bus" function none(value, index){ return value; @@ -412,6 +413,12 @@ function timeCompute(value,unit,dot=0){ } } +function timeFormat34(value) { + return bus.timeFormate(value, "yyyy-MM-dd hh:mm:ss"); +} +function timeFormat35(value) { + return bus.timeFormate(value, "MM/dd/yyyy h:mm:ss a"); +} //unit转化配置信息 /* * value:传递给数据库的值 @@ -615,7 +622,23 @@ let unitOptions=[ ascii:7, }, ] - }//Time end + },//Time end + { + value:'Date&Time', + label: 'Date & Time', + children: [ + { + value:34, + compute: timeFormat34, + label:'YYYY-MM-DD HH:mm:ss', + }, + { + value:35, + compute: timeFormat35, + label:'MM/DD/YYYY h:mm:ss a', + } + ] + } ] let units=[]; window.onload=function(){ diff --git a/nezha-fronted/src/components/common/alert/alertMessageTable.vue b/nezha-fronted/src/components/common/alert/alertMessageTable.vue index 8f3a9ae0a..c781bbc08 100644 --- a/nezha-fronted/src/components/common/alert/alertMessageTable.vue +++ b/nezha-fronted/src/components/common/alert/alertMessageTable.vue @@ -567,7 +567,31 @@ }, promQueryParamConvert(obj){ - let result="(" + obj.alertRule.expr + ")"; + let r = "(" + obj.alertRule.expr + ")"; + if (Object.keys(obj.labels).length > 0) { + r += " and " + function(){ + let group = "(group({"; + let by = " by ("; + + for (let k in obj.labels) { + if (k != 'alertname' && k != 'severity') { + group += k; + group += "="; + group += ("'" + obj.labels[k] + "',"); + by += k; + by += "," + } + } + group = group.substring(0, group.length-1); + group += "})"; + by = by.substring(0, by.length-1); + by += ")"; + + return group + by + ")"; + }(); + } + return r; + /*let result="(" + obj.alertRule.expr + ")"; if(obj.labels){ if(obj.labels.alertname){ delete obj.labels.alertname; @@ -591,7 +615,7 @@ return q; }() + ")"; } - return result; + return result;*/ }, //asset弹框控制 tabControl(data) { diff --git a/nezha-fronted/src/libs/bus.js b/nezha-fronted/src/libs/bus.js index 60d6e4541..01301e6f4 100644 --- a/nezha-fronted/src/libs/bus.js +++ b/nezha-fronted/src/libs/bus.js @@ -100,10 +100,11 @@ export default new Vue({ const o = { 'M+': time.getMonth() + 1, // 月份 'd+': time.getDate(), // 日 - 'h+': time.getHours(), // 小时 + 'hh': time.getHours(), // 小时 'm+': time.getMinutes(), // 分 's+': time.getSeconds(), // 秒 'q+': Math.floor((time.getMonth() + 3) / 3), // 季度 + 'a': time.getHours() > 12 ? "pm" : "am", S: time.getMilliseconds(), // 毫秒 w: week, }; @@ -116,6 +117,7 @@ export default new Vue({ (o[k]) : ((`00${o[k]}`).substr((`${o[k]}`).length))); } }); + fm = fm.replace("h", time.getHours() > 12 ? time.getHours()-12 : time.getHours()); return fm; }, // 格式化tag为字符串表达式