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] added last checkin message to Agent UI #142220

Merged
merged 3 commits into from
Sep 29, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions x-pack/plugins/fleet/common/types/models/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ interface AgentBase {
policy_revision?: number | null;
last_checkin?: string;
last_checkin_status?: 'error' | 'online' | 'degraded' | 'updating';
last_checkin_message?: string;
juliaElastic marked this conversation as resolved.
Show resolved Hide resolved
user_provided_metadata: AgentMetadata;
local_metadata: AgentMetadata;
tags?: string[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ export const AgentDetailsOverviewSection: React.FunctionComponent<{
'-'
),
},
{
title: i18n.translate('xpack.fleet.agentDetails.lastCheckinMessageLabel', {
defaultMessage: 'Last checkin message',
}),
description: agent.last_checkin_message ? agent.last_checkin_message : '-',
},
{
title: i18n.translate('xpack.fleet.agentDetails.hostIdLabel', {
defaultMessage: 'Agent ID',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,33 @@ export const AgentHealth: React.FunctionComponent<Props> = ({
agent,
showOfflinePreviousStatus,
}) => {
const { last_checkin: lastCheckIn } = agent;
const { last_checkin: lastCheckIn, last_checkin_message: lastCheckInMessage } = agent;
const msLastCheckIn = new Date(lastCheckIn || 0).getTime();
const lastCheckInMessageText = lastCheckInMessage ? (
<FormattedMessage
id="xpack.fleet.agentHealth.checkinMessageText"
defaultMessage="Last checkin message: {lastCheckinMessage}"
values={{
lastCheckinMessage: lastCheckInMessage,
}}
/>
) : null;
const lastCheckinText = msLastCheckIn ? (
<>
<FormattedMessage
id="xpack.fleet.agentHealth.checkInTooltipText"
defaultMessage="Last checked in {lastCheckIn}"
values={{
lastCheckIn: <FormattedRelative value={msLastCheckIn} />,
}}
/>
</>
) : (
<FormattedMessage
id="xpack.fleet.agentHealth.noCheckInTooltipText"
defaultMessage="Never checked in"
/>
);

const previousToOfflineStatus = useMemo(() => {
if (!showOfflinePreviousStatus || agent.status !== 'offline') {
Expand All @@ -89,22 +114,10 @@ export const AgentHealth: React.FunctionComponent<Props> = ({
<EuiToolTip
position="top"
content={
msLastCheckIn ? (
<>
<FormattedMessage
id="xpack.fleet.agentHealth.checkInTooltipText"
defaultMessage="Last checked in {lastCheckIn}"
values={{
lastCheckIn: <FormattedRelative value={msLastCheckIn} />,
}}
/>
</>
) : (
<FormattedMessage
id="xpack.fleet.agentHealth.noCheckInTooltipText"
defaultMessage="Never checked in"
/>
)
<>
<p>{lastCheckinText}</p>
<p>{lastCheckInMessageText}</p>
</>
}
>
<>
Expand Down