Skip to content

Commit

Permalink
[Uptime] Use manual intervals for ping histogram (#72928) (#73177)
Browse files Browse the repository at this point in the history
Fixes elastic/uptime#215

Prior to this we'd get too few buckets in some ranges.
  • Loading branch information
andrewvc authored Jul 29, 2020
1 parent f32cf39 commit 5b384ae
Show file tree
Hide file tree
Showing 5 changed files with 175 additions and 88 deletions.
24 changes: 7 additions & 17 deletions x-pack/plugins/uptime/server/lib/requests/get_ping_histogram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { UMElasticsearchQueryFn } from '../adapters';
import { getFilterClause } from '../helper';
import { HistogramResult, HistogramQueryResult } from '../../../common/runtime_types';
import { QUERY } from '../../../common/constants';
import { getHistogramInterval } from '../helper/get_histogram_interval';

export interface GetPingHistogramParams {
/** @member dateRangeStart timestamp bounds */
Expand Down Expand Up @@ -36,22 +37,6 @@ export const getPingHistogram: UMElasticsearchQueryFn<
}
const filter = getFilterClause(from, to, additionalFilters);

const seriesHistogram: any = {};

if (bucketSize) {
seriesHistogram.date_histogram = {
field: '@timestamp',
fixed_interval: bucketSize,
missing: 0,
};
} else {
seriesHistogram.auto_date_histogram = {
field: '@timestamp',
buckets: QUERY.DEFAULT_BUCKET_COUNT,
missing: 0,
};
}

const params = {
index: dynamicSettings.heartbeatIndices,
body: {
Expand All @@ -63,7 +48,12 @@ export const getPingHistogram: UMElasticsearchQueryFn<
size: 0,
aggs: {
timeseries: {
...seriesHistogram,
date_histogram: {
field: '@timestamp',
fixed_interval:
bucketSize || getHistogramInterval(from, to, QUERY.DEFAULT_BUCKET_COUNT) + 'ms',
missing: 0,
},
aggs: {
down: {
filter: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,121 +1,157 @@
{
"histogram": [
{
"x": 1568172664000,
"x": 1568172657286,
"downCount": 7,
"upCount": 93,
"y": 1
},
{
"x": 1568172694000,
"x": 1568172680087,
"downCount": 7,
"upCount": 93,
"y": 1
},
{
"x": 1568172724000,
"x": 1568172702888,
"downCount": 7,
"upCount": 93,
"y": 1
},
{
"x": 1568172754000,
"x": 1568172725689,
"downCount": 0,
"upCount": 0,
"y": 1
},
{
"x": 1568172748490,
"downCount": 7,
"upCount": 93,
"y": 1
},
{
"x": 1568172784000,
"x": 1568172771291,
"downCount": 7,
"upCount": 93,
"y": 1
},
{
"x": 1568172814000,
"x": 1568172794092,
"downCount": 8,
"upCount": 92,
"y": 1
},
{
"x": 1568172844000,
"x": 1568172816893,
"downCount": 0,
"upCount": 0,
"y": 1
},
{
"x": 1568172839694,
"downCount": 7,
"upCount": 93,
"y": 1
},
{
"x": 1568172874000,
"x": 1568172862495,
"downCount": 7,
"upCount": 93,
"y": 1
},
{
"x": 1568172904000,
"x": 1568172885296,
"downCount": 7,
"upCount": 93,
"y": 1
},
{
"x": 1568172934000,
"x": 1568172908097,
"downCount": 0,
"upCount": 0,
"y": 1
},
{
"x": 1568172930898,
"downCount": 7,
"upCount": 93,
"y": 1
},
{
"x": 1568172964000,
"x": 1568172953699,
"downCount": 7,
"upCount": 93,
"y": 1
},
{
"x": 1568172994000,
"x": 1568172976500,
"downCount": 8,
"upCount": 92,
"y": 1
},
{
"x": 1568173024000,
"x": 1568172999301,
"downCount": 0,
"upCount": 0,
"y": 1
},
{
"x": 1568173022102,
"downCount": 7,
"upCount": 93,
"y": 1
},
{
"x": 1568173054000,
"x": 1568173044903,
"downCount": 7,
"upCount": 93,
"y": 1
},
{
"x": 1568173084000,
"x": 1568173067704,
"downCount": 7,
"upCount": 93,
"y": 1
},
{
"x": 1568173114000,
"x": 1568173090505,
"downCount": 0,
"upCount": 0,
"y": 1
},
{
"x": 1568173113306,
"downCount": 7,
"upCount": 93,
"y": 1
},
{
"x": 1568173144000,
"x": 1568173136107,
"downCount": 7,
"upCount": 93,
"y": 1
},
{
"x": 1568173174000,
"x": 1568173158908,
"downCount": 8,
"upCount": 92,
"y": 1
},
{
"x": 1568173204000,
"x": 1568173181709,
"downCount": 7,
"upCount": 93,
"y": 1
},
{
"x": 1568173234000,
"x": 1568173204510,
"downCount": 0,
"upCount": 0,
"y": 1
},
{
"x": 1568173227311,
"downCount": 7,
"upCount": 93,
"y": 1
Expand Down
Loading

0 comments on commit 5b384ae

Please sign in to comment.