mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-07-13 22:05:25 +00:00
update graphql and add namespace
This commit is contained in:
parent
5c961c5ead
commit
96b7662e23
@ -14,19 +14,20 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
export const queryNamespaces = {
|
||||||
|
query: `namespaces: listNamespaces`,
|
||||||
|
};
|
||||||
|
|
||||||
export const queryContainers = {
|
export const queryContainers = {
|
||||||
variable: "$condition: ContainerQueryCondition",
|
variable: "$condition: ContainerQueryCondition",
|
||||||
query: `
|
query: `
|
||||||
containers: queryContainers(condition: $condition) {
|
containers: queryContainers(condition: $condition)`,
|
||||||
containers
|
|
||||||
}`,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const queryStreamingLogs = {
|
export const queryStreamingLogs = {
|
||||||
variable: "$condition: StreamingLogQueryCondition!",
|
variable: "$condition: OndemandLogQueryCondition!",
|
||||||
query: `
|
query: `
|
||||||
logs: queryStreamingLogs(condition: $condition) {
|
logs: ondemandPodLogs(condition: $condition) {
|
||||||
logs {
|
logs {
|
||||||
timestamp
|
timestamp
|
||||||
contentType
|
contentType
|
||||||
|
@ -15,8 +15,14 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { queryContainers, queryStreamingLogs } from "../fragments/demand-log";
|
import {
|
||||||
|
queryContainers,
|
||||||
|
queryStreamingLogs,
|
||||||
|
queryNamespaces,
|
||||||
|
} from "../fragments/demand-log";
|
||||||
|
|
||||||
export const fetchContainers = `query queryContainers(${queryContainers.variable}) {${queryContainers.query}}`;
|
export const fetchContainers = `query queryContainers(${queryContainers.variable}) {${queryContainers.query}}`;
|
||||||
|
|
||||||
export const fetchStreamingLogs = `query queryStreamingLogs(${queryStreamingLogs.variable}) {${queryStreamingLogs.query}}`;
|
export const fetchDemandPodLogs = `query queryStreamingLogs(${queryStreamingLogs.variable}) {${queryStreamingLogs.query}}`;
|
||||||
|
|
||||||
|
export const fetchNamespaces = `query queryContainers {${queryNamespaces.query}}`;
|
||||||
|
@ -140,6 +140,7 @@ const msg = {
|
|||||||
limit: "Limit",
|
limit: "Limit",
|
||||||
page: "Page",
|
page: "Page",
|
||||||
interval: "Refresh Interval",
|
interval: "Refresh Interval",
|
||||||
|
namespace: "Namespace",
|
||||||
hourTip: "Select Hour",
|
hourTip: "Select Hour",
|
||||||
minuteTip: "Select Minute",
|
minuteTip: "Select Minute",
|
||||||
secondTip: "Select Second",
|
secondTip: "Select Second",
|
||||||
|
@ -140,6 +140,7 @@ const msg = {
|
|||||||
processSelect: "Click para seleccionar proceso",
|
processSelect: "Click para seleccionar proceso",
|
||||||
page: "Página",
|
page: "Página",
|
||||||
interval: "Intervalo de actualización",
|
interval: "Intervalo de actualización",
|
||||||
|
namespace: "Espacio de nombres",
|
||||||
hourTip: "Seleccione Hora",
|
hourTip: "Seleccione Hora",
|
||||||
minuteTip: "Seleccione Minuto",
|
minuteTip: "Seleccione Minuto",
|
||||||
secondTip: "Seleccione Segundo",
|
secondTip: "Seleccione Segundo",
|
||||||
|
@ -138,6 +138,7 @@ const msg = {
|
|||||||
limit: "范围",
|
limit: "范围",
|
||||||
page: "页面",
|
page: "页面",
|
||||||
interval: "刷新间隔时间",
|
interval: "刷新间隔时间",
|
||||||
|
namespace: "命名空间",
|
||||||
hourTip: "选择小时",
|
hourTip: "选择小时",
|
||||||
minuteTip: "选择分钟",
|
minuteTip: "选择分钟",
|
||||||
secondTip: "选择秒数",
|
secondTip: "选择秒数",
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import { defineStore } from "pinia";
|
import { defineStore } from "pinia";
|
||||||
|
import { Option } from "@/types/app";
|
||||||
import { Instance } from "@/types/selector";
|
import { Instance } from "@/types/selector";
|
||||||
import { store } from "@/store";
|
import { store } from "@/store";
|
||||||
import graphql from "@/graphql";
|
import graphql from "@/graphql";
|
||||||
@ -30,6 +31,7 @@ interface DemandLogState {
|
|||||||
selectorStore: any;
|
selectorStore: any;
|
||||||
logs: DemandLog[];
|
logs: DemandLog[];
|
||||||
loadLogs: boolean;
|
loadLogs: boolean;
|
||||||
|
namespaces: Option[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export const demandLogStore = defineStore({
|
export const demandLogStore = defineStore({
|
||||||
@ -38,6 +40,7 @@ export const demandLogStore = defineStore({
|
|||||||
containers: [{ label: "Detail", value: "Detail" }],
|
containers: [{ label: "Detail", value: "Detail" }],
|
||||||
instances: [{ value: "", label: "" }],
|
instances: [{ value: "", label: "" }],
|
||||||
conditions: {
|
conditions: {
|
||||||
|
namespace: "",
|
||||||
container: "",
|
container: "",
|
||||||
serviceId: "",
|
serviceId: "",
|
||||||
serviceInstanceId: "",
|
serviceInstanceId: "",
|
||||||
@ -47,6 +50,7 @@ export const demandLogStore = defineStore({
|
|||||||
selectorStore: useSelectorStore(),
|
selectorStore: useSelectorStore(),
|
||||||
logs: [],
|
logs: [],
|
||||||
loadLogs: false,
|
loadLogs: false,
|
||||||
|
namespaces: [],
|
||||||
}),
|
}),
|
||||||
actions: {
|
actions: {
|
||||||
setLogCondition(data: Conditions) {
|
setLogCondition(data: Conditions) {
|
||||||
@ -67,21 +71,35 @@ export const demandLogStore = defineStore({
|
|||||||
this.instances = res.data.data.pods || [];
|
this.instances = res.data.data.pods || [];
|
||||||
return res.data;
|
return res.data;
|
||||||
},
|
},
|
||||||
async getContainers(instanceId?: string) {
|
async getNamespaces() {
|
||||||
const serviceId =
|
const res: AxiosResponse = await graphql
|
||||||
this.selectorStore.currentService &&
|
.query("fetchNamespaces")
|
||||||
this.selectorStore.currentService.id;
|
.params({});
|
||||||
const serviceInstanceId =
|
|
||||||
instanceId ||
|
if (res.data.errors) {
|
||||||
(this.selectorStore.currentInstance &&
|
return res.data;
|
||||||
this.selectorStore.currentInstance.id);
|
}
|
||||||
|
this.namespaces = (res.data.data.namespaces || []).map((d: string) => {
|
||||||
|
return {
|
||||||
|
label: d,
|
||||||
|
value: d,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
return res.data;
|
||||||
|
},
|
||||||
|
async getContainers(namespace: string, serviceInstanceId: string) {
|
||||||
|
if (!this.selectorStore.currentService) {
|
||||||
|
return new Promise((resolve) => resolve({ errors: "No service" }));
|
||||||
|
}
|
||||||
|
const serviceId = this.selectorStore.currentService.id;
|
||||||
const condition = {
|
const condition = {
|
||||||
serviceId,
|
serviceId,
|
||||||
serviceInstanceId,
|
serviceInstanceId,
|
||||||
|
namespace,
|
||||||
};
|
};
|
||||||
const res: AxiosResponse = await graphql.query("fetchContainers").params({
|
const res: AxiosResponse = await graphql
|
||||||
condition,
|
.query("fetchContainers")
|
||||||
});
|
.params({ condition });
|
||||||
|
|
||||||
if (res.data.errors) {
|
if (res.data.errors) {
|
||||||
return res.data;
|
return res.data;
|
||||||
@ -95,7 +113,7 @@ export const demandLogStore = defineStore({
|
|||||||
async getDemandLogs() {
|
async getDemandLogs() {
|
||||||
this.loadLogs = true;
|
this.loadLogs = true;
|
||||||
const res: AxiosResponse = await graphql
|
const res: AxiosResponse = await graphql
|
||||||
.query("fetchStreamingLogs")
|
.query("fetchDemandPodLogs")
|
||||||
.params({ condition: this.conditions });
|
.params({ condition: this.conditions });
|
||||||
this.loadLogs = false;
|
this.loadLogs = false;
|
||||||
if (res.data.errors) {
|
if (res.data.errors) {
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
import { DurationTime, Paging } from "./app";
|
import { DurationTime, Paging } from "./app";
|
||||||
|
|
||||||
export interface Conditions {
|
export interface Conditions {
|
||||||
|
namespace: string;
|
||||||
container: string;
|
container: string;
|
||||||
serviceId: string;
|
serviceId: string;
|
||||||
serviceInstanceId: string;
|
serviceInstanceId: string;
|
||||||
|
@ -25,6 +25,17 @@ limitations under the License. -->
|
|||||||
class="selectors"
|
class="selectors"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="mr-5 mb-5">
|
||||||
|
<span class="grey mr-5">{{ t("namespace") }}:</span>
|
||||||
|
<Selector
|
||||||
|
size="small"
|
||||||
|
:value="state.namespace.value"
|
||||||
|
:options="demandLogStore.namespaces"
|
||||||
|
placeholder="Select a namespace"
|
||||||
|
@change="changeField('namespace', $event)"
|
||||||
|
class="selectors"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<div class="mr-5 mb-5">
|
<div class="mr-5 mb-5">
|
||||||
<span class="grey mr-5">{{ t("container") }}:</span>
|
<span class="grey mr-5">{{ t("container") }}:</span>
|
||||||
<Selector
|
<Selector
|
||||||
@ -131,7 +142,7 @@ limitations under the License. -->
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, reactive, watch } from "vue";
|
import { ref, reactive, watch, computed } 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";
|
||||||
@ -140,6 +151,8 @@ import { useSelectorStore } from "@/store/modules/selectors";
|
|||||||
import { ElMessage } from "element-plus";
|
import { ElMessage } from "element-plus";
|
||||||
import { EntityType } from "../../data";
|
import { EntityType } from "../../data";
|
||||||
import { TimeRanges } from "./data";
|
import { TimeRanges } from "./data";
|
||||||
|
import getLocalTime from "@/utils/localtime";
|
||||||
|
import dateFormatStep from "@/utils/dateFormat";
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const appStore = useAppStoreWithOut();
|
const appStore = useAppStoreWithOut();
|
||||||
@ -155,8 +168,24 @@ 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: "None" },
|
||||||
|
namespace: { value: "", label: "None" },
|
||||||
duration: { label: "Last 30 min", value: 1800 },
|
duration: { label: "Last 30 min", value: 1800 },
|
||||||
});
|
});
|
||||||
|
const rangeTime = computed(() => {
|
||||||
|
const times = {
|
||||||
|
start: getLocalTime(
|
||||||
|
appStore.utc,
|
||||||
|
new Date(new Date().getTime() - state.duration.value * 1000)
|
||||||
|
),
|
||||||
|
end: getLocalTime(appStore.utc, new Date()),
|
||||||
|
step: "SECOND",
|
||||||
|
};
|
||||||
|
return {
|
||||||
|
start: dateFormatStep(times.start, times.step, false),
|
||||||
|
end: dateFormatStep(times.end, times.step, false),
|
||||||
|
step: times.step,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
init();
|
init();
|
||||||
async function init() {
|
async function init() {
|
||||||
@ -164,13 +193,30 @@ async function init() {
|
|||||||
await searchLogs();
|
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();
|
||||||
const resp = await demandLogStore.getContainers(state.instance.id);
|
}
|
||||||
if (resp.errors) {
|
await getNamespaces();
|
||||||
ElMessage.error(resp.errors);
|
getContainers();
|
||||||
return;
|
}
|
||||||
}
|
async function getNamespaces() {
|
||||||
|
const resp = await demandLogStore.getNamespaces();
|
||||||
|
if (resp.errors) {
|
||||||
|
ElMessage.error(resp.errors);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
state.namespace = demandLogStore.namespaces[0];
|
||||||
|
}
|
||||||
|
async function getContainers() {
|
||||||
|
const resp = await demandLogStore.getContainers(
|
||||||
|
state.namespace,
|
||||||
|
state.instance.id || ""
|
||||||
|
);
|
||||||
|
if (resp.errors) {
|
||||||
|
ElMessage.error(resp.errors);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
state.container = demandLogStore.containers[0];
|
state.container = demandLogStore.containers[0];
|
||||||
}
|
}
|
||||||
@ -191,10 +237,11 @@ function searchLogs() {
|
|||||||
serviceId:
|
serviceId:
|
||||||
(selectorStore.currentService && selectorStore.currentService.id) || "",
|
(selectorStore.currentService && selectorStore.currentService.id) || "",
|
||||||
serviceInstanceId: instance || state.instance.id || "",
|
serviceInstanceId: instance || state.instance.id || "",
|
||||||
queryDuration: appStore.durationTime,
|
namespace: state.namespace.value,
|
||||||
|
container: state.container.value,
|
||||||
|
queryDuration: rangeTime.value,
|
||||||
keywordsOfContent: keywordsOfContent.value,
|
keywordsOfContent: keywordsOfContent.value,
|
||||||
excludingKeywordsOfContent: excludingKeywordsOfContent.value,
|
excludingKeywordsOfContent: excludingKeywordsOfContent.value,
|
||||||
paging: { pageNum: 1, pageSize: -1 },
|
|
||||||
});
|
});
|
||||||
queryLogs();
|
queryLogs();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user