mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[Fleet] Fix view agent activity for large action (#170971)
This commit is contained in:
parent
0cb8a487c1
commit
ab1375cf62
2 changed files with 41 additions and 4 deletions
|
@ -26,6 +26,7 @@ import {
|
|||
EuiButtonEmpty,
|
||||
EuiFlyoutFooter,
|
||||
EuiSpacer,
|
||||
EuiToolTip,
|
||||
} from '@elastic/eui';
|
||||
import styled from 'styled-components';
|
||||
|
||||
|
@ -57,6 +58,8 @@ const FlyoutFooterWPadding = styled(EuiFlyoutFooter)`
|
|||
padding: 16px 24px !important;
|
||||
`;
|
||||
|
||||
const MAX_VIEW_AGENTS_COUNT = 2000;
|
||||
|
||||
export const AgentActivityFlyout: React.FunctionComponent<{
|
||||
onClose: () => void;
|
||||
onAbortSuccess: () => void;
|
||||
|
@ -702,17 +705,42 @@ const ViewAgentsButton: React.FunctionComponent<{
|
|||
action: ActionStatus;
|
||||
onClickViewAgents: (action: ActionStatus) => void;
|
||||
}> = ({ action, onClickViewAgents }) => {
|
||||
return action.type !== 'UPDATE_TAGS' ? (
|
||||
if (action.type === 'UPDATE_TAGS') {
|
||||
return null;
|
||||
}
|
||||
|
||||
const button = (
|
||||
<EuiButtonEmpty
|
||||
size="m"
|
||||
onClick={() => onClickViewAgents(action)}
|
||||
flush="left"
|
||||
data-test-subj="agentActivityFlyout.viewAgentsButton"
|
||||
disabled={action.nbAgentsActionCreated > MAX_VIEW_AGENTS_COUNT}
|
||||
>
|
||||
<FormattedMessage
|
||||
id="xpack.fleet.agentActivityFlyout.viewAgentsButton"
|
||||
defaultMessage="View Agents"
|
||||
/>
|
||||
</EuiButtonEmpty>
|
||||
) : null;
|
||||
);
|
||||
|
||||
if (action.nbAgentsActionCreated <= MAX_VIEW_AGENTS_COUNT) {
|
||||
return button;
|
||||
}
|
||||
|
||||
return (
|
||||
<EuiToolTip
|
||||
content={
|
||||
<FormattedMessage
|
||||
id="xpack.fleet.agentActivityFlyout.viewAgentsButtonDisabledMaxTooltip"
|
||||
defaultMessage="The view agents feature is only available for action impacting less then {agentCount} agents"
|
||||
values={{
|
||||
agentCount: MAX_VIEW_AGENTS_COUNT,
|
||||
}}
|
||||
/>
|
||||
}
|
||||
>
|
||||
{button}
|
||||
</EuiToolTip>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -43,7 +43,7 @@ const ES_PASSWORD = 'password';
|
|||
|
||||
const DEFAULT_AGENT_COUNT = 50000;
|
||||
|
||||
const INDEX_BULK_OP = '{ "index":{ } }\n';
|
||||
const INDEX_BULK_OP = '{ "index":{ "_id": "{{id}}" } }\n';
|
||||
|
||||
const {
|
||||
delete: deleteAgentsFirst = false,
|
||||
|
@ -145,6 +145,10 @@ function createAgentWithStatus({
|
|||
hostname: string;
|
||||
}) {
|
||||
const baseAgent = {
|
||||
agent: {
|
||||
id: uuidv4(),
|
||||
version,
|
||||
},
|
||||
access_api_key_id: 'api-key-1',
|
||||
active: true,
|
||||
policy_id: policyId,
|
||||
|
@ -235,7 +239,12 @@ async function deleteAgents() {
|
|||
|
||||
async function createAgentDocsBulk(agents: Agent[]) {
|
||||
const auth = 'Basic ' + Buffer.from(ES_SUPERUSER + ':' + ES_PASSWORD).toString('base64');
|
||||
const body = agents.flatMap((agent) => [INDEX_BULK_OP, JSON.stringify(agent) + '\n']).join('');
|
||||
const body = agents
|
||||
.flatMap((agent) => [
|
||||
INDEX_BULK_OP.replace(/{{id}}/, agent.agent?.id ?? ''),
|
||||
JSON.stringify(agent) + '\n',
|
||||
])
|
||||
.join('');
|
||||
const res = await fetch(`${ES_URL}/.fleet-agents/_bulk`, {
|
||||
method: 'post',
|
||||
body,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue