Skip to content

Commit

Permalink
[LogsUI] Add UI setting to hide Logs Stream and dashboard panel option (
Browse files Browse the repository at this point in the history
elastic#194519)

## 📓 Summary

Closes elastic#193319 
Closes elastic#193320 

This work is part of the effort to progressively deprecate the existing
Logs Stream feature.

Changes taken on this PR consist of:
- Create a new uiSettings `observability:enableLogsStream` which
defaults to `false` on the stateful/cloud deployments and is not
available in serverless ones (still, defaults to `false` behind the
scene).
- When `observability:enableLogsStream` is `false`, the Logs Stream page
route is not registered, and neither is its deep link for global search.
- When `observability:enableLogsStream` is `false`, the panels list on
Dashboard won't show anymore the option `Logs Stream (Deprecated)` to
prevent usage of this embeddable in new dashboards. The embeddable is
still registered for retro-compatibility with active dashboards, and it
has now a callout explaining the status of this embeddable
(unmaintained/deprecated).
- Rename logs ML to "Logs Anomalies" and "Logs Categories".

Other minor improvements regard:
- Remove duplicate Xstate utils and use the relative package instead.
- Remove the duplicated `useBoolean` hook used in the deprecation
callout.
- Sync deep links registration with available routes through a single
`getLogsRoutes` util.

## 🎥 Recordings

### Logs Stream app removed


https://github.com/user-attachments/assets/f4173294-8789-4abd-9972-29c9b7c197ed

### Logs Stream dashboard panel entry removed


https://github.com/user-attachments/assets/7f99ca2a-c030-4867-b976-8fdc1df09d29

### Logs Stream app removed from project nav


https://github.com/user-attachments/assets/de51bdd6-820a-4c03-8b64-fb1a6ced0a12

### Embeddable deprecation callout

<img width="949" alt="Screenshot 2024-10-02 at 10 22 09"
src="https://github.com/user-attachments/assets/99fd5554-004b-45e4-81db-cb23947e210e">

### Unavailable setting in serverless


https://github.com/user-attachments/assets/91bf6c37-0845-4918-a485-b6250bbd96bf

---------

Co-authored-by: Marco Antonio Ghiani <[email protected]>
Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: Mike Birnstiehl <[email protected]>
  • Loading branch information
4 people authored Oct 9, 2024
1 parent 9975fd6 commit 9907601
Show file tree
Hide file tree
Showing 41 changed files with 387 additions and 406 deletions.
1 change: 1 addition & 0 deletions packages/kbn-management/settings/setting_ids/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export const OBSERVABILITY_LOGS_EXPLORER_ALLOWED_DATA_VIEWS_ID =
'observability:logsExplorer:allowedDataViews';
export const OBSERVABILITY_ENTITY_CENTRIC_EXPERIENCE = 'observability:entityCentricExperience';
export const OBSERVABILITY_LOGS_DATA_ACCESS_LOG_SOURCES_ID = 'observability:logSources';
export const OBSERVABILITY_ENABLE_LOGS_STREAM = 'observability:enableLogsStream';
export const OBSERVABILITY_AI_ASSISTANT_SIMULATED_FUNCTION_CALLING =
'observability:aiAssistantSimulatedFunctionCalling';
export const OBSERVABILITY_AI_ASSISTANT_SEARCH_CONNECTOR_INDEX_PATTERN =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,10 @@ export const stackManagementSchema: MakeSchemaFrom<UsageStats> = {
_meta: { description: 'Non-default value of setting.' },
},
},
'observability:enableLogsStream': {
type: 'boolean',
_meta: { description: 'Non-default value of setting.' },
},
'banners:placement': {
type: 'keyword',
_meta: { description: 'Non-default value of setting.' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export interface UsageStats {
'observability:apmEnableServiceInventoryTableSearchBar': boolean;
'observability:logsExplorer:allowedDataViews': string[];
'observability:logSources': string[];
'observability:enableLogsStream': boolean;
'observability:aiAssistantSimulatedFunctionCalling': boolean;
'observability:aiAssistantSearchConnectorIndexPattern': string;
'visualization:heatmap:maxBuckets': number;
Expand Down
6 changes: 6 additions & 0 deletions src/plugins/telemetry/schema/oss_plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -10486,6 +10486,12 @@
}
}
},
"observability:enableLogsStream": {
"type": "boolean",
"_meta": {
"description": "Non-default value of setting."
}
},
"banners:placement": {
"type": "keyword",
"_meta": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

import expect from '@kbn/expect';

import { OBSERVABILITY_ENABLE_LOGS_STREAM } from '@kbn/management-settings-ids';
import { VisualizeConstants } from '@kbn/visualizations-plugin/common/constants';
import { FtrProviderContext } from '../../../ftr_provider_context';

Expand All @@ -28,6 +28,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await kibanaServer.uiSettings.replace({
defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c',
});
await kibanaServer.uiSettings.update({ [OBSERVABILITY_ENABLE_LOGS_STREAM]: true });
});

after(async () => {
await kibanaServer.savedObjects.cleanStandardList();
await kibanaServer.uiSettings.update({ [OBSERVABILITY_ENABLE_LOGS_STREAM]: false });
});

it('ensure toolbar popover closes on add', async () => {
Expand All @@ -39,10 +45,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await dashboardAddPanel.expectEditorMenuClosed();
});

after(async () => {
await kibanaServer.savedObjects.cleanStandardList();
});

describe('add new visualization link', () => {
before(async () => {
await dashboard.navigateToApp();
Expand Down
1 change: 1 addition & 0 deletions test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,6 @@
"@kbn/default-nav-management",
"@kbn/default-nav-devtools",
"@kbn/core-saved-objects-import-export-server-internal",
"@kbn/management-settings-ids",
]
}
30 changes: 30 additions & 0 deletions x-pack/plugins/observability_solution/infra/common/ui_settings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* 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.
*/

/**
* uiSettings definitions for the logs_data_access plugin.
*/
import { schema } from '@kbn/config-schema';
import { UiSettingsParams } from '@kbn/core-ui-settings-common';
import { i18n } from '@kbn/i18n';
import { OBSERVABILITY_ENABLE_LOGS_STREAM } from '@kbn/management-settings-ids';

export const uiSettings: Record<string, UiSettingsParams> = {
[OBSERVABILITY_ENABLE_LOGS_STREAM]: {
category: ['observability'],
name: i18n.translate('xpack.infra.enableLogsStream', {
defaultMessage: 'Logs Stream',
}),
value: false,
description: i18n.translate('xpack.infra.enableLogsStreamDescription', {
defaultMessage: 'Enables the legacy Logs Stream application and dashboard panel. ',
}),
type: 'boolean',
schema: schema.boolean(),
requiresPageReload: true,
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*/

import React, { FC, PropsWithChildren, useEffect, useMemo, useState } from 'react';
import { i18n } from '@kbn/i18n';
import { EuiCallOut, EuiLink } from '@elastic/eui';
import { ReactEmbeddableFactory } from '@kbn/embeddable-plugin/public';
import {
initializeTimeRange,
Expand All @@ -17,6 +19,9 @@ import { AppMountParameters, CoreStart } from '@kbn/core/public';
import { EuiThemeProvider } from '@kbn/kibana-react-plugin/common';
import { Query } from '@kbn/es-query';
import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render';
import { euiThemeVars } from '@kbn/ui-theme';
import useLocalStorage from 'react-use/lib/useLocalStorage';
import { FormattedMessage } from '@kbn/i18n-react';
import type { LogStreamApi, LogStreamSerializedState, Services } from './types';
import { datemathToEpochMillis } from '../../utils/datemath';
import { LOG_STREAM_EMBEDDABLE } from './constants';
Expand Down Expand Up @@ -81,7 +86,7 @@ export function getLogStreamEmbeddableFactory(services: Services) {
theme$={services.coreStart.theme.theme$}
>
<EuiThemeProvider darkMode={darkMode}>
<div style={{ width: '100%' }}>
<div style={{ width: '100%', position: 'relative' }}>
<LogStream
logView={{ type: 'log-view-reference', logViewId: 'default' }}
startTimestamp={startTimestamp}
Expand All @@ -90,6 +95,7 @@ export function getLogStreamEmbeddableFactory(services: Services) {
query={query as Query | undefined}
filters={filters}
/>
<DeprecationCallout />
</div>
</EuiThemeProvider>
</LogStreamEmbeddableProviders>
Expand All @@ -101,6 +107,53 @@ export function getLogStreamEmbeddableFactory(services: Services) {
return factory;
}

const DISMISSAL_STORAGE_KEY = 'observability:logStreamEmbeddableDeprecationCalloutDismissed';
const SAVED_SEARCH_DOCS_URL =
'https://www.elastic.co/guide/en/kibana/current/save-open-search.html';

const DeprecationCallout = () => {
const [isDismissed, setDismissed] = useLocalStorage(DISMISSAL_STORAGE_KEY, false);

if (isDismissed) {
return null;
}

return (
<EuiCallOut
color="warning"
iconType="help"
onDismiss={() => setDismissed(true)}
css={{
position: 'absolute',
bottom: euiThemeVars.euiSizeM,
right: euiThemeVars.euiSizeM,
width: 'min(100%, 40ch)',
}}
>
<p>
<FormattedMessage
id="xpack.infra.logsStreamEmbeddable.deprecationWarningDescription"
defaultMessage="Logs Stream panels are no longer maintained. Try using {savedSearchDocsLink} for a similar visualization."
values={{
savedSearchDocsLink: (
<EuiLink
data-test-subj="infraDeprecationCalloutSavedSearchesLink"
href={SAVED_SEARCH_DOCS_URL}
target="_blank"
>
{i18n.translate(
'xpack.infra.logsStreamEmbeddable.deprecationWarningDescription.savedSearchesLinkLabel',
{ defaultMessage: 'saved searches' }
)}
</EuiLink>
),
}}
/>
</p>
</EuiCallOut>
);
};

export interface LogStreamEmbeddableProvidersProps {
core: CoreStart;
pluginStart: InfraClientStartExports;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,38 @@ import { css } from '@emotion/css';
import { SharePublicStart } from '@kbn/share-plugin/public/plugin';
import { useKibanaContextForPlugin } from '../hooks/use_kibana';

const DISMISSAL_STORAGE_KEY = 'log_stream_deprecation_callout_dismissed';
const pageConfigurations = {
stream: {
dismissalStorageKey: 'log_stream_deprecation_callout_dismissed',
message: i18n.translate('xpack.infra.logsDeprecationCallout.p.theNewLogsExplorerLabel', {
defaultMessage:
'The new Logs Explorer makes viewing and inspecting your logs easier with more features, better performance, and more intuitive navigation. We recommend switching to Logs Explorer, as it will replace Logs Stream in a future version.',
}),
},
settings: {
dismissalStorageKey: 'log_settings_deprecation_callout_dismissed',
message: i18n.translate(
'xpack.infra.logsSettingsDeprecationCallout.p.theNewLogsExplorerLabel',
{
defaultMessage:
'These settings only apply to the legacy Logs Stream app, and we do not recommend configuring them. Instead, use Logs Explorer which makes viewing and inspecting your logs easier with more features, better performance, and more intuitive navigation.',
}
),
},
};

interface LogsDeprecationCalloutProps {
page: keyof typeof pageConfigurations;
}

export const LogsDeprecationCallout = () => {
export const LogsDeprecationCallout = ({ page }: LogsDeprecationCalloutProps) => {
const {
services: { share },
} = useKibanaContextForPlugin();

const [isDismissed, setDismissed] = useLocalStorage(DISMISSAL_STORAGE_KEY, false);
const { dismissalStorageKey, message } = pageConfigurations[page];

const [isDismissed, setDismissed] = useLocalStorage(dismissalStorageKey, false);

if (isDismissed) {
return null;
Expand All @@ -42,12 +66,7 @@ export const LogsDeprecationCallout = () => {
onDismiss={() => setDismissed(true)}
className={calloutStyle}
>
<p>
{i18n.translate('xpack.infra.logsDeprecationCallout.p.theNewLogsExplorerLabel', {
defaultMessage:
'The new Logs Explorer makes viewing and inspecting your logs easier with more features, better performance, and more intuitive navigation. We recommend switching to Logs Explorer, as it will replace Logs Stream in a future version.',
})}
</p>
<p>{message}</p>
<EuiButton
fill
data-test-subj="infraLogsDeprecationCalloutTryLogsExplorerButton"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* 2.0.
*/

import { MatchedStateFromActor } from '@kbn/xstate-utils';
import { LogStreamQueryActorRef } from '../../../log_stream_query_state';
import { MatchedStateFromActor } from '../../../xstate_helpers';
import { LogStreamPageActorRef } from './state_machine';

type LogStreamPageStateWithLogViewIndices =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import { TimeRange } from '@kbn/es-query';
import { actions, ActorRefFrom, createMachine, EmittedFrom } from 'xstate';
import { DEFAULT_REFRESH_INTERVAL } from '@kbn/logs-shared-plugin/common';
import type { LogViewNotificationChannel } from '@kbn/logs-shared-plugin/public';
import { OmitDeprecatedState } from '@kbn/xstate-utils';
import { datemathToEpochMillis } from '../../../../utils/datemath';
import { createLogStreamPositionStateMachine } from '../../../log_stream_position_state/src/state_machine';
import {
createLogStreamQueryStateMachine,
DEFAULT_TIMERANGE,
LogStreamQueryStateMachineDependencies,
} from '../../../log_stream_query_state';
import { OmitDeprecatedState } from '../../../xstate_helpers';
import {
waitForInitialQueryParameters,
waitForInitialPositionParameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { IKbnUrlStateStorage } from '@kbn/kibana-utils-plugin/public';
import { convertISODateToNanoPrecision } from '@kbn/logs-shared-plugin/common';
import moment from 'moment';
import { actions, ActorRefFrom, createMachine, EmittedFrom, SpecialTargets } from 'xstate';
import { OmitDeprecatedState, sendIfDefined } from '@kbn/xstate-utils';
import { isSameTimeKey } from '../../../../common/time';
import { OmitDeprecatedState, sendIfDefined } from '../../xstate_helpers';
import { DESIRED_BUFFER_PAGES, RELATIVE_END_UPDATE_DELAY } from './defaults';
import { LogStreamPositionNotificationEventSelectors } from './notifications';
import type {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { EsQueryConfig } from '@kbn/es-query';
import { IKbnUrlStateStorage } from '@kbn/kibana-utils-plugin/public';
import { actions, ActorRefFrom, createMachine, SpecialTargets, send } from 'xstate';
import { DEFAULT_REFRESH_INTERVAL } from '@kbn/logs-shared-plugin/common';
import { OmitDeprecatedState, sendIfDefined } from '../../xstate_helpers';
import { OmitDeprecatedState, sendIfDefined } from '@kbn/xstate-utils';
import { logStreamQueryNotificationEventSelectors } from './notifications';
import {
subscribeToFilterSearchBarChanges,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,4 @@
*/

export * from './invalid_state_callout';
export * from './notification_channel';
export * from './send_actions';
export * from './types';
export * from './state_machine_playground';

This file was deleted.

Loading

0 comments on commit 9907601

Please sign in to comment.