2022-08-11 15:49:41 +08:00
|
|
|
|
<template>
|
2022-08-12 15:25:54 +08:00
|
|
|
|
<div class="npm-traffic-line">
|
2022-08-31 13:54:20 +08:00
|
|
|
|
<div class="npm-traffic-line-header">
|
2022-11-04 11:26:46 +08:00
|
|
|
|
<div class="npm-traffic-line-title"></div>
|
2022-08-31 13:54:20 +08:00
|
|
|
|
<div class="line-select-metric">
|
|
|
|
|
|
<span>{{$t('network.metric')}}:</span>
|
|
|
|
|
|
<div class="line-select__operation">
|
|
|
|
|
|
<el-select
|
|
|
|
|
|
size="mini"
|
|
|
|
|
|
v-model="metricFilter"
|
|
|
|
|
|
placeholder=""
|
|
|
|
|
|
popper-class="common-select"
|
|
|
|
|
|
:popper-append-to-body="false"
|
|
|
|
|
|
@change="metricChange"
|
|
|
|
|
|
>
|
2022-09-07 11:49:15 +08:00
|
|
|
|
<el-option v-for="item in metricOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>
|
2022-08-31 13:54:20 +08:00
|
|
|
|
</el-select>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2022-08-12 15:25:54 +08:00
|
|
|
|
<div class="npm-traffic-line-body">
|
|
|
|
|
|
<chart-no-data v-if="isNoData"></chart-no-data>
|
2022-09-03 10:57:59 +08:00
|
|
|
|
<div v-show="!isNoData" class="chart-drawing" id="chart"></div>
|
2022-08-12 15:25:54 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2022-08-11 15:49:41 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
2022-08-12 15:25:54 +08:00
|
|
|
|
import * as echarts from 'echarts'
|
|
|
|
|
|
import { trafficLineChartOption } from '@/views/charts2/charts/options/echartOption'
|
|
|
|
|
|
import unitConvert from '@/utils/unit-convert'
|
|
|
|
|
|
import { unitTypes, chartColor3 } from '@/utils/constants.js'
|
2022-09-09 15:13:36 +08:00
|
|
|
|
import { ref, shallowRef } from 'vue'
|
2022-09-03 10:57:59 +08:00
|
|
|
|
import { stackedLineTooltipFormatter } from '@/views/charts/charts/tools'
|
2022-08-12 15:25:54 +08:00
|
|
|
|
import { get } from '@/utils/http'
|
|
|
|
|
|
import { api } from '@/utils/api'
|
|
|
|
|
|
import { getSecond } from '@/utils/date-util'
|
|
|
|
|
|
import ChartNoData from '@/views/charts/charts/ChartNoData'
|
|
|
|
|
|
import _ from 'lodash'
|
2022-08-22 15:49:38 +08:00
|
|
|
|
import chartMixin from '@/views/charts2/chart-mixin'
|
2022-09-09 15:13:36 +08:00
|
|
|
|
import { useRoute } from 'vue-router'
|
|
|
|
|
|
import { overwriteUrl, urlParamsHandler } from '@/utils/tools'
|
2022-08-11 15:49:41 +08:00
|
|
|
|
export default {
|
2022-08-12 15:25:54 +08:00
|
|
|
|
name: 'NpmTrafficLine',
|
2022-08-22 15:49:38 +08:00
|
|
|
|
mixins: [chartMixin],
|
2022-08-12 15:25:54 +08:00
|
|
|
|
components: {
|
|
|
|
|
|
ChartNoData
|
|
|
|
|
|
},
|
|
|
|
|
|
setup () {
|
2022-09-09 15:13:36 +08:00
|
|
|
|
const { query } = useRoute()
|
|
|
|
|
|
const metricFilter = ref(query.lineMetric || 'Bits/s')
|
2022-09-20 10:35:39 +08:00
|
|
|
|
const queryCondition = ref(query.queryCondition || '')
|
|
|
|
|
|
const dimensionType = ref(query.dimensionType || '')
|
2022-08-12 15:25:54 +08:00
|
|
|
|
return {
|
2022-09-09 15:13:36 +08:00
|
|
|
|
metricFilter,
|
2022-09-20 10:35:39 +08:00
|
|
|
|
queryCondition,
|
|
|
|
|
|
dimensionType,
|
2022-08-12 15:25:54 +08:00
|
|
|
|
myChart: shallowRef(null)
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
data () {
|
|
|
|
|
|
return {
|
|
|
|
|
|
unitConvert,
|
|
|
|
|
|
unitTypes,
|
2022-08-20 14:52:55 +08:00
|
|
|
|
side: '',
|
2022-11-03 11:21:39 +08:00
|
|
|
|
mpackets: [
|
|
|
|
|
|
{ name: 'network.total', show: true, positioning: 0, data: [], unitType: 'number' },
|
|
|
|
|
|
{ name: 'network.inbound', show: true, positioning: 1, data: [], unitType: 'number' },
|
|
|
|
|
|
{ name: 'network.outbound', show: true, positioning: 2, data: [], unitType: 'number' },
|
|
|
|
|
|
{ name: 'network.internal', show: true, positioning: 3, data: [], unitType: 'number' },
|
|
|
|
|
|
{ name: 'network.through', show: true, positioning: 4, data: [], unitType: 'number' },
|
|
|
|
|
|
{ name: 'network.other', show: true, positioning: 5, data: [], unitType: 'number' }
|
|
|
|
|
|
],
|
|
|
|
|
|
npmQuantity: [
|
|
|
|
|
|
{ name: 'networkAppPerformance.tcpConnectionEstablishLatency', show: true, positioning: 0, data: [], unitType: unitTypes.time },
|
|
|
|
|
|
{ name: 'networkAppPerformance.httpResponse', show: true, positioning: 0, data: [], unitType: unitTypes.time },
|
|
|
|
|
|
{ name: 'networkAppPerformance.sslResponseLatency', show: true, positioning: 0, data: [], unitType: unitTypes.time },
|
|
|
|
|
|
{ name: 'networkAppPerformance.packetLoss', show: true, positioning: 0, data: [], unitType: unitTypes.percent },
|
|
|
|
|
|
{ name: 'overall.packetRetrans', show: true, positioning: 0, data: [], unitType: unitTypes.percent }
|
|
|
|
|
|
],
|
2022-08-31 13:54:20 +08:00
|
|
|
|
chartData: {},
|
|
|
|
|
|
metricOptions: [
|
|
|
|
|
|
{
|
|
|
|
|
|
value: 'Bits/s',
|
|
|
|
|
|
label: 'Bits/s'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
value: 'Packets/s',
|
|
|
|
|
|
label: 'Packets/s'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
value: 'Sessions/s',
|
|
|
|
|
|
label: 'Sessions/s'
|
2022-09-03 10:57:59 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
value: 'establishLatencyMs',
|
2022-09-07 11:49:15 +08:00
|
|
|
|
label: this.$t('networkAppPerformance.tcpConnectionEstablishLatency')
|
2022-09-03 10:57:59 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
value: 'httpResponseLatency',
|
2022-09-07 11:49:15 +08:00
|
|
|
|
label: this.$t('networkAppPerformance.httpResponse')
|
2022-09-03 10:57:59 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
value: 'sslConLatency',
|
2022-09-07 11:49:15 +08:00
|
|
|
|
label: this.$t('networkAppPerformance.sslResponseLatency')
|
2022-09-03 10:57:59 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
value: 'tcpLostlenPercent',
|
2022-09-07 11:49:15 +08:00
|
|
|
|
label: this.$t('networkAppPerformance.packetLoss')
|
2022-09-03 10:57:59 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
value: 'pktRetransPercent',
|
2022-09-07 11:49:15 +08:00
|
|
|
|
label: this.$t('overall.packetRetrans')
|
2022-08-31 13:54:20 +08:00
|
|
|
|
}
|
2022-09-09 15:13:36 +08:00
|
|
|
|
]
|
2022-08-12 15:25:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2022-08-24 17:09:42 +08:00
|
|
|
|
watch: {
|
2022-09-09 15:13:36 +08:00
|
|
|
|
metricFilter (n) {
|
|
|
|
|
|
const { query } = this.$route
|
|
|
|
|
|
const newUrl = urlParamsHandler(window.location.href, query, {
|
|
|
|
|
|
lineMetric: n
|
|
|
|
|
|
})
|
|
|
|
|
|
overwriteUrl(newUrl)
|
|
|
|
|
|
},
|
2022-08-24 17:09:42 +08:00
|
|
|
|
timeFilter: {
|
|
|
|
|
|
handler (n) {
|
|
|
|
|
|
this.init()
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2022-08-12 15:25:54 +08:00
|
|
|
|
methods: {
|
2022-08-31 13:54:20 +08:00
|
|
|
|
init (val) {
|
|
|
|
|
|
if (!val) {
|
2022-09-20 09:36:53 +08:00
|
|
|
|
val = this.metricFilter
|
2022-08-31 13:54:20 +08:00
|
|
|
|
}
|
2022-09-20 10:35:39 +08:00
|
|
|
|
// const conditionStr = this.$route.query.queryCondition ? this.$route.query.queryCondition : ''
|
2022-08-24 16:58:34 +08:00
|
|
|
|
let condition = ''
|
2022-09-30 16:31:11 +08:00
|
|
|
|
const type = this.dimensionType
|
2022-09-30 17:03:12 +08:00
|
|
|
|
if (this.queryCondition.indexOf(' OR ') > -1) {
|
2022-09-20 10:35:39 +08:00
|
|
|
|
condition = this.queryCondition.split(/["|'](.*?)["|']/)
|
2022-08-24 16:58:34 +08:00
|
|
|
|
} else {
|
2022-09-20 10:35:39 +08:00
|
|
|
|
condition = this.queryCondition
|
2022-08-24 16:58:34 +08:00
|
|
|
|
}
|
2022-09-20 09:33:49 +08:00
|
|
|
|
// const type = this.$store.getters.getDimensionType
|
2022-08-20 14:52:55 +08:00
|
|
|
|
if (this.chartData.id === 24) {
|
|
|
|
|
|
this.side = 'client'
|
2022-08-24 16:58:34 +08:00
|
|
|
|
} else if (this.chartData.id === 29) {
|
2022-08-20 14:52:55 +08:00
|
|
|
|
this.side = 'server'
|
|
|
|
|
|
}
|
2022-08-12 15:25:54 +08:00
|
|
|
|
const params = {
|
|
|
|
|
|
startTime: getSecond(this.timeFilter.startTime),
|
2022-11-02 19:28:11 +08:00
|
|
|
|
endTime: getSecond(this.timeFilter.endTime)
|
|
|
|
|
|
}
|
|
|
|
|
|
if (type) {
|
|
|
|
|
|
params.type = type
|
2022-08-12 15:25:54 +08:00
|
|
|
|
}
|
2022-08-24 16:58:34 +08:00
|
|
|
|
if (condition && (typeof condition !== 'object') && type) {
|
|
|
|
|
|
params.q = condition
|
|
|
|
|
|
} else if (condition.length > 1 && type && type === 'ip') {
|
|
|
|
|
|
params.q = `${type}='${condition[1]}' and side='${this.side}'`
|
|
|
|
|
|
} else if (condition.length > 1 && type && type !== 'ip') {
|
2022-08-24 18:18:28 +08:00
|
|
|
|
if (type === 'country' || type === 'asn' || type === 'province' || type === 'city' || type === 'isp') {
|
2022-08-24 16:58:34 +08:00
|
|
|
|
params.q = `${type}='${condition[1]}'`
|
|
|
|
|
|
} else if (type === 'idcRenter') {
|
|
|
|
|
|
params.q = `idc_renter='${condition[1]}'`
|
|
|
|
|
|
} else {
|
|
|
|
|
|
params.q = `${condition[0]}'${condition[1]}'`
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-08-31 13:54:20 +08:00
|
|
|
|
this.toggleLoading(true)
|
2022-11-02 19:28:11 +08:00
|
|
|
|
if (params.type && params.q) {
|
|
|
|
|
|
get(api.npm.overview.trafficGraph, params).then((res) => {
|
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
|
this.isNoData = res.data.result.length === 0
|
2022-11-03 11:21:39 +08:00
|
|
|
|
if (this.isNoData) {
|
|
|
|
|
|
this.mpackets = [
|
|
|
|
|
|
{ name: 'network.total', show: true, positioning: 0, data: [], unitType: 'number' },
|
|
|
|
|
|
{ name: 'network.inbound', show: true, positioning: 1, data: [], unitType: 'number' },
|
|
|
|
|
|
{ name: 'network.outbound', show: true, positioning: 2, data: [], unitType: 'number' },
|
|
|
|
|
|
{ name: 'network.internal', show: true, positioning: 3, data: [], unitType: 'number' },
|
|
|
|
|
|
{ name: 'network.through', show: true, positioning: 4, data: [], unitType: 'number' },
|
|
|
|
|
|
{ name: 'network.other', show: true, positioning: 5, data: [], unitType: 'number' }
|
|
|
|
|
|
]
|
|
|
|
|
|
this.npmQuantity = [
|
|
|
|
|
|
{ name: 'networkAppPerformance.tcpConnectionEstablishLatency', show: true, positioning: 0, data: [], unitType: unitTypes.time },
|
|
|
|
|
|
{ name: 'networkAppPerformance.httpResponse', show: true, positioning: 0, data: [], unitType: unitTypes.time },
|
|
|
|
|
|
{ name: 'networkAppPerformance.sslResponseLatency', show: true, positioning: 0, data: [], unitType: unitTypes.time },
|
|
|
|
|
|
{ name: 'networkAppPerformance.packetLoss', show: true, positioning: 0, data: [], unitType: unitTypes.percent },
|
|
|
|
|
|
{ name: 'overall.packetRetrans', show: true, positioning: 0, data: [], unitType: unitTypes.percent }
|
|
|
|
|
|
]
|
|
|
|
|
|
}
|
2022-11-02 19:28:11 +08:00
|
|
|
|
res.data.result.forEach((t, i) => {
|
|
|
|
|
|
if (t.type === 'bytes' && val === 'Bits/s') {
|
|
|
|
|
|
const mpackets = _.cloneDeep(this.mpackets)
|
|
|
|
|
|
mpackets[0].data = t.totalBitsRate.values ? t.totalBitsRate.values : []
|
|
|
|
|
|
mpackets[1].data = t.inboundBitsRate.values ? t.inboundBitsRate.values : []
|
|
|
|
|
|
mpackets[2].data = t.outboundBitsRate.values ? t.outboundBitsRate.values : []
|
|
|
|
|
|
mpackets[3].data = t.internalBitsRate.values ? t.internalBitsRate.values : []
|
|
|
|
|
|
mpackets[4].data = t.throughBitsRate.values ? t.throughBitsRate.values : []
|
|
|
|
|
|
mpackets[5].data = t.other.values ? t.other.values : []
|
|
|
|
|
|
mpackets.forEach((e, i) => {
|
2022-09-03 10:57:59 +08:00
|
|
|
|
e.show = true
|
2022-11-02 19:28:11 +08:00
|
|
|
|
})
|
|
|
|
|
|
this.mpackets = mpackets
|
|
|
|
|
|
this.echartsInit(this.mpackets)
|
|
|
|
|
|
} else if (t.type === 'packets' && val === 'Packets/s') {
|
|
|
|
|
|
const mpackets = _.cloneDeep(this.mpackets)
|
|
|
|
|
|
mpackets[0].data = t.totalPacketsRate.values ? t.totalPacketsRate.values : []
|
|
|
|
|
|
mpackets[1].data = t.inboundPacketsRate.values ? t.inboundPacketsRate.values : []
|
|
|
|
|
|
mpackets[2].data = t.outboundPacketsRate.values ? t.outboundPacketsRate.values : []
|
|
|
|
|
|
mpackets[3].data = t.internalPacketsRate.values ? t.internalPacketsRate.values : []
|
|
|
|
|
|
mpackets[4].data = t.throughPacketsRate.values ? t.throughPacketsRate.values : []
|
|
|
|
|
|
mpackets[5].data = t.other.values ? t.other.values : []
|
|
|
|
|
|
mpackets.forEach((e, i) => {
|
2022-09-03 10:57:59 +08:00
|
|
|
|
e.show = true
|
2022-11-02 19:28:11 +08:00
|
|
|
|
})
|
|
|
|
|
|
this.mpackets = mpackets
|
|
|
|
|
|
this.echartsInit(this.mpackets)
|
|
|
|
|
|
} else if (t.type === 'sessions' && val === 'Sessions/s') {
|
|
|
|
|
|
const mpackets = _.cloneDeep(this.mpackets)
|
|
|
|
|
|
mpackets[0].data = t.totalSessionsRate.values ? t.totalSessionsRate.values : []
|
|
|
|
|
|
mpackets.forEach((e, i) => {
|
|
|
|
|
|
if (i !== 0) {
|
|
|
|
|
|
e.show = false
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
this.mpackets = mpackets
|
|
|
|
|
|
this.echartsInit(this.mpackets)
|
|
|
|
|
|
} else if (t.type === 'establishLatencyMs' && val === 'establishLatencyMs') {
|
|
|
|
|
|
const npmQuantity = _.cloneDeep(this.npmQuantity)
|
|
|
|
|
|
npmQuantity[0].data = t.establishLatencyMsAvg.values ? t.establishLatencyMsAvg.values : []
|
|
|
|
|
|
npmQuantity.forEach((e, i) => {
|
|
|
|
|
|
if (i !== 0) {
|
|
|
|
|
|
e.show = false
|
|
|
|
|
|
} else {
|
|
|
|
|
|
e.show = true
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
this.npmQuantity = npmQuantity
|
2022-11-04 12:52:12 +08:00
|
|
|
|
this.echartsInit(this.npmQuantity, '(ms)')
|
2022-11-02 19:28:11 +08:00
|
|
|
|
} else if (t.type === 'httpResponseLatency' && val === 'httpResponseLatency') {
|
|
|
|
|
|
const npmQuantity = _.cloneDeep(this.npmQuantity)
|
|
|
|
|
|
npmQuantity[1].data = t.httpResponseLatencyAvg.values ? t.httpResponseLatencyAvg.values : []
|
|
|
|
|
|
npmQuantity.forEach((e, i) => {
|
|
|
|
|
|
if (i !== 1) {
|
|
|
|
|
|
e.show = false
|
|
|
|
|
|
} else {
|
|
|
|
|
|
e.show = true
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
this.npmQuantity = npmQuantity
|
2022-11-04 12:52:12 +08:00
|
|
|
|
this.echartsInit(this.npmQuantity, '(ms)')
|
2022-11-02 19:28:11 +08:00
|
|
|
|
} else if (t.type === 'sslConLatency' && val === 'sslConLatency') {
|
|
|
|
|
|
const npmQuantity = _.cloneDeep(this.npmQuantity)
|
|
|
|
|
|
npmQuantity[2].data = t.sslConLatencyAvg.values ? t.sslConLatencyAvg.values : []
|
|
|
|
|
|
npmQuantity.forEach((e, i) => {
|
|
|
|
|
|
if (i !== 2) {
|
|
|
|
|
|
e.show = false
|
|
|
|
|
|
} else {
|
|
|
|
|
|
e.show = true
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
this.npmQuantity = npmQuantity
|
2022-11-04 12:52:12 +08:00
|
|
|
|
this.echartsInit(this.npmQuantity, '(ms)')
|
2022-11-02 19:28:11 +08:00
|
|
|
|
} else if (t.type === 'tcpLostlenPercent' && val === 'tcpLostlenPercent') {
|
|
|
|
|
|
const npmQuantity = _.cloneDeep(this.npmQuantity)
|
|
|
|
|
|
npmQuantity[3].data = t.tcpLostlenPercentAvg.values ? t.tcpLostlenPercentAvg.values : []
|
|
|
|
|
|
npmQuantity.forEach((e, i) => {
|
|
|
|
|
|
if (i !== 3) {
|
|
|
|
|
|
e.show = false
|
|
|
|
|
|
} else {
|
|
|
|
|
|
e.show = true
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
this.npmQuantity = npmQuantity
|
2022-11-04 12:52:12 +08:00
|
|
|
|
this.echartsInit(this.npmQuantity, '(%)')
|
2022-11-02 19:28:11 +08:00
|
|
|
|
} else if (t.type === 'pktRetransPercent' && val === 'pktRetransPercent') {
|
|
|
|
|
|
const npmQuantity = _.cloneDeep(this.npmQuantity)
|
|
|
|
|
|
npmQuantity[4].data = t.pktRetransPercentAvg.values ? t.pktRetransPercentAvg.values : []
|
|
|
|
|
|
npmQuantity.forEach((e, i) => {
|
|
|
|
|
|
if (i !== 4) {
|
|
|
|
|
|
e.show = false
|
|
|
|
|
|
} else {
|
|
|
|
|
|
e.show = true
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
this.npmQuantity = npmQuantity
|
2022-11-04 12:52:12 +08:00
|
|
|
|
this.echartsInit(this.npmQuantity, '(%)')
|
2022-11-02 19:28:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.isNoData = true
|
|
|
|
|
|
}
|
|
|
|
|
|
}).catch(e => {
|
|
|
|
|
|
this.isNoData = true
|
|
|
|
|
|
}).finally(() => {
|
|
|
|
|
|
this.toggleLoading(false)
|
|
|
|
|
|
})
|
|
|
|
|
|
} else {
|
|
|
|
|
|
if (val === 'Bits/s' || val === 'Packets/s' || val === 'Sessions/s') {
|
|
|
|
|
|
this.toggleLoading(true)
|
|
|
|
|
|
get(api.npm.overview.totalTrafficAnalysis, params).then(res => {
|
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
|
this.isNoData = res.data.result.length === 0
|
2022-11-03 11:21:39 +08:00
|
|
|
|
if (this.isNoData) {
|
|
|
|
|
|
this.mpackets = [
|
|
|
|
|
|
{ name: 'network.total', show: true, positioning: 0, data: [], unitType: 'number' },
|
|
|
|
|
|
{ name: 'network.inbound', show: true, positioning: 1, data: [], unitType: 'number' },
|
|
|
|
|
|
{ name: 'network.outbound', show: true, positioning: 2, data: [], unitType: 'number' },
|
|
|
|
|
|
{ name: 'network.internal', show: true, positioning: 3, data: [], unitType: 'number' },
|
|
|
|
|
|
{ name: 'network.through', show: true, positioning: 4, data: [], unitType: 'number' },
|
|
|
|
|
|
{ name: 'network.other', show: true, positioning: 5, data: [], unitType: 'number' }
|
|
|
|
|
|
]
|
|
|
|
|
|
}
|
2022-11-02 19:28:11 +08:00
|
|
|
|
res.data.result.forEach((t, i) => {
|
|
|
|
|
|
if (t.type === 'bytes' && val === 'Bits/s') {
|
|
|
|
|
|
const mpackets = _.cloneDeep(this.mpackets)
|
|
|
|
|
|
mpackets[0].data = t.totalBitsRate.values ? t.totalBitsRate.values : []
|
|
|
|
|
|
mpackets[1].data = t.inboundBitsRate.values ? t.inboundBitsRate.values : []
|
|
|
|
|
|
mpackets[2].data = t.outboundBitsRate.values ? t.outboundBitsRate.values : []
|
|
|
|
|
|
mpackets[3].data = t.internalBitsRate.values ? t.internalBitsRate.values : []
|
|
|
|
|
|
mpackets[4].data = t.throughBitsRate.values ? t.throughBitsRate.values : []
|
|
|
|
|
|
mpackets[5].data = t.other.values ? t.other.values : []
|
|
|
|
|
|
mpackets.forEach((e, i) => {
|
|
|
|
|
|
e.show = true
|
|
|
|
|
|
})
|
|
|
|
|
|
this.mpackets = mpackets
|
|
|
|
|
|
this.echartsInit(this.mpackets)
|
|
|
|
|
|
} else if (t.type === 'packets' && val === 'Packets/s') {
|
|
|
|
|
|
const mpackets = _.cloneDeep(this.mpackets)
|
|
|
|
|
|
mpackets[0].data = t.totalPacketsRate.values ? t.totalPacketsRate.values : []
|
|
|
|
|
|
mpackets[1].data = t.inboundPacketsRate.values ? t.inboundPacketsRate.values : []
|
|
|
|
|
|
mpackets[2].data = t.outboundPacketsRate.values ? t.outboundPacketsRate.values : []
|
|
|
|
|
|
mpackets[3].data = t.internalPacketsRate.values ? t.internalPacketsRate.values : []
|
|
|
|
|
|
mpackets[4].data = t.throughPacketsRate.values ? t.throughPacketsRate.values : []
|
|
|
|
|
|
mpackets[5].data = t.other.values ? t.other.values : []
|
|
|
|
|
|
mpackets.forEach((e, i) => {
|
|
|
|
|
|
e.show = true
|
|
|
|
|
|
})
|
|
|
|
|
|
this.mpackets = mpackets
|
|
|
|
|
|
this.echartsInit(this.mpackets)
|
|
|
|
|
|
} else if (t.type === 'sessions' && val === 'Sessions/s') {
|
|
|
|
|
|
const mpackets = _.cloneDeep(this.mpackets)
|
|
|
|
|
|
mpackets[0].data = t.totalSessionsRate.values ? t.totalSessionsRate.values : []
|
|
|
|
|
|
mpackets.forEach((e, i) => {
|
|
|
|
|
|
if (i !== 0) {
|
|
|
|
|
|
e.show = false
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
this.mpackets = mpackets
|
|
|
|
|
|
this.echartsInit(this.mpackets)
|
2022-09-03 10:57:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
2022-11-02 19:28:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
}).catch(e => {
|
|
|
|
|
|
this.isNoData = true
|
|
|
|
|
|
}).finally(() => {
|
|
|
|
|
|
this.toggleLoading(false)
|
|
|
|
|
|
})
|
|
|
|
|
|
} else if (val === 'establishLatencyMs' || val === 'tcpLostlenPercent' || val === 'pktRetransPercent') {
|
|
|
|
|
|
this.toggleLoading(true)
|
|
|
|
|
|
get(api.npm.overview.totalNetworkAnalysis, params).then(res => {
|
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
|
this.isNoData = res.data.result.length === 0
|
2022-11-03 11:21:39 +08:00
|
|
|
|
if (this.isNoData) {
|
|
|
|
|
|
this.npmQuantity = [
|
|
|
|
|
|
{ name: 'networkAppPerformance.tcpConnectionEstablishLatency', show: true, positioning: 0, data: [], unitType: unitTypes.time },
|
2022-11-04 10:22:32 +08:00
|
|
|
|
{ name: 'networkAppPerformance.httpResponse', show: true, positioning: 0, data: [], unitType: unitTypes.time },
|
|
|
|
|
|
{ name: 'networkAppPerformance.sslResponseLatency', show: true, positioning: 0, data: [], unitType: unitTypes.time },
|
2022-11-03 11:21:39 +08:00
|
|
|
|
{ name: 'networkAppPerformance.packetLoss', show: true, positioning: 0, data: [], unitType: unitTypes.percent },
|
|
|
|
|
|
{ name: 'overall.packetRetrans', show: true, positioning: 0, data: [], unitType: unitTypes.percent }
|
|
|
|
|
|
]
|
|
|
|
|
|
}
|
2022-11-02 19:28:11 +08:00
|
|
|
|
res.data.result.forEach((t, i) => {
|
|
|
|
|
|
if (t.type === 'establishLatencyMs' && val === 'establishLatencyMs') {
|
|
|
|
|
|
const npmQuantity = _.cloneDeep(this.npmQuantity)
|
|
|
|
|
|
npmQuantity[0].data = t.establishLatencyMs.values ? t.establishLatencyMs.values : []
|
|
|
|
|
|
npmQuantity.forEach((e, i) => {
|
|
|
|
|
|
if (i !== 0) {
|
|
|
|
|
|
e.show = false
|
|
|
|
|
|
} else {
|
|
|
|
|
|
e.show = true
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
this.npmQuantity = npmQuantity
|
2022-11-04 12:52:12 +08:00
|
|
|
|
this.echartsInit(this.npmQuantity, '(ms)')
|
2022-11-02 19:28:11 +08:00
|
|
|
|
} else if (t.type === 'tcpLostlenPercent' && val === 'tcpLostlenPercent') {
|
|
|
|
|
|
const npmQuantity = _.cloneDeep(this.npmQuantity)
|
2022-11-04 10:22:32 +08:00
|
|
|
|
npmQuantity[3].data = t.tcpLostlenPercent.values ? t.tcpLostlenPercent.values : []
|
2022-11-02 19:28:11 +08:00
|
|
|
|
npmQuantity.forEach((e, i) => {
|
2022-11-04 10:22:32 +08:00
|
|
|
|
if (i !== 3) {
|
2022-11-02 19:28:11 +08:00
|
|
|
|
e.show = false
|
|
|
|
|
|
} else {
|
|
|
|
|
|
e.show = true
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
this.npmQuantity = npmQuantity
|
2022-11-04 12:52:12 +08:00
|
|
|
|
this.echartsInit(this.npmQuantity, '(%)')
|
2022-11-02 19:28:11 +08:00
|
|
|
|
} else if (t.type === 'pktRetransPercent' && val === 'pktRetransPercent') {
|
|
|
|
|
|
const npmQuantity = _.cloneDeep(this.npmQuantity)
|
2022-11-04 10:22:32 +08:00
|
|
|
|
npmQuantity[4].data = t.pktRetransPercent.values ? t.pktRetransPercent.values : []
|
2022-11-02 19:28:11 +08:00
|
|
|
|
npmQuantity.forEach((e, i) => {
|
2022-11-04 10:22:32 +08:00
|
|
|
|
if (i !== 4) {
|
2022-11-02 19:28:11 +08:00
|
|
|
|
e.show = false
|
|
|
|
|
|
} else {
|
|
|
|
|
|
e.show = true
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
this.npmQuantity = npmQuantity
|
2022-11-04 12:52:12 +08:00
|
|
|
|
this.echartsInit(this.npmQuantity, '(%)')
|
2022-09-03 10:57:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
2022-11-02 19:28:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
}).catch(e => {
|
|
|
|
|
|
this.isNoData = true
|
|
|
|
|
|
}).finally(() => {
|
|
|
|
|
|
this.toggleLoading(false)
|
|
|
|
|
|
})
|
|
|
|
|
|
} else if (val === 'httpResponseLatency') {
|
|
|
|
|
|
this.toggleLoading(true)
|
|
|
|
|
|
get(api.npm.overview.totalHttpResponseDelay, params).then(res => {
|
|
|
|
|
|
if (res.code === 200) {
|
2022-11-04 10:22:32 +08:00
|
|
|
|
this.isNoData = res.data.result.length === 0
|
2022-11-03 11:21:39 +08:00
|
|
|
|
if (this.isNoData) {
|
|
|
|
|
|
this.npmQuantity = [
|
2022-11-04 10:22:32 +08:00
|
|
|
|
{ name: 'networkAppPerformance.tcpConnectionEstablishLatency', show: true, positioning: 0, data: [], unitType: unitTypes.time },
|
|
|
|
|
|
{ name: 'networkAppPerformance.httpResponse', show: true, positioning: 0, data: [], unitType: unitTypes.time },
|
|
|
|
|
|
{ name: 'networkAppPerformance.sslResponseLatency', show: true, positioning: 0, data: [], unitType: unitTypes.time },
|
|
|
|
|
|
{ name: 'networkAppPerformance.packetLoss', show: true, positioning: 0, data: [], unitType: unitTypes.percent },
|
|
|
|
|
|
{ name: 'overall.packetRetrans', show: true, positioning: 0, data: [], unitType: unitTypes.percent }
|
2022-11-03 11:21:39 +08:00
|
|
|
|
]
|
|
|
|
|
|
}
|
2022-11-02 19:28:11 +08:00
|
|
|
|
res.data.result.forEach(t => {
|
|
|
|
|
|
if (t.type === 'httpResponseLatency' && val === 'httpResponseLatency') {
|
|
|
|
|
|
const npmQuantity = _.cloneDeep(this.npmQuantity)
|
2022-11-04 10:22:32 +08:00
|
|
|
|
npmQuantity[1].data = t.httpResponseLatency.values ? t.httpResponseLatency.values : []
|
2022-11-02 19:28:11 +08:00
|
|
|
|
npmQuantity.forEach((e, i) => {
|
2022-11-04 10:22:32 +08:00
|
|
|
|
if (i !== 1) {
|
2022-11-02 19:28:11 +08:00
|
|
|
|
e.show = false
|
|
|
|
|
|
} else {
|
|
|
|
|
|
e.show = true
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
this.npmQuantity = npmQuantity
|
2022-11-04 12:52:12 +08:00
|
|
|
|
this.echartsInit(this.npmQuantity, '(ms)')
|
2022-09-03 10:57:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
2022-11-02 19:28:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
}).catch(e => {
|
|
|
|
|
|
this.isNoData = true
|
|
|
|
|
|
}).finally(() => {
|
|
|
|
|
|
this.toggleLoading(false)
|
|
|
|
|
|
})
|
|
|
|
|
|
} else if (val === 'sslConLatency') {
|
|
|
|
|
|
this.toggleLoading(true)
|
|
|
|
|
|
get(api.npm.overview.totalSslConDelay, params).then(res => {
|
|
|
|
|
|
if (res.code === 200) {
|
2022-11-04 10:22:32 +08:00
|
|
|
|
this.isNoData = res.data.result.length === 0
|
2022-11-03 11:21:39 +08:00
|
|
|
|
if (this.isNoData) {
|
|
|
|
|
|
this.npmQuantity = [
|
2022-11-04 10:22:32 +08:00
|
|
|
|
{ name: 'networkAppPerformance.tcpConnectionEstablishLatency', show: true, positioning: 0, data: [], unitType: unitTypes.time },
|
|
|
|
|
|
{ name: 'networkAppPerformance.httpResponse', show: true, positioning: 0, data: [], unitType: unitTypes.time },
|
|
|
|
|
|
{ name: 'networkAppPerformance.sslResponseLatency', show: true, positioning: 0, data: [], unitType: unitTypes.time },
|
|
|
|
|
|
{ name: 'networkAppPerformance.packetLoss', show: true, positioning: 0, data: [], unitType: unitTypes.percent },
|
|
|
|
|
|
{ name: 'overall.packetRetrans', show: true, positioning: 0, data: [], unitType: unitTypes.percent }
|
2022-11-03 11:21:39 +08:00
|
|
|
|
]
|
|
|
|
|
|
}
|
2022-11-02 19:28:11 +08:00
|
|
|
|
res.data.result.forEach(t => {
|
|
|
|
|
|
if (t.type === 'sslConLatency' && val === 'sslConLatency') {
|
|
|
|
|
|
const npmQuantity = _.cloneDeep(this.npmQuantity)
|
2022-11-04 10:22:32 +08:00
|
|
|
|
npmQuantity[2].data = t.sslConLatency.values ? t.sslConLatency.values : []
|
2022-11-02 19:28:11 +08:00
|
|
|
|
npmQuantity.forEach((e, i) => {
|
2022-11-04 10:22:32 +08:00
|
|
|
|
if (i !== 2) {
|
2022-11-02 19:28:11 +08:00
|
|
|
|
e.show = false
|
|
|
|
|
|
} else {
|
|
|
|
|
|
e.show = true
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
this.npmQuantity = npmQuantity
|
2022-11-04 12:52:12 +08:00
|
|
|
|
this.echartsInit(this.npmQuantity, '(ms)')
|
2022-09-03 10:57:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
2022-08-20 14:52:55 +08:00
|
|
|
|
}
|
2022-11-02 19:28:11 +08:00
|
|
|
|
}).catch(e => {
|
|
|
|
|
|
this.isNoData = true
|
|
|
|
|
|
}).finally(() => {
|
|
|
|
|
|
this.toggleLoading(false)
|
2022-08-12 15:25:54 +08:00
|
|
|
|
})
|
|
|
|
|
|
}
|
2022-11-02 19:28:11 +08:00
|
|
|
|
}
|
2022-08-12 15:25:54 +08:00
|
|
|
|
},
|
2022-11-04 12:52:12 +08:00
|
|
|
|
echartsInit (echartsData, legendUnit) {
|
2022-09-03 10:57:59 +08:00
|
|
|
|
echartsData = echartsData.filter(t => t.show === true)
|
|
|
|
|
|
const dom = document.getElementById('chart')
|
2022-09-28 14:59:14 +08:00
|
|
|
|
!this.myChart && (this.myChart = echarts.init(dom))
|
2022-08-12 15:25:54 +08:00
|
|
|
|
this.chartOption = trafficLineChartOption
|
|
|
|
|
|
const chartOption = this.chartOption.series[0]
|
|
|
|
|
|
this.chartOption.series = echartsData.map((t, i) => {
|
2022-10-23 10:17:26 +08:00
|
|
|
|
this.chartOption.yAxis[0].axisLabel.formatter = (value) => {
|
|
|
|
|
|
if (t.unitType === 'percent') {
|
|
|
|
|
|
return unitConvert(value, t.unitType)[0]
|
|
|
|
|
|
} else if (t.unitType === 'time') {
|
|
|
|
|
|
return unitConvert(value, 'number').join('')
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return unitConvert(value, t.unitType).join('')
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-08-12 15:25:54 +08:00
|
|
|
|
return {
|
|
|
|
|
|
...chartOption,
|
2022-11-04 12:52:12 +08:00
|
|
|
|
name: this.$t(t.name) + (legendUnit || ''),
|
2022-08-12 15:25:54 +08:00
|
|
|
|
lineStyle: {
|
|
|
|
|
|
color: chartColor3[t.positioning],
|
|
|
|
|
|
width: 1
|
|
|
|
|
|
},
|
2022-08-31 13:54:20 +08:00
|
|
|
|
stack: t.name !== 'network.total' ? 'network.total' : '',
|
2022-08-12 15:25:54 +08:00
|
|
|
|
areaStyle: {
|
|
|
|
|
|
opacity: 0.1,
|
|
|
|
|
|
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
|
|
|
|
|
{
|
|
|
|
|
|
offset: 0,
|
|
|
|
|
|
color: chartColor3[t.positioning]
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
offset: 1,
|
|
|
|
|
|
color: chartColor3[t.positioning]
|
|
|
|
|
|
}
|
|
|
|
|
|
])
|
|
|
|
|
|
},
|
2022-10-20 14:41:48 +08:00
|
|
|
|
data: t.data.map(v => [Number(v[0]) * 1000, Number(v[1]), t.unitType])
|
2022-08-12 15:25:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
this.chartOption.tooltip.formatter = (params) => {
|
|
|
|
|
|
params.forEach(t => {
|
|
|
|
|
|
t.seriesName = this.$t(t.seriesName)
|
2022-10-20 11:23:32 +08:00
|
|
|
|
this.mpackets.forEach(e => {
|
|
|
|
|
|
if (this.$t(e.name) === t.seriesName) {
|
|
|
|
|
|
t.borderColor = chartColor3[e.positioning]
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
this.npmQuantity.forEach(d => {
|
2022-11-07 10:17:24 +08:00
|
|
|
|
const nameMs = this.$t(d.name) + '(ms)'
|
|
|
|
|
|
const namePrent = this.$t(d.name) + '(%)'
|
|
|
|
|
|
if (nameMs === t.seriesName) {
|
|
|
|
|
|
t.borderColor = chartColor3[d.positioning]
|
|
|
|
|
|
} else if (namePrent === t.seriesName) {
|
2022-10-20 11:23:32 +08:00
|
|
|
|
t.borderColor = chartColor3[d.positioning]
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2022-08-12 15:25:54 +08:00
|
|
|
|
})
|
2022-08-24 18:18:28 +08:00
|
|
|
|
const str = stackedLineTooltipFormatter(params)
|
2022-08-12 15:25:54 +08:00
|
|
|
|
return str
|
|
|
|
|
|
}
|
|
|
|
|
|
this.myChart.on('legendselectchanged', this.handleLegendClick)
|
2022-08-31 13:54:20 +08:00
|
|
|
|
this.myChart.setOption(this.chartOption, true)
|
2022-08-12 15:25:54 +08:00
|
|
|
|
},
|
|
|
|
|
|
// 点击前,高亮legend个数
|
|
|
|
|
|
getSelectedNum (params) {
|
|
|
|
|
|
let selectedNum = 0
|
|
|
|
|
|
const legendItem = params.selected
|
|
|
|
|
|
for (const name in legendItem) {
|
|
|
|
|
|
if (name === params.name) {
|
|
|
|
|
|
if (!legendItem[name]) {
|
|
|
|
|
|
selectedNum = selectedNum + 1
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
if (legendItem[name]) {
|
|
|
|
|
|
selectedNum = selectedNum + 1
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return selectedNum
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
// 自定义legend的点击事件:此方法只处理多条曲线的情况(单条曲线正常切换legend和曲线)
|
|
|
|
|
|
handleLegendClick (params) {
|
|
|
|
|
|
// legend点击事件
|
|
|
|
|
|
const legendNum = Object.keys(params.selected).length
|
|
|
|
|
|
const selectedNum = this.getSelectedNum(params)
|
|
|
|
|
|
|
|
|
|
|
|
const legendItem = params.selected
|
|
|
|
|
|
if (selectedNum === legendNum) { // 点击前:全部曲线高亮
|
|
|
|
|
|
for (const name in legendItem) {
|
|
|
|
|
|
if (name === params.name) {
|
|
|
|
|
|
legendItem[name] = true
|
|
|
|
|
|
} else {
|
|
|
|
|
|
legendItem[name] = false
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
} else if (selectedNum === 1 && !params.selected[params.name]) { // 点击前:多条曲线,且只有一条曲线高亮时
|
|
|
|
|
|
for (const name in legendItem) {
|
|
|
|
|
|
legendItem[name] = true
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
this.myChart.setOption({
|
|
|
|
|
|
legend: {
|
|
|
|
|
|
selected: legendItem
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2022-08-31 13:54:20 +08:00
|
|
|
|
metricChange (value) {
|
|
|
|
|
|
this.init(value)
|
|
|
|
|
|
},
|
2022-08-12 15:25:54 +08:00
|
|
|
|
resize () {
|
|
|
|
|
|
this.myChart.resize()
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
mounted () {
|
2022-08-20 14:52:55 +08:00
|
|
|
|
if (this.chart) {
|
|
|
|
|
|
this.chartData = _.cloneDeep(this.chart)
|
|
|
|
|
|
}
|
2022-08-12 15:25:54 +08:00
|
|
|
|
this.timer = setTimeout(() => {
|
|
|
|
|
|
this.init()
|
|
|
|
|
|
}, 200)
|
|
|
|
|
|
window.addEventListener('resize', this.resize)
|
|
|
|
|
|
},
|
|
|
|
|
|
beforeUnmount () {
|
|
|
|
|
|
clearTimeout(this.timer)
|
2022-08-17 10:46:10 +08:00
|
|
|
|
window.removeEventListener('resize', this.resize)
|
2022-08-12 15:25:54 +08:00
|
|
|
|
}
|
2022-08-11 15:49:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
</script>
|