diff --git a/nezha-fronted/src/components/chart/chart/chartTimeSeries.vue b/nezha-fronted/src/components/chart/chart/chartTimeSeries.vue
index cd13af52c..7a8e2b4f1 100644
--- a/nezha-fronted/src/components/chart/chart/chartTimeSeries.vue
+++ b/nezha-fronted/src/components/chart/chart/chartTimeSeries.vue
@@ -139,10 +139,12 @@ export default {
})
})
const timeSorted = datas.sort((a, b) => {
- return a[0] - b[0]
+ return Number(a[0]) - Number(b[0])
})
const valueSorted = datas.sort((a, b) => {
- return a[1] - b[1]
+ const a1 = isNaN(a[1]) ? 0 : Number(a[1])
+ const b1 = isNaN(b[1]) ? 0 : Number(b[1])
+ return a1 - b1
})
minTime = timeSorted.length ? timeSorted[0][0] : ''
maxTime = timeSorted.length ? timeSorted[timeSorted.length - 1][0] : ''
diff --git a/nezha-fronted/src/components/common/alert/alertMessageInfo.vue b/nezha-fronted/src/components/common/alert/alertMessageInfo.vue
index d10b401b0..095fb46ba 100644
--- a/nezha-fronted/src/components/common/alert/alertMessageInfo.vue
+++ b/nezha-fronted/src/components/common/alert/alertMessageInfo.vue
@@ -132,7 +132,7 @@ export default {
this.multipleTime = false
}
this.time = [startTime, endTime]
- this.chartInfo.loaded && this.chartInfo.alertRule.type !== 3 && this.query(elements, startTime, endTime, step)
+ this.chartInfo.loaded && this.chartInfo.alertRule && this.chartInfo.alertRule.type !== 3 && this.query(elements, startTime, endTime, step)
},
// 参数 isRefresh 标识是否是刷新操作
getChartData (isRefresh, params) {
diff --git a/nezha-fronted/src/components/common/alert/alertMessageInfoTimeLine.vue b/nezha-fronted/src/components/common/alert/alertMessageInfoTimeLine.vue
index f180d3f04..171be90d3 100644
--- a/nezha-fronted/src/components/common/alert/alertMessageInfoTimeLine.vue
+++ b/nezha-fronted/src/components/common/alert/alertMessageInfoTimeLine.vue
@@ -56,7 +56,7 @@
-
{{$t('overall.noMoreData')}}}
+ {{$t('overall.noMoreData')}}
{{$t('overall.loadMore')}}}
diff --git a/nezha-fronted/src/components/common/bottomBox/tabs/alertMessageTabNew.vue b/nezha-fronted/src/components/common/bottomBox/tabs/alertMessageTabNew.vue
index 3ac2d1ebb..78cffc1f8 100644
--- a/nezha-fronted/src/components/common/bottomBox/tabs/alertMessageTabNew.vue
+++ b/nezha-fronted/src/components/common/bottomBox/tabs/alertMessageTabNew.vue
@@ -645,6 +645,7 @@ export default {
color: '#d64f40'
}]
}
+ chartInfo.elements && (chartInfo.elements[0].expression = this.currentMsg.alertRule.expr.replace(/\"/g, '\'').replace(/\r|\n+/g, ''))
} else if (this.currentMsg.alertRule.type === 2) {
chartInfo = lodash.cloneDeep(logData)
chartInfo.elements = [{}]
@@ -655,11 +656,12 @@ export default {
color: '#d64f40'
}]
}
+ chartInfo.elements && (chartInfo.elements[0].expression = this.currentMsg.alertRule.expr.replace(/\r|\n+/g, ''))
}
chartInfo.id = this.currentMsg.id
chartInfo.name = this.currentMsg.alertRule.name
chartInfo.isAlertMessage = true
- chartInfo.elements && (chartInfo.elements[0].expression = this.currentMsg.alertRule.expr.replace(/\"/g, '\'').replace(/\r|\n+/g, ''))
+ chartInfo.alertRule = this.currentMsg.alertRule
chartInfo.elements && (chartInfo.elements[0].filter = encodeURIComponent(decodeURIComponent(this.promQueryParamLabels(this.currentMsg.labels))))
chartInfo.unit = this.currentMsg.alertRule.unit
this.showFullscreen(true, chartInfo)
diff --git a/nezha-fronted/src/components/common/js/tools.js b/nezha-fronted/src/components/common/js/tools.js
index 89208731b..80d410249 100644
--- a/nezha-fronted/src/components/common/js/tools.js
+++ b/nezha-fronted/src/components/common/js/tools.js
@@ -907,15 +907,32 @@ export function getMetricTypeValue (queryItem, type) {
let copy = JSON.parse(JSON.stringify(queryItem))
switch (type) {
case 'min': {
- const min = copy.sort((x, y) => { return parseFloat(x[1]) - parseFloat(y[1]) })[0][1]
+ let min = copy.sort((x, y) => {
+ const x1 = isNaN(x[1]) ? 0 : x[1]
+ const y1 = isNaN(x[1]) ? 0 : y[1]
+ return x1 - y1
+ })[0][1]
+ if (isNaN(min)) {
+ min = 0
+ }
return min
}
case 'max': {
- const max = copy.sort((x, y) => { return parseFloat(y[1]) - parseFloat(x[1]) })[0][1]
+ let max = copy.sort((x, y) => {
+ const x1 = isNaN(x[1]) ? 0 : x[1]
+ const y1 = isNaN(x[1]) ? 0 : y[1]
+ return y1 - x1
+ })[0][1]
+ if (isNaN(max)) {
+ max = 0
+ }
return max
}
case 'avg': {
- copy = copy.map(t => parseFloat(t[1]))
+ copy = copy.map(t => {
+ const t1 = isNaN(t[1]) ? 0 : t[1]
+ return parseFloat(t1)
+ })
const sum = eval(copy.join('+'))
const avg = sum / copy.length
return avg
@@ -929,13 +946,30 @@ export function getMetricTypeValue (queryItem, type) {
return first
}
case 'total': {
- copy = copy.map(t => parseFloat(t[1]))
+ copy = copy.map(t => {
+ const t1 = isNaN(t[1]) ? 0 : t[1]
+ return parseFloat(t1)
+ })
const total = eval(copy.join('+'))
return total
}
case 'range': {
- const min = copy.sort((x, y) => { return parseFloat(x[1]) - parseFloat(y[1]) })[0][1]
- const max = copy.sort((x, y) => { return parseFloat(y[1]) - parseFloat(x[1]) })[0][1]
+ let min = copy.sort((x, y) => {
+ const x1 = isNaN(x[1]) ? 0 : x[1]
+ const y1 = isNaN(x[1]) ? 0 : y[1]
+ return x1 - y1
+ })[0][1]
+ if (isNaN(min)) {
+ min = 0
+ }
+ let max = copy.sort((x, y) => {
+ const x1 = isNaN(x[1]) ? 0 : x[1]
+ const y1 = isNaN(x[1]) ? 0 : y[1]
+ return y1 - x1
+ })[0][1]
+ if (isNaN(max)) {
+ max = 0
+ }
return max - min
}
case 'different': {
diff --git a/nezha-fronted/src/components/page/alert/alertMessage.vue b/nezha-fronted/src/components/page/alert/alertMessage.vue
index 4e8cd18fc..94869a541 100644
--- a/nezha-fronted/src/components/page/alert/alertMessage.vue
+++ b/nezha-fronted/src/components/page/alert/alertMessage.vue
@@ -614,6 +614,7 @@ export default {
color: '#d64f40'
}]
}
+ chartInfo.elements && (chartInfo.elements[0].expression = this.currentMsg.alertRule.expr.replace(/\"/g, '\'').replace(/\r|\n+/g, ''))
} else if (this.currentMsg.alertRule.type === 2) {
chartInfo = lodash.cloneDeep(logData)
chartInfo.elements = [{}]
@@ -624,11 +625,12 @@ export default {
color: '#d64f40'
}]
}
+ chartInfo.elements && (chartInfo.elements[0].expression = this.currentMsg.alertRule.expr.replace(/\r|\n+/g, ''))
}
chartInfo.id = this.currentMsg.id
chartInfo.name = this.currentMsg.alertRule.name
chartInfo.isAlertMessage = true
- chartInfo.elements && (chartInfo.elements[0].expression = this.currentMsg.alertRule.expr.replace(/\"/g, '\'').replace(/\r|\n+/g, ''))
+ chartInfo.alertRule = this.currentMsg.alertRule
chartInfo.elements && (chartInfo.elements[0].filter = encodeURIComponent(decodeURIComponent(this.promQueryParamLabels(this.currentMsg.labels))))
chartInfo.unit = this.currentMsg.alertRule.unit
this.showFullscreen(true, chartInfo)