2020-07-29 14:46:35 +08:00
|
|
|
|
<style lang="scss">
|
2021-04-13 20:33:12 +08:00
|
|
|
|
@import '../../../charts/chart';
|
2020-07-29 14:46:35 +08:00
|
|
|
|
</style>
|
|
|
|
|
|
<template>
|
2021-04-13 20:33:12 +08:00
|
|
|
|
<div>
|
2020-07-29 14:46:35 +08:00
|
|
|
|
<!--表格-->
|
|
|
|
|
|
<el-table
|
2021-04-13 20:33:12 +08:00
|
|
|
|
id="alertMessageTable"
|
|
|
|
|
|
ref="dataTable"
|
|
|
|
|
|
:cell-class-name="labelsClassName"
|
2020-07-29 14:46:35 +08:00
|
|
|
|
:data="tableData"
|
2021-04-13 20:33:12 +08:00
|
|
|
|
:height="height"
|
2020-07-29 14:46:35 +08:00
|
|
|
|
border
|
2021-04-13 20:33:12 +08:00
|
|
|
|
@header-dragend="dragend"
|
2020-07-29 14:46:35 +08:00
|
|
|
|
@sort-change="tableDataSort"
|
2021-04-13 20:33:12 +08:00
|
|
|
|
@selection-change="selectChange"
|
2020-07-29 14:46:35 +08:00
|
|
|
|
>
|
|
|
|
|
|
<el-table-column
|
|
|
|
|
|
:resizable="false"
|
|
|
|
|
|
align="center"
|
2021-04-13 20:33:12 +08:00
|
|
|
|
type="selection"
|
|
|
|
|
|
width="55">
|
2020-07-29 14:46:35 +08:00
|
|
|
|
</el-table-column>
|
|
|
|
|
|
<el-table-column
|
2021-04-13 20:33:12 +08:00
|
|
|
|
v-for="(item, index) in customTableTitle"
|
2020-07-29 14:46:35 +08:00
|
|
|
|
v-if="item.show"
|
|
|
|
|
|
:key="`col-${index}`"
|
2021-04-13 20:33:12 +08:00
|
|
|
|
:fixed="item.fixed"
|
2020-07-29 14:46:35 +08:00
|
|
|
|
:label="item.label"
|
2021-04-13 20:33:12 +08:00
|
|
|
|
:min-width="`${item.minWidth}`"
|
|
|
|
|
|
:prop="item.prop"
|
|
|
|
|
|
:resizable="true"
|
2020-07-29 14:46:35 +08:00
|
|
|
|
:sort-orders="['ascending', 'descending']"
|
2021-05-08 09:40:53 +08:00
|
|
|
|
:sortable="item.sortable"
|
2021-04-13 20:33:12 +08:00
|
|
|
|
:width="`${item.width}`"
|
2020-07-29 14:46:35 +08:00
|
|
|
|
>
|
|
|
|
|
|
<template slot-scope="scope" :column="item">
|
2021-03-19 18:52:19 +08:00
|
|
|
|
<template v-if="item.prop === 'alertRule'">
|
2021-04-13 20:33:12 +08:00
|
|
|
|
<div v-if="scope.row.alertRule.name" >
|
2020-10-15 18:20:32 +08:00
|
|
|
|
<span
|
2021-04-13 20:33:12 +08:00
|
|
|
|
@mouseenter="alertMessageHover(scope.row.alertRule, true, $event)"
|
|
|
|
|
|
@mouseleave="alertMessageHover(scope.row.alertRule, false)"
|
|
|
|
|
|
>{{scope.row.alertRule.name}}</span>
|
2020-09-28 16:27:03 +08:00
|
|
|
|
<alertRuleInfo v-if="scope.row.alertRule.loading" :id="scope.row.alertRule.id" :that="scope.row.alertRule"></alertRuleInfo>
|
|
|
|
|
|
</div>
|
2020-07-29 14:46:35 +08:00
|
|
|
|
<template v-else>-</template>
|
|
|
|
|
|
</template>
|
2021-03-19 18:52:19 +08:00
|
|
|
|
<template v-else-if="item.prop === 'summary'">
|
2020-07-29 14:46:35 +08:00
|
|
|
|
<template v-if="scope.row[item.prop]">{{scope.row[item.prop]}}</template>
|
|
|
|
|
|
<template v-else>-</template>
|
|
|
|
|
|
</template>
|
2021-03-19 18:52:19 +08:00
|
|
|
|
<template v-else-if="item.prop === 'description'">
|
2020-07-29 14:46:35 +08:00
|
|
|
|
<template v-if="scope.row[item.prop]">{{scope.row[item.prop]}}</template>
|
|
|
|
|
|
<span v-else>-</span>
|
|
|
|
|
|
</template>
|
2021-03-19 18:52:19 +08:00
|
|
|
|
<template v-else-if="item.prop === 'remark'">
|
2020-10-30 14:09:11 +08:00
|
|
|
|
<template v-if="scope.row[item.prop]">{{scope.row[item.prop]}}</template>
|
|
|
|
|
|
<span v-else>-</span>
|
|
|
|
|
|
</template>
|
2021-05-08 09:40:53 +08:00
|
|
|
|
<span v-else-if="item.prop === 'severity'&&scope.row[item.prop]" class="severity">
|
|
|
|
|
|
<i class="nz-icon nz-icon-circle" :style="{color:scope.row[item.prop].color,'font-size':'12px','margin-right':'5px'}"></i> {{scope.row[item.prop].name}}
|
2020-09-28 16:27:03 +08:00
|
|
|
|
</span>
|
2021-05-19 18:41:00 +08:00
|
|
|
|
<span v-else-if="item.prop === 'startAt'">{{utcTimeToTimezoneStr(scope.row.startAt)}}</span>
|
2021-03-19 18:52:19 +08:00
|
|
|
|
<template v-else-if="item.prop === 'duration'">
|
2021-04-13 20:33:12 +08:00
|
|
|
|
<el-tooltip :disabled="!scope.row.endAt" effect="light" placement="right">
|
2021-03-05 11:37:44 +08:00
|
|
|
|
<div slot="content">
|
|
|
|
|
|
{{$t('config.terminallog.endTime')}}<br/>
|
2021-05-19 18:41:00 +08:00
|
|
|
|
{{utcTimeToTimezoneStr(scope.row.endAt)}}
|
2021-03-05 11:37:44 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<span>{{getDuration(scope.row)}}</span>
|
|
|
|
|
|
</el-tooltip>
|
|
|
|
|
|
</template>
|
2021-03-19 18:52:19 +08:00
|
|
|
|
<template v-else-if="item.prop === 'labels'" class="labels">
|
|
|
|
|
|
<span v-for="(item, i) in labelsSort(scope.row.labels)" :key="i">
|
2020-10-15 18:20:32 +08:00
|
|
|
|
<span
|
|
|
|
|
|
@mouseenter="labelHover(scope.row, item.label, true, $event)"
|
|
|
|
|
|
@mouseleave="labelHover(scope.row, item.label, false)">
|
2020-09-28 16:27:03 +08:00
|
|
|
|
<nz-alert-tag
|
2021-04-13 20:33:12 +08:00
|
|
|
|
v-if="item.label !== 'alertname' && item.label !== 'severity'" :key="item.label" :cursor-point="tagType(item.label) !== 'info'"
|
|
|
|
|
|
:label="item.label"
|
|
|
|
|
|
:type="tagType(item.label)"
|
|
|
|
|
|
style="margin: 5px 0 5px 5px;"
|
2020-09-28 16:27:03 +08:00
|
|
|
|
>
|
|
|
|
|
|
{{item.value}}
|
|
|
|
|
|
</nz-alert-tag>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
<alertLabel
|
2020-11-17 10:00:39 +08:00
|
|
|
|
v-if="(item.label === 'asset' ||item.label === 'module' || item.label === 'project'||item.label === 'endpoint') && scope.row[item.label] && scope.row[item.label].loading"
|
2020-09-28 16:27:03 +08:00
|
|
|
|
:id="scope.row[item.label].id"
|
|
|
|
|
|
:that="scope.row[item.label]"
|
|
|
|
|
|
:type="item.label"
|
|
|
|
|
|
></alertLabel>
|
2020-10-09 11:26:16 +08:00
|
|
|
|
</span>
|
2020-07-29 14:46:35 +08:00
|
|
|
|
</template>
|
2021-03-19 18:52:19 +08:00
|
|
|
|
<span v-else-if="item.prop === 'state'" :class="{'green': scope.row['state'] == 2, 'red': scope.row['state'] == 1}">
|
2020-09-29 18:51:03 +08:00
|
|
|
|
{{scope.row['state'] == 1 ? "Pending" : ""}}
|
|
|
|
|
|
{{scope.row['state'] == 2 ? "Expired" : ""}}
|
|
|
|
|
|
</span>
|
2020-07-29 14:46:35 +08:00
|
|
|
|
<span v-else-if="scope.row[item.prop]">{{scope.row[item.prop]}}</span>
|
|
|
|
|
|
<template v-else>-</template>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
2021-04-13 20:33:12 +08:00
|
|
|
|
<el-table-column
|
|
|
|
|
|
:resizable="false"
|
|
|
|
|
|
:width="operationWidth"
|
|
|
|
|
|
fixed="right">
|
|
|
|
|
|
<div slot="header" class="table-operation-title">{{$t('overall.option')}}</div>
|
|
|
|
|
|
<div slot-scope="scope" class="table-operation-items">
|
2021-05-10 15:59:39 +08:00
|
|
|
|
<button class="table-operation-item" @click="$emit('messageDetail', scope.row)"><i class="nz-icon nz-icon-view1"></i></button>
|
2021-05-19 14:26:09 +08:00
|
|
|
|
<el-dropdown v-has="['alertMessage_expired']" size="medium" trigger="hover" @command="tableOperation">
|
2021-05-10 15:59:39 +08:00
|
|
|
|
<div class="table-operation-item table-operation-item--more">
|
|
|
|
|
|
<span>…</span><i class="nz-icon nz-icon-arrow-down"></i>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<el-dropdown-menu slot="dropdown">
|
2021-05-19 14:04:16 +08:00
|
|
|
|
<el-dropdown-item v-has="'alertMessage_expired'" :command="['delete', scope.row]"><i class="nz-icon nz-icon-delete"></i><span class="operation-dropdown-text">{{$t('overall.delete')}}</span></el-dropdown-item>
|
2021-05-10 15:59:39 +08:00
|
|
|
|
</el-dropdown-menu>
|
|
|
|
|
|
</el-dropdown>
|
2021-04-13 20:33:12 +08:00
|
|
|
|
</div>
|
2020-07-29 14:46:35 +08:00
|
|
|
|
</el-table-column>
|
|
|
|
|
|
</el-table>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
2021-04-13 20:33:12 +08:00
|
|
|
|
import bus from '../../../../libs/bus'
|
2021-03-19 18:52:19 +08:00
|
|
|
|
import axios from 'axios'
|
2021-04-13 20:33:12 +08:00
|
|
|
|
import table from '@/components/common/mixin/table'
|
|
|
|
|
|
import nzAlertTag from '../../../page/alert/nzAlertTag'
|
|
|
|
|
|
import chartDataFormat from '../../../charts/chartDataFormat'
|
|
|
|
|
|
import alertRuleInfo from '../../alert/alertRuleInfo'
|
2021-05-14 17:50:06 +08:00
|
|
|
|
import alertLabel from '../../alert/alertLabel'
|
2021-04-13 20:33:12 +08:00
|
|
|
|
import { calcDurationByStringTimeB } from '../../js/tools'
|
2021-03-19 18:52:19 +08:00
|
|
|
|
export default {
|
|
|
|
|
|
name: 'alertMessageTable',
|
|
|
|
|
|
components: {
|
2021-04-13 20:33:12 +08:00
|
|
|
|
nzAlertTag,
|
2021-03-19 18:52:19 +08:00
|
|
|
|
alertRuleInfo: alertRuleInfo,
|
2021-05-10 13:49:27 +08:00
|
|
|
|
alertLabel: alertLabel
|
2021-03-19 18:52:19 +08:00
|
|
|
|
},
|
|
|
|
|
|
props: {
|
2021-04-13 20:33:12 +08:00
|
|
|
|
nowTime: {
|
|
|
|
|
|
type: String
|
|
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
},
|
2021-04-13 20:33:12 +08:00
|
|
|
|
mixins: [table, bus],
|
2021-03-19 18:52:19 +08:00
|
|
|
|
data () {
|
|
|
|
|
|
return {
|
|
|
|
|
|
/* 二级列表相关 */
|
|
|
|
|
|
tabList: [], // 二级列表的标签
|
|
|
|
|
|
tabDetailList: [], // 多个详情
|
2020-07-29 14:46:35 +08:00
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
// 详情相关
|
|
|
|
|
|
graphShow: false,
|
|
|
|
|
|
chartDatas: [],
|
|
|
|
|
|
sameLabels: ['instance', 'module', 'project', 'asset', 'endpoint', 'datacenter'],
|
|
|
|
|
|
legend: [],
|
|
|
|
|
|
searchTime: [new Date().setHours(new Date().getHours() - 1), new Date()],
|
|
|
|
|
|
currentMsg: {},
|
|
|
|
|
|
chartUnit: 5,
|
|
|
|
|
|
tableTitle: [
|
|
|
|
|
|
{
|
|
|
|
|
|
label: 'ID',
|
|
|
|
|
|
prop: 'id',
|
|
|
|
|
|
show: true,
|
2021-05-08 09:40:53 +08:00
|
|
|
|
width: 80,
|
2021-05-10 13:49:27 +08:00
|
|
|
|
sortable: 'custom'
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}, {
|
2021-05-10 15:59:39 +08:00
|
|
|
|
label: this.$t('alert.rule'),
|
2021-03-19 18:52:19 +08:00
|
|
|
|
prop: 'alertRule',
|
|
|
|
|
|
show: true,
|
2021-05-08 09:40:53 +08:00
|
|
|
|
width: 180,
|
2021-05-10 13:49:27 +08:00
|
|
|
|
sortable: 'custom'
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}, {
|
|
|
|
|
|
label: this.$t('alert.list.labels'),
|
|
|
|
|
|
prop: 'labels',
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
NotSet: true,
|
2021-05-08 09:40:53 +08:00
|
|
|
|
minWidth: 250,
|
2021-05-10 13:49:27 +08:00
|
|
|
|
sortable: 'custom'
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}, {
|
|
|
|
|
|
label: this.$t('alert.severity'),
|
|
|
|
|
|
prop: 'severity',
|
|
|
|
|
|
show: true,
|
2021-05-08 09:40:53 +08:00
|
|
|
|
width: 110,
|
2021-05-10 13:49:27 +08:00
|
|
|
|
sortable: 'custom'
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}, {
|
|
|
|
|
|
label: this.$t('alert.summary'),
|
|
|
|
|
|
prop: 'summary',
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
minWidth: 200
|
|
|
|
|
|
}, {
|
|
|
|
|
|
label: this.$t('alert.description'),
|
|
|
|
|
|
prop: 'description',
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
minWidth: 200
|
2021-05-10 13:49:27 +08:00
|
|
|
|
}, {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
label: this.$t('alert.startAt'),
|
|
|
|
|
|
prop: 'startAt',
|
|
|
|
|
|
show: true,
|
2021-05-08 09:40:53 +08:00
|
|
|
|
width: 150,
|
2021-05-10 13:49:27 +08:00
|
|
|
|
sortable: 'custom'
|
2021-04-13 20:33:12 +08:00
|
|
|
|
}, {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
label: this.$t('config.terminallog.duration'),
|
|
|
|
|
|
prop: 'duration',
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
width: 150
|
2021-05-10 13:49:27 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
],
|
|
|
|
|
|
viewAssetState: false,
|
|
|
|
|
|
tableDataInitNum: 0
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
computed: {
|
|
|
|
|
|
tagType () {
|
|
|
|
|
|
return (key) => {
|
|
|
|
|
|
if (key == 'asset' || key == 'module' || key == 'project' || key == 'datacenter' || key == 'endpoint') {
|
|
|
|
|
|
return 'normal'
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return 'info'
|
|
|
|
|
|
}
|
2020-07-29 14:46:35 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
tagValue () {
|
|
|
|
|
|
return (key, value) => {
|
|
|
|
|
|
if (key == 'type') {
|
|
|
|
|
|
if (value == 1) {
|
2021-05-14 15:24:32 +08:00
|
|
|
|
value = this.$t('project.project.projectName')
|
2021-03-19 18:52:19 +08:00
|
|
|
|
} else if (value == 2) {
|
|
|
|
|
|
value = this.$t('module.module.module')
|
|
|
|
|
|
} else if (value == 3) {
|
|
|
|
|
|
value = this.$t('asset.asset')
|
2020-07-29 14:46:35 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
return key + ':' + value
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
getDuration () {
|
|
|
|
|
|
return function (record) {
|
2021-05-19 18:41:00 +08:00
|
|
|
|
if (record.endAt) {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
return calcDurationByStringTimeB(record.startAt, record.endAt)
|
2020-07-29 14:46:35 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
return calcDurationByStringTimeB(record.startAt, this.nowTime)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
2021-04-13 20:33:12 +08:00
|
|
|
|
labelsSort (obj) {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
const buildIn = ['asset', 'endpoint', 'module', 'project', 'datacenter']
|
|
|
|
|
|
if (typeof obj === 'string') obj = JSON.parse(obj)
|
|
|
|
|
|
const labels = JSON.parse(JSON.stringify(obj))
|
|
|
|
|
|
const result = []
|
|
|
|
|
|
for (const key of buildIn) {
|
|
|
|
|
|
if (key in labels) {
|
|
|
|
|
|
result.push({ label: key, value: labels[key] })
|
|
|
|
|
|
delete labels[key]
|
2021-03-05 11:37:44 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
2021-05-10 19:47:29 +08:00
|
|
|
|
/* Object.keys(labels).sort().forEach(key => {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
result.push({ label: key, value: labels[key] })
|
2021-05-10 19:47:29 +08:00
|
|
|
|
}) */
|
2021-03-19 18:52:19 +08:00
|
|
|
|
return result
|
|
|
|
|
|
},
|
2021-05-10 13:49:27 +08:00
|
|
|
|
chartUnitChange: function (unit) {
|
|
|
|
|
|
this.chartUnit = unit
|
|
|
|
|
|
this.$nextTick(() => {
|
2021-05-08 11:25:40 +08:00
|
|
|
|
this.queryChartDate()
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2021-04-13 20:33:12 +08:00
|
|
|
|
formatThreshold (value, unit) {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
const unitMethod = chartDataFormat.getUnit(unit)
|
|
|
|
|
|
if (unitMethod && value) {
|
|
|
|
|
|
return unitMethod.compute(value, null, 2)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return value
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
queryChartDate () {
|
|
|
|
|
|
const $temp = this
|
|
|
|
|
|
const start = this.searchTime[0] ? this.searchTime[0] : this.getTime(-1, 'h')
|
|
|
|
|
|
const end = this.searchTime[1] ? this.searchTime[1] : this.getTime(0, 'h')
|
|
|
|
|
|
this.searchTime = [start, end]
|
|
|
|
|
|
const timeDiff = (new Date(end).getTime() - new Date(start).getTime()) / 1000 / (24 * 60 * 60)
|
|
|
|
|
|
let step = '15s'
|
|
|
|
|
|
if (timeDiff < 1) {
|
|
|
|
|
|
step = '15s'
|
|
|
|
|
|
} else if (timeDiff < 7) {
|
|
|
|
|
|
step = '5m'
|
|
|
|
|
|
} else if (timeDiff < 30) {
|
|
|
|
|
|
step = '10m'
|
|
|
|
|
|
} else {
|
|
|
|
|
|
step = '30m'
|
|
|
|
|
|
}
|
|
|
|
|
|
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).replace(/\+/g, '%2B').replace(/ /g, '%20').replace(/\\/g, '') + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&step=' + step))
|
|
|
|
|
|
this.legend = []
|
|
|
|
|
|
this.chartDatas = []
|
|
|
|
|
|
axios.all(axiosArr).then(res => {
|
|
|
|
|
|
try {
|
|
|
|
|
|
res.forEach((response, promIndex) => {
|
|
|
|
|
|
if (response.status == 200) {
|
|
|
|
|
|
if (response.data.status == 'success') {
|
|
|
|
|
|
const queryData = response.data.data.result[0]
|
|
|
|
|
|
if (queryData) {
|
|
|
|
|
|
const chartData = {
|
|
|
|
|
|
type: 'line',
|
|
|
|
|
|
symbol: 'none', // 去掉点
|
|
|
|
|
|
smooth: 0.2, // 曲线变平滑
|
|
|
|
|
|
name: '',
|
|
|
|
|
|
lineStyle: {
|
|
|
|
|
|
width: 1,
|
|
|
|
|
|
opacity: 0.9
|
|
|
|
|
|
},
|
|
|
|
|
|
markLine: {
|
|
|
|
|
|
silent: true,
|
|
|
|
|
|
symbol: ['circle', 'circle'],
|
|
|
|
|
|
label: {
|
|
|
|
|
|
distance: this.computeDistance(chartDataFormat.getUnit(this.currentMsg.alertRule.unit ? this.currentMsg.alertRule.unit : 2).compute(this.currentMsg.alertRule.threshold)),
|
2021-04-13 20:33:12 +08:00
|
|
|
|
formatter (params) {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
return chartDataFormat.getUnit($temp.currentMsg.alertRule.unit ? $temp.currentMsg.alertRule.unit : 2).compute(params.value)
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
lineStyle: {
|
|
|
|
|
|
color: '#d64f40',
|
|
|
|
|
|
width: 2,
|
|
|
|
|
|
type: 'dotted'
|
|
|
|
|
|
},
|
|
|
|
|
|
data: [{
|
|
|
|
|
|
yAxis: Number(this.currentMsg.alertRule.threshold)
|
|
|
|
|
|
}]
|
|
|
|
|
|
},
|
|
|
|
|
|
markArea: {
|
|
|
|
|
|
itemStyle: {
|
|
|
|
|
|
color: '#d64f40',
|
|
|
|
|
|
opacity: 0.1
|
|
|
|
|
|
},
|
|
|
|
|
|
data: [this.returnMarkArea()]
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (this.currentMsg.alertRule.operator == '==' || this.currentMsg.alertRule.operator == '!=') {
|
|
|
|
|
|
delete chartData.markArea
|
|
|
|
|
|
}
|
|
|
|
|
|
let alias = chartData.name
|
|
|
|
|
|
chartData.name += '{'
|
|
|
|
|
|
alias += '{'
|
|
|
|
|
|
Object.keys(queryData.metric).forEach((item, index) => {
|
|
|
|
|
|
const label = item
|
|
|
|
|
|
const value = queryData.metric[label]
|
|
|
|
|
|
chartData.name += label + "='" + value + "',"
|
|
|
|
|
|
})
|
|
|
|
|
|
chartData.name = chartData.name.charAt(chartData.name.length - 1) == ',' ? chartData.name.substr(0, chartData.name.length - 1) : chartData.name
|
|
|
|
|
|
chartData.name += '}'
|
|
|
|
|
|
const legend = {
|
|
|
|
|
|
name: chartData.name,
|
|
|
|
|
|
alias: alias,
|
|
|
|
|
|
isGray: false
|
|
|
|
|
|
}
|
|
|
|
|
|
this.legend.push(legend)
|
|
|
|
|
|
chartData.data = queryData.values.map((dpsItem, dpsIndex) => {
|
|
|
|
|
|
return [dpsItem[0] * 1000, parseFloat(dpsItem[1]).toFixed(2)]
|
|
|
|
|
|
})
|
|
|
|
|
|
this.chartDatas.push(chartData)
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(response.data.error)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.$refs.messageChart.setRandomColors(this.chartDatas.length)
|
|
|
|
|
|
this.$refs.messageChart.setLegend(this.legend)
|
|
|
|
|
|
this.$refs.messageChart.setSeries(this.chartDatas)
|
|
|
|
|
|
this.$refs.messageChart.endLoading()
|
|
|
|
|
|
})
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
this.$message.error(err)
|
|
|
|
|
|
this.$refs.messageChart.endLoading()
|
2020-07-29 14:46:35 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2021-04-13 20:33:12 +08:00
|
|
|
|
computeDistance (str) {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
let width = 0
|
|
|
|
|
|
const html = document.createElement('span')
|
|
|
|
|
|
html.innerText = str
|
|
|
|
|
|
html.className = 'getTextWidth'
|
|
|
|
|
|
document.querySelector('body').appendChild(html)
|
|
|
|
|
|
width = document.querySelector('.getTextWidth').offsetWidth
|
|
|
|
|
|
document.querySelector('.getTextWidth').remove()
|
|
|
|
|
|
return Number('-' + (width + 5))
|
|
|
|
|
|
},
|
2021-04-13 20:33:12 +08:00
|
|
|
|
returnMarkArea () {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
if (this.currentMsg) {
|
|
|
|
|
|
if (this.currentMsg.alertRule.operator == '>' || this.currentMsg.alertRule.operator == '>=') {
|
|
|
|
|
|
return [{ yAxis: this.currentMsg.alertRule.threshold }, {}]
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return [{}, { yAxis: this.currentMsg.alertRule.threshold }]
|
2020-07-29 14:46:35 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
detail (obj) {
|
|
|
|
|
|
if (!obj.current) { return }
|
|
|
|
|
|
this.chartDatas = []
|
|
|
|
|
|
this.legend = []
|
|
|
|
|
|
this.graphShow = true
|
|
|
|
|
|
this.currentMsg = obj
|
|
|
|
|
|
this.chartUnit = obj.alertRule.unit ? obj.alertRule.unit : 5
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.queryChartDate()
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2021-05-10 13:49:27 +08:00
|
|
|
|
dialogClose () {
|
|
|
|
|
|
this.graphShow = false
|
2021-05-08 15:04:17 +08:00
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
getAlertList () {
|
|
|
|
|
|
if (!this.scrollbarWrap) {
|
2020-07-29 14:46:35 +08:00
|
|
|
|
this.$nextTick(() => {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.scrollbarWrap = this.$refs.alertListTable.bodyWrapper
|
|
|
|
|
|
this.toTopBtnHandler(this.scrollbarWrap)
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
promQueryParamConvert (obj) {
|
|
|
|
|
|
let r = '(' + obj.alertRule.expr + ')'
|
|
|
|
|
|
let intoLabels = false
|
|
|
|
|
|
if (Object.keys(obj.labels).length > 0) {
|
|
|
|
|
|
r += (function () {
|
|
|
|
|
|
let group = ' and ' + '(group({'
|
|
|
|
|
|
let by = ' by ('
|
2020-11-17 18:07:02 +08:00
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
for (const k in obj.labels) {
|
|
|
|
|
|
if (k != 'alertname' && k != 'severity') {
|
|
|
|
|
|
intoLabels = true
|
|
|
|
|
|
group += k
|
|
|
|
|
|
group += '='
|
|
|
|
|
|
group += ("'" + obj.labels[k] + "',")
|
|
|
|
|
|
by += k
|
|
|
|
|
|
by += ','
|
2020-11-17 18:07:02 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (intoLabels) {
|
|
|
|
|
|
group = group.substring(0, group.length - 1)
|
|
|
|
|
|
by = by.substring(0, by.length - 1)
|
|
|
|
|
|
group += '})'
|
|
|
|
|
|
by += ')'
|
|
|
|
|
|
return group + by + ')'
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return ''
|
|
|
|
|
|
}
|
|
|
|
|
|
}())
|
|
|
|
|
|
}
|
|
|
|
|
|
return r
|
|
|
|
|
|
/* let result="(" + obj.alertRule.expr + ")";
|
2020-07-29 14:46:35 +08:00
|
|
|
|
if(obj.labels){
|
|
|
|
|
|
if(obj.labels.alertname){
|
|
|
|
|
|
delete obj.labels.alertname;
|
|
|
|
|
|
}
|
|
|
|
|
|
if(obj.labels.severity){
|
|
|
|
|
|
delete obj.labels.severity;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if(Object.keys(obj.labels).length>0){
|
|
|
|
|
|
result+=" and ("+function(){
|
|
|
|
|
|
let q = "{";
|
|
|
|
|
|
for (let k in obj.labels) {
|
|
|
|
|
|
q += k;
|
|
|
|
|
|
q += "=";
|
|
|
|
|
|
q += ("'" + obj.labels[k] + "',");
|
|
|
|
|
|
};
|
|
|
|
|
|
if (q.length > 1) {
|
|
|
|
|
|
q = q.substring(0, q.length-1);
|
|
|
|
|
|
}
|
|
|
|
|
|
q += "}";
|
|
|
|
|
|
return q;
|
|
|
|
|
|
}() + ")";
|
|
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
return result; */
|
|
|
|
|
|
},
|
|
|
|
|
|
// asset弹框控制
|
|
|
|
|
|
tabControl (data) {
|
|
|
|
|
|
if (data === 'close') {
|
|
|
|
|
|
this.viewAssetState = false
|
|
|
|
|
|
this.$refs.assetEditUnit.tabView = false
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
toDeleteMessage (obj) {
|
2021-04-13 20:33:12 +08:00
|
|
|
|
this.$emit('toDelete', obj)
|
2021-03-19 18:52:19 +08:00
|
|
|
|
},
|
|
|
|
|
|
selectChange (s) {
|
|
|
|
|
|
const ids = []
|
|
|
|
|
|
this.deleteBox.ids = ''
|
|
|
|
|
|
s.forEach(item => {
|
|
|
|
|
|
ids.push(item.id)
|
|
|
|
|
|
})
|
|
|
|
|
|
this.deleteBox.ids = ids.join(',')
|
|
|
|
|
|
this.$emit('select-change', s)
|
|
|
|
|
|
},
|
|
|
|
|
|
closeDialog () {
|
|
|
|
|
|
this.importBox.show = false
|
|
|
|
|
|
this.deleteBox.show = false
|
|
|
|
|
|
},
|
2021-04-13 20:33:12 +08:00
|
|
|
|
getTimeString () {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
const split = '-'
|
|
|
|
|
|
const date = new Date()
|
|
|
|
|
|
const year = date.getFullYear()
|
|
|
|
|
|
const month = this.formatNum(date.getMonth() + 1)
|
|
|
|
|
|
const day = this.formatNum(date.getDate())
|
|
|
|
|
|
const hours = this.formatNum(date.getHours())
|
|
|
|
|
|
const minutes = this.formatNum(date.getMinutes())
|
|
|
|
|
|
const seconds = this.formatNum(date.getSeconds())
|
|
|
|
|
|
return year + split + month + split + day + ' ' + hours + split + minutes + split + seconds
|
|
|
|
|
|
},
|
2021-04-13 20:33:12 +08:00
|
|
|
|
formatNum (num) {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
return num > 9 ? num : '0' + num
|
|
|
|
|
|
},
|
|
|
|
|
|
labelsClassName (row) {
|
|
|
|
|
|
if (row.column.label == this.$t('alert.list.labels')) {
|
|
|
|
|
|
return 'alert-message-list-labels'
|
|
|
|
|
|
} else if (row.column.label == this.$t('alert.list.state')) {
|
|
|
|
|
|
if (row.row.state == 1) {
|
|
|
|
|
|
return 'danger'
|
|
|
|
|
|
} else if (row.row.state == 2) {
|
|
|
|
|
|
return 'success'
|
2020-09-28 16:27:03 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
return ''
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2021-04-13 20:33:12 +08:00
|
|
|
|
closeViews () {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.$refs.alertConfigBox.show(false, false)
|
|
|
|
|
|
this.$refs.projectBox.show(false, false)
|
|
|
|
|
|
this.$refs.moduleBox.show(false, false)
|
|
|
|
|
|
this.viewAssetState = false
|
|
|
|
|
|
},
|
|
|
|
|
|
// label tooltip是否显示
|
|
|
|
|
|
labelToolTipDis (labelType) {
|
|
|
|
|
|
switch (labelType) {
|
|
|
|
|
|
case 'asset':
|
|
|
|
|
|
case 'module':
|
|
|
|
|
|
case 'endpoint':
|
|
|
|
|
|
case 'project':
|
|
|
|
|
|
return false
|
|
|
|
|
|
default: return true
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2021-04-13 20:33:12 +08:00
|
|
|
|
// alertName鼠标划入
|
|
|
|
|
|
alertMessageHover (item, loading, e) {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
if (e) {
|
|
|
|
|
|
const dom = e.currentTarget
|
|
|
|
|
|
const position = dom.getBoundingClientRect()
|
|
|
|
|
|
this.$set(item, 'position', position)
|
|
|
|
|
|
}
|
|
|
|
|
|
this.$set(item, 'loading', loading)
|
|
|
|
|
|
// item.loading = true;
|
|
|
|
|
|
// this.$set(this.tableData,index,item);// 调用父组件
|
|
|
|
|
|
},
|
|
|
|
|
|
// label 鼠标划入
|
|
|
|
|
|
labelHover (item, type, loading, e) {
|
|
|
|
|
|
if (this.labelToolTipDis(type)) {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
if (e) {
|
|
|
|
|
|
const dom = e.currentTarget
|
|
|
|
|
|
const position = dom.getBoundingClientRect()
|
|
|
|
|
|
this.$set(item[type], 'position', position)
|
|
|
|
|
|
}
|
|
|
|
|
|
this.$set(item[type], 'loading', loading)
|
|
|
|
|
|
// this.$set(this.tableData,index,item);// 调用父组件
|
|
|
|
|
|
},
|
|
|
|
|
|
// Severity Label
|
|
|
|
|
|
returnSeverityLabel (key) {
|
|
|
|
|
|
return this.$CONSTANTS.alertMessage.severityData.find(s => { return s.value == key }).label
|
|
|
|
|
|
}
|
|
|
|
|
|
/* plpsscrolly(el,self){
|
2020-11-20 15:02:36 +08:00
|
|
|
|
if (el._ps_.scrollbarYTop > 50) {
|
|
|
|
|
|
self.tools.showTopBtn = true;
|
2020-11-21 15:33:40 +08:00
|
|
|
|
self.tools.tableHover = true;
|
2020-11-20 15:02:36 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
self.tools.showTopBtn = false;
|
2020-11-21 15:33:40 +08:00
|
|
|
|
self.tools.tableHover = false;
|
2020-11-20 15:02:36 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}, */
|
2020-07-29 14:46:35 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
2020-07-29 14:46:35 +08:00
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
2021-05-08 09:29:25 +08:00
|
|
|
|
<style scoped lang=scss>
|
2021-05-08 11:25:40 +08:00
|
|
|
|
.pointer{
|
|
|
|
|
|
background: #FA901c;
|
|
|
|
|
|
border-radius: 2px;
|
|
|
|
|
|
border: none;
|
|
|
|
|
|
width: 40px;
|
|
|
|
|
|
height: 22px;
|
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
|
text-align:center;
|
|
|
|
|
|
color: #fff;
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
margin-right: 20px;
|
|
|
|
|
|
}
|
2020-07-29 14:46:35 +08:00
|
|
|
|
.alertLabelInfo{
|
|
|
|
|
|
border: 1px solid #ebeef5;
|
|
|
|
|
|
border-bottom: none;
|
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
|
line-height: 26px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.alertLabelBox{
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content:space-between;
|
|
|
|
|
|
border-bottom: 1px solid #ebeef5;
|
|
|
|
|
|
}
|
|
|
|
|
|
.alertLabelTitle{
|
|
|
|
|
|
text-align: left;
|
|
|
|
|
|
width: 90px;
|
|
|
|
|
|
border-right: 1px solid #ebeef5;
|
|
|
|
|
|
color: #666;
|
|
|
|
|
|
padding: 0 3px 0 13px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.alertLabelValue{
|
|
|
|
|
|
text-align: left;
|
|
|
|
|
|
width: 150px;
|
|
|
|
|
|
color: #1a1a1a;
|
|
|
|
|
|
padding: 0 3px 0 13px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.danger{
|
|
|
|
|
|
background-color: #d64f40;
|
|
|
|
|
|
color: white;
|
|
|
|
|
|
padding: 2px 5px;
|
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.success{
|
|
|
|
|
|
background-color: #50d050;
|
|
|
|
|
|
color: white;
|
|
|
|
|
|
padding: 2px 5px;
|
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
|
}
|
|
|
|
|
|
/deep/.active-icon{
|
|
|
|
|
|
margin-top: 0;
|
|
|
|
|
|
}
|
2020-08-03 16:58:27 +08:00
|
|
|
|
.contentTable{
|
2020-07-29 14:46:35 +08:00
|
|
|
|
height: calc(100% - 105px)
|
|
|
|
|
|
}
|
2020-08-03 16:58:27 +08:00
|
|
|
|
.contentProject{
|
|
|
|
|
|
height: calc(100% - 60px);
|
|
|
|
|
|
margin-bottom: 15px;
|
|
|
|
|
|
}
|
2020-07-29 14:46:35 +08:00
|
|
|
|
.tabelH100{
|
|
|
|
|
|
height: 100% !important;
|
|
|
|
|
|
}
|
2020-07-30 14:13:11 +08:00
|
|
|
|
/deep/.too-long-split{
|
|
|
|
|
|
vertical-align: bottom;
|
|
|
|
|
|
}
|
|
|
|
|
|
/deep/.el-tooltip{
|
|
|
|
|
|
display: inline-block;
|
|
|
|
|
|
}
|
2020-07-31 10:55:25 +08:00
|
|
|
|
/deep/.alert-clean-pop.el-popover{
|
2020-08-06 10:10:49 +08:00
|
|
|
|
top: -30px !important;
|
2020-07-31 10:55:25 +08:00
|
|
|
|
}
|
2020-08-03 10:18:48 +08:00
|
|
|
|
.pointer{
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
}
|
2020-10-14 14:24:07 +08:00
|
|
|
|
.severity .P1{
|
2020-10-13 11:18:04 +08:00
|
|
|
|
background: #F5846A;
|
2020-10-12 11:02:30 +08:00
|
|
|
|
border-radius: 2px;
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
color: #FFFFFF;
|
|
|
|
|
|
padding: 2px 6px;
|
|
|
|
|
|
}
|
2020-10-14 14:24:07 +08:00
|
|
|
|
.severity .P2{
|
2020-10-13 11:18:04 +08:00
|
|
|
|
background: #F7A54A;
|
2020-10-12 11:02:30 +08:00
|
|
|
|
border-radius: 2px;
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
color: #FFFFFF;
|
|
|
|
|
|
padding: 2px 6px;
|
|
|
|
|
|
}
|
2020-10-14 14:24:07 +08:00
|
|
|
|
.severity .P3{
|
2020-10-13 11:18:04 +08:00
|
|
|
|
background: #F1C13D;
|
2020-10-12 11:02:30 +08:00
|
|
|
|
border-radius: 2px;
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
color: #FFFFFF;
|
|
|
|
|
|
padding: 2px 6px;
|
|
|
|
|
|
}
|
2020-10-14 14:24:07 +08:00
|
|
|
|
.red,.green{
|
|
|
|
|
|
color: white;
|
|
|
|
|
|
padding: 2px 5px;
|
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
|
}
|
2020-10-30 15:35:39 +08:00
|
|
|
|
/deep/ .nz-message .el-textarea textarea{
|
|
|
|
|
|
height: 108px !important;
|
|
|
|
|
|
}
|
2020-07-29 14:46:35 +08:00
|
|
|
|
</style>
|