2020-07-27 18:26:44 +08:00
|
|
|
<template>
|
2021-12-31 10:15:36 +08:00
|
|
|
<div :style="calcPosition(that.position,that)" class="alert-label__border alert-label" v-loading="loading" ref="alertLabels">
|
2020-09-29 18:51:03 +08:00
|
|
|
<div class="alert-rule-info" >
|
|
|
|
|
<div class="alert-rule-box">
|
|
|
|
|
<div class="alert-rule-title">ID</div>
|
2021-10-27 14:02:09 +08:00
|
|
|
<div class="alert-rule-value">{{alertRuleData.id ? alertRuleData.id : '--'}}</div>
|
2020-09-29 18:51:03 +08:00
|
|
|
</div>
|
|
|
|
|
<div class="alert-rule-box">
|
2021-10-26 17:47:49 +08:00
|
|
|
<div class="alert-rule-title">{{$t('alert.name')}}</div>
|
2021-10-27 14:02:09 +08:00
|
|
|
<div class="alert-rule-value">{{alertRuleData.name ? alertRuleData.name : '--'}}</div>
|
2020-09-29 18:51:03 +08:00
|
|
|
</div>
|
|
|
|
|
<div class="alert-rule-box">
|
2021-10-26 17:47:49 +08:00
|
|
|
<div class="alert-rule-title">{{$t('alert.type')}}</div>
|
2021-11-02 11:04:06 +08:00
|
|
|
<div class="alert-rule-value">
|
|
|
|
|
<span v-if="alertRuleData.type === 1">
|
|
|
|
|
{{$t('project.metrics.metrics')}}
|
|
|
|
|
</span>
|
|
|
|
|
<span v-else-if="alertRuleData.type === 2">
|
|
|
|
|
{{$t('overall.logs')}}
|
|
|
|
|
</span>
|
|
|
|
|
<span v-else-if="alertRuleData.type === 3">SNMP trap</span>
|
|
|
|
|
<span v-else>--</span>
|
|
|
|
|
</div>
|
2021-05-21 19:28:50 +08:00
|
|
|
</div>
|
|
|
|
|
<div class="alert-rule-box">
|
2021-10-26 17:47:49 +08:00
|
|
|
<div class="alert-rule-title">{{$t('alert.severity')}}</div>
|
2021-10-27 14:02:09 +08:00
|
|
|
<div class="alert-rule-value"><i class="nz-icon nz-icon-circle" :style="{color:severityColor,'font-size':'12px','margin-right':'5px'}"></i>{{alertRuleData.severityId ? severityData.find(s => alertRuleData.severityId === s.id).name : '--'}}</div>
|
2021-05-21 19:28:50 +08:00
|
|
|
</div>
|
|
|
|
|
<div class="alert-rule-box">
|
2021-10-26 17:47:49 +08:00
|
|
|
<div class="alert-rule-title">{{$t('alert.config.expr')}}</div>
|
2021-10-27 14:02:09 +08:00
|
|
|
<div class="alert-rule-value">{{alertRuleData.expr ? (alertRuleData.expr + alertRuleData.operator + formatThreshold(alertRuleData.threshold,alertRuleData.unit)) : '--'}}</div>
|
2021-10-26 17:47:49 +08:00
|
|
|
</div>
|
|
|
|
|
<div class="alert-rule-box">
|
|
|
|
|
<div class="alert-rule-title">{{$t('alert.alertNum')}}</div>
|
2022-03-01 11:04:16 +08:00
|
|
|
<div class="alert-rule-value" v-if="alertRuleData">
|
|
|
|
|
<i :class="alertRuleData.alertNum ? 'red' : 'green'" class="nz-icon nz-icon-overview-alert vertical-align-top;" @mouseenter="tooltipHover('',true, $event)" @mouseleave="tooltipHover('',false, $event)"></i>
|
|
|
|
|
<div v-if="alertNumtooltipShow" class="alert-days-info-tooltip" :style="{left: position.left + 'px',top:position.top + 'px'}">
|
|
|
|
|
<div class="tooltip-title">Alert message (active)</div>
|
|
|
|
|
<div class="severity-info" style='justify-content: space-between'>
|
|
|
|
|
<div class="severity-name">{{$t('overall.result.total')}}</div>
|
|
|
|
|
<div class="severity-value">{{alertRuleData.alertNum}}</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<alertDaysInfo
|
|
|
|
|
v-show="!trendLoading"
|
|
|
|
|
:alertDaysData="alertDaysData"
|
|
|
|
|
/>
|
2021-10-26 17:47:49 +08:00
|
|
|
</div>
|
2020-07-27 18:26:44 +08:00
|
|
|
</div>
|
2021-09-14 14:19:38 +08:00
|
|
|
<div class="alert-rule-box">
|
|
|
|
|
<div class="alert-rule-title">{{$t('alert.config.trbShot')}}</div>
|
2021-11-01 17:23:01 +08:00
|
|
|
<div class="alert-rule-value" @click="trbShotShow"><i class="nz-icon nz-icon-guzhangshuju"></i></div>
|
2021-09-14 14:19:38 +08:00
|
|
|
</div>
|
2021-10-26 17:47:49 +08:00
|
|
|
<div class="alert-rule-box">
|
|
|
|
|
<div class="alert-rule-title">{{$t('alert.state')}}</div>
|
|
|
|
|
<div class="alert-rule-value" style="margin-left: 3px">
|
|
|
|
|
<div v-if="alertRuleData.state === 1">
|
|
|
|
|
<i class="active-icon green-bg inline-block"></i>
|
|
|
|
|
{{ $t('overall.enabled') }}
|
|
|
|
|
</div>
|
|
|
|
|
<div v-else-if="alertRuleData.state === 0">
|
|
|
|
|
<i class="active-icon gray-bg inline-block"></i>
|
|
|
|
|
{{ $t('overall.disabled') }}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2020-07-27 18:26:44 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2021-03-19 18:52:19 +08:00
|
|
|
import chartDataFormat from '../../charts/chartDataFormat'
|
2022-03-01 11:04:16 +08:00
|
|
|
import trendMixins from '@/components/common/alert/trendMixins'
|
2021-03-19 18:52:19 +08:00
|
|
|
export default {
|
|
|
|
|
name: 'alert-rule-info',
|
2022-03-01 11:04:16 +08:00
|
|
|
mixins: [trendMixins],
|
2021-03-19 18:52:19 +08:00
|
|
|
props: {
|
|
|
|
|
id: {},
|
|
|
|
|
messageLoad: {},
|
2022-02-14 14:13:49 +08:00
|
|
|
detailList: Boolean,
|
2021-05-21 19:28:50 +08:00
|
|
|
that: {},
|
|
|
|
|
severityData: Array
|
2021-03-19 18:52:19 +08:00
|
|
|
},
|
|
|
|
|
data () {
|
|
|
|
|
return {
|
|
|
|
|
loading: true,
|
2021-10-26 17:47:49 +08:00
|
|
|
alertRuleData: '',
|
|
|
|
|
severityColor: ''
|
2021-03-19 18:52:19 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
components: {
|
2020-07-27 18:26:44 +08:00
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
},
|
|
|
|
|
computed: {
|
|
|
|
|
calcPosition () {
|
|
|
|
|
return function (position) {
|
2021-09-14 14:19:38 +08:00
|
|
|
if (!position) {
|
|
|
|
|
return {
|
|
|
|
|
left: '0px',
|
|
|
|
|
top: '0px'
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
const clientHeight = (document.body.clientHeight < document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight
|
2021-12-31 10:15:36 +08:00
|
|
|
// const windowWidth = window.innerWidth
|
|
|
|
|
const boxHeight = this.$refs.alertLabels ? this.$refs.alertLabels.offsetHeight : 231
|
|
|
|
|
const windowHeight = window.innerHeight
|
2022-02-14 14:13:49 +08:00
|
|
|
const leftOffSetView = this.detailList ? -80 : 10
|
2021-12-31 10:15:36 +08:00
|
|
|
if (position.top > windowHeight / 2) {
|
2021-03-19 18:52:19 +08:00
|
|
|
return {
|
2022-02-14 14:13:49 +08:00
|
|
|
left: `${position.left + position.width + leftOffSetView}px`,
|
2021-12-31 10:15:36 +08:00
|
|
|
top: `${position.top - boxHeight}px`
|
2020-09-28 16:27:03 +08:00
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
} else {
|
|
|
|
|
return {
|
2022-02-14 14:13:49 +08:00
|
|
|
left: `${position.left + position.width + leftOffSetView}px`,
|
2021-12-31 10:15:36 +08:00
|
|
|
top: `${position.top}px`
|
2020-10-15 18:20:32 +08:00
|
|
|
}
|
|
|
|
|
}
|
2020-09-28 16:27:03 +08:00
|
|
|
}
|
2020-11-20 11:19:25 +08:00
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
formatThreshold (value, unit) {
|
|
|
|
|
const unitMethod = chartDataFormat.getUnit(unit)
|
|
|
|
|
if (unitMethod && value) {
|
|
|
|
|
return unitMethod.compute(value, null, 2)
|
|
|
|
|
} else {
|
|
|
|
|
return value
|
|
|
|
|
}
|
2021-09-14 14:19:38 +08:00
|
|
|
},
|
|
|
|
|
trbShotShow () {
|
|
|
|
|
this.$emit('showText')
|
2021-10-26 17:47:49 +08:00
|
|
|
},
|
|
|
|
|
severityDataColor () {
|
|
|
|
|
this.severityData.map(item => {
|
|
|
|
|
this.severityColor = item.color
|
|
|
|
|
})
|
2021-03-19 18:52:19 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
mounted () {
|
2021-05-21 19:28:50 +08:00
|
|
|
this.$get('/alert/rule/' + this.id).then((res) => {
|
2021-03-19 18:52:19 +08:00
|
|
|
if (res.msg === 'success') {
|
|
|
|
|
this.loading = false
|
2021-10-26 17:47:49 +08:00
|
|
|
this.severityDataColor()
|
2021-05-21 19:28:50 +08:00
|
|
|
this.alertRuleData = res.data
|
2022-03-01 11:04:16 +08:00
|
|
|
const weekDays = this.getWeeksTime()
|
|
|
|
|
if (this.trendTimer) {
|
|
|
|
|
clearTimeout(this.trendTimer)
|
|
|
|
|
this.trendTimer = null
|
|
|
|
|
}
|
|
|
|
|
this.trendTimer = setTimeout(() => {
|
|
|
|
|
this.trendLoading = true
|
|
|
|
|
const params = {
|
|
|
|
|
type: 'total',
|
|
|
|
|
dimension: 'priority',
|
|
|
|
|
step: 'd'
|
|
|
|
|
}
|
|
|
|
|
params['rule' + 'Id'] = this.id
|
|
|
|
|
this.$get('/stat/alertMessage/trend', params).then((res) => {
|
2022-03-10 13:34:24 +08:00
|
|
|
if (!res.data) {
|
|
|
|
|
return
|
|
|
|
|
}
|
2022-03-01 11:04:16 +08:00
|
|
|
const alertDaysData = res.data.result ? res.data.result[0].values : []
|
|
|
|
|
const newWeekDays = JSON.parse(JSON.stringify(weekDays))
|
|
|
|
|
alertDaysData.forEach(item => {
|
|
|
|
|
item.values.forEach(time => {
|
|
|
|
|
const findItem = newWeekDays.find(days => days.time == time[0])
|
|
|
|
|
if (findItem) {
|
|
|
|
|
findItem[item.metric.priority] = time[1]
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.alertDaysData = newWeekDays
|
|
|
|
|
this.trendLoading = false
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|
2021-03-19 18:52:19 +08:00
|
|
|
} else {
|
|
|
|
|
this.$message.error(res.msg)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-07-27 18:26:44 +08:00
|
|
|
|
|
|
|
|
</script>
|