diff --git a/nezha-fronted/src/components/charts/chart-list-group.vue b/nezha-fronted/src/components/charts/chart-list-group.vue index f43eaeeb2..33ad09b4f 100644 --- a/nezha-fronted/src/components/charts/chart-list-group.vue +++ b/nezha-fronted/src/components/charts/chart-list-group.vue @@ -734,7 +734,7 @@ export default { this.$nextTick(() => { const axiosArr = chartItem.elements.map((ele) => { const filterItem = ele - let query = filterItem.expression + let query = escape(filterItem.expression) if ((chartInfo.type === 'line' || chartInfo.type === 'bar' || chartInfo.type === 'stackArea' || chartInfo.type === 'table') && chartInfo.param) { // 如果是这三个 默认给null chartInfo.param.nullType = chartInfo.param.nullType || 'null' query += '&nullType=' + chartInfo.param.nullType @@ -749,7 +749,7 @@ export default { if (chartInfo.type == 'logs') { return chartTempData } - return this.$get('/prom/api/v1/query_range?query=' + escape(query) + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step) + return this.$get('/prom/api/v1/query_range?query=' + query + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step) }) // 一个图表的所有element单独获取数据 axios.all(axiosArr).then((res) => { @@ -1227,12 +1227,12 @@ export default { const endTime = bus.timeFormate(now, 'yyyy-MM-dd hh:mm:ss') // const step = bus.getStep(startTime, endTime) this.$nextTick(() => { - let query = chartInfo.elements[0].expression + let query = escape(chartInfo.elements[0].expression) if ((chartInfo.type === 'line' || chartInfo.type === 'bar' || chartInfo.type === 'stackArea') && chartInfo.param) { chartInfo.param.nullType = chartInfo.param.nullType || 'null' query += '&nullType=' + chartInfo.param.nullType } - this.$get('/prom/api/v1/query_range?query=' + escape(query) + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=5m').then(response => { + this.$get('/prom/api/v1/query_range?query=' + query + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=5m').then(response => { if (response.status === 'success') { if (response.data.result) { const series = { diff --git a/nezha-fronted/src/components/charts/chart-list.vue b/nezha-fronted/src/components/charts/chart-list.vue index 3831de841..91dd9beb5 100644 --- a/nezha-fronted/src/components/charts/chart-list.vue +++ b/nezha-fronted/src/components/charts/chart-list.vue @@ -1004,7 +1004,7 @@ export default { this.$nextTick(() => { const axiosArr = chartItem.elements.map((ele) => { const filterItem = ele - let query = filterItem.expression + let query = escape(filterItem.expression) if ((chartInfo.type === 'line' || chartInfo.type === 'bar' || chartInfo.type === 'stackArea' || chartInfo.type === 'table') && chartInfo.param) { // 如果是这三个 默认给null chartInfo.param.nullType = chartInfo.param.nullType || 'null' query += '&nullType=' + chartInfo.param.nullType @@ -1018,7 +1018,7 @@ export default { if (chartInfo.type == 'logs') { return chartTempData } - return this.$get('/prom/api/v1/query_range?query=' + escape(query) + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step) + return this.$get('/prom/api/v1/query_range?query=' + query + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step) }) // 一个图表的所有element单独获取数据 axios.all(axiosArr).then((res) => { diff --git a/nezha-fronted/src/components/charts/chartPreview.vue b/nezha-fronted/src/components/charts/chartPreview.vue index 5bc4f3060..00850d551 100644 --- a/nezha-fronted/src/components/charts/chartPreview.vue +++ b/nezha-fronted/src/components/charts/chartPreview.vue @@ -418,7 +418,7 @@ export default { this.$nextTick(() => { const axiosArr = chartItem.elements.map((ele) => { const filterItem = ele - const query = filterItem.expression + const query = escape(filterItem.expression) // if(chartItem.type === 'table'&&chartItem.param&&chartItem.param.last == 1){ // return this.$get('/prom/api/v1/query_range?query=' + query + "&start=" + this.$stringTimeParseToUnix(endTime) + "&end=" + this.$stringTimeParseToUnix(endTime) + '&step=' + step); // } @@ -427,7 +427,7 @@ export default { chartItem.param.nullType = chartItem.param.nullType || 'null' str += '&nullType=' + chartItem.param.nullType } - return this.$get('/prom/api/v1/query_range?query=' + escape(query) + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step + str) + return this.$get('/prom/api/v1/query_range?query=' + query + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step + str) }) // 一个图表的所有element单独获取数据 axios.all(axiosArr).then((res) => { @@ -1662,16 +1662,16 @@ export default { const step = bus.getStep(startTime, endTime) axiosArr = this.chart.elements.map((ele) => { const filterItem = ele - const query = filterItem.expression + const query = escape(filterItem.expression) let str = '' if ((chartItem.type === 'line' || chartItem.type === 'bar' || chartItem.type === 'stackArea' || chartItem.type === 'table') && chartItem.param) { // 如果是这三个 默认给null chartItem.param.nullType = chartItem.param.nullType || 'null' str += '&nullType=' + chartItem.param.nullType } if (chartItem.type === 'table' && chartItem.param && chartItem.param.last == 1) { - return this.$get('/prom/api/v1/query_range?query=' + escape(query) + '&start=' + this.$stringTimeParseToUnix(endTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step + str) + return this.$get('/prom/api/v1/query_range?query=' + query + '&start=' + this.$stringTimeParseToUnix(endTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step + str) } - return this.$get('/prom/api/v1/query_range?query=' + escape(query) + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step + str) + return this.$get('/prom/api/v1/query_range?query=' + query + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step + str) }) // 一个图表 axios.all(axiosArr).then(res => { diff --git a/nezha-fronted/src/components/charts/line-chart-block.vue b/nezha-fronted/src/components/charts/line-chart-block.vue index ad0f38ca0..a5440d477 100644 --- a/nezha-fronted/src/components/charts/line-chart-block.vue +++ b/nezha-fronted/src/components/charts/line-chart-block.vue @@ -1645,44 +1645,44 @@ export default { if (type === 'list') { // 普通模式,主控台使用 axiosArr = this.data.elements.map((ele) => { const filterItem = ele - let query = filterItem.expression + let query = escape(filterItem.expression) if (this.chartInfo.type === 'line' || this.chartInfo.type === 'bar' || this.chartInfo.type === 'stackArea') { // 如果是这三个 默认给null !this.chartInfo.param && (this.chartInfo.param = {}) this.chartInfo.param.nullType = this.chartInfo.param.nullType || 'null' query += '&nullType=' + this.chartInfo.param.nullType } - return this.$get('/prom/api/v1/query_range?query=' + escape(query) + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step) + return this.$get('/prom/api/v1/query_range?query=' + query + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step) }) if (this.$refs.pickTime.$refs.multipleTime && this.$refs.pickTime.$refs.multipleTime.searchTime.length) { // 判断是否需要添加比较 startTime = bus.timeFormate(this.$refs.pickTime.$refs.multipleTime.searchTime[0], 'yyyy-MM-dd hh:mm:ss') endTime = bus.timeFormate(this.$refs.pickTime.$refs.multipleTime.searchTime[1], 'yyyy-MM-dd hh:mm:ss') this.data.elements.forEach((ele) => { const filterItem = ele - let query = filterItem.expression + let query = escape(filterItem.expression) if (this.chartInfo.type === 'line' || this.chartInfo.type === 'bar' || this.chartInfo.type === 'stackArea') { // 如果是这三个 默认给null !this.chartInfo.param && (this.chartInfo.param = {}) this.chartInfo.param.nullType = this.chartInfo.param.nullType || 'null' query += '&nullType=' + this.chartInfo.param.nullType } - axiosArr.push(this.$get('/prom/api/v1/query_range?query=' + escape(query) + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step)) + axiosArr.push(this.$get('/prom/api/v1/query_range?query=' + query + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step)) }) } } else if (type === 'dashboard') { // 概览模式,指标概览中使用 // 概览模式,需要区分单独一个和多个 if (this.stableFilter.chartCount === 'multiple') { - let query = this.data.name + let query = escape(this.data.name) if (this.chartInfo.type === 'line' || this.chartInfo.type === 'bar' || this.chartInfo.type === 'stackArea') { // 如果是这三个 默认给null this.chartInfo.param.nullType = this.chartInfo.param.nullType || 'null' query += '&nullType=' + this.chartInfo.param.nullType } - axiosArr = [this.$get('/prom/api/v1/query_range?query=' + escape(query) + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step)] + axiosArr = [this.$get('/prom/api/v1/query_range?query=' + query + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step)] } else { - let query = this.data.elements[0].expression + let query = escape(this.data.elements[0].expression) if (this.chartInfo.type === 'line' || this.chartInfo.type === 'bar' || this.chartInfo.type === 'stackArea') { // 如果是这三个 默认给null this.chartInfo.param.nullType = this.chartInfo.param.nullType || 'null' query += '&nullType=' + this.chartInfo.param.nullType } - axiosArr = [this.$get('/prom/api/v1/query_range?query=' + escape(query) + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step)] + axiosArr = [this.$get('/prom/api/v1/query_range?query=' + query+ '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step)] } } // 一个图表 diff --git a/nezha-fronted/src/components/common/ChartDiagram/diagram.vue b/nezha-fronted/src/components/common/ChartDiagram/diagram.vue index 092811c10..347f7aef6 100644 --- a/nezha-fronted/src/components/common/ChartDiagram/diagram.vue +++ b/nezha-fronted/src/components/common/ChartDiagram/diagram.vue @@ -681,8 +681,9 @@ export default { resolve({ data: '', status: 'no query' }) }) } + query = escape(query) query += '&nullType=' + 'null' - return this.$get('/prom/api/v1/query_range?query=' + escape(query) + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step) + return this.$get('/prom/api/v1/query_range?query=' + query + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step) }) } axiosArr.push({ item, arr }) diff --git a/nezha-fronted/src/components/common/project/L5/topoTooltip.vue b/nezha-fronted/src/components/common/project/L5/topoTooltip.vue index d7e8bbb59..54d424123 100644 --- a/nezha-fronted/src/components/common/project/L5/topoTooltip.vue +++ b/nezha-fronted/src/components/common/project/L5/topoTooltip.vue @@ -137,7 +137,7 @@ export default { this.$nextTick(() => { const axiosArr = chartItem.elements.map((ele) => { const filterItem = ele - let query = filterItem.expression + let query = escape(filterItem.expression) if ((chartInfo.type === 'line' || chartInfo.type === 'bar' || chartInfo.type === 'stackArea' || chartInfo.type === 'table') && chartInfo.param) { // 如果是这三个 默认给null chartInfo.param.nullType = chartInfo.param.nullType || 'null' query += '&nullType=' + chartInfo.param.nullType @@ -148,7 +148,7 @@ export default { if (this.from === fromRoute.chartTemp) { return chartTempData } - return this.$get('/prom/api/v1/query_range?query=' + escape(query) + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step) + return this.$get('/prom/api/v1/query_range?query=' + query + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step) }) // 一个图表的所有element单独获取数据 axios.all(axiosArr).then((res) => { diff --git a/nezha-fronted/src/components/common/project/topologyL5.vue b/nezha-fronted/src/components/common/project/topologyL5.vue index 5febe6186..5190c56cc 100644 --- a/nezha-fronted/src/components/common/project/topologyL5.vue +++ b/nezha-fronted/src/components/common/project/topologyL5.vue @@ -686,8 +686,9 @@ export default { resolve({ data: '', status: 'no query' }) }) } + query = escape(query) query += '&nullType=' + 'null' - return this.$get('/prom/api/v1/query_range?query=' + escape(query) + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step) + return this.$get('/prom/api/v1/query_range?query=' + query + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step) }) } axiosArr.push({ item, arr })