Skip to content

Commit

Permalink
[Logs] Update logs stream links to logs explorer (elastic#190835)
Browse files Browse the repository at this point in the history
## Summary

Implements elastic#190782, as part of
the deprecate Logs UI project:
elastic/observability-dev#3242.

## Overview

- Previously the top level logs locators would redirect to the locators
registered in Infra first (for the stream), and logs explorer second if
the stream wasn't available. This fork no longer exists, with the top
level locators navigating to the logs explorer only.

- Infra no longer registers locators for the logs stream.

- Consumer / solution uses have been updated.

## Semi-breaking change

- Previously we had `link-to` routes that would translate into an
internal link. These no longer accept a log view (as this is a stream
concept, and is also soon to be deprecated itself). This means
bookmarked link-to routes may now ultimately point to slightly different
data (depending on the users log sources advanced setting). I don't
really see a full proof way around this if we are to truly deprecate all
the pieces we need. Also, with the `link-to` routes always being a
translation layer this might be absolutely fine — we are just
translating things differently now.

## Reviewer notes

- The ES Deprecation logs page can be found at:
`/app/management/stack/upgrade_assistant/es_deprecation_logs`.

## Change points

(Not fully exhaustive)

![Screenshot 2024-08-30 at 17 04
24](https://github.com/user-attachments/assets/9062de51-aba1-47bd-b95d-59f72b2202bf)

![Screenshot 2024-08-30 at 17 15
37](https://github.com/user-attachments/assets/c54c91ca-6750-408d-b3cb-d3895a7ae9a1)

![Screenshot 2024-08-30 at 17 18
51](https://github.com/user-attachments/assets/a4e3241d-85ed-4cdc-bb22-4ba07bd077f2)

![Screenshot 2024-08-30 at 17 21
32](https://github.com/user-attachments/assets/2263c463-133f-41d0-ba3e-3943ea48a950)

![Screenshot 2024-08-30 at 17 23
35](https://github.com/user-attachments/assets/0f600a38-5102-40d3-ae1e-4106ee287652)

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
Kerry350 and elasticmachine authored Sep 5, 2024
1 parent c772d89 commit 773f3b3
Show file tree
Hide file tree
Showing 41 changed files with 226 additions and 728 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jest.mock('@kbn/logs-shared-plugin/public', () => {
jest.mock('@kbn/logs-shared-plugin/common', () => {
return {
getLogsLocatorsFromUrlService: jest.fn().mockReturnValue({
logsLocator: { getRedirectUrl: jest.fn(() => 'https://discover-redirect-url') },
logsLocator: { getRedirectUrl: jest.fn(() => 'https://logs-explorer-redirect-url') },
}),
};
});
Expand Down Expand Up @@ -130,7 +130,7 @@ describe('AgentLogsUI', () => {
const result = renderComponent();
expect(result.getByTestId('viewInLogsBtn')).toHaveAttribute(
'href',
`https://discover-redirect-url`
`https://logs-explorer-redirect-url`
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
*/

import React, { useMemo } from 'react';
import { EuiButton } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';

import { getLogsLocatorsFromUrlService } from '@kbn/logs-shared-plugin/common';

import moment from 'moment';

import { useDiscoverLocator, useStartServices, useAuthz } from '../../../../../hooks';
import { EuiButton } from '@elastic/eui';

import { FormattedMessage } from '@kbn/i18n-react';

import { useStartServices, useAuthz } from '../../../../../hooks';

interface ViewLogsProps {
logStreamQuery: string;
Expand All @@ -32,8 +34,6 @@ export const ViewLogsButton: React.FunctionComponent<ViewLogsProps> = ({
startTime,
endTime,
}) => {
const discoverLocator = useDiscoverLocator();

const { share } = useStartServices();
const { logsLocator } = getLogsLocatorsFromUrlService(share.url);
const authz = useAuthz();
Expand All @@ -54,11 +54,11 @@ export const ViewLogsButton: React.FunctionComponent<ViewLogsProps> = ({
});
}, [endTime, logStreamQuery, logsLocator, startTime]);

return authz.fleet.readAgents && (logsLocator || discoverLocator) ? (
return authz.fleet.readAgents && logsLocator ? (
<EuiButton href={logsUrl} iconType="popout" data-test-subj="viewInLogsBtn">
<FormattedMessage
id="xpack.fleet.agentLogs.openInLogsUiLinkText"
defaultMessage="Open in Logs"
defaultMessage="Open in Logs Explorer"
/>
</EuiButton>
) : null;
Expand Down
17 changes: 8 additions & 9 deletions x-pack/plugins/fleet/public/custom_logs_assets_extension.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,25 @@
import React from 'react';
import { i18n } from '@kbn/i18n';

import { getLogsLocatorsFromUrlService } from '@kbn/logs-shared-plugin/common';

import { CustomAssetsAccordion } from './components/custom_assets_accordion';
import type { CustomAssetsAccordionProps } from './components/custom_assets_accordion';
import { useStartServices } from './hooks';
import type { PackageAssetsComponent } from './types';

export const CustomLogsAssetsExtension: PackageAssetsComponent = () => {
const { http, cloud } = useStartServices();
const isLogsUIAvailable = !cloud?.isServerlessEnabled;
// if logs ui is not available, link to discover
// TODO: move away from hardcoded link and use locators instead
const logStreamUrl = isLogsUIAvailable
? http.basePath.prepend('/app/logs/stream')
: http.basePath.prepend('/app/discover');
const {
share: { url },
} = useStartServices();
const { logsLocator } = getLogsLocatorsFromUrlService(url);

const views: CustomAssetsAccordionProps['views'] = [
{
name: i18n.translate('xpack.fleet.assets.customLogs.name', { defaultMessage: 'Logs' }),
url: logStreamUrl,
url: logsLocator.getRedirectUrl({}),
description: i18n.translate('xpack.fleet.assets.customLogs.description', {
defaultMessage: 'View Custom logs data in Logs app',
defaultMessage: 'View Custom logs data in Logs Explorer',
}),
},
];
Expand Down
113 changes: 0 additions & 113 deletions x-pack/plugins/observability_solution/infra/common/locators/helpers.ts

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 773f3b3

Please sign in to comment.