feat: add readRecords to metric types (#172)

This commit is contained in:
Fine0830
2022-10-17 21:55:14 +08:00
committed by GitHub
parent 77d189cdfb
commit 5e161f17c2
3 changed files with 26 additions and 0 deletions

View File

@@ -21,6 +21,7 @@ export enum MetricQueryTypes {
ReadLabeledMetricsValues = "readLabeledMetricsValues",
READHEATMAP = "readHeatMap",
ReadSampledRecords = "readSampledRecords",
ReadRecords = "readRecords",
}
export enum Calculations {
@@ -101,4 +102,10 @@ export const RespFields: any = {
value
refId
}`,
readRecords: `{
id
name
value
refId
}`,
};

View File

@@ -73,6 +73,22 @@ export function useQueryProcessor(config: any) {
topN: c.topN || 10,
order: c.sortOrder || "DES",
};
} else if ([MetricQueryTypes.ReadRecords].includes(metricType)) {
variables.push(`$condition${index}: RecordCondition!`);
conditions[`condition${index}`] = {
name,
parentEntity: {
scope: config.catalog,
normal: selectorStore.currentService
? selectorStore.currentService.normal
: true,
serviceName: ["All"].includes(dashboardStore.entity)
? null
: selectorStore.currentService.value,
},
topN: c.topN || 10,
order: c.sortOrder || "DES",
};
} else {
if (metricType === MetricQueryTypes.ReadLabeledMetricsValues) {
const labels = (c.labelsIndex || "")
@@ -435,6 +451,7 @@ export async function useGetMetricEntity(metric: string, metricType: any) {
[
MetricQueryTypes.ReadSampledRecords,
MetricQueryTypes.SortMetrics,
MetricQueryTypes.ReadRecords,
].includes(metricType)
) {
const res = await dashboardStore.fetchMetricList(metric);