forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fleet] Add agent incoming data endpoint and presentational component (…
…elastic#127177) * [Fleet] Create endpoint to check if agent has incoming data * Document new endpoint * Improvements to component * Update endpoint schema * Remove button for now * Address review comments * Add dynamic button functionality * Add option to hide button and improve query Co-authored-by: Kibana Machine <[email protected]>
- Loading branch information
1 parent
6792a03
commit 2f876bc
Showing
16 changed files
with
406 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,8 @@ paths: | |
$ref: paths/agent_status_deprecated.yaml | ||
/agent_status: | ||
$ref: paths/agent_status.yaml | ||
/agent_status/data: | ||
$ref: paths/[email protected] | ||
/agents: | ||
$ref: paths/agents.yaml | ||
/agents/bulk_upgrade: | ||
|
27 changes: 27 additions & 0 deletions
27
x-pack/plugins/fleet/common/openapi/paths/[email protected]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
get: | ||
summary: Agents - Get incoming data | ||
tags: [] | ||
responses: | ||
'200': | ||
description: OK | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
items: | ||
type: array | ||
items: | ||
type: object | ||
additionalProperties: | ||
type: object | ||
properties: | ||
data: | ||
type: boolean | ||
operationId: get-agent-data | ||
parameters: | ||
- schema: | ||
type: array | ||
name: agentsId | ||
in: query | ||
required: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
x-pack/plugins/fleet/public/components/agent_enrollment_flyout/confirm_incoming_data.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { EuiCallOut, EuiText, EuiSpacer, EuiButton } from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
|
||
import type { InstalledIntegrationPolicy } from '../../hooks'; | ||
import { useGetAgentIncomingData } from '../../hooks'; | ||
interface Props { | ||
agentsIds: string[]; | ||
installedPolicy?: InstalledIntegrationPolicy; | ||
} | ||
|
||
export const ConfirmIncomingData: React.FunctionComponent<Props> = ({ | ||
agentsIds, | ||
installedPolicy, | ||
}) => { | ||
const { enrolledAgents, numAgentsWithData, isLoading, linkButton } = useGetAgentIncomingData( | ||
agentsIds, | ||
installedPolicy | ||
); | ||
|
||
return ( | ||
<> | ||
{isLoading ? ( | ||
<EuiText size="s"> | ||
{i18n.translate('xpack.fleet.confirmIncomingData.loading', { | ||
defaultMessage: | ||
'It may take a few minutes for data to arrive in Elasticsearch. If the system is not generating data, it may help to generate some to ensure data is being collected correctly. If you’re having trouble, see our troubleshooting guide. You may close this dialog and check later by viewing our integration assets.', | ||
})} | ||
</EuiText> | ||
) : ( | ||
<> | ||
<EuiCallOut | ||
data-test-subj="IncomingDataConfirmedCallOut" | ||
title={i18n.translate('xpack.fleet.confirmIncomingData.title', { | ||
defaultMessage: | ||
'Incoming data received from {numAgentsWithData} of {enrolledAgents} recently enrolled { enrolledAgents, plural, one {agent} other {agents}}.', | ||
values: { | ||
numAgentsWithData, | ||
enrolledAgents, | ||
}, | ||
})} | ||
color="success" | ||
iconType="check" | ||
/> | ||
<EuiSpacer size="m" /> | ||
<EuiText size="s"> | ||
{i18n.translate('xpack.fleet.confirmIncomingData.subtitle', { | ||
defaultMessage: 'Your agent is enrolled successfully and your data is received.', | ||
})} | ||
</EuiText> | ||
</> | ||
)} | ||
|
||
<EuiSpacer size="m" /> | ||
{installedPolicy && ( | ||
<EuiButton | ||
href={linkButton.href} | ||
isDisabled={isLoading} | ||
color="primary" | ||
fill | ||
data-test-subj="IncomingDataConfirmedButton" | ||
> | ||
{linkButton.text} | ||
</EuiButton> | ||
)} | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
x-pack/plugins/fleet/public/hooks/use_get_agent_incoming_data.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
import { useEffect, useState, useMemo } from 'react'; | ||
import { i18n } from '@kbn/i18n'; | ||
|
||
import type { IncomingDataList } from '../../common/types/rest_spec/agent'; | ||
|
||
import { sendGetAgentIncomingData, useLink } from './index'; | ||
|
||
export interface InstalledIntegrationPolicy { | ||
name: string; | ||
version: string; | ||
} | ||
|
||
export const useGetAgentIncomingData = ( | ||
agentsIds: string[], | ||
installedPolicy?: InstalledIntegrationPolicy | ||
) => { | ||
const [isLoading, setIsLoading] = useState<boolean>(true); | ||
const [incomingData, setIncomingData] = useState<IncomingDataList[]>([]); | ||
|
||
useEffect(() => { | ||
const getIncomingData = async () => { | ||
const { data } = await sendGetAgentIncomingData({ agentsIds }); | ||
if (data?.items) { | ||
setIncomingData(data?.items); | ||
setIsLoading(false); | ||
} | ||
}; | ||
if (agentsIds) { | ||
getIncomingData(); | ||
} | ||
}, [agentsIds]); | ||
|
||
const enrolledAgents = useMemo(() => incomingData.length, [incomingData.length]); | ||
const numAgentsWithData = useMemo( | ||
() => | ||
incomingData.reduce((acc, curr) => { | ||
const agentData = Object.values(curr)[0]; | ||
return !!agentData.data ? acc + 1 : acc; | ||
}, 0), | ||
[incomingData] | ||
); | ||
const { getAbsolutePath, getHref } = useLink(); | ||
|
||
let href; | ||
let text; | ||
if (!installedPolicy) { | ||
href = ''; | ||
text = ''; | ||
} | ||
|
||
if (installedPolicy?.name === 'apm') { | ||
href = getAbsolutePath('/app/home#/tutorial/apm'); | ||
text = i18n.translate('xpack.fleet.confirmIncomingData.installApmAgentButtonText', { | ||
defaultMessage: 'Install APM Agent', | ||
}); | ||
} else { | ||
href = getHref('integration_details_assets', { | ||
pkgkey: `${installedPolicy?.name}-${installedPolicy?.version}`, | ||
}); | ||
text = i18n.translate('xpack.fleet.confirmIncomingData.viewDataAssetsButtonText', { | ||
defaultMessage: 'View assets', | ||
}); | ||
} | ||
const linkButton = { href, text }; | ||
|
||
return { | ||
enrolledAgents, | ||
numAgentsWithData, | ||
isLoading, | ||
linkButton, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.