Skip to content

Commit

Permalink
Remove field_stats pre-flight option for index patterns (#12814)
Browse files Browse the repository at this point in the history
* Remove field_stats pre-flight option for index patterns

This feature was originally added to make searches against Elasticsearch
more performant when searching across many indices, such as when dealing
with daily indices that have accumulated for years. Elasticsearch now
automatically optimizes index access once a certain amount of shards are
in play, so Kibana doesn't need to hack its own solution.

This option can be removed entirely as existing index patterns that had
this option configured will degrade gracefully.

* test: fix parse error test to account for multiple shards
  • Loading branch information
epixa authored Jul 13, 2017
1 parent 10d243d commit 60c636b
Show file tree
Hide file tree
Showing 10 changed files with 1 addition and 459 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,6 @@ describe('createIndexPattern UI', () => {
}
});
});

it('displays the option (off) to expand wildcards', () => {
const { $view } = setup();
const $enableExpand = $view.findTestSubject('createIndexPatternEnableExpand');
expect($enableExpand).to.have.length(1);
expect($enableExpand.is(':checked')).to.be(false);
});
});

describe('cross cluster pattern', () => {
Expand All @@ -127,13 +120,5 @@ describe('createIndexPattern UI', () => {
expect(classes).to.contain('ng-valid');
expect(classes).to.not.contain('ng-invalid');
});

it('removes the option to expand wildcards', () => {
const { $view, setNameTo } = setup();
setNameTo('cluster2:logstash-*');

const $enableExpand = $view.findTestSubject('createIndexPatternEnableExpand');
expect($enableExpand).to.have.length(0);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -131,43 +131,6 @@
</div>
</div>

<!-- Expand index pattern checkbox -->
<div class="kuiVerticalRhythm" ng-if="controller.canEnableExpandWildcard()">
<label class="kuiCheckBoxLabel kuiVerticalRhythm">
<input
class="kuiCheckBox"
type="checkbox"
data-test-subj="createIndexPatternEnableExpand"
ng-model="controller.formValues.expandWildcard"
>
<span class="kuiCheckBoxLabel__text">
<span translate="KIBANA-EXPAND_INDEX_PATTERN"></span>
<span translate="KIBANA-DEPRECATED"></span>
</span>
</label>

<!-- Checkbox help text -->
<div class="kuiVerticalRhythm">
<p
class="kuiSubText kuiVerticalRhythmSmall"
translate="KIBANA-WILDCARD_DEFAULT_EXPANDED_TO_CURRENT_TIME_RANGE"
></p>

<p class="kuiSubText kuiVerticalRhythmSmall">
<span translate="KIBANA-SEARCH_AGAINST_INDEX_PATTERN"></span>
<em translate="KIBANA-LOGSTASH_WILDCARD"></em>
<span translate="KIBANA-ACTUALLY_QUERY"></span>
<em translate="KIBANA-EXAMPLE_TIME_RANGE"></em>
<span translate="KIBANA-FALL_WITHIN_CURRENT_TIME_RANGE"></span>
</p>

<p
class="kuiSubText kuiVerticalRhythmSmall"
translate="KIBANA-EXPAND_INDEX_PATTERN_DEPRECATION"
></p>
</div>
</div>

<!-- Form actions -->
<button
data-test-subj="createIndexPatternCreateButton"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import _ from 'lodash';
import { IndexPatternMissingIndices } from 'ui/errors';
import 'ui/directives/validate_index_name';
import 'ui/directives/auto_select_if_only_one';
Expand Down Expand Up @@ -33,7 +32,6 @@ uiModules.get('apps/management')
this.formValues = {
id: $routeParams.id ? decodeURIComponent($routeParams.id) : undefined,
name: config.get('indexPattern:placeholder'),
expandWildcard: false,
timeFieldOption: null,
};

Expand Down Expand Up @@ -134,21 +132,6 @@ uiModules.get('apps/management')
return Boolean(this.formValues.timeFieldOption.fieldName);
};

this.canEnableExpandWildcard = () => {
return (
this.isTimeBased() &&
!this.isCrossClusterName() &&
_.includes(this.formValues.name, '*')
);
};

this.isExpandWildcardEnabled = () => {
return (
this.canEnableExpandWildcard() &&
!!this.formValues.expandWildcard
);
};

this.isCrossClusterName = () => {
return (
this.formValues.name &&
Expand Down Expand Up @@ -217,16 +200,11 @@ uiModules.get('apps/management')
? timeFieldOption.fieldName
: undefined;

const notExpandable = this.isExpandWildcardEnabled()
? undefined
: true;

loadingCount += 1;
sendCreateIndexPatternRequest(indexPatterns, {
id,
name,
timeFieldName,
notExpandable,
}).then(createdId => {
if (!createdId) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ export function sendCreateIndexPatternRequest(indexPatterns, {
id,
name,
timeFieldName,
notExpandable,
}) {
// get an empty indexPattern to start
return indexPatterns.get()
Expand All @@ -11,7 +10,6 @@ export function sendCreateIndexPatternRequest(indexPatterns, {
id,
title: name,
timeFieldName,
notExpandable,
});

// fetch the fields
Expand Down
9 changes: 0 additions & 9 deletions src/core_plugins/kibana/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"KIBANA-CONFIGURE_INDEX_PATTERN": "Configure an index pattern",
"KIBANA-MUST_CONFIGURE_INDEX_PATTERN": "In order to use Kibana you must configure at least one index pattern. Index patterns are used to identify the Elasticsearch index to run search and analytics against. They are also used to configure fields.",
"KIBANA-INDEX_NAME_CREATED_BY_EVENT_TIMES": "Use event times to create index names ",
"KIBANA-DEPRECATED": "[DEPRECATED]",
"KIBANA-ALERT_INDEX_PATTERN_DEPRECATED": "Time-interval based index patterns are deprecated!",
"KIBANA-WE": " We",
"KIBANA-STRONGLY_RECOMMEND": " strongly recommend",
Expand All @@ -18,14 +17,6 @@
"KIBANA-STATIC_TEXT_IN_DYNAMIC_INDEX_PATTERNS": "Patterns allow you to define dynamic index names. Static text in an index name is denoted using brackets. Example: [logstash-]YYYY.MM.DD. Please note that weeks are setup to use ISO weeks which start on Monday.",
"KIBANA-NOTE_COLON": "Note:",
"KIBANA-WEEKLY_ISO_NOTICE": "I noticed you are using weekly indices. Kibana requires ISO weeks be used in your index creation.",
"KIBANA-EXPAND_INDEX_PATTERN": "Expand index pattern when searching",
"KIBANA-WILDCARD_DEFAULT_EXPANDED_TO_CURRENT_TIME_RANGE": "With this option selected, searches against any time-based index pattern that contains a wildcard will automatically be expanded to query only the indices that contain data within the currently selected time range.",
"KIBANA-SEARCH_AGAINST_INDEX_PATTERN": "Searching against the index pattern ",
"KIBANA-LOGSTASH_WILDCARD": "logstash-*",
"KIBANA-ACTUALLY_QUERY": " will actually query Elasticsearch for the specific matching indices (e.g. ",
"KIBANA-EXAMPLE_TIME_RANGE": "logstash-2015.12.21",
"KIBANA-FALL_WITHIN_CURRENT_TIME_RANGE": ") that fall within the current time range.",
"KIBANA-EXPAND_INDEX_PATTERN_DEPRECATION": "With recent changes to Elasticsearch, this option should no longer be necessary and will likely be removed in future versions of Kibana.",
"KIBANA-SAMPLE_ALERT": "Attempted to match the following indices and aliases:",
"KIBANA-EXPAND_SEARCH": "Expand Search",
"KIBANA-EXISTING_MATCH_PERCENT": "Pattern matches {{indexExistingMatchPercent}} of existing indices and aliases",
Expand Down
78 changes: 0 additions & 78 deletions src/ui/public/index_patterns/__tests__/_index_pattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { Notifier } from 'ui/notify';
import { FieldsFetcherProvider } from '../fields_fetcher_provider';
import { StubIndexPatternsApiClientModule } from './stub_index_patterns_api_client';
import { IndexPatternsApiClientProvider } from '../index_patterns_api_client_provider';
import { IndexPatternsCalculateIndicesProvider } from '../_calculate_indices';
import { IsUserAwareOfUnsupportedTimePatternProvider } from '../unsupported_time_patterns';
import { SavedObjectsClientProvider } from 'ui/saved_objects';

Expand All @@ -33,25 +32,12 @@ describe('index pattern', function () {
let savedObjectsResponse;
const indexPatternId = 'test-pattern';
let indexPattern;
let calculateIndices;
let intervals;
let indexPatternsApiClient;
let defaultTimeField;
let isUserAwareOfUnsupportedTimePattern;

beforeEach(ngMock.module('kibana', StubIndexPatternsApiClientModule, (PrivateProvider) => {
PrivateProvider.swap(IndexPatternsCalculateIndicesProvider, () => {
// stub calculateIndices
calculateIndices = sinon.spy(function () {
return Promise.resolve([
{ index: 'foo', max: Infinity, min: -Infinity },
{ index: 'bar', max: Infinity, min: -Infinity }
]);
});

return calculateIndices;
});

isUserAwareOfUnsupportedTimePattern = sinon.stub().returns(false);
PrivateProvider.swap(IsUserAwareOfUnsupportedTimePatternProvider, () => {
return isUserAwareOfUnsupportedTimePattern;
Expand Down Expand Up @@ -317,33 +303,6 @@ describe('index pattern', function () {
});

describe('when index pattern is a time-base wildcard', function () {
beforeEach(function () {
indexPattern.id = 'randomID';
indexPattern.title = 'logstash-*';
indexPattern.timeFieldName = defaultTimeField.name;
indexPattern.intervalName = null;
indexPattern.notExpandable = false;
});

it('invokes calculateIndices with given start/stop times and sortOrder', async function () {
await indexPattern.toDetailedIndexList(1, 2, 'sortOrder');

const { title, timeFieldName } = indexPattern;

sinon.assert.calledOnce(calculateIndices);
expect(calculateIndices.getCall(0).args).to.eql([
title, timeFieldName, 1, 2, 'sortOrder'
]);
});

it('is fulfilled by the result of calculateIndices', async function () {
const indexList = await indexPattern.toDetailedIndexList();
expect(indexList[0].index).to.equal('foo');
expect(indexList[1].index).to.equal('bar');
});
});

describe('when index pattern is a time-base wildcard that is configured not to expand', function () {
beforeEach(function () {
indexPattern.id = 'randomID';
indexPattern.title = 'logstash-*';
Expand Down Expand Up @@ -411,28 +370,6 @@ describe('index pattern', function () {
});

describe('when index pattern is a time-base wildcard', function () {
beforeEach(function () {
indexPattern.id = 'randomID';
indexPattern.title = 'logstash-*';
indexPattern.timeFieldName = defaultTimeField.name;
indexPattern.intervalName = null;
indexPattern.notExpandable = false;
});

it('invokes calculateIndices with given start/stop times and sortOrder', async function () {
await indexPattern.toIndexList(1, 2, 'sortOrder');
const { title, timeFieldName } = indexPattern;
expect(calculateIndices.calledWith(title, timeFieldName, 1, 2, 'sortOrder')).to.be(true);
});

it('is fulfilled by the result of calculateIndices', async function () {
const indexList = await indexPattern.toIndexList();
expect(indexList[0]).to.equal('foo');
expect(indexList[1]).to.equal('bar');
});
});

describe('when index pattern is a time-base wildcard that is configured not to expand', function () {
beforeEach(function () {
indexPattern.id = 'randomID';
indexPattern.title = 'logstash-*';
Expand Down Expand Up @@ -463,21 +400,6 @@ describe('index pattern', function () {
});
});

describe('#isIndexExpansionEnabled()', function () {
it('returns true if notExpandable is false', function () {
indexPattern.notExpandable = false;
expect(indexPattern.isIndexExpansionEnabled()).to.be(true);
});
it('returns true if notExpandable is not defined', function () {
delete indexPattern.notExpandable;
expect(indexPattern.isIndexExpansionEnabled()).to.be(true);
});
it('returns false if notExpandable is true', function () {
indexPattern.notExpandable = true;
expect(indexPattern.isIndexExpansionEnabled()).to.be(false);
});
});

describe('#isTimeBased()', function () {
beforeEach(function () {
// for the sake of these tests, it doesn't much matter what type of field
Expand Down
Loading

0 comments on commit 60c636b

Please sign in to comment.