Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scale histogram aggregation interval to avoid crashing browser (#14157)
* update histogram agg to fetch min and max when search request started * scale interval when too many buckets are created * move min and max params into autoBounds param, remove typo in help text * use decorated property instead of params to avoid changing agg state, add functional test * remove sleep from functional test * make args for onSearchRequest functions specific. Add getters and setters for autoBounds to AggConfig. Protect against divide by zero * add unused arguments with eslint comment
- Loading branch information
Showing
13 changed files
with
197 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<div class="form-group"> | ||
<label for="visEditorInterval{{agg.id}}"> | ||
Minimum Interval | ||
<kbn-info | ||
placement="right" | ||
info="Interval will be automatically scaled in the event that the provided value creates more buckets than specified by Advanced Setting's histogram:maxBars"> | ||
</kbn-info> | ||
</label> | ||
<input | ||
id="visEditorInterval{{agg.id}}" | ||
ng-model="agg.params.interval" | ||
required | ||
type="number" | ||
class="form-control" | ||
name="interval" | ||
min="0" | ||
input-number | ||
> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
test/functional/apps/visualize/_histogram_request_start.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import expect from 'expect.js'; | ||
|
||
export default function ({ getService, getPageObjects }) { | ||
const log = getService('log'); | ||
const PageObjects = getPageObjects(['common', 'visualize', 'header']); | ||
|
||
describe('histogram agg onSearchRequestStart', function describeIndexTests() { | ||
before(async function () { | ||
const fromTime = '2015-09-19 06:31:44.000'; | ||
const toTime = '2015-09-23 18:31:44.000'; | ||
|
||
log.debug('navigateToApp visualize'); | ||
await PageObjects.common.navigateToUrl('visualize', 'new'); | ||
log.debug('clickDataTable'); | ||
await PageObjects.visualize.clickDataTable(); | ||
await PageObjects.visualize.clickNewSearch(); | ||
log.debug('Set absolute time range from \"' + fromTime + '\" to \"' + toTime + '\"'); | ||
await PageObjects.header.setAbsoluteRange(fromTime, toTime); | ||
log.debug('Bucket = Split Rows'); | ||
await PageObjects.visualize.clickBucket('Split Rows'); | ||
log.debug('Aggregation = Histogram'); | ||
await PageObjects.visualize.selectAggregation('Histogram'); | ||
log.debug('Field = bytes'); | ||
await PageObjects.visualize.selectField('bytes'); | ||
}); | ||
|
||
describe('interval parameter uses autoBounds', function indexPatternCreation() { | ||
it('should use provided value when number of generated buckets is less than histogram:maxBars', async function () { | ||
const providedInterval = 2000; | ||
log.debug(`Interval = ${providedInterval}`); | ||
await PageObjects.visualize.setNumericInterval(providedInterval); | ||
await PageObjects.visualize.clickGo(); | ||
await PageObjects.header.waitUntilLoadingHasFinished(); | ||
|
||
const data = await PageObjects.visualize.getDataTableData(); | ||
const dataArray = data.replace(/,/g, '').split('\n'); | ||
expect(dataArray.length).to.eql(20); | ||
const bucketStart = parseInt(dataArray[0], 10); | ||
const bucketEnd = parseInt(dataArray[2], 10); | ||
const actualInterval = bucketEnd - bucketStart; | ||
expect(actualInterval).to.eql(providedInterval); | ||
}); | ||
|
||
it('should scale value to round number when number of generated buckets is greater than histogram:maxBars', async function () { | ||
const providedInterval = 100; | ||
log.debug(`Interval = ${providedInterval}`); | ||
await PageObjects.visualize.setNumericInterval(providedInterval); | ||
await PageObjects.visualize.clickGo(); | ||
await PageObjects.header.waitUntilLoadingHasFinished(); | ||
|
||
const data = await PageObjects.visualize.getDataTableData(); | ||
const dataArray = data.replace(/,/g, '').split('\n'); | ||
expect(dataArray.length).to.eql(20); | ||
const bucketStart = parseInt(dataArray[0], 10); | ||
const bucketEnd = parseInt(dataArray[2], 10); | ||
const actualInterval = bucketEnd - bucketStart; | ||
expect(actualInterval).to.eql(200); | ||
}); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters