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