mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-15 09:48:43 +00:00
update query
This commit is contained in:
parent
5678b1b506
commit
0a7e191f4e
@ -16,13 +16,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
export const queryContainers = {
|
export const queryContainers = {
|
||||||
variable: "$condition: ContainerQueryCondition",
|
variable: "$condition: OndemandContainergQueryCondition!",
|
||||||
query: `
|
query: `
|
||||||
containers: queryContainers(condition: $condition)`,
|
containers: listContainers(condition: $condition)`,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const queryStreamingLogs = {
|
export const queryStreamingLogs = {
|
||||||
variable: "$condition: OndemandLogQueryCondition!",
|
variable: "$condition: OndemandLogQueryCondition",
|
||||||
query: `
|
query: `
|
||||||
logs: ondemandPodLogs(condition: $condition) {
|
logs: ondemandPodLogs(condition: $condition) {
|
||||||
logs {
|
logs {
|
||||||
|
@ -17,6 +17,6 @@
|
|||||||
|
|
||||||
import { queryContainers, queryStreamingLogs } from "../fragments/demand-log";
|
import { queryContainers, queryStreamingLogs } from "../fragments/demand-log";
|
||||||
|
|
||||||
export const fetchContainers = `query queryContainers(${queryContainers.variable}) {${queryContainers.query}}`;
|
export const fetchContainers = `query listContainers(${queryContainers.variable}) {${queryContainers.query}}`;
|
||||||
|
|
||||||
export const fetchDemandPodLogs = `query queryStreamingLogs(${queryStreamingLogs.variable}) {${queryStreamingLogs.query}}`;
|
export const fetchDemandPodLogs = `query ondemandPodLogs(${queryStreamingLogs.variable}) {${queryStreamingLogs.query}}`;
|
||||||
|
@ -35,12 +35,12 @@ interface DemandLogState {
|
|||||||
export const demandLogStore = defineStore({
|
export const demandLogStore = defineStore({
|
||||||
id: "demandLog",
|
id: "demandLog",
|
||||||
state: (): DemandLogState => ({
|
state: (): DemandLogState => ({
|
||||||
containers: [{ label: "Detail", value: "Detail" }],
|
containers: [{ label: "istio-proxy", value: "istio-proxy" }],
|
||||||
instances: [{ value: "", label: "" }],
|
instances: [{ value: "", label: "" }],
|
||||||
conditions: {
|
conditions: {
|
||||||
container: "",
|
container: "",
|
||||||
serviceInstanceId: "",
|
serviceInstanceId: "",
|
||||||
queryDuration: useAppStoreWithOut().durationTime,
|
duration: useAppStoreWithOut().durationTime,
|
||||||
},
|
},
|
||||||
selectorStore: useSelectorStore(),
|
selectorStore: useSelectorStore(),
|
||||||
logs: [],
|
logs: [],
|
||||||
@ -66,12 +66,12 @@ export const demandLogStore = defineStore({
|
|||||||
return res.data;
|
return res.data;
|
||||||
},
|
},
|
||||||
async getContainers(serviceInstanceId: string) {
|
async getContainers(serviceInstanceId: string) {
|
||||||
if (!this.selectorStore.currentService) {
|
if (!serviceInstanceId) {
|
||||||
return new Promise((resolve) => resolve({ errors: "No service" }));
|
return new Promise((resolve) =>
|
||||||
|
resolve({ errors: "No service instance" })
|
||||||
|
);
|
||||||
}
|
}
|
||||||
const serviceId = this.selectorStore.currentService.id;
|
|
||||||
const condition = {
|
const condition = {
|
||||||
serviceId,
|
|
||||||
serviceInstanceId,
|
serviceInstanceId,
|
||||||
};
|
};
|
||||||
const res: AxiosResponse = await graphql
|
const res: AxiosResponse = await graphql
|
||||||
@ -81,10 +81,7 @@ export const demandLogStore = defineStore({
|
|||||||
if (res.data.errors) {
|
if (res.data.errors) {
|
||||||
return res.data;
|
return res.data;
|
||||||
}
|
}
|
||||||
this.containers =
|
this.containers = [{ label: "istio-proxy", value: "istio-proxy" }];
|
||||||
res.data.data.containers.containers.map((d: string) => {
|
|
||||||
return { label: d, value: d };
|
|
||||||
}) || [];
|
|
||||||
return res.data;
|
return res.data;
|
||||||
},
|
},
|
||||||
async getDemandLogs() {
|
async getDemandLogs() {
|
||||||
|
@ -19,7 +19,7 @@ import { DurationTime } from "./app";
|
|||||||
export interface Conditions {
|
export interface Conditions {
|
||||||
container: string;
|
container: string;
|
||||||
serviceInstanceId: string;
|
serviceInstanceId: string;
|
||||||
queryDuration: DurationTime;
|
duration: DurationTime;
|
||||||
keywordsOfContent?: string[];
|
keywordsOfContent?: string[];
|
||||||
excludingKeywordsOfContent?: string;
|
excludingKeywordsOfContent?: string;
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ limitations under the License. -->
|
|||||||
class="selectors"
|
class="selectors"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="mr-5 mb-5">
|
<div class="mr-5 mb-5" v-if="state.container">
|
||||||
<span class="grey mr-5">{{ t("container") }}:</span>
|
<span class="grey mr-5">{{ t("container") }}:</span>
|
||||||
<Selector
|
<Selector
|
||||||
size="small"
|
size="small"
|
||||||
@ -41,7 +41,7 @@ limitations under the License. -->
|
|||||||
<el-input-number
|
<el-input-number
|
||||||
v-model="limit"
|
v-model="limit"
|
||||||
:min="1"
|
:min="1"
|
||||||
:max="100"
|
:max="1000"
|
||||||
size="small"
|
size="small"
|
||||||
controls-position="right"
|
controls-position="right"
|
||||||
@change="changeField('limit', $event)"
|
@change="changeField('limit', $event)"
|
||||||
@ -132,7 +132,7 @@ limitations under the License. -->
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, reactive, watch, computed } from "vue";
|
import { ref, reactive, watch, computed, onMounted } from "vue";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
import { useDemandLogStore } from "@/store/modules/demand-log";
|
import { useDemandLogStore } from "@/store/modules/demand-log";
|
||||||
import { useDashboardStore } from "@/store/modules/dashboard";
|
import { useDashboardStore } from "@/store/modules/dashboard";
|
||||||
@ -157,7 +157,7 @@ const limit = ref<number>(1);
|
|||||||
const intervalTime = ref<number>(1);
|
const intervalTime = ref<number>(1);
|
||||||
const state = reactive<any>({
|
const state = reactive<any>({
|
||||||
instance: { value: "", label: "" },
|
instance: { value: "", label: "" },
|
||||||
container: { value: "", label: "None" },
|
container: { value: "", label: "" },
|
||||||
duration: { label: "Last 30 min", value: 1800 },
|
duration: { label: "Last 30 min", value: 1800 },
|
||||||
});
|
});
|
||||||
/*global Nullable */
|
/*global Nullable */
|
||||||
@ -178,26 +178,30 @@ const rangeTime = computed(() => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
init();
|
onMounted(() => {
|
||||||
async function init() {
|
|
||||||
fetchSelectors();
|
fetchSelectors();
|
||||||
await searchLogs();
|
});
|
||||||
}
|
|
||||||
async function fetchSelectors() {
|
async function fetchSelectors() {
|
||||||
if (dashboardStore.entity === EntityType[3].value) {
|
if (dashboardStore.entity !== EntityType[3].value) {
|
||||||
state.instance = this.selectorStore.currentInstance || {};
|
|
||||||
} else {
|
|
||||||
await getInstances();
|
await getInstances();
|
||||||
}
|
}
|
||||||
getContainers();
|
getContainers();
|
||||||
|
if (intervalFn.value) {
|
||||||
|
clearInterval(intervalFn.value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async function getContainers() {
|
async function getContainers() {
|
||||||
const resp = await demandLogStore.getContainers(state.instance.id || "");
|
const resp = await demandLogStore.getContainers(
|
||||||
|
state.instance.id || selectorStore.currentPod.id || ""
|
||||||
|
);
|
||||||
if (resp.errors) {
|
if (resp.errors) {
|
||||||
ElMessage.error(resp.errors);
|
ElMessage.error(resp.errors);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
state.container = demandLogStore.containers[0];
|
if (demandLogStore.containers.length) {
|
||||||
|
state.container = demandLogStore.containers[0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async function getInstances() {
|
async function getInstances() {
|
||||||
const resp = await demandLogStore.getInstances();
|
const resp = await demandLogStore.getInstances();
|
||||||
@ -212,22 +216,27 @@ function runInterval() {
|
|||||||
clearInterval(intervalFn.value);
|
clearInterval(intervalFn.value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
searchLogs();
|
||||||
intervalFn.value = setInterval(searchLogs, intervalTime.value * 1000);
|
intervalFn.value = setInterval(searchLogs, intervalTime.value * 1000);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
clearInterval(intervalFn.value);
|
clearInterval(intervalFn.value);
|
||||||
}, state.duration * 1000);
|
}, state.duration * 1000);
|
||||||
}
|
}
|
||||||
function searchLogs() {
|
function searchLogs() {
|
||||||
let instance = "";
|
let instance = state.instance.id;
|
||||||
if (dashboardStore.entity === EntityType[3].value) {
|
if (dashboardStore.entity === EntityType[3].value) {
|
||||||
instance = selectorStore.currentPod.id;
|
instance = selectorStore.currentPod.id;
|
||||||
}
|
}
|
||||||
demandLogStore.setLogCondition({
|
demandLogStore.setLogCondition({
|
||||||
serviceInstanceId: instance || state.instance.id || "",
|
serviceInstanceId: instance || state.instance.id || "",
|
||||||
container: state.container.value,
|
container: state.container.value,
|
||||||
queryDuration: rangeTime.value,
|
duration: rangeTime.value,
|
||||||
keywordsOfContent: keywordsOfContent.value,
|
keywordsOfContent: keywordsOfContent.value.length
|
||||||
excludingKeywordsOfContent: excludingKeywordsOfContent.value,
|
? keywordsOfContent.value
|
||||||
|
: undefined,
|
||||||
|
excludingKeywordsOfContent: excludingKeywordsOfContent.value.length
|
||||||
|
? excludingKeywordsOfContent.value
|
||||||
|
: undefined,
|
||||||
});
|
});
|
||||||
queryLogs();
|
queryLogs();
|
||||||
}
|
}
|
||||||
@ -244,6 +253,9 @@ function changeField(type: string, opt: any) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
state[type] = opt[0];
|
state[type] = opt[0];
|
||||||
|
if (type === "instance") {
|
||||||
|
getContainers();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
function removeContent(index: number) {
|
function removeContent(index: number) {
|
||||||
const keywordsOfContentList = keywordsOfContent.value || [];
|
const keywordsOfContentList = keywordsOfContent.value || [];
|
||||||
@ -288,7 +300,7 @@ watch(
|
|||||||
() => selectorStore.currentService,
|
() => selectorStore.currentService,
|
||||||
() => {
|
() => {
|
||||||
if (dashboardStore.entity === EntityType[0].value) {
|
if (dashboardStore.entity === EntityType[0].value) {
|
||||||
init();
|
fetchSelectors();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -296,7 +308,7 @@ watch(
|
|||||||
() => [selectorStore.currentPod],
|
() => [selectorStore.currentPod],
|
||||||
() => {
|
() => {
|
||||||
if (dashboardStore.entity === EntityType[3].value) {
|
if (dashboardStore.entity === EntityType[3].value) {
|
||||||
init();
|
fetchSelectors();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user