mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-07-01 11:19:45 +00:00
feat: update expression metrics
This commit is contained in:
parent
e2670b872f
commit
94dc2f3642
@ -15,16 +15,24 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { MetricQueryTypes, Calculations } from "./data";
|
||||
import { ExpressionResultType } from "@/views/dashboard/data";
|
||||
|
||||
export function useListConfig(config: Indexable, index: string) {
|
||||
const i = Number(index);
|
||||
const types = [Calculations.Average, Calculations.ApdexAvg, Calculations.PercentageAvg];
|
||||
const calculation = config.metricConfig && config.metricConfig[i] && config.metricConfig[i].calculation;
|
||||
const isLinear =
|
||||
[MetricQueryTypes.ReadMetricsValues, MetricQueryTypes.ReadLabeledMetricsValues].includes(config.metricTypes[i]) &&
|
||||
!types.includes(calculation);
|
||||
[
|
||||
MetricQueryTypes.ReadMetricsValues,
|
||||
MetricQueryTypes.ReadLabeledMetricsValues,
|
||||
ExpressionResultType.TIME_SERIES_VALUES,
|
||||
].includes(config.metricTypes[i]) && !types.includes(calculation);
|
||||
const isAvg =
|
||||
[MetricQueryTypes.ReadMetricsValues, MetricQueryTypes.ReadLabeledMetricsValues].includes(config.metricTypes[i]) &&
|
||||
types.includes(calculation);
|
||||
[
|
||||
MetricQueryTypes.ReadMetricsValues,
|
||||
MetricQueryTypes.ReadLabeledMetricsValues,
|
||||
ExpressionResultType.TIME_SERIES_VALUES,
|
||||
].includes(config.metricTypes[i]) && types.includes(calculation);
|
||||
return {
|
||||
isLinear,
|
||||
isAvg,
|
||||
|
@ -22,6 +22,7 @@ import { useSelectorStore } from "@/store/modules/selectors";
|
||||
import { useAppStoreWithOut } from "@/store/modules/app";
|
||||
import type { Instance, Endpoint, Service } from "@/types/selector";
|
||||
import type { MetricConfigOpt } from "@/types/dashboard";
|
||||
import type { E } from "vitest/dist/types-c441ef31";
|
||||
|
||||
export function useQueryProcessor(config: Indexable) {
|
||||
if (!(config.metrics && config.metrics[0])) {
|
||||
@ -277,7 +278,7 @@ export function usePodsSource(
|
||||
const names: string[] = [];
|
||||
const metricConfigArr: MetricConfigOpt[] = [];
|
||||
const metricTypesArr: string[] = [];
|
||||
const data = pods.map((d: Instance & Indexable, idx: number) => {
|
||||
const data = pods.map((d: any, idx: number) => {
|
||||
config.metrics.map((name: string, index: number) => {
|
||||
const c: any = (config.metricConfig && config.metricConfig[index]) || {};
|
||||
const key = name + idx + index;
|
||||
|
3
src/types/selector.d.ts
vendored
3
src/types/selector.d.ts
vendored
@ -21,6 +21,7 @@ export type Service = {
|
||||
layers?: string[];
|
||||
normal?: boolean;
|
||||
group?: string;
|
||||
merge?: string;
|
||||
};
|
||||
|
||||
export type Instance = {
|
||||
@ -30,12 +31,14 @@ export type Instance = {
|
||||
instanceUUID?: string;
|
||||
attributes?: { name: string; value: string }[];
|
||||
id?: string;
|
||||
merge?: boolean;
|
||||
};
|
||||
|
||||
export type Endpoint = {
|
||||
id?: string;
|
||||
label: string;
|
||||
value: string;
|
||||
merge?: string;
|
||||
};
|
||||
|
||||
export type Service = {
|
||||
|
@ -120,10 +120,18 @@ limitations under the License. -->
|
||||
endpoints.value = resp.data.pods || [];
|
||||
queryEndpointMetrics(endpoints.value);
|
||||
}
|
||||
async function queryEndpointMetrics(currentPods: Endpoint[]) {
|
||||
if (!currentPods.length) {
|
||||
async function queryEndpointMetrics(arr: Endpoint[]) {
|
||||
if (!arr.length) {
|
||||
return;
|
||||
}
|
||||
const currentPods = arr.map((d: Endpoint) => {
|
||||
return {
|
||||
id: d.id,
|
||||
value: d.value,
|
||||
label: d.label,
|
||||
merge: d.merge,
|
||||
};
|
||||
});
|
||||
if (props.config.metricMode === "Expression") {
|
||||
queryEndpointExpressions(currentPods);
|
||||
return;
|
||||
|
@ -150,10 +150,21 @@ limitations under the License. -->
|
||||
queryInstanceMetrics(instances.value);
|
||||
}
|
||||
|
||||
async function queryInstanceMetrics(currentInstances: Instance[]) {
|
||||
if (!currentInstances.length) {
|
||||
async function queryInstanceMetrics(arr: Instance[]) {
|
||||
if (!arr.length) {
|
||||
return;
|
||||
}
|
||||
const currentInstances = arr.map((d: Instance) => {
|
||||
return {
|
||||
id: d.id,
|
||||
value: d.value,
|
||||
label: d.label,
|
||||
merge: d.merge,
|
||||
language: d.language,
|
||||
instanceUUID: d.instanceUUID,
|
||||
attributes: d.attributes,
|
||||
};
|
||||
});
|
||||
if (props.config.metricMode === "Expression") {
|
||||
queryInstanceExpressions(currentInstances);
|
||||
return;
|
||||
|
@ -191,10 +191,21 @@ limitations under the License. -->
|
||||
|
||||
router.push(path);
|
||||
}
|
||||
async function queryServiceMetrics(currentServices: Service[]) {
|
||||
if (!currentServices.length) {
|
||||
async function queryServiceMetrics(arr: Service[]) {
|
||||
if (!arr.length) {
|
||||
return;
|
||||
}
|
||||
const currentServices = arr.map((d: Service) => {
|
||||
return {
|
||||
id: d.id,
|
||||
value: d.value,
|
||||
label: d.label,
|
||||
layers: d.layers,
|
||||
group: d.group,
|
||||
normal: d.normal,
|
||||
merge: d.merge,
|
||||
};
|
||||
});
|
||||
if (props.config.metricMode === "Expression") {
|
||||
queryServiceExpressions(currentServices);
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user