From 5d895aa09a73ebfc9d73f10bafb657c3466c33f1 Mon Sep 17 00:00:00 2001 From: zhangyu Date: Thu, 30 Dec 2021 18:30:34 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E6=94=B9=20alertMessage?= =?UTF-8?q?=20=E9=98=88=E5=80=BC=E6=B2=A1=E6=9C=89=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/bottomBox/tabs/alertMessageTabNew.vue | 14 ++++++++++++++ .../src/components/page/alert/alertMessage.vue | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/nezha-fronted/src/components/common/bottomBox/tabs/alertMessageTabNew.vue b/nezha-fronted/src/components/common/bottomBox/tabs/alertMessageTabNew.vue index d2760d91d..4594e801f 100644 --- a/nezha-fronted/src/components/common/bottomBox/tabs/alertMessageTabNew.vue +++ b/nezha-fronted/src/components/common/bottomBox/tabs/alertMessageTabNew.vue @@ -590,6 +590,13 @@ export default { if (this.currentMsg.alertRule.type === 1) { const chartInfo = lodash.cloneDeep(lineData) chartInfo.elements = [{}] + if (!isNaN(this.currentMsg.alertRule.threshold)) { + chartInfo.param.enable.thresholds = true + chartInfo.param.thresholds = [{ + value: this.currentMsg.alertRule.threshold, + color: '#d64f40' + }] + } chartInfo.elements[0].expression = encodeURIComponent(this.currentMsg.alertRule.expr.replace(/\"/g, '\'').replace(/\r|\n+/g, '')) chartInfo.elements[0].filter = encodeURIComponent(decodeURIComponent(this.promQueryParamLabels(this.currentMsg.labels))) chartInfo.unit = this.currentMsg.unit @@ -597,6 +604,13 @@ export default { } else if (this.currentMsg.alertRule.type === 2) { const chartInfo = lodash.cloneDeep(logData) chartInfo.elements = [{}] + if (!isNaN(this.currentMsg.alertRule.threshold)) { + chartInfo.param.enable.thresholds = true + chartInfo.param.thresholds = [{ + value: this.currentMsg.alertRule.threshold, + color: '#d64f40' + }] + } chartInfo.elements[0].expression = encodeURIComponent(this.currentMsg.alertRule.expr.replace(/\"/g, '\'').replace(/\r|\n+/g, '')) chartInfo.elements[0].filter = encodeURIComponent(decodeURIComponent(this.promQueryParamLabels(this.currentMsg.labels))) chartInfo.unit = this.currentMsg.unit diff --git a/nezha-fronted/src/components/page/alert/alertMessage.vue b/nezha-fronted/src/components/page/alert/alertMessage.vue index d992908eb..ac6fdb26d 100644 --- a/nezha-fronted/src/components/page/alert/alertMessage.vue +++ b/nezha-fronted/src/components/page/alert/alertMessage.vue @@ -572,6 +572,13 @@ export default { if (this.currentMsg.alertRule.type === 1) { const chartInfo = lodash.cloneDeep(lineData) chartInfo.elements = [{}] + if (!isNaN(this.currentMsg.alertRule.threshold)) { + chartInfo.param.enable.thresholds = true + chartInfo.param.thresholds = [{ + value: this.currentMsg.alertRule.threshold, + color: '#d64f40' + }] + } chartInfo.elements[0].expression = encodeURIComponent(this.currentMsg.alertRule.expr.replace(/\"/g, '\'').replace(/\r|\n+/g, '')) chartInfo.elements[0].filter = encodeURIComponent(decodeURIComponent(this.promQueryParamLabels(this.currentMsg.labels))) chartInfo.unit = this.currentMsg.unit @@ -579,6 +586,13 @@ export default { } else if (this.currentMsg.alertRule.type === 2) { const chartInfo = lodash.cloneDeep(logData) chartInfo.elements = [{}] + if (!isNaN(this.currentMsg.alertRule.threshold)) { + chartInfo.param.enable.thresholds = true + chartInfo.param.thresholds = [{ + value: this.currentMsg.alertRule.threshold, + color: '#d64f40' + }] + } chartInfo.elements[0].expression = encodeURIComponent(this.currentMsg.alertRule.expr.replace(/\"/g, '\'').replace(/\r|\n+/g, '')) chartInfo.elements[0].filter = encodeURIComponent(decodeURIComponent(this.promQueryParamLabels(this.currentMsg.labels))) chartInfo.unit = this.currentMsg.unit