Merge branch 'dev-3.2' of https://git.mesalab.cn/nezha/nezha-fronted into dev-3.3
# Conflicts: # nezha-fronted/src/components/common/bottomBox/tabs/alertMessageTabNew.vue # nezha-fronted/src/components/page/alert/alertMessage.vue
This commit is contained in:
@@ -139,10 +139,12 @@ export default {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
const timeSorted = datas.sort((a, b) => {
|
const timeSorted = datas.sort((a, b) => {
|
||||||
return a[0] - b[0]
|
return Number(a[0]) - Number(b[0])
|
||||||
})
|
})
|
||||||
const valueSorted = datas.sort((a, b) => {
|
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] : ''
|
minTime = timeSorted.length ? timeSorted[0][0] : ''
|
||||||
maxTime = timeSorted.length ? timeSorted[timeSorted.length - 1][0] : ''
|
maxTime = timeSorted.length ? timeSorted[timeSorted.length - 1][0] : ''
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ export default {
|
|||||||
this.multipleTime = false
|
this.multipleTime = false
|
||||||
}
|
}
|
||||||
this.time = [startTime, endTime]
|
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 标识是否是刷新操作
|
// 参数 isRefresh 标识是否是刷新操作
|
||||||
getChartData (isRefresh, params) {
|
getChartData (isRefresh, params) {
|
||||||
|
|||||||
@@ -56,7 +56,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</el-timeline-item>
|
</el-timeline-item>
|
||||||
<div v-if="timeLineData.length >= total">{{$t('overall.noMoreData')}}}</div>
|
<div v-if="timeLineData.length >= total" style="text-align: center">{{$t('overall.noMoreData')}}</div>
|
||||||
<div v-else class="load-more-box">
|
<div v-else class="load-more-box">
|
||||||
<el-button size="small" @click="getTimeLineData()" :loading="loading">{{$t('overall.loadMore')}}}</el-button>
|
<el-button size="small" @click="getTimeLineData()" :loading="loading">{{$t('overall.loadMore')}}}</el-button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -645,6 +645,7 @@ export default {
|
|||||||
color: '#d64f40'
|
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) {
|
} else if (this.currentMsg.alertRule.type === 2) {
|
||||||
chartInfo = lodash.cloneDeep(logData)
|
chartInfo = lodash.cloneDeep(logData)
|
||||||
chartInfo.elements = [{}]
|
chartInfo.elements = [{}]
|
||||||
@@ -655,11 +656,12 @@ export default {
|
|||||||
color: '#d64f40'
|
color: '#d64f40'
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
|
chartInfo.elements && (chartInfo.elements[0].expression = this.currentMsg.alertRule.expr.replace(/\r|\n+/g, ''))
|
||||||
}
|
}
|
||||||
chartInfo.id = this.currentMsg.id
|
chartInfo.id = this.currentMsg.id
|
||||||
chartInfo.name = this.currentMsg.alertRule.name
|
chartInfo.name = this.currentMsg.alertRule.name
|
||||||
chartInfo.isAlertMessage = true
|
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.elements && (chartInfo.elements[0].filter = encodeURIComponent(decodeURIComponent(this.promQueryParamLabels(this.currentMsg.labels))))
|
||||||
chartInfo.unit = this.currentMsg.alertRule.unit
|
chartInfo.unit = this.currentMsg.alertRule.unit
|
||||||
this.showFullscreen(true, chartInfo)
|
this.showFullscreen(true, chartInfo)
|
||||||
|
|||||||
@@ -907,15 +907,32 @@ export function getMetricTypeValue (queryItem, type) {
|
|||||||
let copy = JSON.parse(JSON.stringify(queryItem))
|
let copy = JSON.parse(JSON.stringify(queryItem))
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'min': {
|
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
|
return min
|
||||||
}
|
}
|
||||||
case 'max': {
|
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
|
return max
|
||||||
}
|
}
|
||||||
case 'avg': {
|
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 sum = eval(copy.join('+'))
|
||||||
const avg = sum / copy.length
|
const avg = sum / copy.length
|
||||||
return avg
|
return avg
|
||||||
@@ -929,13 +946,30 @@ export function getMetricTypeValue (queryItem, type) {
|
|||||||
return first
|
return first
|
||||||
}
|
}
|
||||||
case 'total': {
|
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('+'))
|
const total = eval(copy.join('+'))
|
||||||
return total
|
return total
|
||||||
}
|
}
|
||||||
case 'range': {
|
case 'range': {
|
||||||
const min = copy.sort((x, y) => { return parseFloat(x[1]) - parseFloat(y[1]) })[0][1]
|
let min = copy.sort((x, y) => {
|
||||||
const max = copy.sort((x, y) => { return parseFloat(y[1]) - parseFloat(x[1]) })[0][1]
|
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
|
return max - min
|
||||||
}
|
}
|
||||||
case 'different': {
|
case 'different': {
|
||||||
|
|||||||
@@ -614,6 +614,7 @@ export default {
|
|||||||
color: '#d64f40'
|
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) {
|
} else if (this.currentMsg.alertRule.type === 2) {
|
||||||
chartInfo = lodash.cloneDeep(logData)
|
chartInfo = lodash.cloneDeep(logData)
|
||||||
chartInfo.elements = [{}]
|
chartInfo.elements = [{}]
|
||||||
@@ -624,11 +625,12 @@ export default {
|
|||||||
color: '#d64f40'
|
color: '#d64f40'
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
|
chartInfo.elements && (chartInfo.elements[0].expression = this.currentMsg.alertRule.expr.replace(/\r|\n+/g, ''))
|
||||||
}
|
}
|
||||||
chartInfo.id = this.currentMsg.id
|
chartInfo.id = this.currentMsg.id
|
||||||
chartInfo.name = this.currentMsg.alertRule.name
|
chartInfo.name = this.currentMsg.alertRule.name
|
||||||
chartInfo.isAlertMessage = true
|
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.elements && (chartInfo.elements[0].filter = encodeURIComponent(decodeURIComponent(this.promQueryParamLabels(this.currentMsg.labels))))
|
||||||
chartInfo.unit = this.currentMsg.alertRule.unit
|
chartInfo.unit = this.currentMsg.alertRule.unit
|
||||||
this.showFullscreen(true, chartInfo)
|
this.showFullscreen(true, chartInfo)
|
||||||
|
|||||||
Reference in New Issue
Block a user