mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
# Backport This will backport the following commits from `main` to `8.16`: - [[Stack Monitoring / Logs] Fix Stack Monitoring logs links (#200043)](https://github.com/elastic/kibana/pull/200043) <!--- Backport version: 8.9.8 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Kerry Gallagher","email":"kerry.gallagher@elastic.co"},"sourceCommit":{"committedDate":"2024-11-14T17:26:24Z","message":"[Stack Monitoring / Logs] Fix Stack Monitoring logs links (#200043)\n\n## Summary\r\n\r\nFixes\r\nhttps://github.com/elastic/kibana/issues/199902#issuecomment-2474040264.\r\n\r\nThis was missed in https://github.com/elastic/kibana/pull/190835 due to\r\nStack Monitoring's lack of type checking in certain files. `infra` no\r\nlonger exposes `logsLocators`.\r\n\r\nThis uses `getLogsLocatorsFromUrlService`, technically we could go to\r\nDiscover now knowing that Logs Explorer will be deprecated in the\r\nfuture. But it will make more sense to convert\r\n`getLogsLocatorsFromUrlService` over to using the Discover locators in\r\none when that happens. This puts us on the same page as\r\nhttps://github.com/elastic/kibana/pull/190835.\r\n\r\nThis link should now work, and have the correct filters applied.\r\n\r\n\r\n\r\n---------\r\n\r\nCo-authored-by: mohamedhamed-ahmed <mohamed.ahmed@elastic.co>","sha":"4e852ea041b63e3e3ad918ceee1bc3861dd1e519","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","ci:cloud-deploy","Team:obs-ux-logs","backport:version","v8.17.0","v8.16.1"],"number":200043,"url":"https://github.com/elastic/kibana/pull/200043","mergeCommit":{"message":"[Stack Monitoring / Logs] Fix Stack Monitoring logs links (#200043)\n\n## Summary\r\n\r\nFixes\r\nhttps://github.com/elastic/kibana/issues/199902#issuecomment-2474040264.\r\n\r\nThis was missed in https://github.com/elastic/kibana/pull/190835 due to\r\nStack Monitoring's lack of type checking in certain files. `infra` no\r\nlonger exposes `logsLocators`.\r\n\r\nThis uses `getLogsLocatorsFromUrlService`, technically we could go to\r\nDiscover now knowing that Logs Explorer will be deprecated in the\r\nfuture. But it will make more sense to convert\r\n`getLogsLocatorsFromUrlService` over to using the Discover locators in\r\none when that happens. This puts us on the same page as\r\nhttps://github.com/elastic/kibana/pull/190835.\r\n\r\nThis link should now work, and have the correct filters applied.\r\n\r\n\r\n\r\n---------\r\n\r\nCo-authored-by: mohamedhamed-ahmed <mohamed.ahmed@elastic.co>","sha":"4e852ea041b63e3e3ad918ceee1bc3861dd1e519"}},"sourceBranch":"main","suggestedTargetBranches":["8.16"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/200043","number":200043,"mergeCommit":{"message":"[Stack Monitoring / Logs] Fix Stack Monitoring logs links (#200043)\n\n## Summary\r\n\r\nFixes\r\nhttps://github.com/elastic/kibana/issues/199902#issuecomment-2474040264.\r\n\r\nThis was missed in https://github.com/elastic/kibana/pull/190835 due to\r\nStack Monitoring's lack of type checking in certain files. `infra` no\r\nlonger exposes `logsLocators`.\r\n\r\nThis uses `getLogsLocatorsFromUrlService`, technically we could go to\r\nDiscover now knowing that Logs Explorer will be deprecated in the\r\nfuture. But it will make more sense to convert\r\n`getLogsLocatorsFromUrlService` over to using the Discover locators in\r\none when that happens. This puts us on the same page as\r\nhttps://github.com/elastic/kibana/pull/190835.\r\n\r\nThis link should now work, and have the correct filters applied.\r\n\r\n\r\n\r\n---------\r\n\r\nCo-authored-by: mohamedhamed-ahmed <mohamed.ahmed@elastic.co>","sha":"4e852ea041b63e3e3ad918ceee1bc3861dd1e519"}},{"branch":"8.x","label":"v8.17.0","labelRegex":"^v8.17.0$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/200227","number":200227,"state":"OPEN"},{"branch":"8.16","label":"v8.16.1","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Kerry Gallagher <kerry.gallagher@elastic.co>
This commit is contained in:
parent
7cce086de3
commit
de09e01d98
6 changed files with 57 additions and 16 deletions
|
@ -15,7 +15,8 @@
|
||||||
"observability",
|
"observability",
|
||||||
"observabilityShared",
|
"observabilityShared",
|
||||||
"dataViews",
|
"dataViews",
|
||||||
"unifiedSearch"
|
"unifiedSearch",
|
||||||
|
"share"
|
||||||
],
|
],
|
||||||
"optionalPlugins": [
|
"optionalPlugins": [
|
||||||
"infra",
|
"infra",
|
||||||
|
@ -30,6 +31,11 @@
|
||||||
"dashboard",
|
"dashboard",
|
||||||
"fleet"
|
"fleet"
|
||||||
],
|
],
|
||||||
"requiredBundles": ["kibanaUtils", "alerting", "kibanaReact"]
|
"requiredBundles": [
|
||||||
|
"kibanaUtils",
|
||||||
|
"alerting",
|
||||||
|
"kibanaReact",
|
||||||
|
"logsShared"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,11 +10,12 @@ import { RedirectAppLinks } from '@kbn/shared-ux-link-redirect-app';
|
||||||
import { upperFirst } from 'lodash';
|
import { upperFirst } from 'lodash';
|
||||||
import { Legacy } from '../../legacy_shims';
|
import { Legacy } from '../../legacy_shims';
|
||||||
import { EuiBasicTable, EuiTitle, EuiSpacer, EuiText, EuiCallOut, EuiLink } from '@elastic/eui';
|
import { EuiBasicTable, EuiTitle, EuiSpacer, EuiText, EuiCallOut, EuiLink } from '@elastic/eui';
|
||||||
import { INFRA_SOURCE_ID } from '../../../common/constants';
|
|
||||||
import { formatDateTimeLocal } from '../../../common/formatting';
|
import { formatDateTimeLocal } from '../../../common/formatting';
|
||||||
import { i18n } from '@kbn/i18n';
|
import { i18n } from '@kbn/i18n';
|
||||||
import { FormattedMessage } from '@kbn/i18n-react';
|
import { FormattedMessage } from '@kbn/i18n-react';
|
||||||
import { Reason } from './reason';
|
import { Reason } from './reason';
|
||||||
|
import { useKibana } from '@kbn/kibana-react-plugin/public';
|
||||||
|
import { getLogsLocatorsFromUrlService } from '@kbn/logs-shared-plugin/common';
|
||||||
|
|
||||||
const getFormattedDateTimeLocal = (timestamp) => {
|
const getFormattedDateTimeLocal = (timestamp) => {
|
||||||
const timezone = Legacy.shims.uiSettings?.get('dateFormat:tz');
|
const timezone = Legacy.shims.uiSettings?.get('dateFormat:tz');
|
||||||
|
@ -110,7 +111,7 @@ const clusterColumns = [
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
function getLogsUiLink(clusterUuid, nodeId, indexUuid) {
|
function getLogsUiLink(clusterUuid, nodeId, indexUuid, sharePlugin) {
|
||||||
const params = [];
|
const params = [];
|
||||||
if (clusterUuid) {
|
if (clusterUuid) {
|
||||||
params.push(`elasticsearch.cluster.uuid:${clusterUuid}`);
|
params.push(`elasticsearch.cluster.uuid:${clusterUuid}`);
|
||||||
|
@ -122,15 +123,23 @@ function getLogsUiLink(clusterUuid, nodeId, indexUuid) {
|
||||||
params.push(`elasticsearch.index.name:${indexUuid}`);
|
params.push(`elasticsearch.index.name:${indexUuid}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const base = Legacy.shims.infra.locators.logsLocator.getRedirectUrl({
|
const filter = params.join(' and ');
|
||||||
logView: { logViewId: INFRA_SOURCE_ID, type: 'log-view-reference' },
|
const { logsLocator } = getLogsLocatorsFromUrlService(sharePlugin.url);
|
||||||
...(params.length ? { filter: params.join(' and ') } : {}),
|
|
||||||
|
const base = logsLocator.getRedirectUrl({
|
||||||
|
filter,
|
||||||
});
|
});
|
||||||
|
|
||||||
return base;
|
return base;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Logs extends PureComponent {
|
export const Logs = (props) => {
|
||||||
|
const {
|
||||||
|
services: { share },
|
||||||
|
} = useKibana();
|
||||||
|
return <LogsContent sharePlugin={share} {...props} />;
|
||||||
|
};
|
||||||
|
export class LogsContent extends PureComponent {
|
||||||
renderLogs() {
|
renderLogs() {
|
||||||
const {
|
const {
|
||||||
logs: { enabled, logs },
|
logs: { enabled, logs },
|
||||||
|
@ -165,7 +174,9 @@ export class Logs extends PureComponent {
|
||||||
nodeId,
|
nodeId,
|
||||||
clusterUuid,
|
clusterUuid,
|
||||||
indexUuid,
|
indexUuid,
|
||||||
|
sharePlugin,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
if (!enabled || !show) {
|
if (!enabled || !show) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -184,7 +195,7 @@ export class Logs extends PureComponent {
|
||||||
defaultMessage="Visit {link} to dive deeper."
|
defaultMessage="Visit {link} to dive deeper."
|
||||||
values={{
|
values={{
|
||||||
link: (
|
link: (
|
||||||
<EuiLink href={getLogsUiLink(clusterUuid, nodeId, indexUuid)}>
|
<EuiLink href={getLogsUiLink(clusterUuid, nodeId, indexUuid, sharePlugin)}>
|
||||||
{i18n.translate('xpack.monitoring.logs.listing.calloutLinkText', {
|
{i18n.translate('xpack.monitoring.logs.listing.calloutLinkText', {
|
||||||
defaultMessage: 'Logs',
|
defaultMessage: 'Logs',
|
||||||
})}
|
})}
|
||||||
|
|
|
@ -7,7 +7,18 @@
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { shallow } from 'enzyme';
|
import { shallow } from 'enzyme';
|
||||||
import { Logs } from './logs';
|
import { LogsContent } from './logs';
|
||||||
|
import { sharePluginMock } from '@kbn/share-plugin/public/mocks';
|
||||||
|
|
||||||
|
const sharePlugin = sharePluginMock.createStartContract();
|
||||||
|
|
||||||
|
jest.mock('@kbn/logs-shared-plugin/common', () => {
|
||||||
|
return {
|
||||||
|
getLogsLocatorsFromUrlService: jest.fn().mockReturnValue({
|
||||||
|
logsLocator: { getRedirectUrl: jest.fn(() => '') },
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
jest.mock('../../legacy_shims', () => ({
|
jest.mock('../../legacy_shims', () => ({
|
||||||
Legacy: {
|
Legacy: {
|
||||||
|
@ -123,32 +134,40 @@ const logs = {
|
||||||
|
|
||||||
describe('Logs', () => {
|
describe('Logs', () => {
|
||||||
it('should render normally', () => {
|
it('should render normally', () => {
|
||||||
const component = shallow(<Logs logs={logs} />);
|
const component = shallow(<LogsContent sharePlugin={sharePlugin} logs={logs} />);
|
||||||
expect(component).toMatchSnapshot();
|
expect(component).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render fewer columns for node or index view', () => {
|
it('should render fewer columns for node or index view', () => {
|
||||||
const component = shallow(<Logs logs={logs} nodeId="12345" />);
|
const component = shallow(<LogsContent sharePlugin={sharePlugin} logs={logs} nodeId="12345" />);
|
||||||
expect(component.find('EuiBasicTable').prop('columns')).toMatchSnapshot();
|
expect(component.find('EuiBasicTable').prop('columns')).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render a link to filter by cluster uuid', () => {
|
it('should render a link to filter by cluster uuid', () => {
|
||||||
const component = shallow(<Logs logs={logs} clusterUuid="12345" />);
|
const component = shallow(
|
||||||
|
<LogsContent sharePlugin={sharePlugin} logs={logs} clusterUuid="12345" />
|
||||||
|
);
|
||||||
expect(component.find('EuiCallOut')).toMatchSnapshot();
|
expect(component.find('EuiCallOut')).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render a link to filter by cluster uuid and node uuid', () => {
|
it('should render a link to filter by cluster uuid and node uuid', () => {
|
||||||
const component = shallow(<Logs logs={logs} clusterUuid="12345" nodeId="6789" />);
|
const component = shallow(
|
||||||
|
<LogsContent sharePlugin={sharePlugin} logs={logs} clusterUuid="12345" nodeId="6789" />
|
||||||
|
);
|
||||||
expect(component.find('EuiCallOut')).toMatchSnapshot();
|
expect(component.find('EuiCallOut')).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render a link to filter by cluster uuid and index uuid', () => {
|
it('should render a link to filter by cluster uuid and index uuid', () => {
|
||||||
const component = shallow(<Logs logs={logs} clusterUuid="12345" indexUuid="6789" />);
|
const component = shallow(
|
||||||
|
<LogsContent sharePlugin={sharePlugin} logs={logs} clusterUuid="12345" indexUuid="6789" />
|
||||||
|
);
|
||||||
expect(component.find('EuiCallOut')).toMatchSnapshot();
|
expect(component.find('EuiCallOut')).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render a reason if the logs are disabled', () => {
|
it('should render a reason if the logs are disabled', () => {
|
||||||
const component = shallow(<Logs logs={{ enabled: false, limit: 15, reason: {} }} />);
|
const component = shallow(
|
||||||
|
<LogsContent sharePlugin={sharePlugin} logs={{ enabled: false, limit: 15, reason: {} }} />
|
||||||
|
);
|
||||||
expect(component).toMatchSnapshot();
|
expect(component).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -101,6 +101,7 @@ export class MonitoringPlugin
|
||||||
element: params.element,
|
element: params.element,
|
||||||
core: coreStart,
|
core: coreStart,
|
||||||
data: pluginsStart.data,
|
data: pluginsStart.data,
|
||||||
|
share: pluginsStart.share,
|
||||||
isCloud: Boolean(plugins.cloud?.isCloudEnabled),
|
isCloud: Boolean(plugins.cloud?.isCloudEnabled),
|
||||||
pluginInitializerContext: this.initializerContext,
|
pluginInitializerContext: this.initializerContext,
|
||||||
externalConfig,
|
externalConfig,
|
||||||
|
@ -124,6 +125,7 @@ export class MonitoringPlugin
|
||||||
appMountParameters: deps.appMountParameters,
|
appMountParameters: deps.appMountParameters,
|
||||||
dataViews: deps.dataViews,
|
dataViews: deps.dataViews,
|
||||||
infra: deps.infra,
|
infra: deps.infra,
|
||||||
|
share: deps.share,
|
||||||
});
|
});
|
||||||
|
|
||||||
const config = Object.fromEntries(externalConfig);
|
const config = Object.fromEntries(externalConfig);
|
||||||
|
|
|
@ -16,6 +16,7 @@ import { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public';
|
||||||
import { DashboardStart } from '@kbn/dashboard-plugin/public';
|
import { DashboardStart } from '@kbn/dashboard-plugin/public';
|
||||||
import { FleetStart } from '@kbn/fleet-plugin/public';
|
import { FleetStart } from '@kbn/fleet-plugin/public';
|
||||||
import type { InfraClientStartExports } from '@kbn/infra-plugin/public';
|
import type { InfraClientStartExports } from '@kbn/infra-plugin/public';
|
||||||
|
import { SharePluginStart } from '@kbn/share-plugin/public';
|
||||||
|
|
||||||
export interface MonitoringStartPluginDependencies {
|
export interface MonitoringStartPluginDependencies {
|
||||||
navigation: NavigationStart;
|
navigation: NavigationStart;
|
||||||
|
@ -26,6 +27,7 @@ export interface MonitoringStartPluginDependencies {
|
||||||
dashboard?: DashboardStart;
|
dashboard?: DashboardStart;
|
||||||
fleet?: FleetStart;
|
fleet?: FleetStart;
|
||||||
infra?: InfraClientStartExports;
|
infra?: InfraClientStartExports;
|
||||||
|
share: SharePluginStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface LegacyStartDependencies {
|
interface LegacyStartDependencies {
|
||||||
|
|
|
@ -49,6 +49,7 @@
|
||||||
"@kbn/flot-charts",
|
"@kbn/flot-charts",
|
||||||
"@kbn/ui-theme",
|
"@kbn/ui-theme",
|
||||||
"@kbn/core-elasticsearch-server",
|
"@kbn/core-elasticsearch-server",
|
||||||
|
"@kbn/share-plugin",
|
||||||
],
|
],
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"target/**/*",
|
"target/**/*",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue