forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Logs+] Use central log sources setting in the Logs UI (elastic#188020)
## Summary Implements elastic/logs-dev#170 ## High-level overview of changes - Log Views now have a new log indices reference type of `kibana_advanced_setting`. - The Log View clients have been amended to be able to fully resolve this new type. - **All** consumers of the Log Stream Component have had to be updated to require the logs data access plugin, this is due to the component relying on consumers correctly setting up dependencies in a wrapping Kibana Context Provider. This facilitates the LSC instantiating it's own Log Views client (the log sources service is a dependency of the Log View client). I had some issues setting up Enterprise Search locally, would really appreciate if someone from that team could check that usage. - Originally I'd implemented this so that if using the defaults (advanced setting) or switching to the `kibana_advanced_setting` type the other two deprecated options would be hidden, however this breaks a lot of functional tests, so all three remain selectable (but noted as deprecated), realistically we're always going to have to deal with the migration path anyway. ## 🎨 UI / UX changes ![Screenshot 2024-07-24 at 11 55 46](https://github.com/user-attachments/assets/e04dfd31-155a-4026-8355-895854e54aab) --------- Co-authored-by: kibanamachine <[email protected]>
- Loading branch information
1 parent
0559de6
commit 59abfd3
Showing
52 changed files
with
533 additions
and
79 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
"features", | ||
"licensing", | ||
"logsShared", | ||
"logsDataAccess", | ||
"esUiShared", | ||
"navigation", | ||
], | ||
|
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
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
137 changes: 137 additions & 0 deletions
137
...solution/infra/public/pages/logs/settings/kibana_advanced_setting_configuration_panel.tsx
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,137 @@ | ||
/* | ||
* 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 { EuiDescribedFormGroup, EuiFieldText, EuiFormRow } from '@elastic/eui'; | ||
import { FormattedMessage } from '@kbn/i18n-react'; | ||
import React, { useEffect, useMemo, useState } from 'react'; | ||
import { useTrackPageview } from '@kbn/observability-shared-plugin/public'; | ||
import { LogSourcesKibanaAdvancedSettingReference } from '@kbn/logs-shared-plugin/common'; | ||
import { ApplicationStart } from '@kbn/core-application-browser'; | ||
import { EuiLink } from '@elastic/eui'; | ||
import { useTrackedPromise } from '../../../hooks/use_tracked_promise'; | ||
import { useKibanaContextForPlugin } from '../../../hooks/use_kibana'; | ||
import { FormElement } from './form_elements'; | ||
import { getFormRowProps } from './form_field_props'; | ||
import { FormValidationError } from './validation_errors'; | ||
|
||
function getKibanaAdvancedSettingsHref(application: ApplicationStart) { | ||
return application.getUrlForApp('management', { | ||
path: `/kibana/settings?query=${encodeURIComponent('Log sources')}`, | ||
}); | ||
} | ||
|
||
export const KibanaAdvancedSettingConfigurationPanel: React.FC<{ | ||
isLoading: boolean; | ||
isReadOnly: boolean; | ||
advancedSettingFormElement: FormElement< | ||
LogSourcesKibanaAdvancedSettingReference, | ||
FormValidationError | ||
>; | ||
}> = ({ isLoading, isReadOnly, advancedSettingFormElement }) => { | ||
const { | ||
services: { application, logsDataAccess }, | ||
} = useKibanaContextForPlugin(); | ||
|
||
useTrackPageview({ app: 'infra_logs', path: 'log_source_configuration_kibana_advanced_setting' }); | ||
useTrackPageview({ | ||
app: 'infra_logs', | ||
path: 'log_source_configuration_kibana_advanced_setting', | ||
delay: 15000, | ||
}); | ||
|
||
const advancedSettingsHref = useMemo( | ||
() => getKibanaAdvancedSettingsHref(application), | ||
[application] | ||
); | ||
|
||
const [logSourcesSettingValue, setLogSourcesSettingValue] = useState<string | undefined>( | ||
undefined | ||
); | ||
|
||
const [getLogSourcesRequest, getLogSources] = useTrackedPromise( | ||
{ | ||
cancelPreviousOn: 'resolution', | ||
createPromise: async () => { | ||
return await logsDataAccess.services.logSourcesService.getLogSources(); | ||
}, | ||
onResolve: (response) => { | ||
setLogSourcesSettingValue(response.map((logSource) => logSource.indexPattern).join(',')); | ||
}, | ||
}, | ||
[] | ||
); | ||
|
||
const isLoadingLogSourcesSetting = useMemo( | ||
() => getLogSourcesRequest.state === 'pending', | ||
[getLogSourcesRequest.state] | ||
); | ||
|
||
useEffect(() => { | ||
getLogSources(); | ||
}, [getLogSources]); | ||
|
||
return ( | ||
<> | ||
<EuiDescribedFormGroup | ||
title={ | ||
<h4> | ||
<FormattedMessage | ||
id="xpack.infra.sourceConfiguration.logSourcesSettingTitle" | ||
defaultMessage="Advanced setting" | ||
/> | ||
</h4> | ||
} | ||
description={ | ||
<FormattedMessage | ||
id="xpack.infra.sourceConfiguration.logSourcesSettingDescription" | ||
defaultMessage="This value is synchronised with the Kibana log sources advanced setting. It can be changed via the {advancedSettingsLink}." | ||
values={{ | ||
advancedSettingsLink: ( | ||
<EuiLink | ||
data-test-subj="xpack.infra.sourceConfiguration.logSourcesSettingLink" | ||
href={advancedSettingsHref} | ||
> | ||
<FormattedMessage | ||
id="xpack.infra.sourceConfiguration.logSourcesSettingLinkText" | ||
defaultMessage="advanced settings page" | ||
/> | ||
</EuiLink> | ||
), | ||
}} | ||
/> | ||
} | ||
> | ||
<EuiFormRow | ||
fullWidth | ||
helpText={ | ||
<FormattedMessage | ||
id="xpack.infra.sourceConfiguration.logSourcesSettingValue" | ||
defaultMessage="The current setting value" | ||
/> | ||
} | ||
label={ | ||
<FormattedMessage | ||
id="xpack.infra.sourceConfiguration.logSourcesSettingLabel" | ||
defaultMessage="Log sources advanced setting" | ||
/> | ||
} | ||
{...getFormRowProps(advancedSettingFormElement)} | ||
> | ||
<EuiFieldText | ||
data-test-subj="logSourcesSettingInput" | ||
fullWidth | ||
disabled={isLoading} | ||
isLoading={isLoadingLogSourcesSetting} | ||
readOnly={true} | ||
value={logSourcesSettingValue} | ||
isInvalid={false} | ||
/> | ||
</EuiFormRow> | ||
</EuiDescribedFormGroup> | ||
</> | ||
); | ||
}; |
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
Oops, something went wrong.