mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[8.1] Fix empty data view and welcome screen appearing when ent search is enabled (#127260) (#127815)
* Fix empty data view and welcome screen appearing when ent search is enabled (#127260)
(cherry picked from commit 1cbe1f3819
)
# Conflicts:
# src/plugins/data_views/server/has_user_index_pattern.ts
* fix unit test
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
4705a1dc9f
commit
c35c2fdc97
13 changed files with 67 additions and 25 deletions
|
@ -58,7 +58,7 @@ export type {
|
|||
} from '../../data_views/common';
|
||||
export {
|
||||
RUNTIME_FIELD_TYPES,
|
||||
FLEET_ASSETS_TO_IGNORE,
|
||||
DEFAULT_ASSETS_TO_IGNORE,
|
||||
META_FIELDS,
|
||||
DATA_VIEW_SAVED_OBJECT_TYPE,
|
||||
INDEX_PATTERN_SAVED_OBJECT_TYPE,
|
||||
|
|
|
@ -202,7 +202,7 @@ exports[`EmptyIndexListPrompt should render normally 1`] = `
|
|||
onClick={[Function]}
|
||||
>
|
||||
<FormattedMessage
|
||||
defaultMessage="create a data view against hidden or system indices."
|
||||
defaultMessage="create a data view against hidden, system or default indices."
|
||||
id="indexPatternEditor.createDataView.emptyState.createAnywayLink"
|
||||
values={Object {}}
|
||||
/>
|
||||
|
|
|
@ -53,7 +53,7 @@ export const EmptyIndexListPrompt = ({
|
|||
<EuiLink onClick={() => createAnyway()} data-test-subj="createAnyway">
|
||||
<FormattedMessage
|
||||
id="indexPatternEditor.createDataView.emptyState.createAnywayLink"
|
||||
defaultMessage="create a data view against hidden or system indices."
|
||||
defaultMessage="create a data view against hidden, system or default indices."
|
||||
/>
|
||||
</EuiLink>
|
||||
),
|
||||
|
|
|
@ -84,6 +84,26 @@ describe('isUserDataIndex', () => {
|
|||
expect(isUserDataIndex(fleetAssetIndex)).toBe(false);
|
||||
});
|
||||
|
||||
test('ent search logs not data index', () => {
|
||||
const fleetAssetIndex: MatchedItem = {
|
||||
name: 'logs-enterprise_search.api-default',
|
||||
tags: [
|
||||
{
|
||||
key: 'data_stream',
|
||||
name: 'Data stream',
|
||||
color: 'primary',
|
||||
},
|
||||
],
|
||||
item: {
|
||||
name: 'logs-enterprise_search.api-default',
|
||||
backing_indices: ['.ds-logs-enterprise_search.api-default-2022.03.07-000001'],
|
||||
timestamp_field: '@timestamp',
|
||||
},
|
||||
};
|
||||
|
||||
expect(isUserDataIndex(fleetAssetIndex)).toBe(false);
|
||||
});
|
||||
|
||||
test('metrics-endpoint.metadata_current_default is not data index', () => {
|
||||
const fleetAssetIndex: MatchedItem = {
|
||||
name: 'metrics-endpoint.metadata_current_default',
|
||||
|
|
|
@ -18,7 +18,7 @@ import { getIndices } from '../../lib';
|
|||
import { EmptyIndexListPrompt } from './empty_index_list_prompt';
|
||||
import { EmptyIndexPatternPrompt } from './empty_index_pattern_prompt';
|
||||
import { PromptFooter } from './prompt_footer';
|
||||
import { FLEET_ASSETS_TO_IGNORE } from '../../../../data/common';
|
||||
import { DEFAULT_ASSETS_TO_IGNORE } from '../../../../data/common';
|
||||
|
||||
const removeAliases = (item: MatchedItem) =>
|
||||
!(item as unknown as ResolveIndexResponseItemAlias).indices;
|
||||
|
@ -33,10 +33,11 @@ export function isUserDataIndex(source: MatchedItem) {
|
|||
// filter out indices that start with `.`
|
||||
if (source.name.startsWith('.')) return false;
|
||||
|
||||
// filter out sources from FLEET_ASSETS_TO_IGNORE
|
||||
if (source.name === FLEET_ASSETS_TO_IGNORE.LOGS_DATA_STREAM_TO_IGNORE) return false;
|
||||
if (source.name === FLEET_ASSETS_TO_IGNORE.METRICS_DATA_STREAM_TO_IGNORE) return false;
|
||||
if (source.name === FLEET_ASSETS_TO_IGNORE.METRICS_ENDPOINT_INDEX_TO_IGNORE) return false;
|
||||
// filter out sources from DEFAULT_ASSETS_TO_IGNORE
|
||||
if (source.name === DEFAULT_ASSETS_TO_IGNORE.LOGS_DATA_STREAM_TO_IGNORE) return false;
|
||||
if (source.name === DEFAULT_ASSETS_TO_IGNORE.METRICS_DATA_STREAM_TO_IGNORE) return false;
|
||||
if (source.name === DEFAULT_ASSETS_TO_IGNORE.METRICS_ENDPOINT_INDEX_TO_IGNORE) return false;
|
||||
if (source.name === DEFAULT_ASSETS_TO_IGNORE.ENT_SEARCH_LOGS_DATA_STREAM_TO_IGNORE) return false;
|
||||
|
||||
// filter out empty sources created by apm server
|
||||
if (source.name.startsWith('apm-')) return false;
|
||||
|
|
|
@ -22,11 +22,12 @@ export const RUNTIME_FIELD_TYPES = [
|
|||
* Should be revised after https://github.com/elastic/kibana/issues/82851 is fixed
|
||||
* For more background see: https://github.com/elastic/kibana/issues/107020
|
||||
*/
|
||||
export const FLEET_ASSETS_TO_IGNORE = {
|
||||
export const DEFAULT_ASSETS_TO_IGNORE = {
|
||||
LOGS_INDEX_PATTERN: 'logs-*',
|
||||
METRICS_INDEX_PATTERN: 'metrics-*',
|
||||
LOGS_DATA_STREAM_TO_IGNORE: 'logs-elastic_agent', // ignore ds created by Fleet server itself
|
||||
METRICS_DATA_STREAM_TO_IGNORE: 'metrics-elastic_agent', // ignore ds created by Fleet server itself
|
||||
ENT_SEARCH_LOGS_DATA_STREAM_TO_IGNORE: 'logs-enterprise_search.api-default', // ignore ds created by enterprise search
|
||||
METRICS_ENDPOINT_INDEX_TO_IGNORE: 'metrics-endpoint.metadata_current_default', // ignore index created by Fleet endpoint package installed by default in Cloud
|
||||
};
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import { fieldFormatsMock } from '../../../field_formats/common/mocks';
|
|||
|
||||
import { UiSettingsCommon, SavedObjectsClientCommon, SavedObject } from '../types';
|
||||
import { stubbedSavedObjectIndexPattern } from '../data_view.stub';
|
||||
import { FLEET_ASSETS_TO_IGNORE } from '../constants';
|
||||
import { DEFAULT_ASSETS_TO_IGNORE } from '../constants';
|
||||
|
||||
const createFieldsFetcher = jest.fn().mockImplementation(() => ({
|
||||
getFieldsForWildcard: jest.fn().mockImplementation(() => {
|
||||
|
@ -382,12 +382,12 @@ describe('IndexPatterns', () => {
|
|||
{
|
||||
id: 'id1',
|
||||
version: 'a',
|
||||
attributes: { title: FLEET_ASSETS_TO_IGNORE.LOGS_INDEX_PATTERN },
|
||||
attributes: { title: DEFAULT_ASSETS_TO_IGNORE.LOGS_INDEX_PATTERN },
|
||||
},
|
||||
{
|
||||
id: 'id2',
|
||||
version: 'a',
|
||||
attributes: { title: FLEET_ASSETS_TO_IGNORE.METRICS_INDEX_PATTERN },
|
||||
attributes: { title: DEFAULT_ASSETS_TO_IGNORE.METRICS_INDEX_PATTERN },
|
||||
},
|
||||
{
|
||||
id: 'id3',
|
||||
|
|
|
@ -11,7 +11,11 @@
|
|||
import { i18n } from '@kbn/i18n';
|
||||
import { PublicMethodsOf } from '@kbn/utility-types';
|
||||
import { castEsToKbnFieldTypeName } from '@kbn/field-types';
|
||||
import { DATA_VIEW_SAVED_OBJECT_TYPE, FLEET_ASSETS_TO_IGNORE, SavedObjectsClientCommon } from '..';
|
||||
import {
|
||||
DATA_VIEW_SAVED_OBJECT_TYPE,
|
||||
DEFAULT_ASSETS_TO_IGNORE,
|
||||
SavedObjectsClientCommon,
|
||||
} from '..';
|
||||
|
||||
import { createDataViewCache } from '.';
|
||||
import type { RuntimeField } from '../types';
|
||||
|
@ -711,8 +715,8 @@ export class DataViewsService {
|
|||
// otherwise fallback to any data view
|
||||
const userDataViews = patterns.filter(
|
||||
(pattern) =>
|
||||
pattern.title !== FLEET_ASSETS_TO_IGNORE.LOGS_INDEX_PATTERN &&
|
||||
pattern.title !== FLEET_ASSETS_TO_IGNORE.METRICS_INDEX_PATTERN
|
||||
pattern.title !== DEFAULT_ASSETS_TO_IGNORE.LOGS_INDEX_PATTERN &&
|
||||
pattern.title !== DEFAULT_ASSETS_TO_IGNORE.METRICS_INDEX_PATTERN
|
||||
);
|
||||
|
||||
defaultId = userDataViews[0]?.id ?? patterns[0].id;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
export {
|
||||
RUNTIME_FIELD_TYPES,
|
||||
FLEET_ASSETS_TO_IGNORE,
|
||||
DEFAULT_ASSETS_TO_IGNORE,
|
||||
META_FIELDS,
|
||||
DATA_VIEW_SAVED_OBJECT_TYPE,
|
||||
INDEX_PATTERN_SAVED_OBJECT_TYPE,
|
||||
|
|
|
@ -138,6 +138,23 @@ describe('hasUserIndexPattern', () => {
|
|||
expect(await hasUserIndexPattern({ esClient, soClient })).toEqual(false);
|
||||
});
|
||||
|
||||
it('returns false if only logs-enterprise_search.api-default data stream exists', async () => {
|
||||
esClient.indices.resolveIndex.mockReturnValue(
|
||||
elasticsearchServiceMock.createSuccessTransportRequestPromise({
|
||||
indices: [],
|
||||
data_streams: [
|
||||
{
|
||||
name: 'logs-enterprise_search.api-default',
|
||||
timestamp_field: '@timestamp',
|
||||
backing_indices: ['.ds-logs-enterprise_search.api-default-2022.03.07-000001'],
|
||||
},
|
||||
],
|
||||
aliases: [],
|
||||
})
|
||||
);
|
||||
expect(await hasUserIndexPattern({ esClient, soClient })).toEqual(false);
|
||||
});
|
||||
|
||||
it('returns false if only metrics-endpoint.metadata_current_default index exists', async () => {
|
||||
esClient.indices.resolveIndex.mockReturnValue(
|
||||
elasticsearchServiceMock.createSuccessTransportRequestPromise({
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import { ElasticsearchClient, SavedObjectsClientContract } from '../../../core/server';
|
||||
import { IndexPatternSavedObjectAttrs } from '../common/data_views';
|
||||
import { FLEET_ASSETS_TO_IGNORE } from '../common/constants';
|
||||
import { DEFAULT_ASSETS_TO_IGNORE } from '../common/constants';
|
||||
|
||||
interface Deps {
|
||||
esClient: ElasticsearchClient;
|
||||
|
@ -33,27 +33,28 @@ export const hasUserIndexPattern = async ({ esClient, soClient }: Deps): Promise
|
|||
if (
|
||||
indexPatterns.saved_objects.some(
|
||||
(ip) =>
|
||||
ip.attributes.title !== FLEET_ASSETS_TO_IGNORE.METRICS_INDEX_PATTERN &&
|
||||
ip.attributes.title !== FLEET_ASSETS_TO_IGNORE.LOGS_INDEX_PATTERN
|
||||
ip.attributes.title !== DEFAULT_ASSETS_TO_IGNORE.METRICS_INDEX_PATTERN &&
|
||||
ip.attributes.title !== DEFAULT_ASSETS_TO_IGNORE.LOGS_INDEX_PATTERN
|
||||
)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const resolveResponse = await esClient.indices.resolveIndex({
|
||||
name: `${FLEET_ASSETS_TO_IGNORE.LOGS_INDEX_PATTERN},${FLEET_ASSETS_TO_IGNORE.METRICS_INDEX_PATTERN}`,
|
||||
name: `${DEFAULT_ASSETS_TO_IGNORE.LOGS_INDEX_PATTERN},${DEFAULT_ASSETS_TO_IGNORE.METRICS_INDEX_PATTERN}`,
|
||||
});
|
||||
|
||||
const hasAnyNonDefaultFleetIndices = resolveResponse.body.indices.some(
|
||||
(ds) => ds.name !== FLEET_ASSETS_TO_IGNORE.METRICS_ENDPOINT_INDEX_TO_IGNORE
|
||||
(ds) => ds.name !== DEFAULT_ASSETS_TO_IGNORE.METRICS_ENDPOINT_INDEX_TO_IGNORE
|
||||
);
|
||||
|
||||
if (hasAnyNonDefaultFleetIndices) return true;
|
||||
|
||||
const hasAnyNonDefaultFleetDataStreams = resolveResponse.body.data_streams.some(
|
||||
(ds) =>
|
||||
ds.name !== FLEET_ASSETS_TO_IGNORE.METRICS_DATA_STREAM_TO_IGNORE &&
|
||||
ds.name !== FLEET_ASSETS_TO_IGNORE.LOGS_DATA_STREAM_TO_IGNORE
|
||||
ds.name !== DEFAULT_ASSETS_TO_IGNORE.METRICS_DATA_STREAM_TO_IGNORE &&
|
||||
ds.name !== DEFAULT_ASSETS_TO_IGNORE.LOGS_DATA_STREAM_TO_IGNORE &&
|
||||
ds.name !== DEFAULT_ASSETS_TO_IGNORE.ENT_SEARCH_LOGS_DATA_STREAM_TO_IGNORE
|
||||
);
|
||||
|
||||
if (hasAnyNonDefaultFleetDataStreams) return true;
|
||||
|
|
|
@ -4293,7 +4293,6 @@
|
|||
"home.tutorials.zscalerLogs.shortDescription": "Filebeatを使用してZscaler NSSからログを収集して解析します。",
|
||||
"home.welcomeTitle": "Elasticへようこそ",
|
||||
"indexPatternEditor.aliasLabel": "エイリアス",
|
||||
"indexPatternEditor.createDataView.emptyState.createAnywayLink": "非表示のインデックスまたはシステムインデックスに対してデータビューを作成します。",
|
||||
"indexPatternEditor.createIndex.noMatch": "名前は1つ以上のデータストリーム、インデックス、またはインデックスエイリアスと一致する必要があります。",
|
||||
"indexPatternEditor.createIndexPattern.emptyState.checkDataButton": "新規データを確認",
|
||||
"indexPatternEditor.createIndexPattern.emptyState.createAnywayTxt": "{link}もできます。",
|
||||
|
|
|
@ -4302,7 +4302,6 @@
|
|||
"home.tutorials.zscalerLogs.shortDescription": "使用 Filebeat 从 Zscaler NSS 收集并解析日志。",
|
||||
"home.welcomeTitle": "欢迎使用 Elastic",
|
||||
"indexPatternEditor.aliasLabel": "别名",
|
||||
"indexPatternEditor.createDataView.emptyState.createAnywayLink": "根据隐藏或系统索引创建数据视图。",
|
||||
"indexPatternEditor.createIndex.noMatch": "名称必须匹配一个或多个数据流、索引或索引别名。",
|
||||
"indexPatternEditor.createIndexPattern.emptyState.checkDataButton": "检查新数据",
|
||||
"indexPatternEditor.createIndexPattern.emptyState.createAnywayTxt": "您还可以{link}",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue