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

[Fleet] Add a message when log collection is disabled on the log details page #103166

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import { RedirectAppLinks } from '../../../../../../../../../../../src/plugins/k
import type { TimeRange } from '../../../../../../../../../../../src/plugins/data/public';
import { esKuery } from '../../../../../../../../../../../src/plugins/data/public';
import { LogStream } from '../../../../../../../../../infra/public';
import type { Agent } from '../../../../../types';
import { useStartServices } from '../../../../../hooks';
import type { Agent, AgentPolicy } from '../../../../../types';
import { useLink, useStartServices } from '../../../../../hooks';

import { DEFAULT_DATE_RANGE } from './constants';
import { DatasetFilter } from './filter_dataset';
Expand All @@ -51,6 +51,7 @@ const DatePickerFlexItem = styled(EuiFlexItem)`

export interface AgentLogsProps {
agent: Agent;
agentPolicy?: AgentPolicy;
state: AgentLogsState;
}

Expand All @@ -64,7 +65,50 @@ export interface AgentLogsState {

export const AgentLogsUrlStateHelper = createStateContainerReactHelpers();

export const AgentLogsUI: React.FunctionComponent<AgentLogsProps> = memo(({ agent, state }) => {
const AgentPolicyLogsNotEnabledCallout: React.FunctionComponent<{ agentPolicy: AgentPolicy }> = ({
agentPolicy,
}) => {
const { getHref } = useLink();

return (
<EuiFlexItem>
<EuiCallOut
size="m"
color="primary"
iconType="iInCircle"
title={
<FormattedMessage
id="xpack.fleet.agentLogs.logDisabledCallOutTitle"
defaultMessage="Log collection is disabled"
/>
}
>
<FormattedMessage
id="xpack.fleet.agentLogs.logDisabledCallOutDescription"
defaultMessage="Update the agent's policy {settingsLink} to enable logs collection."
values={{
settingsLink: (
<EuiLink
href={getHref('policy_details', {
policyId: agentPolicy.id,
tabId: 'settings',
})}
>
<FormattedMessage
id="xpack.fleet.agentLogs.settingsLink"
defaultMessage="settings"
/>
</EuiLink>
),
}}
/>
</EuiCallOut>
</EuiFlexItem>
);
};

export const AgentLogsUI: React.FunctionComponent<AgentLogsProps> = memo(
({ agent, agentPolicy, state }) => {
const { data, application, http } = useStartServices();
const { update: updateState } = AgentLogsUrlStateHelper.useTransitions();

Expand Down Expand Up @@ -232,6 +276,9 @@ export const AgentLogsUI: React.FunctionComponent<AgentLogsProps> = memo(({ agen

return (
<WrapperFlexGroup direction="column" gutterSize="m">
{agentPolicy && !agentPolicy.monitoring_enabled?.includes('logs') && (
<AgentPolicyLogsNotEnabledCallout agentPolicy={agentPolicy} />
)}
<EuiFlexItem grow={false}>
<EuiFlexGroup gutterSize="m">
<EuiFlexItem>
Expand Down Expand Up @@ -311,4 +358,5 @@ export const AgentLogsUI: React.FunctionComponent<AgentLogsProps> = memo(({ agen
</EuiFlexItem>
</WrapperFlexGroup>
);
});
}
);
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ import { DEFAULT_LOGS_STATE, STATE_STORAGE_KEY } from './constants';
import type { AgentLogsProps, AgentLogsState } from './agent_logs';
import { AgentLogsUI, AgentLogsUrlStateHelper } from './agent_logs';

export const AgentLogs: React.FunctionComponent<Pick<AgentLogsProps, 'agent'>> = memo(
({ agent }) => {
export const AgentLogs: React.FunctionComponent<
Pick<AgentLogsProps, 'agent' | 'agentPolicy'>
> = memo(({ agent, agentPolicy }) => {
const stateContainer = useMemo(
() =>
createStateContainer<
Expand Down Expand Up @@ -71,8 +72,7 @@ export const AgentLogs: React.FunctionComponent<Pick<AgentLogsProps, 'agent'>> =

return (
<AgentLogsUrlStateHelper.Provider value={stateContainer}>
{isSyncReady ? <AgentLogsConnected agent={agent} /> : null}
{isSyncReady ? <AgentLogsConnected agent={agent} agentPolicy={agentPolicy} /> : null}
</AgentLogsUrlStateHelper.Provider>
);
}
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ const AgentDetailsPageContent: React.FunctionComponent<{
<Route
path={FLEET_ROUTING_PATHS.agent_details_logs}
render={() => {
return <AgentLogs agent={agent} />;
return <AgentLogs agent={agent} agentPolicy={agentPolicy} />;
}}
/>
<Route
Expand Down