diff --git a/src/graphql/fragments/ebpf.ts b/src/graphql/fragments/ebpf.ts index 920065d4..d5ec74e4 100644 --- a/src/graphql/fragments/ebpf.ts +++ b/src/graphql/fragments/ebpf.ts @@ -33,12 +33,15 @@ export const createEBPFTask = { }`, }; export const queryEBPFTasks = { - variable: "$serviceId: ID!", + variable: + "$serviceId: ID, $serviceInstanceId: ID, $targets: [EBPFProfilingTargetType!]", query: ` - queryEBPFTasks: queryEBPFProfilingTasks(serviceId: $serviceId) { + queryEBPFTasks: queryEBPFProfilingTasks(serviceId: $serviceId, serviceInstanceId: $serviceInstanceId, targets: $targets) { taskId serviceName serviceId + serviceInstanceId + serviceInstanceName processLabels taskStartTime triggerType @@ -90,3 +93,22 @@ export const analysisEBPFResult = { } }`, }; + +export const createNetworkProfiling = { + variable: "$request: EBPFProfilingNetworkTaskRequest!", + query: ` + createEBPFNetworkProfiling(request: $request) { + status + errorReason + id + }`, +}; + +export const keepNetworkProfiling = { + variable: "$taskId: ID!", + query: ` + keepEBPFNetworkProfiling(taskId: $taskId) { + status + errorReason + }`, +}; diff --git a/src/graphql/query/ebpf.ts b/src/graphql/query/ebpf.ts index 131b57a3..2518ebb3 100644 --- a/src/graphql/query/ebpf.ts +++ b/src/graphql/query/ebpf.ts @@ -21,6 +21,8 @@ import { queryEBPFTasks, queryEBPFSchedules, analysisEBPFResult, + createNetworkProfiling, + keepNetworkProfiling, } from "../fragments/ebpf"; export const getCreateTaskData = `query queryCreateTaskData(${queryCreateTaskData.variable}) {${queryCreateTaskData.query}}`; @@ -32,3 +34,7 @@ export const getEBPFTasks = `query queryEBPFTasks(${queryEBPFTasks.variable}) {$ export const getEBPFSchedules = `query queryEBPFSchedules(${queryEBPFSchedules.variable}) {${queryEBPFSchedules.query}}`; export const getEBPFResult = `query analysisEBPFResult(${analysisEBPFResult.variable}) {${analysisEBPFResult.query}}`; + +export const saveNetworkProfiling = `mutation createNetworkProfiling(${createNetworkProfiling.variable}) {${createNetworkProfiling.query}}`; + +export const aliveNetworkProfiling = `mutation keepNetworkProfiling(${keepNetworkProfiling.variable}) {${keepNetworkProfiling.query}}`; diff --git a/src/store/modules/ebpf.ts b/src/store/modules/ebpf.ts index 987422b8..4496ad58 100644 --- a/src/store/modules/ebpf.ts +++ b/src/store/modules/ebpf.ts @@ -1,3 +1,4 @@ +import { TaskListItem } from "./../../types/profile.d"; /** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -28,13 +29,16 @@ import { AxiosResponse } from "axios"; interface EbpfStore { taskList: EBPFTaskList[]; + networkTasks: EBPFTaskList[]; eBPFSchedules: EBPFProfilingSchedule[]; currentSchedule: EBPFProfilingSchedule | Record; analyzeTrees: AnalyzationTrees[]; labels: Option[]; couldProfiling: boolean; tip: string; + networkTip: string; selectedTask: Recordable; + selectedNetworkTask: Recordable; aggregateType: string; } @@ -42,18 +46,24 @@ export const ebpfStore = defineStore({ id: "eBPF", state: (): EbpfStore => ({ taskList: [], + networkTasks: [], eBPFSchedules: [], currentSchedule: {}, analyzeTrees: [], labels: [{ value: "", label: "" }], couldProfiling: false, tip: "", + networkTip: "", selectedTask: {}, + selectedNetworkTask: {}, aggregateType: "COUNT", }), actions: { setSelectedTask(task: EBPFTaskList) { - this.selectedTask = task; + this.selectedTask = task || {}; + }, + setSelectedNetworkTask(task: EBPFTaskList) { + this.selectedNetworkTask = task || {}; }, setCurrentSchedule(s: EBPFProfilingSchedule) { this.currentSchedule = s; @@ -84,24 +94,44 @@ export const ebpfStore = defineStore({ if (res.data.errors) { return res.data; } - this.getTaskList(param.serviceId); + this.getTaskList({ + serviceId: param.serviceId, + targets: ["ON_CPU", "OFF_CPU"], + }); return res.data; }, - async getTaskList(serviceId: string) { - if (!serviceId) { + async getTaskList(params: { + serviceId: string; + serviceInstanceId: string; + targets: string[]; + }) { + if (!params.serviceId) { return new Promise((resolve) => resolve({})); } const res: AxiosResponse = await graphql .query("getEBPFTasks") - .params({ serviceId }); + .params(params); - this.tip = ""; - if (res.data.errors) { - return res.data; - } - this.taskList = res.data.data.queryEBPFTasks || []; - if (!this.taskList.length) { - return res.data; + if (params.serviceInstanceId) { + this.networkTip = ""; + if (res.data.errors) { + return res.data; + } + this.networkTasks = res.data.data.queryEBPFTasks || []; + if (!this.networkTasks.length) { + return res.data; + } + this.selectedNetworkTask = this.networkTasks[0] || {}; + this.setSelectedNetworkTask(this.selectedNetworkTask); + } else { + this.tip = ""; + if (res.data.errors) { + return res.data; + } + this.taskList = res.data.data.queryEBPFTasks || []; + if (!this.taskList.length) { + return res.data; + } } this.getEBPFSchedules({ taskId: this.taskList[0].taskId }); return res.data; diff --git a/src/views/dashboard/controls/NetworkProfiling.vue b/src/views/dashboard/controls/NetworkProfiling.vue index 6a206a8d..d5dfd490 100644 --- a/src/views/dashboard/controls/NetworkProfiling.vue +++ b/src/views/dashboard/controls/NetworkProfiling.vue @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. -->