summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nezha-fronted/package-lock.json9
-rw-r--r--nezha-fronted/package.json1
-rw-r--r--nezha-fronted/src/assets/css/components/page/dashboard/explore/queryPrompt.scss2
-rw-r--r--nezha-fronted/src/components/chart/logContext.vue18
4 files changed, 22 insertions, 8 deletions
diff --git a/nezha-fronted/package-lock.json b/nezha-fronted/package-lock.json
index be7d108b9..7e16b4037 100644
--- a/nezha-fronted/package-lock.json
+++ b/nezha-fronted/package-lock.json
@@ -7531,6 +7531,11 @@
"resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz",
"integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ=="
},
+ "bignumber.js": {
+ "version": "9.1.2",
+ "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.1.2.tgz",
+ "integrity": "sha512-2/mKyZH9K85bzOEfhXDBFZTGd1CTs+5IHpeFQo9luiBG7hghdC851Pj2WAhb6E3R6b9tZj/XKhbg4fum+Kepug=="
+ },
"binary-extensions": {
"version": "1.13.1",
"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.13.1.tgz",
@@ -17727,7 +17732,7 @@
},
"node-sass": {
"version": "4.14.1",
- "resolved": "https://registry.npmjs.org/node-sass/-/node-sass-4.14.1.tgz",
+ "resolved": "https://registry.npmmirror.com/node-sass/-/node-sass-4.14.1.tgz",
"integrity": "sha512-sjCuOlvGyCJS40R8BscF5vhVlQjNN069NtQ1gSxyK1u9iqvn6tf7O1R4GNowVZfiZUCRt5MmMs1xd+4V/7Yr0g==",
"dev": true,
"requires": {
@@ -24359,7 +24364,7 @@
},
"webpack-bundle-analyzer": {
"version": "2.13.1",
- "resolved": "https://registry.npmjs.org/webpack-bundle-analyzer/-/webpack-bundle-analyzer-2.13.1.tgz",
+ "resolved": "https://registry.npmmirror.com/webpack-bundle-analyzer/-/webpack-bundle-analyzer-2.13.1.tgz",
"integrity": "sha512-rwxyfecTAxoarCC9VlHlIpfQCmmJ/qWD5bpbjkof+7HrNhTNZIwZITxN6CdlYL2axGmwNUQ+tFgcSOiNXMf/sQ==",
"dev": true,
"requires": {
diff --git a/nezha-fronted/package.json b/nezha-fronted/package.json
index e4cd21695..75c0ed203 100644
--- a/nezha-fronted/package.json
+++ b/nezha-fronted/package.json
@@ -56,6 +56,7 @@
"axios": "^0.19.0",
"babel-loader": "^8.3.0",
"babel-preset-mobx": "^2.0.0",
+ "bignumber.js": "^9.1.2",
"browserslist": "^4.21.4",
"caniuse-lite": "^1.0.30001412",
"css-minimizer-webpack-plugin": "^1.0.0",
diff --git a/nezha-fronted/src/assets/css/components/page/dashboard/explore/queryPrompt.scss b/nezha-fronted/src/assets/css/components/page/dashboard/explore/queryPrompt.scss
index 940b121bf..72a507781 100644
--- a/nezha-fronted/src/assets/css/components/page/dashboard/explore/queryPrompt.scss
+++ b/nezha-fronted/src/assets/css/components/page/dashboard/explore/queryPrompt.scss
@@ -49,7 +49,7 @@
.log-content-left-label, .log-content-right-value{
height: 32px;
line-height: 32px;
- text-transform: capitalize;
+ // text-transform: capitalize;
box-sizing: border-box;
padding: 0 8px 0 20px;
display: flex;
diff --git a/nezha-fronted/src/components/chart/logContext.vue b/nezha-fronted/src/components/chart/logContext.vue
index c3c569d8f..3bf210e87 100644
--- a/nezha-fronted/src/components/chart/logContext.vue
+++ b/nezha-fronted/src/components/chart/logContext.vue
@@ -92,6 +92,8 @@
<script>
import copy from '@/components/common/copy'
import axios from 'axios'
+// 引入 BigNumber 库
+import BigNumber from 'bignumber.js'
export default {
name: 'logContext',
components: { copy },
@@ -123,13 +125,19 @@ export default {
methods: {
queryContext () {
this.loading = true
- const beforDate = this.rowData.secondTime - 2 * 60 * 60 // 向前查两个小时
- const nowDate = this.rowData.secondTime
- const afterDate = this.rowData.secondTime + 2 * 60 * 60 // 向后查两个小时
+ const twoHours = 2 * 60 * 60 * 1000 * 1000 // 纳秒
+ const bigNum = new BigNumber(this.rowData.timestamp)
+
+ const beforStart = bigNum.minus(twoHours) // 向前查两个小时
+ const beforEnd = this.rowData.timestamp
+
+ const afterStart = bigNum.plus(1) // start加一纳秒 防止出现重复数据
+ const afterEnd = bigNum.plus(twoHours) // 向后查两个小时
+
const requestArr = []
const expr = this.getExpression()
- requestArr.push(this.$get('/logs/loki/api/v1/query_range?format=1&query=' + encodeURIComponent(expr) + '&start=' + nowDate + '&end=' + afterDate + '&limit=' + this.lines + '&direction=forward')) // after
- requestArr.push(this.$get('/logs/loki/api/v1/query_range?format=1&query=' + encodeURIComponent(expr) + '&start=' + beforDate + '&end=' + nowDate + '&limit=' + this.lines + '&direction=backward')) // befor
+ requestArr.push(this.$get('/logs/loki/api/v1/query_range?format=1&query=' + encodeURIComponent(expr) + '&start=' + afterStart + '&end=' + afterEnd + '&limit=' + this.lines + '&direction=forward')) // after
+ requestArr.push(this.$get('/logs/loki/api/v1/query_range?format=1&query=' + encodeURIComponent(expr) + '&start=' + beforStart + '&end=' + beforEnd + '&limit=' + this.lines + '&direction=backward')) // befor
Promise.all(requestArr).then(res => {
const logData = res.map(r => r.data)
this.beforeLength = logData[1].result.length