2020-03-29 16:33:49 +08:00
|
|
|
|
<style scope>
|
2021-11-01 23:05:28 +08:00
|
|
|
|
.plTableBox.nz-table /deep/ .el-table{
|
|
|
|
|
|
display: block !important;
|
|
|
|
|
|
}
|
2021-03-31 15:26:01 +08:00
|
|
|
|
.project-calendar{
|
|
|
|
|
|
margin-top: 2px;
|
|
|
|
|
|
}
|
2021-11-01 23:05:28 +08:00
|
|
|
|
.control-icon-unchecked {
|
|
|
|
|
|
color: #999999;
|
|
|
|
|
|
cursor: not-allowed;
|
|
|
|
|
|
}
|
2020-03-29 16:33:49 +08:00
|
|
|
|
</style>
|
2020-04-24 17:41:33 +08:00
|
|
|
|
<style>
|
|
|
|
|
|
.endpoint-dialog .el-dialog__body{
|
2020-05-18 14:12:56 +08:00
|
|
|
|
height: calc(100% - 48px) !important;
|
|
|
|
|
|
padding-bottom: 0 !important;
|
2020-04-24 17:41:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
</style>
|
2020-03-29 16:33:49 +08:00
|
|
|
|
<template>
|
2021-02-24 17:46:30 +08:00
|
|
|
|
<span style="z-index: 1999;position: relative">
|
2020-03-29 16:33:49 +08:00
|
|
|
|
<div class="sub-top-tools">
|
|
|
|
|
|
<div class="sub-list-tabs">
|
|
|
|
|
|
<div class="sub-list-tab-title">{{$t("project.endpoint.endpointId")}}: {{currentEndpoint ? currentEndpoint.id : ''}}</div><div
|
2021-02-04 11:21:00 +08:00
|
|
|
|
class="sub-list-tab" @click="changeTab('panel')" id="endpoint-query-changepanel">{{$t("overall.detail")}}</div>
|
2022-06-17 10:39:36 +08:00
|
|
|
|
<div class="sub-list-tab" @click="changeTab('alertMessage')" id="endpoint-query-alertMessage">{{$t("alert.alertMessage")}}</div>
|
2020-09-25 15:33:02 +08:00
|
|
|
|
<div class="sub-list-tab sub-list-tab-active">{{$t("overall.query")}}</div>
|
2020-03-29 16:33:49 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div class="top-tool-right">
|
|
|
|
|
|
<div class="top-tool-search margin-r-20">
|
|
|
|
|
|
<el-input ref="elementQuery" @clear="clearInput" id="elementQuery" @focus="focusInput" @blur="blurInput" v-model="queryExpression" class="query-input-inactive" size="mini" clearable :placeholder="$t('project.endpoint.promExpr')" >
|
2020-09-10 17:00:32 +08:00
|
|
|
|
<i slot="suffix" class="el-input__icon nz-icon nz-icon-search" style="float:right" @click="focusInput"></i>
|
2020-03-29 16:33:49 +08:00
|
|
|
|
</el-input>
|
|
|
|
|
|
</div>
|
2020-04-10 21:40:36 +08:00
|
|
|
|
<div class="margin-r-20 nz-btn-group nz-btn-group-size-small nz-btn-group-light">
|
2022-07-01 09:39:20 +08:00
|
|
|
|
<button @click="changeTime(-10)" class="nz-btn nz-btn-size-normal nz-btn-style-light change-time-height nz-input-group-prepend" id="endpoint-query-changetime" :title="$t('overall.decreaseTime')"><i class="el-icon-d-arrow-left"></i></button>
|
2022-01-04 14:57:59 +08:00
|
|
|
|
<my-date-picker
|
|
|
|
|
|
v-model="formatTime"
|
|
|
|
|
|
type="datetime"
|
|
|
|
|
|
size="mini"
|
|
|
|
|
|
class="project-calendar nz-input-group-middle"
|
|
|
|
|
|
clearable
|
|
|
|
|
|
:time-arrow-control="true"
|
|
|
|
|
|
placeholder="Moment"
|
|
|
|
|
|
:value-format="timeFormatStrToDatePickFormat(timeFormatMain)"
|
|
|
|
|
|
:format="timeFormatStrToDatePickFormat(timeFormatMain)"
|
|
|
|
|
|
@change="pickTime"
|
2020-03-29 16:33:49 +08:00
|
|
|
|
>
|
2022-01-04 14:57:59 +08:00
|
|
|
|
</my-date-picker>
|
2022-07-01 09:39:20 +08:00
|
|
|
|
<button @click="changeTime(10)" class="nz-btn nz-btn-size-normal nz-btn-style-light change-time-height nz-input-group-append" :title="$t('overall.increaseTime')"><i class="el-icon-d-arrow-right"></i></button>
|
2020-03-29 16:33:49 +08:00
|
|
|
|
</div>
|
2020-04-21 22:39:07 +08:00
|
|
|
|
<div class="nz-btn-group nz-btn-group-size-normal nz-btn-group-light" style="height: 24px;">
|
2022-07-01 09:39:20 +08:00
|
|
|
|
<button class="nz-btn nz-btn-size-normal nz-btn-style-light" @click="viewGraph" :title="$t('overall.showLineChart')">
|
2020-04-21 22:39:07 +08:00
|
|
|
|
<i class="nz-icon nz-icon-chart" :class="{'control-icon-unchecked':selectedEndpoints.length<1,'control-icon-checked':selectedEndpoints.length>0}"></i>
|
|
|
|
|
|
</button><button @mouseenter="dropdownHandler(true)" @mouseleave="dropdownHandler(false)" class="nz-btn nz-btn-size-normal nz-btn-style-light export-dropdown-btn" id="browser-go">
|
2020-09-10 17:00:32 +08:00
|
|
|
|
<i class="nz-icon nz-icon-arrow-down"></i>
|
2020-04-21 22:39:07 +08:00
|
|
|
|
<transition name="el-zoom-in-top">
|
|
|
|
|
|
<div v-if="dropdownShow" class="endpoint-query-dropdown el-popover">
|
|
|
|
|
|
<span style="padding-top: 2px">{{$t('project.endpoint.hideSameLabels')}}</span>
|
2021-11-30 16:08:02 +08:00
|
|
|
|
<el-switch v-model="hideSameLabels" size="small"></el-switch>
|
2020-04-21 22:39:07 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</transition>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
2020-03-29 16:33:49 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2022-07-01 09:39:20 +08:00
|
|
|
|
<div class="table-header-inner" @click="clearSelectedMetrics"><span><i style="font-size: 12px;margin-left: 2px;" class="nz-icon nz-icon-close " :class="{'control-icon-unchecked':selectedEndpoints.length<1,'control-icon-checked':selectedEndpoints.length>0}" :title="$t('overall.close')"></i></span></div>
|
2022-06-21 18:14:21 +08:00
|
|
|
|
<pl-table :row-height="28" use-virtual :datas="tableData" border :empty-text="$t('overall.noData')" :header-cell-class-name="cellClass" :style="{height: $tableHeight.noPagination}"
|
2022-03-25 15:40:05 +08:00
|
|
|
|
:pagination-show="false" class="nz-table endpoint-query-table" ref="endpointQueryTable" style="width: 100%;" v-my-loading="loading"
|
2021-03-19 18:52:19 +08:00
|
|
|
|
v-if="tableShow && plTableSHow" id="endpoint-list-table" :tooltip-effect="'light'" @selection-change="selectChange">
|
2020-04-20 12:19:11 +08:00
|
|
|
|
<pl-table-column
|
|
|
|
|
|
type="selection"
|
|
|
|
|
|
width="39"
|
|
|
|
|
|
align="center"
|
2020-11-24 14:32:51 +08:00
|
|
|
|
column-key="sel"
|
2020-04-20 12:19:11 +08:00
|
|
|
|
:selectable="selectable">
|
|
|
|
|
|
</pl-table-column>
|
|
|
|
|
|
<pl-table-column
|
|
|
|
|
|
prop="element"
|
2020-07-17 19:13:44 +08:00
|
|
|
|
:resizable="true"
|
2020-11-24 14:32:51 +08:00
|
|
|
|
:min-width="1000"
|
|
|
|
|
|
column-key="element"
|
2020-11-26 09:43:51 +08:00
|
|
|
|
:show-overflow-tooltip="true"
|
2022-06-16 15:58:17 +08:00
|
|
|
|
:label="$t('dashboard.panel.chartForm.element')">
|
2020-04-20 12:19:11 +08:00
|
|
|
|
<template v-slot="scope">
|
2021-10-27 14:32:26 +08:00
|
|
|
|
<el-popover trigger="hover" placement="right" v-if="typeof scope.row.metricTip != 'undefined' && scope.row.metricTip != null">
|
2020-04-20 12:19:11 +08:00
|
|
|
|
<div>
|
|
|
|
|
|
<ul>
|
|
|
|
|
|
<li><span class="metirc-tip-list">metric : </span><span>{{scope.row.metricTip.metric?scope.row.metricTip.metric:'--'}}</span></li>
|
|
|
|
|
|
<li><span class="metirc-tip-list">type : </span><span>{{scope.row.metricTip.type?scope.row.metricTip.type:'unknown'}}</span></li>
|
|
|
|
|
|
<li><span class="metirc-tip-list">help : </span><span>{{scope.row.metricTip.help?scope.row.metricTip.help:'--'}}</span></li>
|
|
|
|
|
|
<li><span class="metirc-tip-list">unit : </span><span>{{scope.row.metricTip.unit?scope.row.metricTip.unit:'--'}}</span></li>
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<span slot="reference"><i class="nz-icon nz-icon-info-normal metric-tip-icon"></i></span>
|
|
|
|
|
|
</el-popover>
|
2020-11-24 14:32:51 +08:00
|
|
|
|
<span style="word-break: break-all;" v-html="hideSameLabels?scope.row.colorSimpleElement: scope.row.colorElement"></span>
|
2020-04-20 12:19:11 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</pl-table-column>
|
|
|
|
|
|
<pl-table-column
|
|
|
|
|
|
:resizable="false"
|
|
|
|
|
|
prop="value"
|
2020-11-24 14:32:51 +08:00
|
|
|
|
column-key="value"
|
2022-06-16 15:58:17 +08:00
|
|
|
|
:label="$t('overall.value')"
|
2020-07-17 19:13:44 +08:00
|
|
|
|
min-width="180">
|
2020-04-20 12:19:11 +08:00
|
|
|
|
</pl-table-column>
|
|
|
|
|
|
</pl-table>
|
2022-07-01 09:39:20 +08:00
|
|
|
|
<button :class="{'to-top-is-hover': tools.tableHover}" @click="toTop(scrollbarWrap)" class="to-top" v-show="tools.showTopBtn" id="endpoint-list-totop" :title="$t('overall.backToTop')"><i class="nz-icon nz-icon-top"></i></button>
|
2020-03-29 16:33:49 +08:00
|
|
|
|
|
2023-03-15 15:39:06 +08:00
|
|
|
|
<el-dialog
|
|
|
|
|
|
class="line-chart-block-modal nz-dialog endpoint-dialog"
|
|
|
|
|
|
:title="$t('project.endpoint.dialogTitle')"
|
|
|
|
|
|
:visible.sync="graphShow"
|
|
|
|
|
|
width="90%"
|
|
|
|
|
|
:modal-append-to-body="false"
|
|
|
|
|
|
@close="dialogClose">
|
2020-03-29 16:33:49 +08:00
|
|
|
|
<div slot="title">
|
|
|
|
|
|
{{$t("project.endpoint.dialogTitle")}}
|
2020-04-24 17:41:33 +08:00
|
|
|
|
<div class="float-right panel-calendar dialog-tool" style="display: flex">
|
2021-03-31 15:26:01 +08:00
|
|
|
|
<pick-time :refresh-data-func="queryChartDate" :use-refresh="false" v-model="searchTime" style="height: 28px;" @unitChange="chartUnitChange" id="endpoint-query-full-chart" :show-multiple="true" ref="pickTime"></pick-time>
|
2021-11-04 09:29:01 +08:00
|
|
|
|
<button id="endpoint-query-full-chart-save" v-has="'project_endpoint_query_chart_toAdd'" class="nz-btn nz-btn-size-large nz-btn-style-normal" @click="saveChart">{{$t('dashboard.metric.saveChart')}}</button>
|
2020-03-29 16:33:49 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2021-03-31 15:26:01 +08:00
|
|
|
|
<chart ref="endpointChart" :unit="chartUnit" :minusTime="minusTime"></chart>
|
2020-03-29 16:33:49 +08:00
|
|
|
|
</el-dialog>
|
2020-07-24 19:22:52 +08:00
|
|
|
|
<transition name="right-box">
|
2021-02-24 18:21:55 +08:00
|
|
|
|
<chart-box :chart="chart" :panel-data="panelData" :show-panel="{id: -1, name: '', type: 'endpointQuery'}" @close="rightBox.show = false" @on-create-success="createSuccess" @reload="getPanelData" @reloadOnlyPanel="getPanelData" box-class="save-chart-box" from="project_endpoint_query" ref="addChartModal" v-if="rightBox.show" style="z-index: 2900" :fromEndpoint="true"></chart-box>
|
2020-07-24 19:22:52 +08:00
|
|
|
|
</transition>
|
2020-03-29 16:33:49 +08:00
|
|
|
|
</span>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
2021-03-19 18:52:19 +08:00
|
|
|
|
import chartBox from '../../../page/dashboard/chartBox'
|
|
|
|
|
|
import axios from 'axios'
|
|
|
|
|
|
import bus from '../../../../libs/bus'
|
|
|
|
|
|
import chart from '../../../page/dashboard/overview/chart'
|
|
|
|
|
|
|
|
|
|
|
|
let timeout
|
|
|
|
|
|
let internal
|
|
|
|
|
|
export default {
|
|
|
|
|
|
name: 'endpointQueryTab',
|
|
|
|
|
|
components: {
|
|
|
|
|
|
'chart-box': chartBox,
|
|
|
|
|
|
chart: chart
|
|
|
|
|
|
},
|
|
|
|
|
|
props: {
|
|
|
|
|
|
obj: Object, // 关联的实体对象
|
|
|
|
|
|
from: String
|
|
|
|
|
|
},
|
|
|
|
|
|
data () {
|
|
|
|
|
|
return {
|
|
|
|
|
|
chart: {},
|
|
|
|
|
|
tableShow: true,
|
|
|
|
|
|
dropdownShow: false,
|
|
|
|
|
|
loading: false,
|
|
|
|
|
|
tools: {
|
|
|
|
|
|
showTopBtn: false, // 主列表top按钮
|
|
|
|
|
|
tableHover: false
|
|
|
|
|
|
},
|
|
|
|
|
|
currentEndpoint: {},
|
|
|
|
|
|
queryData: [], // endpoint 查询列表数据
|
|
|
|
|
|
tableData: [],
|
|
|
|
|
|
tableDataCopy: '',
|
|
|
|
|
|
queryExpression: '',
|
|
|
|
|
|
elementMetricDatas: [], // element 列提示信息列表
|
|
|
|
|
|
formatTime: '', // 查询endpoint的时间,
|
|
|
|
|
|
selectedEndpoints: [], // 选中的metric{label='value'}
|
|
|
|
|
|
chartDatas: [], // 从query_range查询到的数据
|
|
|
|
|
|
legend: [], // echart legend
|
|
|
|
|
|
graphShow: false,
|
|
|
|
|
|
searchTime: [new Date().setHours(new Date().getHours() - 1), new Date()],
|
|
|
|
|
|
panelData: [], // chart-box的panel下拉框数据,
|
|
|
|
|
|
hideSameLabels: true,
|
|
|
|
|
|
sameLabels: ['instance', 'module', 'project', 'asset', 'endpoint', 'datacenter'],
|
|
|
|
|
|
chartUnit: 5,
|
|
|
|
|
|
rightBox: { show: false },
|
|
|
|
|
|
plTableSHow: true,
|
|
|
|
|
|
scrollTop: 0,
|
2021-03-31 15:26:01 +08:00
|
|
|
|
scrollbarWrap: null,
|
2022-03-07 09:37:27 +08:00
|
|
|
|
minusTime: 0
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
changeTab (tab) {
|
|
|
|
|
|
this.$emit('changeTab', tab)
|
2020-03-29 16:33:49 +08:00
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
saveChart () { // 新增chart
|
|
|
|
|
|
const chart = {
|
|
|
|
|
|
title: '',
|
|
|
|
|
|
type: 'line',
|
|
|
|
|
|
span: 12,
|
|
|
|
|
|
height: '400',
|
|
|
|
|
|
unit: this.chartUnit,
|
|
|
|
|
|
param: {
|
|
|
|
|
|
url: '',
|
|
|
|
|
|
threshold: ''
|
2020-12-15 21:13:07 +08:00
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
elements: [],
|
|
|
|
|
|
panel: '',
|
|
|
|
|
|
sync: 0
|
|
|
|
|
|
}
|
|
|
|
|
|
for (let i = 0; i < this.selectedEndpoints.length; i++) {
|
|
|
|
|
|
if (this.selectedEndpoints[i] && this.selectedEndpoints[i].element !== '') {
|
|
|
|
|
|
chart.elements.push({ chartId: '', expression: this.selectedEndpoints[i].element, type: 'expert' })
|
|
|
|
|
|
}
|
2020-03-29 16:33:49 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.chart = chart
|
|
|
|
|
|
this.rightBox.show = true
|
2020-03-29 16:33:49 +08:00
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
dropdownHandler (show) {
|
|
|
|
|
|
if (show) {
|
|
|
|
|
|
clearTimeout(timeout)
|
|
|
|
|
|
this.dropdownShow = true
|
|
|
|
|
|
} else {
|
|
|
|
|
|
timeout = setTimeout(() => {
|
|
|
|
|
|
this.dropdownShow = false
|
|
|
|
|
|
}, 700)
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
createSuccess (type, response, param, panel) {
|
2023-03-15 15:39:06 +08:00
|
|
|
|
this.$confirm(this.$t('dashboard.metric.goDashboardTip'), this.$t('tip.saveSuccess'), {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
confirmButtonText: this.$t('tip.yes'),
|
|
|
|
|
|
cancelButtonText: this.$t('tip.no'),
|
|
|
|
|
|
type: 'success'
|
|
|
|
|
|
}).then(() => {
|
|
|
|
|
|
bus.$emit('menu-change', 'panel')
|
|
|
|
|
|
this.$store.state.showPanel.id = panel.id
|
|
|
|
|
|
this.$store.state.showPanel.name = panel.name
|
|
|
|
|
|
this.$router.push({
|
2023-03-15 15:39:06 +08:00
|
|
|
|
path: '/dashboard',
|
2021-03-19 18:52:19 +08:00
|
|
|
|
query: {
|
|
|
|
|
|
t: +new Date()
|
2020-07-06 19:49:04 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
tableReload () {
|
|
|
|
|
|
const table = this.$refs.endpointQueryTable
|
|
|
|
|
|
internal = setInterval(() => {
|
|
|
|
|
|
if (!window.resizing) {
|
|
|
|
|
|
table.setHeight()
|
|
|
|
|
|
clearInterval(internal)
|
2020-07-31 20:57:04 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}, 200)
|
|
|
|
|
|
},
|
|
|
|
|
|
queryEndpoint () {
|
|
|
|
|
|
this.loading = true
|
|
|
|
|
|
this.queryElementTips()
|
|
|
|
|
|
this.queryData = []
|
|
|
|
|
|
this.tableData = []
|
|
|
|
|
|
this.tableDataCopy = ''
|
|
|
|
|
|
setTimeout(() => {
|
2021-11-25 15:20:00 +08:00
|
|
|
|
this.$get('/prom/api/v1/query?query=' + encodeURIComponent("{endpoint_id='" + this.currentEndpoint.id + "'}") + '&time=' + this.formatTime).then(response => {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.loading = false
|
|
|
|
|
|
if (response.status === 'success') {
|
|
|
|
|
|
const results = response.data.result
|
|
|
|
|
|
this.queryData = JSON.parse(JSON.stringify(results))
|
|
|
|
|
|
this.tableData = this.handlerTableData(results)
|
|
|
|
|
|
this.tableDataCopy = JSON.stringify(this.tableData)
|
|
|
|
|
|
this.$nextTick(this.$refs.endpointQueryTable.doLayout())
|
|
|
|
|
|
if (!this.scrollbarWrap) {
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.scrollbarWrap = this.$refs.endpointQueryTable.$refs.singleTable.bodyWrapper
|
|
|
|
|
|
this.toTopBtnHandler(this.scrollbarWrap)
|
|
|
|
|
|
})
|
2020-03-29 16:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
})
|
|
|
|
|
|
}, 450)
|
|
|
|
|
|
},
|
|
|
|
|
|
clearSelectedMetrics () {
|
|
|
|
|
|
this.$refs.endpointQueryTable.clearSelection()
|
|
|
|
|
|
},
|
2021-04-13 20:33:12 +08:00
|
|
|
|
changeTime (size, unit) {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.formatTime = this.getTime(size, unit)
|
|
|
|
|
|
this.showEndpoint()
|
|
|
|
|
|
},
|
2021-04-13 20:33:12 +08:00
|
|
|
|
pickTime () {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.showEndpoint()
|
|
|
|
|
|
},
|
2021-04-13 20:33:12 +08:00
|
|
|
|
getTime (size, unit) { // 计算时间
|
2021-03-19 18:52:19 +08:00
|
|
|
|
const now = !this.formatTime ? new Date(bus.computeTimezone(new Date().getTime())) : new Date(this.formatTime)
|
|
|
|
|
|
if (unit) {
|
|
|
|
|
|
switch (unit) {
|
|
|
|
|
|
case 'y':
|
|
|
|
|
|
now.setFullYear(now.getFullYear() + size)
|
|
|
|
|
|
break
|
|
|
|
|
|
case 'M':
|
|
|
|
|
|
now.setMonth(now.getMonth() + size)
|
|
|
|
|
|
break
|
|
|
|
|
|
case 'd':
|
|
|
|
|
|
now.setDate(now.getDate() + size)
|
|
|
|
|
|
break
|
|
|
|
|
|
case 'h':
|
|
|
|
|
|
now.setHours(now.getHours() + size)
|
|
|
|
|
|
break
|
|
|
|
|
|
case 'm':
|
|
|
|
|
|
now.setMinutes(now.getMinutes() + size)
|
|
|
|
|
|
break
|
|
|
|
|
|
case 's':
|
|
|
|
|
|
now.setSeconds(now.getSeconds() + size)
|
|
|
|
|
|
break
|
|
|
|
|
|
default:
|
|
|
|
|
|
console.error('unit error')
|
2020-03-29 16:33:49 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
now.setSeconds(now.getSeconds() + size)
|
|
|
|
|
|
}
|
|
|
|
|
|
const year = now.getFullYear()
|
|
|
|
|
|
let month = now.getMonth() + 1
|
|
|
|
|
|
month = month < 10 ? '0' + month : month
|
|
|
|
|
|
let day = now.getDate()
|
|
|
|
|
|
day = day < 10 ? '0' + day : day
|
|
|
|
|
|
let hour = now.getHours()
|
|
|
|
|
|
hour = hour < 10 ? '0' + hour : hour
|
|
|
|
|
|
let minute = now.getMinutes()
|
|
|
|
|
|
minute = minute < 10 ? '0' + minute : minute
|
|
|
|
|
|
let second = now.getSeconds()
|
|
|
|
|
|
second = second < 10 ? '0' + second : second
|
|
|
|
|
|
return year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second
|
|
|
|
|
|
},
|
|
|
|
|
|
handlerTableData (results) {
|
|
|
|
|
|
const tableData = []
|
|
|
|
|
|
for (const result of results) {
|
|
|
|
|
|
const metricName = result.metric.__name__
|
|
|
|
|
|
let temp = metricName
|
|
|
|
|
|
let simpleTemp = metricName// 显示简略信息:隐藏same labels后的结果
|
|
|
|
|
|
const metricColor = ''
|
|
|
|
|
|
const bracketsColor = '#eb7b18'// #eb7b18
|
|
|
|
|
|
const labelColor = '#65bbd1'// #66d9ef
|
|
|
|
|
|
const valueColor = '#61c261'// #74e680
|
|
|
|
|
|
let colorTemp = `<span style="${metricColor}">${metricName}</span>`
|
|
|
|
|
|
let colorSimpleTemp = `<span>${metricName}</span>`
|
|
|
|
|
|
let metricTip = {}
|
|
|
|
|
|
const queryInfos = (this.elementMetricDatas.filter((item) => {
|
|
|
|
|
|
return item.metric === temp
|
|
|
|
|
|
}))
|
|
|
|
|
|
if (queryInfos && queryInfos.length > 0) {
|
|
|
|
|
|
metricTip = queryInfos[0]
|
|
|
|
|
|
} else {
|
|
|
|
|
|
metricTip.metric = temp
|
|
|
|
|
|
}
|
|
|
|
|
|
delete result.metric.__name__
|
|
|
|
|
|
temp += '{'
|
|
|
|
|
|
simpleTemp += '{'
|
|
|
|
|
|
colorTemp += `<span style="color: ${bracketsColor}">{</span>`
|
|
|
|
|
|
colorSimpleTemp += `<span style="color: ${bracketsColor}">{</span>`
|
|
|
|
|
|
const keys = Object.keys(result.metric)
|
|
|
|
|
|
for (const index in keys) {
|
|
|
|
|
|
const key = keys[index]
|
|
|
|
|
|
temp += key + "='" + result.metric[key] + "',"
|
|
|
|
|
|
colorTemp += `<span style="color: ${labelColor}">${key}</span>=<span style="color: ${valueColor}">'${result.metric[key]}'</span>,`
|
|
|
|
|
|
if (!this.sameLabels.some((i) => { return i == key })) {
|
|
|
|
|
|
simpleTemp += key + "='" + result.metric[key] + "',"
|
|
|
|
|
|
colorSimpleTemp += `<span style="color: ${labelColor}">${key}</span>=<span style="color: ${valueColor}">'${result.metric[key]}'</span>,`
|
2020-08-07 17:11:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
if (temp.indexOf(',') !== -1) {
|
|
|
|
|
|
temp = temp.substr(0, temp.length - 1)
|
2020-03-29 16:33:49 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
if (simpleTemp.indexOf(',') !== -1) {
|
|
|
|
|
|
simpleTemp = simpleTemp.substr(0, simpleTemp.length - 1)
|
2020-03-29 16:33:49 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
if (colorTemp.indexOf(',') !== -1) {
|
|
|
|
|
|
colorTemp = colorTemp.substr(0, colorTemp.length - 1)
|
2020-03-29 16:33:49 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
if (colorSimpleTemp.indexOf(',') !== -1) {
|
|
|
|
|
|
colorSimpleTemp = colorSimpleTemp.substr(0, colorSimpleTemp.length - 1)
|
2020-03-29 16:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
temp += '}'
|
|
|
|
|
|
simpleTemp += '}'
|
|
|
|
|
|
colorTemp += `<span style="color: ${bracketsColor}">}</span>`
|
|
|
|
|
|
colorSimpleTemp += `<span style="color: ${bracketsColor}">}</span>`
|
|
|
|
|
|
if (!/.+\{.+\}/.test(simpleTemp)) {
|
|
|
|
|
|
simpleTemp = simpleTemp.substr(0, simpleTemp.length - 2)
|
2020-03-29 16:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
if (!/.+\{<\/span><span.+?>.+?\}/.test(colorSimpleTemp)) {
|
|
|
|
|
|
const metricReg = new RegExp('<span.*?>' + metricName + '<\/span>')
|
|
|
|
|
|
colorSimpleTemp = metricReg.exec(colorSimpleTemp)[0]
|
2020-03-29 16:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
const edpQueryData = { element: temp, simpleElement: simpleTemp, colorElement: colorTemp, colorSimpleElement: colorSimpleTemp, value: result.value[1], type: (result.metric.type ? result.metric.type : '2'), metricTip: metricTip }
|
|
|
|
|
|
// this.tableData.push(edpQueryData);
|
|
|
|
|
|
tableData.push(edpQueryData)
|
|
|
|
|
|
}
|
|
|
|
|
|
return tableData
|
|
|
|
|
|
},
|
2021-04-13 20:33:12 +08:00
|
|
|
|
selectChange (selection) { // selection 选中的row的数组
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.selectedEndpoints = selection
|
|
|
|
|
|
},
|
2021-04-13 20:33:12 +08:00
|
|
|
|
selectable (row, index) {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
if (this.selectedEndpoints.length >= 20 && !this.selectedEndpoints.includes(row)) {
|
|
|
|
|
|
return false
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return true
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2021-04-13 20:33:12 +08:00
|
|
|
|
viewGraph () {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
if (this.selectedEndpoints.length < 1) {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.chartDatas = []
|
|
|
|
|
|
this.legend = []
|
|
|
|
|
|
this.graphShow = true
|
2021-03-31 15:26:01 +08:00
|
|
|
|
this.$refs.pickTime.$refs.multipleTime.searchTime = []
|
|
|
|
|
|
this.$refs.pickTime.$refs.multipleTime.showTime = {
|
|
|
|
|
|
id: 12,
|
|
|
|
|
|
text: this.$t('dashboard.panel.noDate')
|
|
|
|
|
|
}
|
|
|
|
|
|
this.$refs.pickTime.$refs.multipleTime.showDropdown = false
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.$refs.endpointChart.startLoading()
|
|
|
|
|
|
this.queryChartDate()
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2021-04-13 20:33:12 +08:00
|
|
|
|
dialogClose () {
|
2021-03-31 15:26:01 +08:00
|
|
|
|
this.$refs.pickTime.$refs.multipleTime.searchTime = []
|
|
|
|
|
|
this.$refs.pickTime.$refs.multipleTime.showTime = {
|
|
|
|
|
|
id: 12,
|
|
|
|
|
|
text: this.$t('dashboard.panel.noDate')
|
|
|
|
|
|
}
|
|
|
|
|
|
this.$refs.pickTime.$refs.multipleTime.showDropdown = false
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.graphShow = false
|
|
|
|
|
|
},
|
2021-04-13 20:33:12 +08:00
|
|
|
|
chartUnitChange (unit) {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.chartUnit = unit
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.queryChartDate()
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2021-04-13 20:33:12 +08:00
|
|
|
|
queryChartDate () {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
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)
|
|
|
|
|
|
// end - start < 1 day : 15s
|
|
|
|
|
|
// end - start < 7 day : 5m
|
|
|
|
|
|
// end - start < 30 day : 10m
|
|
|
|
|
|
// end - start > 30 day : 30m
|
|
|
|
|
|
let step = '15s'
|
|
|
|
|
|
if (timeDiff < 1) {
|
|
|
|
|
|
step = '15s'
|
|
|
|
|
|
} else if (timeDiff < 7) {
|
|
|
|
|
|
step = '5m'
|
|
|
|
|
|
} else if (timeDiff < 30) {
|
|
|
|
|
|
step = '10m'
|
|
|
|
|
|
} else {
|
|
|
|
|
|
step = '30m'
|
|
|
|
|
|
}
|
|
|
|
|
|
const axiosArr = []
|
|
|
|
|
|
for (const endpoint of this.selectedEndpoints) {
|
2021-11-25 13:51:06 +08:00
|
|
|
|
axiosArr.push(axios.get('/prom/api/v1/query_range?query=' + encodeURIComponent(endpoint.element) + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&step=' + step))
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
2021-03-31 15:26:01 +08:00
|
|
|
|
if (this.$refs.pickTime && this.$refs.pickTime.$refs.multipleTime && this.$refs.pickTime.$refs.multipleTime.searchTime.length) { // 判断是否需要添加比较
|
2021-12-31 16:41:30 +08:00
|
|
|
|
const startTime = bus.timeFormate(this.$refs.pickTime.$refs.multipleTime.searchTime[0], 'YYYY-MM-DD HH:mm:ss')
|
|
|
|
|
|
const endTime = bus.timeFormate(this.$refs.pickTime.$refs.multipleTime.searchTime[1], 'YYYY-MM-DD HH:mm:ss')
|
2021-03-31 15:26:01 +08:00
|
|
|
|
for (const endpoint of this.selectedEndpoints) {
|
2021-11-25 13:51:06 +08:00
|
|
|
|
axiosArr.push(axios.get('/prom/api/v1/query_range?query=' + encodeURIComponent(endpoint.element) + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step))
|
2021-03-31 15:26:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.legend = []
|
|
|
|
|
|
this.chartDatas = []
|
|
|
|
|
|
axios.all(axiosArr).then(res => {
|
|
|
|
|
|
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,
|
|
|
|
|
|
lineStyle: {
|
|
|
|
|
|
width: 1,
|
|
|
|
|
|
opacity: 0.9
|
|
|
|
|
|
}
|
2020-03-29 16:33:49 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
chartData.name = queryData.metric.__name__
|
|
|
|
|
|
let alias = queryData.metric.__name__
|
|
|
|
|
|
delete queryData.metric.__name__
|
|
|
|
|
|
chartData.name += '{'
|
|
|
|
|
|
alias += '{'
|
|
|
|
|
|
Object.keys(queryData.metric).forEach((item, index) => {
|
|
|
|
|
|
const label = item
|
|
|
|
|
|
const value = queryData.metric[label]
|
|
|
|
|
|
chartData.name += label + "='" + value + "',"
|
|
|
|
|
|
if (!this.sameLabels.some((i) => { return i == label })) {
|
|
|
|
|
|
alias += label + "='" + value + "',"
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
chartData.name = chartData.name.charAt(chartData.name.length - 1) === ',' ? chartData.name.substr(0, chartData.name.length - 1) : chartData.name
|
|
|
|
|
|
alias = alias.charAt(alias.length - 1) === ',' ? alias.substr(0, alias.length - 1) : alias
|
|
|
|
|
|
chartData.name += '}'
|
|
|
|
|
|
alias += '}'
|
|
|
|
|
|
if (!/.+\{.+\}/.test(alias)) {
|
|
|
|
|
|
alias = alias.substr(0, alias.length - 2)
|
|
|
|
|
|
}
|
|
|
|
|
|
const legend = {
|
|
|
|
|
|
name: chartData.name,
|
|
|
|
|
|
alias: alias,
|
|
|
|
|
|
// showText:this.formatLegend(chartData.name),
|
|
|
|
|
|
isGray: false
|
2020-03-29 16:33:49 +08:00
|
|
|
|
}
|
2021-03-31 15:26:01 +08:00
|
|
|
|
if (promIndex >= this.selectedEndpoints.length) {
|
2021-03-31 16:45:29 +08:00
|
|
|
|
legend.name = 'Previous ' + legend.name
|
2021-03-31 16:33:24 +08:00
|
|
|
|
chartData.name = legend.name
|
2021-03-31 16:45:29 +08:00
|
|
|
|
legend.alias = 'Previous ' + legend.alias
|
2021-03-31 15:26:01 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.legend.push(legend)
|
|
|
|
|
|
chartData.data = queryData.values.map((dpsItem, dpsIndex) => {
|
|
|
|
|
|
return [dpsItem[0] * 1000, Number(dpsItem[1])]
|
|
|
|
|
|
})
|
|
|
|
|
|
this.chartDatas.push(chartData)
|
2020-03-29 16:33:49 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(response.data.error)
|
|
|
|
|
|
console.error(response.data)
|
2020-03-29 16:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2021-03-31 15:26:01 +08:00
|
|
|
|
|
|
|
|
|
|
if (this.$refs.pickTime.$refs.multipleTime && this.$refs.pickTime.$refs.multipleTime.searchTime.length && res.length > this.selectedEndpoints.length) {
|
|
|
|
|
|
const minusTime = (new Date(this.searchTime[0]).getTime() - new Date(this.$refs.pickTime.$refs.multipleTime.searchTime[0]).getTime())
|
|
|
|
|
|
this.minusTime = minusTime
|
|
|
|
|
|
let cutPoint = 0
|
|
|
|
|
|
res.forEach((item, index) => {
|
|
|
|
|
|
if (index < res.length / 2) {
|
|
|
|
|
|
cutPoint += res[index].data.data.result.length
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
this.chartDatas.forEach((item, index) => {
|
|
|
|
|
|
if (index >= cutPoint) {
|
|
|
|
|
|
this.chartDatas[index].data.forEach((item1, index1) => {
|
|
|
|
|
|
item1[0] = item1[0] + minusTime
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
if (this.$refs.endpointChart) {
|
|
|
|
|
|
this.$refs.endpointChart.setRandomColors(this.chartDatas.length)
|
|
|
|
|
|
this.$refs.endpointChart.setLegend(this.legend)
|
|
|
|
|
|
this.$refs.endpointChart.modifyOption('tooltip', 'backgroundColor', 'rgba(221,228,237,1)')
|
|
|
|
|
|
this.$refs.endpointChart.modifyOption('tooltip', 'textStyle', { color: '#000' })
|
|
|
|
|
|
this.$refs.endpointChart.modifyOption('grid', 'top', 30)
|
|
|
|
|
|
this.$refs.endpointChart.modifyOption('grid', 'left', 0)
|
|
|
|
|
|
this.$refs.endpointChart.modifyOption('grid', 'right', 30)
|
|
|
|
|
|
this.$refs.endpointChart.modifyOption('grid', 'bottom', 8)
|
|
|
|
|
|
this.$refs.endpointChart.modifyOption('grid', 'containLabel', true)
|
|
|
|
|
|
this.$refs.endpointChart.setSeries(this.chartDatas)
|
|
|
|
|
|
this.$refs.endpointChart.endLoading()
|
2020-03-29 16:33:49 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
cellClass (row) { // 给复选框那一列添加 类名为 ‘disabledCheck’
|
|
|
|
|
|
if (row.columnIndex === 0) {
|
|
|
|
|
|
return 'disabledCheck'
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
getPanelData () { // 获取panel数据
|
|
|
|
|
|
this.$get('panel?pageNo=1&pageSize=-1').then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.panelData = response.data.list
|
2020-03-29 16:33:49 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
tableFilter () {
|
|
|
|
|
|
const temp = this
|
|
|
|
|
|
const tableDatas = JSON.parse(this.tableDataCopy)
|
|
|
|
|
|
this.tableData = tableDatas.filter((item) => {
|
|
|
|
|
|
const element = temp.hideSameLabels ? item.simpleElement : item.element
|
|
|
|
|
|
return element.indexOf(this.queryExpression) !== -1
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2021-04-13 20:33:12 +08:00
|
|
|
|
tableFilterHistory (expression) {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
let metric = ''
|
|
|
|
|
|
let labels = []
|
|
|
|
|
|
if (/\w*\{.*\}.*/i.test(expression)) {
|
|
|
|
|
|
metric = expression.substr(0, expression.indexOf('{'))
|
|
|
|
|
|
const labelStr = expression.substr(expression.indexOf('{') + 1, expression.indexOf('}') - expression.indexOf('{') - 1)
|
|
|
|
|
|
const labelArr = labelStr.split(',')
|
|
|
|
|
|
|
|
|
|
|
|
if (labelArr.length > 0) {
|
|
|
|
|
|
labels = labelArr.map((item, index) => {
|
|
|
|
|
|
const temp = item.split('=')
|
|
|
|
|
|
const label = temp[0] ? temp[0] : null
|
|
|
|
|
|
const value = temp[1] ? temp[1] : null
|
|
|
|
|
|
return label ? { label: label, value: value } : null
|
|
|
|
|
|
})
|
2020-03-29 16:33:49 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
metric = expression
|
|
|
|
|
|
}
|
|
|
|
|
|
this.tableData = []
|
|
|
|
|
|
let sourceData = JSON.parse(JSON.stringify(this.queryData))
|
|
|
|
|
|
sourceData = sourceData.filter((item) => {
|
|
|
|
|
|
const metricName = item.metric.__name__
|
|
|
|
|
|
if (metricName.indexOf(metric) === -1) {
|
|
|
|
|
|
return false
|
2020-03-29 16:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
if (labels.length > 0) {
|
|
|
|
|
|
for (const i in labels) {
|
|
|
|
|
|
const label = labels[i]
|
|
|
|
|
|
if (label && label.label) {
|
|
|
|
|
|
const value = item.metric[label.label]
|
|
|
|
|
|
let queryVal = label.value
|
|
|
|
|
|
if (/^'.+'$/.test(queryVal)) {
|
|
|
|
|
|
queryVal = queryVal.substr(1, queryVal.length - 2)
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!value || value != queryVal) {
|
|
|
|
|
|
return false
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return true
|
|
|
|
|
|
}
|
2020-03-29 16:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
return true
|
|
|
|
|
|
})
|
|
|
|
|
|
for (const i in sourceData) {
|
|
|
|
|
|
const item = sourceData[i]
|
|
|
|
|
|
// {"metric":{"instance":"192.168.40.126:9100","__name__":"scrape_duration_seconds","module":"node_exporter","project":"kafka","asset":"192.168.40.126","job":"ed_1","dc":"dc5"},"value":[1580782176.522,"0.000560761"]}
|
|
|
|
|
|
const metricName = item.metric.__name__
|
|
|
|
|
|
let temp = metricName
|
|
|
|
|
|
delete item.metric.__name__
|
|
|
|
|
|
temp += '{'
|
|
|
|
|
|
const hasLabel = true
|
|
|
|
|
|
for (const key in item.metric) {
|
|
|
|
|
|
const label = key
|
|
|
|
|
|
const value = item.metric[label]
|
|
|
|
|
|
temp += label + "='" + value + "',"
|
2020-03-29 16:33:49 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
temp = temp.charAt(temp.length - 1) == ',' ? temp.substr(0, temp.length - 1) : temp
|
|
|
|
|
|
temp += '}'
|
|
|
|
|
|
if (hasLabel) {
|
|
|
|
|
|
const edpQueryData = { element: temp, value: item.value[1], type: (item.metric.type ? item.metric.type : '2') }
|
|
|
|
|
|
this.tableData.push(edpQueryData)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-03-29 16:33:49 +08:00
|
|
|
|
},
|
2021-04-13 20:33:12 +08:00
|
|
|
|
focusInput () {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
let classVal = document.getElementById('elementQuery').parentElement.getAttribute('class')
|
|
|
|
|
|
classVal = classVal.replace('query-input-inactive', 'query-input-active')
|
|
|
|
|
|
document.getElementById('elementQuery').parentElement.setAttribute('class', classVal)
|
|
|
|
|
|
this.$refs.elementQuery.focus()
|
|
|
|
|
|
},
|
2021-04-13 20:33:12 +08:00
|
|
|
|
blurInput () {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
if (!this.queryExpression || this.queryExpression == '') {
|
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
|
let classVal = document.getElementById('elementQuery').parentElement.getAttribute('class')
|
|
|
|
|
|
classVal = classVal.replace('query-input-active', 'query-input-inactive')
|
|
|
|
|
|
document.getElementById('elementQuery').parentElement.setAttribute('class', classVal)
|
|
|
|
|
|
}, 100)
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2021-04-13 20:33:12 +08:00
|
|
|
|
clearInput () {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.$refs.elementQuery.focus()
|
|
|
|
|
|
},
|
|
|
|
|
|
queryElementTips: async function () {
|
|
|
|
|
|
this.elementMetricDatas = []
|
|
|
|
|
|
const response = await axios.get('/metric/metadata?endpointId=' + this.currentEndpoint.id)
|
|
|
|
|
|
if (response && response.status === 200) {
|
|
|
|
|
|
if (response.data.msg === 'success') {
|
|
|
|
|
|
this.elementMetricDatas = response.data.data.list
|
2020-03-29 16:33:49 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2021-04-13 20:33:12 +08:00
|
|
|
|
getStateContent (row) {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
if (row) {
|
|
|
|
|
|
if (row.state == 1) {
|
|
|
|
|
|
return 'up' + '[' + this.formatUpdateTime(row.lastUpdate) + ']'
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return 'down' + '[' + this.getStateErrorMsg(row) + ']'
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-03-29 16:33:49 +08:00
|
|
|
|
},
|
2021-04-13 20:33:12 +08:00
|
|
|
|
formatUpdateTime (date) {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
const time = new Date(date)
|
|
|
|
|
|
const hours = time.getHours() > 9 ? time.getHours() : '0' + time.getHours()
|
|
|
|
|
|
const minutes = time.getMinutes() > 9 ? time.getMinutes() : '0' + time.getMinutes()
|
|
|
|
|
|
|
|
|
|
|
|
return hours + ':' + minutes
|
|
|
|
|
|
},
|
2021-04-13 20:33:12 +08:00
|
|
|
|
getStateErrorMsg (row) {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
const errCodes = [230009, 230010, 230011]
|
|
|
|
|
|
if (row) {
|
|
|
|
|
|
if (row.state == 0) {
|
|
|
|
|
|
if (errCodes.find((item) => { return row.stateInfo.code == item })) {
|
|
|
|
|
|
return this.$t('project.endpoint.stateInfo_' + row.stateInfo.code)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error('state code error')
|
|
|
|
|
|
return row.stateInfo.msg
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
watch: {
|
|
|
|
|
|
obj: {
|
|
|
|
|
|
immediate: true,
|
|
|
|
|
|
deep: true,
|
|
|
|
|
|
handler (n) {
|
|
|
|
|
|
if (n) {
|
2022-06-15 14:04:03 +08:00
|
|
|
|
this.searchLabel = {}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.currentEndpoint = JSON.parse(JSON.stringify(n))
|
|
|
|
|
|
this.queryEndpoint()
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-11-20 11:19:25 +08:00
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
queryExpression (n, o) {
|
|
|
|
|
|
const temp = this
|
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
|
temp.tableFilter()
|
|
|
|
|
|
}, 500)
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
mounted () {
|
|
|
|
|
|
this.getPanelData()
|
|
|
|
|
|
setTimeout(() => { this.$refs.endpointQueryTable.setHeight() }, 700)
|
2020-03-29 16:33:49 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
2020-03-29 16:33:49 +08:00
|
|
|
|
</script>
|