mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
Make link to es deprecation logs more useful (#203487)
## Summary resolves https://github.com/elastic/kibana/issues/201538 Added a profile to the deprecation logs so by default it shows the columns. Decided to allow this behaviour if the pattern contains multiple patterns for deprecation logs like: `.logs-deprecation.abc,.logs-deprecation.def` , this can be easily changed if we prefer not to do it this way. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
5be7182bd4
commit
c423e3e9d3
6 changed files with 157 additions and 0 deletions
2
.github/CODEOWNERS
vendored
2
.github/CODEOWNERS
vendored
|
@ -1144,6 +1144,8 @@ x-pack/test_serverless/api_integration/test_suites/common/platform_security @ela
|
|||
/x-pack/test_serverless/functional/test_suites/common/examples/unified_field_list_examples @elastic/kibana-data-discovery
|
||||
/x-pack/test_serverless/functional/test_suites/common/management/data_views @elastic/kibana-data-discovery
|
||||
src/plugins/discover/public/context_awareness/profile_providers/security @elastic/kibana-data-discovery @elastic/security-threat-hunting-investigations
|
||||
# TODO: this deprecation_logs folder should be owned by kibana management team after 9.0
|
||||
src/plugins/discover/public/context_awareness/profile_providers/common/deprecation_logs @elastic/kibana-data-discovery @elastic/kibana-core
|
||||
src/plugins/discover/public/context_awareness/profile_providers/observability @elastic/kibana-data-discovery @elastic/obs-ux-logs-team
|
||||
|
||||
# Platform Docs
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the "Elastic License
|
||||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
|
||||
* Public License v 1"; you may not use this file except in compliance with, at
|
||||
* your election, the "Elastic License 2.0", the "GNU Affero General Public
|
||||
* License v3.0 only", or the "Server Side Public License, v 1".
|
||||
*/
|
||||
|
||||
export const DEPRECATION_LOGS_PROFILE_ID = 'deprecation-logs-profile';
|
||||
export const DEPRECATION_LOGS_PATTERN_PREFIX = '.logs-deprecation';
|
|
@ -0,0 +1,10 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the "Elastic License
|
||||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
|
||||
* Public License v 1"; you may not use this file except in compliance with, at
|
||||
* your election, the "Elastic License 2.0", the "GNU Affero General Public
|
||||
* License v3.0 only", or the "Server Side Public License, v 1".
|
||||
*/
|
||||
|
||||
export { createDeprecationLogsDataSourceProfileProvider } from './profile';
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the "Elastic License
|
||||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
|
||||
* Public License v 1"; you may not use this file except in compliance with, at
|
||||
* your election, the "Elastic License 2.0", the "GNU Affero General Public
|
||||
* License v3.0 only", or the "Server Side Public License, v 1".
|
||||
*/
|
||||
|
||||
import { createStubIndexPattern } from '@kbn/data-views-plugin/common/data_view.stub';
|
||||
import { createDataViewDataSource } from '../../../../../common/data_sources';
|
||||
import { DataSourceCategory, RootContext, SolutionType } from '../../../profiles';
|
||||
import { createDeprecationLogsDataSourceProfileProvider } from './profile';
|
||||
import type { ContextWithProfileId } from '../../../profile_service';
|
||||
import { DEPRECATION_LOGS_PROFILE_ID } from './consts';
|
||||
|
||||
describe('deprecationLogsProfileProvider', () => {
|
||||
const deprecationLogsProfileProvider = createDeprecationLogsDataSourceProfileProvider();
|
||||
const VALID_INDEX_PATTERN = '.logs-deprecation.elasticsearch-default';
|
||||
const VALID_MIXED_INDEX_PATTERN =
|
||||
'.logs-deprecation.elasticsearch-default,.logs-deprecation.abc,.logs-deprecation.def';
|
||||
const INVALID_MIXED_INDEX_PATTERN = '.logs-deprecation.elasticsearch-default,metrics-*';
|
||||
const INVALID_INDEX_PATTERN = 'my_source-access-*';
|
||||
const ROOT_CONTEXT: ContextWithProfileId<RootContext> = {
|
||||
profileId: DEPRECATION_LOGS_PROFILE_ID,
|
||||
solutionType: SolutionType.Default,
|
||||
};
|
||||
const RESOLUTION_MATCH = {
|
||||
isMatch: true,
|
||||
context: {
|
||||
category: DataSourceCategory.Logs,
|
||||
},
|
||||
};
|
||||
const RESOLUTION_MISMATCH = {
|
||||
isMatch: false,
|
||||
};
|
||||
|
||||
it('should match data view sources with an allowed index pattern', () => {
|
||||
const result = deprecationLogsProfileProvider.resolve({
|
||||
rootContext: ROOT_CONTEXT,
|
||||
dataSource: createDataViewDataSource({ dataViewId: VALID_INDEX_PATTERN }),
|
||||
dataView: createStubIndexPattern({ spec: { title: VALID_INDEX_PATTERN } }),
|
||||
});
|
||||
expect(result).toEqual(RESOLUTION_MATCH);
|
||||
});
|
||||
|
||||
it('should match data view sources with a mixed pattern containing allowed index patterns', () => {
|
||||
const result = deprecationLogsProfileProvider.resolve({
|
||||
rootContext: ROOT_CONTEXT,
|
||||
dataSource: createDataViewDataSource({ dataViewId: VALID_MIXED_INDEX_PATTERN }),
|
||||
dataView: createStubIndexPattern({ spec: { title: VALID_MIXED_INDEX_PATTERN } }),
|
||||
});
|
||||
expect(result).toEqual(RESOLUTION_MATCH);
|
||||
});
|
||||
|
||||
it('should NOT match data view sources with not allowed index pattern', () => {
|
||||
const result = deprecationLogsProfileProvider.resolve({
|
||||
rootContext: ROOT_CONTEXT,
|
||||
dataSource: createDataViewDataSource({ dataViewId: INVALID_INDEX_PATTERN }),
|
||||
dataView: createStubIndexPattern({ spec: { title: INVALID_INDEX_PATTERN } }),
|
||||
});
|
||||
expect(result).toEqual(RESOLUTION_MISMATCH);
|
||||
});
|
||||
|
||||
it('should NOT match data view sources with a mixed pattern containing not allowed index patterns', () => {
|
||||
const result = deprecationLogsProfileProvider.resolve({
|
||||
rootContext: ROOT_CONTEXT,
|
||||
dataSource: createDataViewDataSource({ dataViewId: INVALID_MIXED_INDEX_PATTERN }),
|
||||
dataView: createStubIndexPattern({ spec: { title: INVALID_MIXED_INDEX_PATTERN } }),
|
||||
});
|
||||
expect(result).toEqual(RESOLUTION_MISMATCH);
|
||||
});
|
||||
});
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the "Elastic License
|
||||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
|
||||
* Public License v 1"; you may not use this file except in compliance with, at
|
||||
* your election, the "Elastic License 2.0", the "GNU Affero General Public
|
||||
* License v3.0 only", or the "Server Side Public License, v 1".
|
||||
*/
|
||||
|
||||
import { DataSourceCategory } from '../../../profiles';
|
||||
import { type DataSourceProfileProvider } from '../../../profiles';
|
||||
import { DEPRECATION_LOGS_PATTERN_PREFIX, DEPRECATION_LOGS_PROFILE_ID } from './consts';
|
||||
import { extractIndexPatternFrom } from '../../extract_index_pattern_from';
|
||||
|
||||
export const createDeprecationLogsDataSourceProfileProvider =
|
||||
(): DataSourceProfileProvider<{}> => ({
|
||||
profileId: DEPRECATION_LOGS_PROFILE_ID,
|
||||
profile: {
|
||||
getDefaultAppState: () => () => ({
|
||||
columns: [
|
||||
{ name: 'log.level', width: 150 },
|
||||
{ name: 'message' },
|
||||
{ name: 'elasticsearch.http.request.x_opaque_id', width: 250 },
|
||||
{ name: 'elasticsearch.cluster.name', width: 250 },
|
||||
{ name: 'elasticsearch.event.category', width: 250 },
|
||||
],
|
||||
}),
|
||||
},
|
||||
resolve: (params) => {
|
||||
const indexPattern = extractIndexPatternFrom(params);
|
||||
|
||||
if (!checkAllIndicesInPatternAreDeprecationLogs(indexPattern)) {
|
||||
return { isMatch: false };
|
||||
}
|
||||
|
||||
return {
|
||||
isMatch: true,
|
||||
context: {
|
||||
category: DataSourceCategory.Logs,
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
/*
|
||||
This function returns true if the index pattern belongs to deprecation logs.
|
||||
It also considers multiple patterns separated by commas.
|
||||
*/
|
||||
const checkAllIndicesInPatternAreDeprecationLogs = (indexPattern: string | null): boolean => {
|
||||
if (!indexPattern) {
|
||||
return false;
|
||||
}
|
||||
const indexPatternArray = indexPattern.split(',');
|
||||
const result = indexPatternArray.reduce(
|
||||
(acc, val) => acc && val.startsWith(DEPRECATION_LOGS_PATTERN_PREFIX),
|
||||
true
|
||||
);
|
||||
return result;
|
||||
};
|
|
@ -28,6 +28,7 @@ import {
|
|||
} from './profile_provider_services';
|
||||
import type { DiscoverServices } from '../../build_services';
|
||||
import { createObservabilityRootProfileProvider } from './observability/observability_root_profile';
|
||||
import { createDeprecationLogsDataSourceProfileProvider } from './common/deprecation_logs';
|
||||
|
||||
/**
|
||||
* Register profile providers for root, data source, and document contexts to the profile profile services
|
||||
|
@ -133,6 +134,7 @@ const createRootProfileProviders = (providerServices: ProfileProviderServices) =
|
|||
*/
|
||||
const createDataSourceProfileProviders = (providerServices: ProfileProviderServices) => [
|
||||
createExampleDataSourceProfileProvider(),
|
||||
createDeprecationLogsDataSourceProfileProvider(),
|
||||
...createObservabilityLogsDataSourceProfileProviders(providerServices),
|
||||
];
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue