mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Fleet] Expose agent logging level in agent policy settings (#180607)
Closes https://github.com/elastic/kibana/issues/158861 ## Summary Expose agent logging level in agent policy settings. The new setting is added via the new settings framework and will show up under "advanced settings". It's currently hidden until the agent supports it. ### Testing Enable the settings config: https://github.com/elastic/kibana/pull/180597#discussion_r1562448034 - Go to the agent policy settings form - Under advanced settings there is a new dropdown "Agent logging level". Choose a value and save the policy - The new value should be retained after saving - Go to the agent policies tab and select action "View policy" - The new field should be visible under `agent.logging.level` <details> <summary> Screenshots</summary>     </details> ### Checklist - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --------- Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
fd90462486
commit
f1abe4f7eb
11 changed files with 61 additions and 23 deletions
|
@ -37,3 +37,19 @@ 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 AGENT_LOG_LEVELS = {
|
||||
ERROR: 'error',
|
||||
WARNING: 'warning',
|
||||
INFO: 'info',
|
||||
DEBUG: 'debug',
|
||||
};
|
||||
|
||||
export const DEFAULT_LOG_LEVEL = AGENT_LOG_LEVELS.INFO;
|
||||
|
||||
export const agentLoggingLevels = {
|
||||
Info: 'info',
|
||||
Debug: 'debug',
|
||||
Warning: 'warning',
|
||||
Error: 'error',
|
||||
} as const;
|
||||
|
|
|
@ -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
|
||||
|
@ -126,4 +128,21 @@ export const AGENT_POLICY_ADVANCED_SETTINGS: SettingsConfig[] = [
|
|||
})
|
||||
.default({}),
|
||||
},
|
||||
{
|
||||
name: 'agent.logging.level',
|
||||
hidden: true,
|
||||
title: i18n.translate('xpack.fleet.settings.agentPolicyAdvanced.agentLoggingLevelTitle', {
|
||||
defaultMessage: 'Agent Logging Level',
|
||||
}),
|
||||
description: i18n.translate(
|
||||
'xpack.fleet.settings.agentPolicyAdvanced.agentLoggingLevelDescription',
|
||||
{
|
||||
defaultMessage: 'Set the Agent log level. The default log level is "info".',
|
||||
}
|
||||
),
|
||||
api_field: {
|
||||
name: 'agent_logging_level',
|
||||
},
|
||||
schema: z.nativeEnum(agentLoggingLevels),
|
||||
},
|
||||
];
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
@ -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,
|
||||
}: {
|
||||
|
|
|
@ -63,7 +63,6 @@ interface Props {
|
|||
agentPolicy: Partial<NewAgentPolicy | AgentPolicy>;
|
||||
updateAgentPolicy: (u: Partial<NewAgentPolicy | AgentPolicy>) => void;
|
||||
validation: ValidationResults;
|
||||
isEditing?: boolean;
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
|
@ -71,7 +70,6 @@ export const AgentPolicyAdvancedOptionsContent: React.FunctionComponent<Props> =
|
|||
agentPolicy,
|
||||
updateAgentPolicy,
|
||||
validation,
|
||||
isEditing = false,
|
||||
disabled = false,
|
||||
}) => {
|
||||
const { docLinks } = useStartServices();
|
||||
|
@ -401,7 +399,6 @@ export const AgentPolicyAdvancedOptionsContent: React.FunctionComponent<Props> =
|
|||
}}
|
||||
/>
|
||||
</EuiDescribedFormGroup>
|
||||
|
||||
{AgentTamperProtectionSection}
|
||||
|
||||
<EuiDescribedFormGroup
|
||||
|
|
|
@ -188,7 +188,6 @@ export const AgentPolicyCreateInlineForm: React.FunctionComponent<Props> = ({
|
|||
agentPolicy={newAgentPolicy}
|
||||
updateAgentPolicy={updateNewAgentPolicy}
|
||||
validation={validation}
|
||||
isEditing={false}
|
||||
/>
|
||||
</StyledEuiAccordion>
|
||||
</>
|
||||
|
|
|
@ -141,7 +141,6 @@ export const AgentPolicyForm: React.FunctionComponent<Props> = ({
|
|||
agentPolicy={agentPolicy}
|
||||
updateAgentPolicy={updateAgentPolicy}
|
||||
validation={validation}
|
||||
isEditing={isEditing}
|
||||
/>
|
||||
|
||||
{advancedPolicySettings ? (
|
||||
|
@ -168,7 +167,6 @@ export const AgentPolicyForm: React.FunctionComponent<Props> = ({
|
|||
agentPolicy={agentPolicy}
|
||||
updateAgentPolicy={updateAgentPolicy}
|
||||
validation={validation}
|
||||
isEditing={isEditing}
|
||||
disabled={disabled}
|
||||
/>
|
||||
{advancedPolicySettings ? (
|
||||
|
|
|
@ -35,8 +35,6 @@ interface Props {
|
|||
withSysMonitoring: boolean;
|
||||
updateSysMonitoring: (newValue: boolean) => void;
|
||||
validation: ValidationResults;
|
||||
isEditing?: boolean;
|
||||
onDelete?: () => void;
|
||||
}
|
||||
|
||||
export const AgentPolicyIntegrationForm: React.FunctionComponent<Props> = ({
|
||||
|
@ -45,8 +43,6 @@ export const AgentPolicyIntegrationForm: React.FunctionComponent<Props> = ({
|
|||
withSysMonitoring,
|
||||
updateSysMonitoring,
|
||||
validation,
|
||||
isEditing = false,
|
||||
onDelete = () => {},
|
||||
}) => {
|
||||
return (
|
||||
<EuiForm>
|
||||
|
@ -101,7 +97,6 @@ export const AgentPolicyIntegrationForm: React.FunctionComponent<Props> = ({
|
|||
agentPolicy={agentPolicy}
|
||||
updateAgentPolicy={updateAgentPolicy}
|
||||
validation={validation}
|
||||
isEditing={isEditing}
|
||||
/>
|
||||
</StyledEuiAccordion>
|
||||
</>
|
||||
|
|
|
@ -48,12 +48,3 @@ export const DEFAULT_LOGS_STATE: AgentLogsState = {
|
|||
|
||||
export const STATE_STORAGE_KEY = '_q';
|
||||
export const STATE_DATASET_FIELD = 'datasets';
|
||||
|
||||
export const AGENT_LOG_LEVELS = {
|
||||
ERROR: 'error',
|
||||
WARNING: 'warning',
|
||||
INFO: 'info',
|
||||
DEBUG: 'debug',
|
||||
};
|
||||
|
||||
export const DEFAULT_LOG_LEVEL = AGENT_LOG_LEVELS.INFO;
|
||||
|
|
|
@ -10,7 +10,7 @@ import type { EuiSelectableOption } from '@elastic/eui';
|
|||
import { EuiPopover, EuiFilterButton, EuiSelectable } from '@elastic/eui';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
import { AGENT_LOG_LEVELS } from './constants';
|
||||
import { AGENT_LOG_LEVELS } from '../../../../../../../../common/constants';
|
||||
|
||||
const LEVEL_VALUES = Object.values(AGENT_LOG_LEVELS);
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ import { EuiSelect, EuiFormLabel, EuiButtonEmpty, EuiFlexItem, EuiFlexGroup } fr
|
|||
import type { Agent } from '../../../../../types';
|
||||
import { sendPostAgentAction, useAuthz, useStartServices } from '../../../../../hooks';
|
||||
|
||||
import { AGENT_LOG_LEVELS, DEFAULT_LOG_LEVEL } from './constants';
|
||||
import { AGENT_LOG_LEVELS, DEFAULT_LOG_LEVEL } from '../../../../../../../../common/constants';
|
||||
|
||||
const LEVEL_VALUES = Object.values(AGENT_LOG_LEVELS);
|
||||
|
||||
|
|
|
@ -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');
|
||||
|
@ -727,6 +728,7 @@ describe('getFullAgentPolicy', () => {
|
|||
id: 'agent-policy',
|
||||
agent: {
|
||||
limits: { go_max_procs: 2 },
|
||||
logging: { level: 'debug' },
|
||||
},
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue