Skip to content

Commit d65c18b

Browse files
authored
feat: add queries for alarm tags (#417)
1 parent a5b0acd commit d65c18b

File tree

7 files changed

+56
-17
lines changed

7 files changed

+56
-17
lines changed

src/graphql/fragments/alarm.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,14 @@ export const Alarm = {
4646
}
4747
}`,
4848
};
49+
export const AlarmTagKeys = {
50+
variable: "$duration: Duration!",
51+
query: `
52+
tagKeys: queryAlarmTagAutocompleteKeys(duration: $duration)`,
53+
};
54+
55+
export const AlarmTagValues = {
56+
variable: "$tagKey: String!, $duration: Duration!",
57+
query: `
58+
tagValues: queryAlarmTagAutocompleteValues(tagKey: $tagKey, duration: $duration)`,
59+
};

src/graphql/query/alarm.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { Alarm } from "../fragments/alarm";
18+
import { Alarm, AlarmTagKeys, AlarmTagValues } from "../fragments/alarm";
1919

2020
export const queryAlarms = `query queryAlarms(${Alarm.variable}) {${Alarm.query}}`;
21+
export const queryAlarmTagValues = `query queryTagValues(${AlarmTagValues.variable}) {${AlarmTagValues.query}}`;
22+
export const queryAlarmTagKeys = `query queryTagKeys(${AlarmTagKeys.variable}) {${AlarmTagKeys.query}}`;

src/store/modules/alarm.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { store } from "@/store";
1919
import graphql from "@/graphql";
2020
import type { AxiosResponse } from "axios";
2121
import type { Alarm } from "@/types/alarm";
22+
import { useAppStoreWithOut } from "@/store/modules/app";
2223

2324
interface AlarmState {
2425
loading: boolean;
@@ -35,7 +36,9 @@ export const alarmStore = defineStore({
3536
}),
3637
actions: {
3738
async getAlarms(params: Recordable) {
39+
this.loading = true;
3840
const res: AxiosResponse = await graphql.query("queryAlarms").params(params);
41+
this.loading = false;
3942
if (res.data.errors) {
4043
return res.data;
4144
}
@@ -45,6 +48,20 @@ export const alarmStore = defineStore({
4548
}
4649
return res.data;
4750
},
51+
async getAlarmTagKeys() {
52+
const res: AxiosResponse = await graphql
53+
.query("queryAlarmTagKeys")
54+
.params({ duration: useAppStoreWithOut().durationTime });
55+
56+
return res.data;
57+
},
58+
async getAlarmTagValues(tagKey: string) {
59+
const res: AxiosResponse = await graphql
60+
.query("queryAlarmTagValues")
61+
.params({ tagKey, duration: useAppStoreWithOut().durationTime });
62+
63+
return res.data;
64+
},
4865
},
4966
});
5067

src/views/alarm/Content.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
See the License for the specific language governing permissions and
1414
limitations under the License. -->
1515
<template>
16-
<div class="timeline-table clear">
16+
<div class="timeline-table clear" v-loading="alarmStore.loading">
1717
<div v-for="(i, index) in alarmStore.alarms" :key="index" class="clear timeline-item">
1818
<div class="g-sm-3 grey sm hide-xs time-line tr">
1919
{{ dateFormat(parseInt(i.startTime)) }}
@@ -132,7 +132,7 @@ limitations under the License. -->
132132
currentDetail.value = item;
133133
currentEvents.value = item.events;
134134
alarmTags.value = currentDetail.value.tags.map((d: { key: string; value: string }) => {
135-
return `${d.key} = ${d.value}`;
135+
return `${d.key}=${d.value}`;
136136
});
137137
}
138138

src/views/components/ConditionTags.vue

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,7 @@ limitations under the License. -->
2121
<span class="remove-icon" @click="removeTags(index)">×</span>
2222
</span>
2323
</span>
24-
<el-input
25-
v-if="type === 'ALARM'"
26-
size="small"
27-
v-model="tags"
28-
class="trace-new-tag"
29-
@change="addLabels"
30-
:placeholder="t('addTags')"
31-
/>
32-
<el-popover v-else trigger="click" :visible="visible" width="300px">
24+
<el-popover trigger="click" :visible="visible" width="300px">
3325
<template #reference>
3426
<el-input
3527
size="small"
@@ -47,7 +39,7 @@ limitations under the License. -->
4739
</span>
4840
</div>
4941
</el-popover>
50-
<span class="tags-tip" :class="type !== 'ALARM' && tagArr.length ? 'link-tips' : ''">
42+
<span class="tags-tip" :class="tagArr.length ? 'link-tips' : ''">
5143
<a
5244
target="blank"
5345
href="https://github.com/apache/skywalking/blob/master/docs/en/setup/backend/configuration-vocabulary.md"
@@ -68,6 +60,7 @@ limitations under the License. -->
6860
import { useI18n } from "vue-i18n";
6961
import { useTraceStore } from "@/store/modules/trace";
7062
import { useLogStore } from "@/store/modules/log";
63+
import { useAlarmStore } from "@/store/modules/alarm";
7164
import { ElMessage } from "element-plus";
7265
import { useAppStoreWithOut } from "@/store/modules/app";
7366
@@ -79,6 +72,7 @@ limitations under the License. -->
7972
const traceStore = useTraceStore();
8073
const logStore = useLogStore();
8174
const appStore = useAppStoreWithOut();
75+
const alarmStore = useAlarmStore();
8276
const { t } = useI18n();
8377
const tags = ref<string>("");
8478
const tagsList = ref<string[]>([]);
@@ -121,10 +115,18 @@ limitations under the License. -->
121115
let resp: Recordable = {};
122116
if (props.type === "TRACE") {
123117
resp = await traceStore.getTagKeys();
124-
} else {
118+
}
119+
if (props.type === "LOG") {
125120
resp = await logStore.getLogTagKeys();
126121
}
127122
123+
if (props.type === "ALARM") {
124+
resp = await alarmStore.getAlarmTagKeys();
125+
}
126+
127+
if (!resp.data) {
128+
return;
129+
}
128130
if (resp.errors) {
129131
ElMessage.error(resp.errors);
130132
return;
@@ -140,10 +142,17 @@ limitations under the License. -->
140142
let resp: Recordable = {};
141143
if (props.type === "TRACE") {
142144
resp = await traceStore.getTagValues(param);
143-
} else {
145+
}
146+
if (props.type === "LOG") {
144147
resp = await logStore.getLogTagValues(param);
145148
}
149+
if (props.type === "ALARM") {
150+
resp = await alarmStore.getAlarmTagValues(param);
151+
}
146152
153+
if (!resp.data) {
154+
return;
155+
}
147156
if (resp.errors) {
148157
ElMessage.error(resp.errors);
149158
return;

src/views/dashboard/related/log/LogTable/LogDetail.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ limitations under the License. -->
5050
return [];
5151
}
5252
return props.currentLog.tags.map((d: { key: string; value: string }) => {
53-
return `${d.key} = ${d.value}`;
53+
return `${d.key}=${d.value}`;
5454
});
5555
});
5656

src/views/dashboard/related/trace/components/D3Graph/SpanDetail.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ limitations under the License. -->
110110
<div>
111111
<span class="grey title">Tags:</span>
112112
<div class="mb-5" v-for="(tag, index) in currentEvent.tags || []" :key="index" style="white-space: pre-wrap">
113-
{{ tag.key + "=" + tag.value }};
113+
{{ `${tag.key}=${tag.value}` }};
114114
</div>
115115
</div>
116116
</div>

0 commit comments

Comments
 (0)