NEZ-1332 feat: alert message 查看请求参数调整(metrics,logs)
This commit is contained in:
@@ -462,16 +462,13 @@ export default {
|
||||
})
|
||||
},
|
||||
messageDetail (row) {
|
||||
console.log(row)
|
||||
if (row.alertRule.type == 3) {
|
||||
return
|
||||
}
|
||||
this.$get('/alert/rule/' + row.alertRule.id).then(res => {
|
||||
this.currentMsg = { ...row, alertRule: { ...res.data } }
|
||||
if (row.alertRule.type !== 1) {
|
||||
this.graphShow = false
|
||||
} else {
|
||||
this.graphShow = true
|
||||
}
|
||||
this.graphShow = true
|
||||
this.$nextTick(() => {
|
||||
this.searchTimeDialog = [bus.computeTimezoneTime(new Date().getTime() - 1 * 60 * 60 * 1000), bus.computeTimezoneTime(new Date().getTime())]
|
||||
this.queryDate()
|
||||
@@ -492,7 +489,7 @@ export default {
|
||||
this.queryChartDate()
|
||||
})
|
||||
} else if (this.currentMsg.alertRule.type === 2) {
|
||||
this.queryLogData(1000)
|
||||
this.queryLogData(100)
|
||||
}
|
||||
},
|
||||
queryChartDate () {
|
||||
@@ -514,8 +511,7 @@ export default {
|
||||
if (this.$refs.messageChart) {
|
||||
this.$refs.messageChart.startLoading()
|
||||
const axiosArr = []
|
||||
const paramStr = JSON.stringify(this.promQueryParamConvert(this.currentMsg))
|
||||
axiosArr.push(axios.get('/prom/api/v1/query_range?query=' + paramStr.substring(1, paramStr.length - 1) + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&step=' + step))
|
||||
axiosArr.push(axios.get('/prom/api/v1/query_range?query=' + escape(this.currentMsg.alertRule.expr.replace(/\"/g, '\'').replace(/\s+/g, '')) + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&step=' + step + '&filter=' + escape(unescape(this.promQueryParamLabels(this.currentMsg.labels)))))
|
||||
this.legend = []
|
||||
this.chartDatas = []
|
||||
axios.all(axiosArr).then(res => {
|
||||
@@ -658,12 +654,12 @@ export default {
|
||||
},
|
||||
queryLogData (limit) { // log的chart和table是一个请求
|
||||
if (!limit) {
|
||||
limit = 1000
|
||||
limit = 100
|
||||
}
|
||||
const start = this.searchTimeDialog[0] ? this.searchTimeDialog[0] : bus.computeTimezoneTime(new Date().getTime() - 1 * 60 * 60 * 1000)
|
||||
const end = this.searchTimeDialog[1] ? this.searchTimeDialog[1] : bus.computeTimezoneTime(new Date().getTime())
|
||||
this.expressions = [this.currentMsg.alertRule.expr]
|
||||
this.$get('/logs/loki/api/v1/query_range?format=1&query=' + this.currentMsg.alertRule.expr + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&limit=' + limit).then(res => {
|
||||
this.$get('/logs/loki/api/v1/query_range?format=1&query=' + escape(this.currentMsg.alertRule.expr) + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&limit=' + limit + '&filter=' + escape(unescape(this.promQueryParamLabels(this.currentMsg.labels)))).then(res => {
|
||||
this.chartLoading = false
|
||||
const logData = [res.data]
|
||||
this.resultType = res.data.resultType
|
||||
@@ -939,6 +935,14 @@ export default {
|
||||
}
|
||||
return r
|
||||
},
|
||||
promQueryParamLabels (labels) {
|
||||
const obj = JSON.parse(labels)
|
||||
const filterArr = ['alertname', 'severity_id', 'severity', 'rule_type']
|
||||
filterArr.forEach(key => {
|
||||
delete obj[key]
|
||||
})
|
||||
return JSON.stringify(obj)
|
||||
},
|
||||
// asset弹框控制
|
||||
tabControl (data) {
|
||||
if (data === 'close') {
|
||||
|
||||
Reference in New Issue
Block a user