|
|
|
@ -36,13 +36,13 @@ export class PrometheusMetric extends AbstractMetric {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
let result = res.data.data.result; |
|
|
|
|
let result_matrix = { |
|
|
|
|
let result_matrix: MetricResults = { |
|
|
|
|
columns: ['timestamp'], |
|
|
|
|
values: [] |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
result.map(r => { |
|
|
|
|
let keys = []; |
|
|
|
|
let keys: string[] = []; |
|
|
|
|
for(let key in r.metric) { |
|
|
|
|
keys.push(`${key}=${r.metric[key]}`); |
|
|
|
|
} |
|
|
|
@ -51,8 +51,8 @@ export class PrometheusMetric extends AbstractMetric {
|
|
|
|
|
|
|
|
|
|
let values = result.map(r => r.values); |
|
|
|
|
|
|
|
|
|
let timestamps = []; |
|
|
|
|
values.map(v => v.map(row => timestamps.push(row[0]))); |
|
|
|
|
let timestamps: (number | null)[] = []; |
|
|
|
|
values.forEach(v => v.forEach((row: number[]) => timestamps.push(row[0]))); |
|
|
|
|
timestamps = timestamps.filter(function(item, i, ar) { |
|
|
|
|
return ar.indexOf(item) === i; //uniq values
|
|
|
|
|
}); |
|
|
|
@ -70,12 +70,11 @@ export class PrometheusMetric extends AbstractMetric {
|
|
|
|
|
if(currentTimestamp === t) { |
|
|
|
|
row.push(+currentValue); |
|
|
|
|
v.shift(); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
} else { |
|
|
|
|
row.push(null); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
row[0] = +row[0] * 1000; //convert timestamp to ms
|
|
|
|
|
row[0] = +(row[0] as number) * 1000; //convert timestamp to ms
|
|
|
|
|
result_matrix.values.push(row); |
|
|
|
|
}; |
|
|
|
|
return result_matrix; |
|
|
|
|