From 276e43fc6b84210623833021a0675f942372885f Mon Sep 17 00:00:00 2001 From: Julia Bardi Date: Thu, 29 Sep 2022 15:01:08 +0200 Subject: [PATCH 1/2] added last checkin message to Agent UI --- .../fleet/common/types/models/agent.ts | 1 + .../agent_details/agent_details_overview.tsx | 6 +++ .../agents/components/agent_health.tsx | 47 ++++++++++++------- 3 files changed, 37 insertions(+), 17 deletions(-) diff --git a/x-pack/plugins/fleet/common/types/models/agent.ts b/x-pack/plugins/fleet/common/types/models/agent.ts index 5def12287b4fd..2cc6ddcb59838 100644 --- a/x-pack/plugins/fleet/common/types/models/agent.ts +++ b/x-pack/plugins/fleet/common/types/models/agent.ts @@ -84,6 +84,7 @@ interface AgentBase { policy_revision?: number | null; last_checkin?: string; last_checkin_status?: 'error' | 'online' | 'degraded' | 'updating'; + last_checkin_message?: string; user_provided_metadata: AgentMetadata; local_metadata: AgentMetadata; tags?: string[]; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_details/agent_details_overview.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_details/agent_details_overview.tsx index 5799b130b6a46..11ddcef4c8aee 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_details/agent_details_overview.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_details/agent_details_overview.tsx @@ -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', diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_health.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_health.tsx index b2c03ba745d7b..93091ff726258 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_health.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_health.tsx @@ -74,8 +74,33 @@ export const AgentHealth: React.FunctionComponent = ({ 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 ? ( + + ) : null; + const lastCheckinText = msLastCheckIn ? ( + <> + , + }} + /> + + ) : ( + + ); const previousToOfflineStatus = useMemo(() => { if (!showOfflinePreviousStatus || agent.status !== 'offline') { @@ -89,22 +114,10 @@ export const AgentHealth: React.FunctionComponent = ({ - , - }} - /> - - ) : ( - - ) + <> +

{lastCheckinText}

+

{lastCheckInMessageText}

+ } > <> From cacfa49c7cf32e54b59bc6f984d648ea42346516 Mon Sep 17 00:00:00 2001 From: Julia Bardi Date: Thu, 29 Sep 2022 15:14:35 +0200 Subject: [PATCH 2/2] added last_checkin_message to FleetServerAgent --- x-pack/plugins/fleet/common/types/models/agent.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/x-pack/plugins/fleet/common/types/models/agent.ts b/x-pack/plugins/fleet/common/types/models/agent.ts index 2cc6ddcb59838..fa54f8c943e27 100644 --- a/x-pack/plugins/fleet/common/types/models/agent.ts +++ b/x-pack/plugins/fleet/common/types/models/agent.ts @@ -230,6 +230,10 @@ export interface FleetServerAgent { * Last checkin status */ last_checkin_status?: 'error' | 'online' | 'degraded' | 'updating'; + /** + * Last checkin message + */ + last_checkin_message?: string; /** * ID of the API key the Elastic Agent uses to authenticate with elasticsearch */