Skip to content
Merged
7 changes: 7 additions & 0 deletions x-pack/plugins/fleet/common/constants/agent_policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,10 @@ export const LICENSE_FOR_SCHEDULE_UPGRADE = 'platinum';
export const DEFAULT_MAX_AGENT_POLICIES_WITH_INACTIVITY_TIMEOUT = 750;

export const AGENTLESS_POLICY_ID = 'agentless'; // the policy id defined here: https://github.com/elastic/project-controller/blob/main/internal/project/security/security_kibana_config.go#L86

export const agentLoggingLevels = {
Comment thread
juliaElastic marked this conversation as resolved.
Info: 'info',
Debug: 'debug',
Warning: 'warning',
Error: 'error',
} as const;
16 changes: 16 additions & 0 deletions x-pack/plugins/fleet/common/settings/agent_policy_settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import { i18n } from '@kbn/i18n';
import { z } from 'zod';

import { agentLoggingLevels } from '../constants';

import type { SettingsConfig } from './types';

export const zodStringWithDurationValidation = z
Expand Down Expand Up @@ -126,4 +128,18 @@ export const AGENT_POLICY_ADVANCED_SETTINGS: SettingsConfig[] = [
})
.default({}),
},
{
name: 'agent.logging.level',
hidden: true,
title: i18n.translate('xpack.fleet.settings.agentPolicyAdvanced.agentLoggingLevel', {
Comment thread
criamico marked this conversation as resolved.
Outdated
defaultMessage: 'Agent Logging Level',
}),
description: i18n.translate('xpack.fleet.settings.agentPolicyAdvanced.goMaxProcsDescription', {
Comment thread
criamico marked this conversation as resolved.
Outdated
defaultMessage: 'Set the Agent log level. The default log level is "info".',
}),
api_field: {
name: 'agent_logging_level',
},
schema: z.nativeEnum(agentLoggingLevels),
Comment thread
criamico marked this conversation as resolved.
},
];
8 changes: 7 additions & 1 deletion x-pack/plugins/fleet/common/types/models/agent_policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@

import type { SecurityRoleDescriptor } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';

import type { agentPolicyStatuses } from '../../constants';
import type { agentPolicyStatuses, agentLoggingLevels } from '../../constants';
import type { MonitoringType, PolicySecretReference, ValueOf } from '..';

import type { PackagePolicy, PackagePolicyPackage } from './package_policy';
import type { Output } from './output';

export type AgentPolicyStatus = typeof agentPolicyStatuses;

type AgentLoggingLevelKeys = keyof typeof agentLoggingLevels;
export type AgentLoggingLevel = typeof agentLoggingLevels[AgentLoggingLevelKeys];

// adding a property here? If it should be cloned when duplicating a policy, add it to `agentPolicyService.copy`
// x-pack/plugins/fleet/server/services/agent_policy.ts#L571
export interface NewAgentPolicy {
Expand Down Expand Up @@ -121,6 +124,9 @@ export interface FullAgentPolicy {
uninstall_token_hash: string;
signing_key: string;
};
logging?: {
level: AgentLoggingLevel;
};
};
secret_references?: PolicySecretReference[];
signed?: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { ZodFirstPartyTypeKind } from 'zod';
import React from 'react';
import { EuiFieldNumber, EuiFieldText } from '@elastic/eui';
import { EuiFieldNumber, EuiFieldText, EuiSelect } from '@elastic/eui';

import type { SettingsConfig } from '../../../../../common/settings/types';

Expand Down Expand Up @@ -61,6 +61,27 @@ settingComponentRegistry.set(ZodFirstPartyTypeKind.ZodString, (settingsConfig) =
);
});

settingComponentRegistry.set(ZodFirstPartyTypeKind.ZodNativeEnum, (settingsConfig) => {
return (
<SettingsFieldWrapper
settingsConfig={settingsConfig}
typeName={ZodFirstPartyTypeKind.ZodString}
renderItem={({ fieldKey, fieldValue, handleChange, coercedSchema }: any) => (
<EuiSelect
data-test-subj={fieldKey}
value={fieldValue}
fullWidth
onChange={handleChange}
options={Object.keys(coercedSchema.enum).map((level) => ({
text: level,
value: coercedSchema.enum[level],
}))}
/>
)}
/>
);
});

export function ConfiguredSettings({
configuredSettings,
}: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,13 @@ interface Props {
agentPolicy: Partial<NewAgentPolicy | AgentPolicy>;
updateAgentPolicy: (u: Partial<NewAgentPolicy | AgentPolicy>) => void;
validation: ValidationResults;
isEditing?: boolean;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field was not used anymore so I removed it

disabled?: boolean;
}

export const AgentPolicyAdvancedOptionsContent: React.FunctionComponent<Props> = ({
agentPolicy,
updateAgentPolicy,
validation,
isEditing = false,
disabled = false,
}) => {
const { docLinks } = useStartServices();
Expand Down Expand Up @@ -401,7 +399,6 @@ export const AgentPolicyAdvancedOptionsContent: React.FunctionComponent<Props> =
}}
/>
</EuiDescribedFormGroup>

{AgentTamperProtectionSection}

<EuiDescribedFormGroup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ export const AgentPolicyCreateInlineForm: React.FunctionComponent<Props> = ({
agentPolicy={newAgentPolicy}
updateAgentPolicy={updateNewAgentPolicy}
validation={validation}
isEditing={false}
/>
</StyledEuiAccordion>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ export const AgentPolicyForm: React.FunctionComponent<Props> = ({
agentPolicy={agentPolicy}
updateAgentPolicy={updateAgentPolicy}
validation={validation}
isEditing={isEditing}
/>

{advancedPolicySettings ? (
Expand All @@ -168,7 +167,6 @@ export const AgentPolicyForm: React.FunctionComponent<Props> = ({
agentPolicy={agentPolicy}
updateAgentPolicy={updateAgentPolicy}
validation={validation}
isEditing={isEditing}
disabled={disabled}
/>
{advancedPolicySettings ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ interface Props {
withSysMonitoring: boolean;
updateSysMonitoring: (newValue: boolean) => void;
validation: ValidationResults;
isEditing?: boolean;
onDelete?: () => void;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, the linter catched unused props

}

export const AgentPolicyIntegrationForm: React.FunctionComponent<Props> = ({
Expand All @@ -45,8 +43,6 @@ export const AgentPolicyIntegrationForm: React.FunctionComponent<Props> = ({
withSysMonitoring,
updateSysMonitoring,
validation,
isEditing = false,
onDelete = () => {},
}) => {
return (
<EuiForm>
Expand Down Expand Up @@ -101,7 +97,6 @@ export const AgentPolicyIntegrationForm: React.FunctionComponent<Props> = ({
agentPolicy={agentPolicy}
updateAgentPolicy={updateAgentPolicy}
validation={validation}
isEditing={isEditing}
/>
</StyledEuiAccordion>
</>
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/fleet/public/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export type {
AgentMetadata,
AgentPolicy,
NewAgentPolicy,
AgentLoggingLevel,
SimplifiedAgentStatus,
EnrollmentAPIKey,
PackagePolicy,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,7 @@ describe('getFullAgentPolicy', () => {
mockAgentPolicy({
advanced_settings: {
agent_limits_go_max_procs: 2,
agent_logging_level: 'debug',
},
});
const agentPolicy = await getFullAgentPolicy(savedObjectsClientMock.create(), 'agent-policy');
Expand All @@ -727,6 +728,7 @@ describe('getFullAgentPolicy', () => {
id: 'agent-policy',
agent: {
limits: { go_max_procs: 2 },
logging: { level: 'debug' },
},
});
});
Expand Down