Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Stack Monitoring / Logs] Fix Stack Monitoring logs links #200043

Merged
merged 4 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions x-pack/plugins/monitoring/kibana.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"observability",
"observabilityShared",
"dataViews",
"unifiedSearch"
"unifiedSearch",
"share"
],
"optionalPlugins": [
"infra",
Expand All @@ -39,7 +40,8 @@
"requiredBundles": [
"kibanaUtils",
"alerting",
"kibanaReact"
"kibanaReact",
"logsShared"
]
}
}
25 changes: 18 additions & 7 deletions x-pack/plugins/monitoring/public/components/logs/logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ import { RedirectAppLinks } from '@kbn/shared-ux-link-redirect-app';
import { upperFirst } from 'lodash';
import { Legacy } from '../../legacy_shims';
import { EuiBasicTable, EuiTitle, EuiSpacer, EuiText, EuiCallOut, EuiLink } from '@elastic/eui';
import { INFRA_SOURCE_ID } from '../../../common/constants';
import { formatDateTimeLocal } from '../../../common/formatting';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';
import { Reason } from './reason';
import { useKibana } from '@kbn/kibana-react-plugin/public';
import { getLogsLocatorsFromUrlService } from '@kbn/logs-shared-plugin/common';

const getFormattedDateTimeLocal = (timestamp) => {
const timezone = Legacy.shims.uiSettings?.get('dateFormat:tz');
Expand Down Expand Up @@ -110,7 +111,7 @@ const clusterColumns = [
},
];

function getLogsUiLink(clusterUuid, nodeId, indexUuid) {
function getLogsUiLink(clusterUuid, nodeId, indexUuid, sharePlugin) {
const params = [];
if (clusterUuid) {
params.push(`elasticsearch.cluster.uuid:${clusterUuid}`);
Expand All @@ -122,15 +123,23 @@ function getLogsUiLink(clusterUuid, nodeId, indexUuid) {
params.push(`elasticsearch.index.name:${indexUuid}`);
}

const base = Legacy.shims.infra.locators.logsLocator.getRedirectUrl({
logView: { logViewId: INFRA_SOURCE_ID, type: 'log-view-reference' },
...(params.length ? { filter: params.join(' and ') } : {}),
const filter = params.join(' and ');
const { logsLocator } = getLogsLocatorsFromUrlService(sharePlugin.url);

const base = logsLocator.getRedirectUrl({
filter,
});

return base;
}

export class Logs extends PureComponent {
export const Logs = (props) => {
mohamedhamed-ahmed marked this conversation as resolved.
Show resolved Hide resolved
const {
services: { share },
} = useKibana();
return <LogsContent sharePlugin={share} {...props} />;
};
export class LogsContent extends PureComponent {
renderLogs() {
const {
logs: { enabled, logs },
Expand Down Expand Up @@ -165,7 +174,9 @@ export class Logs extends PureComponent {
nodeId,
clusterUuid,
indexUuid,
sharePlugin,
} = this.props;

if (!enabled || !show) {
return null;
}
Expand All @@ -184,7 +195,7 @@ export class Logs extends PureComponent {
defaultMessage="Visit {link} to dive deeper."
values={{
link: (
<EuiLink href={getLogsUiLink(clusterUuid, nodeId, indexUuid)}>
<EuiLink href={getLogsUiLink(clusterUuid, nodeId, indexUuid, sharePlugin)}>
{i18n.translate('xpack.monitoring.logs.listing.calloutLinkText', {
defaultMessage: 'Logs',
})}
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/monitoring/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export class MonitoringPlugin
element: params.element,
core: coreStart,
data: pluginsStart.data,
share: pluginsStart.share,
isCloud: Boolean(plugins.cloud?.isCloudEnabled),
pluginInitializerContext: this.initializerContext,
externalConfig,
Expand All @@ -124,6 +125,7 @@ export class MonitoringPlugin
appMountParameters: deps.appMountParameters,
dataViews: deps.dataViews,
infra: deps.infra,
share: deps.share,
});

const config = Object.fromEntries(externalConfig);
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/monitoring/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public';
import { DashboardStart } from '@kbn/dashboard-plugin/public';
import { FleetStart } from '@kbn/fleet-plugin/public';
import type { InfraClientStartExports } from '@kbn/infra-plugin/public';
import { SharePluginStart } from '@kbn/share-plugin/public';

export interface MonitoringStartPluginDependencies {
navigation: NavigationStart;
Expand All @@ -26,6 +27,7 @@ export interface MonitoringStartPluginDependencies {
dashboard?: DashboardStart;
fleet?: FleetStart;
infra?: InfraClientStartExports;
share: SharePluginStart;
}

interface LegacyStartDependencies {
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/monitoring/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"@kbn/flot-charts",
"@kbn/ui-theme",
"@kbn/core-elasticsearch-server",
"@kbn/share-plugin",
],
"exclude": [
"target/**/*",
Expand Down