[APM] fixes incorrect values in service overview throughput chart (#89348)
* [APM] fixes incorrect values in service overview throughput chart
This commit is contained in:
parent
7465976c25
commit
8e57b63deb
|
@ -27,12 +27,17 @@ interface Options {
|
||||||
|
|
||||||
type ESResponse = PromiseReturnType<typeof fetcher>;
|
type ESResponse = PromiseReturnType<typeof fetcher>;
|
||||||
|
|
||||||
function transform(response: ESResponse) {
|
function transform(response: ESResponse, options: Options) {
|
||||||
|
const { end, start } = options.setup;
|
||||||
|
const deltaAsMinutes = (end - start) / 1000 / 60;
|
||||||
if (response.hits.total.value === 0) {
|
if (response.hits.total.value === 0) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
const buckets = response.aggregations?.throughput.buckets ?? [];
|
const buckets = response.aggregations?.throughput.buckets ?? [];
|
||||||
return buckets.map(({ key: x, doc_count: y }) => ({ x, y }));
|
return buckets.map(({ key: x, doc_count: y }) => ({
|
||||||
|
x,
|
||||||
|
y: y / deltaAsMinutes,
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetcher({
|
async function fetcher({
|
||||||
|
@ -82,6 +87,6 @@ async function fetcher({
|
||||||
|
|
||||||
export async function getThroughput(options: Options) {
|
export async function getThroughput(options: Options) {
|
||||||
return {
|
return {
|
||||||
throughput: transform(await fetcher(options)),
|
throughput: transform(await fetcher(options), options),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ Array [
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607435880000,
|
"x": 1607435880000,
|
||||||
"y": 4,
|
"y": 0.133333333333333,
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607435910000,
|
"x": 1607435910000,
|
||||||
|
@ -16,7 +16,7 @@ Array [
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607435940000,
|
"x": 1607435940000,
|
||||||
"y": 2,
|
"y": 0.0666666666666667,
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607435970000,
|
"x": 1607435970000,
|
||||||
|
@ -24,11 +24,11 @@ Array [
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607436000000,
|
"x": 1607436000000,
|
||||||
"y": 3,
|
"y": 0.1,
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607436030000,
|
"x": 1607436030000,
|
||||||
"y": 1,
|
"y": 0.0333333333333333,
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607436060000,
|
"x": 1607436060000,
|
||||||
|
@ -40,7 +40,7 @@ Array [
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607436120000,
|
"x": 1607436120000,
|
||||||
"y": 4,
|
"y": 0.133333333333333,
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607436150000,
|
"x": 1607436150000,
|
||||||
|
@ -56,7 +56,7 @@ Array [
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607436240000,
|
"x": 1607436240000,
|
||||||
"y": 6,
|
"y": 0.2,
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607436270000,
|
"x": 1607436270000,
|
||||||
|
@ -68,15 +68,15 @@ Array [
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607436330000,
|
"x": 1607436330000,
|
||||||
"y": 1,
|
"y": 0.0333333333333333,
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607436360000,
|
"x": 1607436360000,
|
||||||
"y": 5,
|
"y": 0.166666666666667,
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607436390000,
|
"x": 1607436390000,
|
||||||
"y": 1,
|
"y": 0.0333333333333333,
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607436420000,
|
"x": 1607436420000,
|
||||||
|
@ -88,11 +88,11 @@ Array [
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607436480000,
|
"x": 1607436480000,
|
||||||
"y": 2,
|
"y": 0.0666666666666667,
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607436510000,
|
"x": 1607436510000,
|
||||||
"y": 5,
|
"y": 0.166666666666667,
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607436540000,
|
"x": 1607436540000,
|
||||||
|
@ -104,11 +104,11 @@ Array [
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607436600000,
|
"x": 1607436600000,
|
||||||
"y": 2,
|
"y": 0.0666666666666667,
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607436630000,
|
"x": 1607436630000,
|
||||||
"y": 7,
|
"y": 0.233333333333333,
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607436660000,
|
"x": 1607436660000,
|
||||||
|
@ -124,7 +124,7 @@ Array [
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607436750000,
|
"x": 1607436750000,
|
||||||
"y": 2,
|
"y": 0.0666666666666667,
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607436780000,
|
"x": 1607436780000,
|
||||||
|
@ -132,15 +132,15 @@ Array [
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607436810000,
|
"x": 1607436810000,
|
||||||
"y": 1,
|
"y": 0.0333333333333333,
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607436840000,
|
"x": 1607436840000,
|
||||||
"y": 1,
|
"y": 0.0333333333333333,
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607436870000,
|
"x": 1607436870000,
|
||||||
"y": 2,
|
"y": 0.0666666666666667,
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607436900000,
|
"x": 1607436900000,
|
||||||
|
@ -152,11 +152,11 @@ Array [
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607436960000,
|
"x": 1607436960000,
|
||||||
"y": 2,
|
"y": 0.0666666666666667,
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607436990000,
|
"x": 1607436990000,
|
||||||
"y": 4,
|
"y": 0.133333333333333,
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607437020000,
|
"x": 1607437020000,
|
||||||
|
@ -168,11 +168,11 @@ Array [
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607437080000,
|
"x": 1607437080000,
|
||||||
"y": 1,
|
"y": 0.0333333333333333,
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607437110000,
|
"x": 1607437110000,
|
||||||
"y": 1,
|
"y": 0.0333333333333333,
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607437140000,
|
"x": 1607437140000,
|
||||||
|
@ -184,15 +184,15 @@ Array [
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607437200000,
|
"x": 1607437200000,
|
||||||
"y": 2,
|
"y": 0.0666666666666667,
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607437230000,
|
"x": 1607437230000,
|
||||||
"y": 7,
|
"y": 0.233333333333333,
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607437260000,
|
"x": 1607437260000,
|
||||||
"y": 1,
|
"y": 0.0333333333333333,
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607437290000,
|
"x": 1607437290000,
|
||||||
|
@ -200,11 +200,11 @@ Array [
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607437320000,
|
"x": 1607437320000,
|
||||||
"y": 1,
|
"y": 0.0333333333333333,
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607437350000,
|
"x": 1607437350000,
|
||||||
"y": 2,
|
"y": 0.0666666666666667,
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607437380000,
|
"x": 1607437380000,
|
||||||
|
@ -216,11 +216,11 @@ Array [
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607437440000,
|
"x": 1607437440000,
|
||||||
"y": 1,
|
"y": 0.0333333333333333,
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607437470000,
|
"x": 1607437470000,
|
||||||
"y": 3,
|
"y": 0.1,
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607437500000,
|
"x": 1607437500000,
|
||||||
|
@ -232,7 +232,7 @@ Array [
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607437560000,
|
"x": 1607437560000,
|
||||||
"y": 1,
|
"y": 0.0333333333333333,
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"x": 1607437590000,
|
"x": 1607437590000,
|
||||||
|
|
Loading…
Reference in a new issue