{{$t('overall.time')}}
{{utcTimeToTimezoneStr(row.date)}}
+
+ {{aliasLegend(row)}}
+
@@ -78,7 +85,11 @@ export default {
name: 'logTab',
props: {
logData: Array,
- tabIndex: Number
+ tabIndex: Number,
+ showSwitch: {
+ type: Boolean,
+ default: true
+ }
},
computed: {
tableTimeFormat () {
@@ -406,6 +417,52 @@ export default {
},
resizeChart () {
this.myChart.resize()
+ },
+ aliasLegend (row) {
+ let host = ''// up,
+ let alias = ''
+ if (row.labels && Object.keys(row.labels).length > 0) {
+ const metric = Object.keys(row.labels)
+ if (metric.__name__) {
+ host = `${metric.__name__}{`// up,
+ }
+ metric.forEach((tag, i) => {
+ if (tag !== '__name__') {
+ host += `${tag}="${row.labels[tag]}",`
+ }
+ })
+ if (host.endsWith(',')) {
+ host = host.substr(0, host.length - 1)
+ }
+ if (metric.__name__) {
+ host += '}'
+ }
+ // 处理legend别名
+ alias = this.dealLegendAlias(host, row.elements.legend)
+ if (!alias || alias === '') {
+ alias = host
+ }
+ } else {
+ alias = row.elements.legend
+ }
+ return alias
+ },
+ dealLegendAlias: function (legend, expression) {
+ if (/\{\{.+\}\}/.test(expression)) {
+ const labelValue = expression.replace(/(\{\{.+?\}\})/g, function (i) {
+ const label = i.substr(i.indexOf('{{') + 2, i.indexOf('}}') - i.indexOf('{{') - 2)
+ const reg = new RegExp(label + '=".+?"')
+ let value = null
+ if (reg.test(legend)) {
+ const find = legend.match(reg)[0]
+ value = find.substr(find.indexOf('"') + 1, find.lastIndexOf('"') - find.indexOf('"') - 1)
+ }
+ return value || label
+ })
+ return labelValue
+ } else {
+ return expression
+ }
}
},
watch: {
diff --git a/nezha-fronted/src/components/page/dashboard/metricSet.vue b/nezha-fronted/src/components/page/dashboard/metricSet.vue
index 5aff83f06..3656cc8a4 100644
--- a/nezha-fronted/src/components/page/dashboard/metricSet.vue
+++ b/nezha-fronted/src/components/page/dashboard/metricSet.vue
@@ -176,7 +176,6 @@ export default {
saveChart () { // 新增chart
this.$refs.addChartModal.setTitle(this.$t('dashboard.panel.createChartTitle'))
this.$refs.addChartModal.show(true)
- // console.log('1_+_+_+_+_+_+',JSON.stringify(this.metricInfo));
this.$refs.addChartModal.createData(-1, this.metricInfo)
},
// 删除指标,第一步, 新方法
diff --git a/nezha-fronted/src/store/index.js b/nezha-fronted/src/store/index.js
index 41476e79d..5c4c962a9 100644
--- a/nezha-fronted/src/store/index.js
+++ b/nezha-fronted/src/store/index.js
@@ -62,7 +62,6 @@ const store = new Vuex.Store({
return state.showTopoScreen
},
getLogo (state) {
- // console.log('get logo', state)
return state.logo
},
getIsShrink (state) {
@@ -142,7 +141,6 @@ const store = new Vuex.Store({
state.showTopoScreen = boolean
},
setLogo (state, logo) {
- // console.log('set log', logo)
state.logo = logo
},
isShrink (state) {
diff --git a/nezha-fronted/static/config.json b/nezha-fronted/static/config.json
index 5f74f5d01..864f961ff 100644
--- a/nezha-fronted/static/config.json
+++ b/nezha-fronted/static/config.json
@@ -1 +1 @@
-{"baseUrl":"/", "version": "21.04"}
+{"baseUrl":"http://192.168.40.42:8080/nz-admin/", "version": "21.04"}