[Rollups] Re-enable rollup support (#24888)

* Re-enable rollup support extension points

* [Rollups] Hide rollups consumption behind a feature flag in Advanced Settings. (#24698)
This commit is contained in:
Jen Huang 2018-10-31 11:54:37 -07:00 committed by GitHub
parent 2ce57a5e6e
commit 9527e0e7c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 180 additions and 126 deletions

View file

@ -533,5 +533,14 @@ export function getUiSettingDefaults() {
`,
category: ['accessibility'],
},
'rollups:enableIndexPatterns': {
name: 'Enable rollup index patterns',
value: true,
description: `
Enable the creation of index patterns which capture rollup indices, which in turn enable
visualizations based on rollup data. Refresh the page to apply the changes.
`,
category: ['rollups'],
},
};
}

View file

@ -25,20 +25,16 @@ export function rollup(kibana) {
managementSections: [
'plugins/rollup/crud_app',
],
// NOTE: These extension points are temporarily disabled until we've resolved issues
// with auto-scaling the interval for date histogram visualizations.
// See https://github.com/elastic/kibana/pull/24428 for more info.
//
// indexManagement: [
// 'plugins/rollup/index_pattern_creation',
// 'plugins/rollup/index_pattern_list',
// ],
// visualize: [
// 'plugins/rollup/visualize',
// ],
// search: [
// 'plugins/rollup/search',
// ],
indexManagement: [
'plugins/rollup/index_pattern_creation',
'plugins/rollup/index_pattern_list',
],
visualize: [
'plugins/rollup/visualize',
],
search: [
'plugins/rollup/search',
],
migrations: {
'index-pattern': {
'6.5.0': (doc) => {

View file

@ -4,4 +4,13 @@
* you may not use this file except in compliance with the Elastic License.
*/
import './register';
import chrome from 'ui/chrome';
import { initIndexPatternCreation } from './register';
const uiSettings = chrome.getUiSettingsClient();
const isRollupIndexPatternsEnabled = uiSettings.get('rollups:enableIndexPatterns');
if (isRollupIndexPatternsEnabled) {
initIndexPatternCreation();
}

View file

@ -7,4 +7,6 @@
import { IndexPatternCreationConfigRegistry } from 'ui/management/index_pattern_creation';
import { RollupIndexPatternCreationConfig } from './rollup_index_pattern_creation_config';
IndexPatternCreationConfigRegistry.register(() => RollupIndexPatternCreationConfig);
export function initIndexPatternCreation() {
IndexPatternCreationConfigRegistry.register(() => RollupIndexPatternCreationConfig);
}

View file

@ -4,4 +4,12 @@
* you may not use this file except in compliance with the Elastic License.
*/
import './register';
import chrome from 'ui/chrome';
import { initIndexPatternList } from './register';
const uiSettings = chrome.getUiSettingsClient();
const isRollupIndexPatternsEnabled = uiSettings.get('rollups:enableIndexPatterns');
if (isRollupIndexPatternsEnabled) {
initIndexPatternList();
}

View file

@ -7,4 +7,6 @@
import { IndexPatternListConfigRegistry } from 'ui/management/index_pattern_list';
import { RollupIndexPatternListConfig } from './rollup_index_pattern_list_config';
IndexPatternListConfigRegistry.register(() => RollupIndexPatternListConfig);
export function initIndexPatternList() {
IndexPatternListConfigRegistry.register(() => RollupIndexPatternListConfig);
}

View file

@ -4,4 +4,13 @@
* you may not use this file except in compliance with the Elastic License.
*/
import './register';
import chrome from 'ui/chrome';
import { initSearch } from './register';
const uiSettings = chrome.getUiSettingsClient();
const isRollupIndexPatternsEnabled = uiSettings.get('rollups:enableIndexPatterns');
if (isRollupIndexPatternsEnabled) {
initSearch();
}

View file

@ -7,4 +7,6 @@
import { addSearchStrategy } from 'ui/courier';
import { rollupSearchStrategy } from './rollup_search_strategy';
addSearchStrategy(rollupSearchStrategy);
export function initSearch() {
addSearchStrategy(rollupSearchStrategy);
}

View file

@ -6,18 +6,20 @@
import { aggTypeFieldFilters } from 'ui/agg_types/param_types/filter';
/**
* If rollup index pattern, check its capabilities
* and limit available fields for a given aggType based on that.
*/
aggTypeFieldFilters.addFilter(
(field, fieldParamType, aggConfig) => {
const indexPattern = aggConfig.getIndexPattern();
if(!indexPattern || indexPattern.type !== 'rollup') {
return true;
export function initAggTypeFieldFilter() {
/**
* If rollup index pattern, check its capabilities
* and limit available fields for a given aggType based on that.
*/
aggTypeFieldFilters.addFilter(
(field, fieldParamType, aggConfig) => {
const indexPattern = aggConfig.getIndexPattern();
if(!indexPattern || indexPattern.type !== 'rollup') {
return true;
}
const aggName = aggConfig.type && aggConfig.type.name;
const aggFields = indexPattern.typeMeta && indexPattern.typeMeta.aggs && indexPattern.typeMeta.aggs[aggName];
return aggFields && aggFields[field.name];
}
const aggName = aggConfig.type && aggConfig.type.name;
const aggFields = indexPattern.typeMeta && indexPattern.typeMeta.aggs && indexPattern.typeMeta.aggs[aggName];
return aggFields && aggFields[field.name];
}
);
);
}

View file

@ -6,20 +6,22 @@
import { aggTypeFilters } from 'ui/agg_types/filter';
/**
* If rollup index pattern, check its capabilities
* and limit available aggregations based on that.
*/
aggTypeFilters.addFilter(
(aggType, indexPattern) => {
if(indexPattern.type !== 'rollup') {
return true;
}
const aggName = aggType.name;
const aggs = indexPattern.typeMeta && indexPattern.typeMeta.aggs;
export function initAggTypeFilter() {
/**
* If rollup index pattern, check its capabilities
* and limit available aggregations based on that.
*/
aggTypeFilters.addFilter(
(aggType, indexPattern) => {
if(indexPattern.type !== 'rollup') {
return true;
}
const aggName = aggType.name;
const aggs = indexPattern.typeMeta && indexPattern.typeMeta.aggs;
// Return doc_count (which is collected by default for rollup date histogram, histogram, and terms)
// and the rest of the defined metrics from capabilities.
return aggName === 'count' || Object.keys(aggs).includes(aggName);
}
);
// Return doc_count (which is collected by default for rollup date histogram, histogram, and terms)
// and the rest of the defined metrics from capabilities.
return aggName === 'count' || Object.keys(aggs).includes(aggName);
}
);
}

View file

@ -6,77 +6,79 @@
import { editorConfigProviders } from 'ui/vis/editors/config/editor_config_providers';
// Limit agg params based on rollup capabilities
editorConfigProviders.register((aggType, indexPattern, aggConfig) => {
if(indexPattern.type !== 'rollup') {
export function initEditorConfig() {
// Limit agg params based on rollup capabilities
editorConfigProviders.register((aggType, indexPattern, aggConfig) => {
if(indexPattern.type !== 'rollup') {
return {};
}
const aggTypeName = aggConfig.type && aggConfig.type.name;
// Exclude certain param options for terms:
// otherBucket, missingBucket, orderBy, orderAgg
if(aggTypeName === 'terms') {
return {
otherBucket: {
hidden: true
},
missingBucket: {
hidden: true
},
orderBy: {
fixedValue: '_key',
hidden: true
},
orderAgg: {
hidden: true,
}
};
}
const rollupAggs = indexPattern.typeMeta && indexPattern.typeMeta.aggs;
const field = aggConfig.params && aggConfig.params.field && aggConfig.params.field.name;
const fieldAgg = rollupAggs && field && rollupAggs[aggTypeName] && rollupAggs[aggTypeName][field];
if(!rollupAggs || !field || !fieldAgg) {
return {};
}
// Set interval and base interval for histograms based on rollup capabilities
if(aggTypeName === 'histogram') {
const interval = fieldAgg.interval;
return interval ? {
intervalBase: {
fixedValue: interval
},
interval: {
base: interval,
help: `Must be a multiple of rollup configuration interval: ${interval}`
}
} : {};
}
// Set date histogram time zone based on rollup capabilities
if (aggTypeName === 'date_histogram') {
const timezone = fieldAgg.time_zone || 'UTC';
const interval = fieldAgg.interval;
return {
time_zone: {
fixedValue: timezone,
},
interval: {
fixedValue: 'custom',
},
useNormalizedEsInterval: {
fixedValue: false,
},
customInterval: {
default: interval,
timeBase: interval,
help: `Must be a multiple of rollup configuration interval: ${interval}`
}
};
}
return {};
}
const aggTypeName = aggConfig.type && aggConfig.type.name;
// Exclude certain param options for terms:
// otherBucket, missingBucket, orderBy, orderAgg
if(aggTypeName === 'terms') {
return {
otherBucket: {
hidden: true
},
missingBucket: {
hidden: true
},
orderBy: {
fixedValue: '_key',
hidden: true
},
orderAgg: {
hidden: true,
}
};
}
const rollupAggs = indexPattern.typeMeta && indexPattern.typeMeta.aggs;
const field = aggConfig.params && aggConfig.params.field && aggConfig.params.field.name;
const fieldAgg = rollupAggs && field && rollupAggs[aggTypeName] && rollupAggs[aggTypeName][field];
if(!rollupAggs || !field || !fieldAgg) {
return {};
}
// Set interval and base interval for histograms based on rollup capabilities
if(aggTypeName === 'histogram') {
const interval = fieldAgg.interval;
return interval ? {
intervalBase: {
fixedValue: interval
},
interval: {
base: interval,
help: `Must be a multiple of rollup configuration interval: ${interval}`
}
} : {};
}
// Set date histogram time zone based on rollup capabilities
if (aggTypeName === 'date_histogram') {
const timezone = fieldAgg.time_zone || 'UTC';
const interval = fieldAgg.interval;
return {
time_zone: {
fixedValue: timezone,
},
interval: {
fixedValue: 'custom',
},
useNormalizedEsInterval: {
fixedValue: false,
},
customInterval: {
default: interval,
timeBase: interval,
help: `Must be a multiple of rollup configuration interval: ${interval}`
}
};
}
return {};
});
});
}

View file

@ -4,6 +4,17 @@
* you may not use this file except in compliance with the Elastic License.
*/
import './agg_type_filter';
import './agg_type_field_filter';
import './editor_config';
import chrome from 'ui/chrome';
import { initAggTypeFilter } from './agg_type_filter';
import { initAggTypeFieldFilter } from './agg_type_field_filter';
import { initEditorConfig } from './editor_config';
const uiSettings = chrome.getUiSettingsClient();
const isRollupIndexPatternsEnabled = uiSettings.get('rollups:enableIndexPatterns');
if (isRollupIndexPatternsEnabled) {
initAggTypeFilter();
initAggTypeFieldFilter();
initEditorConfig();
}