-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Logs+] End onboarding wizard in default discover (#163218)
closes [#163080](#163080) ## 📝 Summary This PR navigates to default discover at the end of the onboarding flow for both custom and system workflows. It also adds `logs-*` as the default dataview along with a preset filter for the intended dataset during the onboarding flow. ## ✅ Testing 1. Navigate to the onboarding flow `/app/observabilityOnboarding/` 2. Choose either System logs or Stream log files 3. Go through the onboarding wizard 4. Click the Explore logs button at the end 5. Observe the DataView and Preset Filter after being navigated to Discover ## 🎥 Demo https://github.com/elastic/kibana/assets/11225826/5eff74e4-c12a-46e7-968a-6efa34a6a7a9 --------- Co-authored-by: kibanamachine <[email protected]>
- Loading branch information
1 parent
25c7852
commit a42df25
Showing
15 changed files
with
206 additions
and
91 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions
9
x-pack/plugins/observability_onboarding/common/elastic_agent_logs/index.ts
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,9 @@ | ||
/* | ||
* 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; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
export * from './custom_logs/generate_custom_logs_yml'; | ||
export * from './system_logs/generate_system_logs_yml'; |
File renamed without changes.
File renamed without changes.
103 changes: 103 additions & 0 deletions
103
...bservability_onboarding/common/elastic_agent_logs/system_logs/generate_system_logs_yml.ts
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,103 @@ | ||
/* | ||
* 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; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { dump } from 'js-yaml'; | ||
|
||
interface SystemLogsStream { | ||
id: string; | ||
data_stream: { | ||
dataset: string; | ||
type: string; | ||
}; | ||
paths: string[]; | ||
exclude_files: string[]; | ||
multiline: { | ||
pattern: string; | ||
match: string; | ||
}; | ||
tags?: string[]; | ||
processors: Array<{ | ||
add_locale: string | null; | ||
}>; | ||
} | ||
|
||
export const generateSystemLogsYml = ({ | ||
namespace = 'default', | ||
apiKey, | ||
esHost, | ||
uuid, | ||
}: { | ||
namespace?: string; | ||
apiKey: string; | ||
esHost: string[]; | ||
uuid: string; | ||
}) => { | ||
return dump({ | ||
outputs: { | ||
default: { | ||
type: 'elasticsearch', | ||
hosts: esHost, | ||
api_key: apiKey, | ||
}, | ||
}, | ||
inputs: [ | ||
{ | ||
id: `system-logs-${uuid}`, | ||
type: 'logfile', | ||
data_stream: { | ||
namespace, | ||
}, | ||
streams: getSystemLogsDataStreams(uuid), | ||
}, | ||
], | ||
}); | ||
}; | ||
|
||
/* | ||
* Utils | ||
*/ | ||
export const getSystemLogsDataStreams = ( | ||
uuid: string = '' | ||
): SystemLogsStream[] => [ | ||
{ | ||
id: `logfile-system.auth-${uuid}`, | ||
data_stream: { | ||
dataset: 'system.auth', | ||
type: 'logs', | ||
}, | ||
paths: ['/var/log/auth.log*', '/var/log/secure*'], | ||
exclude_files: ['.gz$'], | ||
multiline: { | ||
pattern: '^s', | ||
match: 'after', | ||
}, | ||
tags: ['system-auth'], | ||
processors: [ | ||
{ | ||
add_locale: null, | ||
}, | ||
], | ||
}, | ||
{ | ||
id: `logfile-system.syslog-${uuid}`, | ||
data_stream: { | ||
dataset: 'system.syslog', | ||
type: 'logs', | ||
}, | ||
paths: ['/var/log/messages*', '/var/log/syslog*', '/var/log/system*'], | ||
exclude_files: ['.gz$'], | ||
multiline: { | ||
pattern: '^s', | ||
match: 'after', | ||
}, | ||
processors: [ | ||
{ | ||
add_locale: null, | ||
}, | ||
], | ||
}, | ||
]; |
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
56 changes: 56 additions & 0 deletions
56
x-pack/plugins/observability_onboarding/public/components/app/utils.ts
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,56 @@ | ||
/* | ||
* 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; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import type { DataViewSpec } from '@kbn/data-views-plugin/common'; | ||
import { DiscoverAppLocatorParams } from '@kbn/discover-plugin/common'; | ||
import { Filter, FilterStateStore } from '@kbn/es-query'; | ||
|
||
type DiscoverPropertiesToPick = 'dataViewId' | 'dataViewSpec' | 'filters'; | ||
|
||
type DiscoverNavigationParams = Pick< | ||
DiscoverAppLocatorParams, | ||
DiscoverPropertiesToPick | ||
>; | ||
|
||
const defaultFilterKey = 'data_stream.dataset'; | ||
const defaultLogsDataViewId = 'logs-*'; | ||
const defaultLogsDataView: DataViewSpec = { | ||
id: defaultLogsDataViewId, | ||
title: defaultLogsDataViewId, | ||
}; | ||
|
||
const getDefaultDatasetFilter = (datasets: string[]): Filter[] => [ | ||
{ | ||
meta: { | ||
index: defaultLogsDataViewId, | ||
key: defaultFilterKey, | ||
params: datasets, | ||
type: 'phrases', | ||
}, | ||
query: { | ||
bool: { | ||
minimum_should_match: 1, | ||
should: datasets.map((dataset) => ({ | ||
match_phrase: { | ||
[defaultFilterKey]: dataset, | ||
}, | ||
})), | ||
}, | ||
}, | ||
$state: { | ||
store: FilterStateStore.APP_STATE, | ||
}, | ||
}, | ||
]; | ||
|
||
export const getDiscoverNavigationParams = ( | ||
datasets: string[] | ||
): DiscoverNavigationParams => ({ | ||
dataViewId: defaultLogsDataViewId, | ||
dataViewSpec: defaultLogsDataView, | ||
filters: getDefaultDatasetFilter(datasets), | ||
}); |
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
82 changes: 0 additions & 82 deletions
82
...ervability_onboarding/server/routes/elastic_agent/system_logs/generate_system_logs_yml.ts
This file was deleted.
Oops, something went wrong.
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