Skip to content

Commit

Permalink
removed restriction to use remote es as integration data
Browse files Browse the repository at this point in the history
  • Loading branch information
juliaElastic committed Dec 14, 2023
1 parent 395489f commit efa5a6a
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ describe('useOutputOptions', () => {
`);
});

it('should only enable remote es output for monitoring output', async () => {
it('should enable remote es output for data and monitoring output', async () => {
const testRenderer = createFleetTestRendererMock();
mockedUseLicence.mockReturnValue({
hasAtLeast: () => true,
Expand All @@ -545,7 +545,8 @@ describe('useOutputOptions', () => {
expect(result.current.isLoading).toBeTruthy();

await waitForNextUpdate();
expect(result.current.dataOutputOptions.length).toEqual(1);
expect(result.current.dataOutputOptions.length).toEqual(2);
expect(result.current.dataOutputOptions[1].value).toEqual('remote1');
expect(result.current.monitoringOutputOptions.length).toEqual(2);
expect(result.current.monitoringOutputOptions[1].value).toEqual('remote1');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
useGetDownloadSources,
useGetFleetServerHosts,
} from '../../../../hooks';
import { LICENCE_FOR_PER_POLICY_OUTPUT, outputType } from '../../../../../../../common/constants';
import { LICENCE_FOR_PER_POLICY_OUTPUT } from '../../../../../../../common/constants';
import {
getAllowedOutputTypeForPolicy,
policyHasFleetServer,
Expand Down Expand Up @@ -99,28 +99,26 @@ export function useOutputOptions(agentPolicy: Partial<NewAgentPolicy | AgentPoli

return [
getDefaultOutput(defaultOutputName, defaultOutputDisabled, defaultOutputDisabledMessage),
...outputsRequest.data.items
.filter((item) => item.type !== outputType.RemoteElasticsearch)
.map((item) => {
const isOutputTypeUnsupported = !allowedOutputTypes.includes(item.type);
...outputsRequest.data.items.map((item) => {
const isOutputTypeUnsupported = !allowedOutputTypes.includes(item.type);

return {
value: item.id,
inputDisplay: getOutputLabel(
item.name,
isOutputTypeUnsupported ? (
<FormattedMessage
id="xpack.fleet.agentPolicyForm.outputOptionDisabledTypeNotSupportedText"
defaultMessage="{outputType} output for agent integration is not supported for Fleet Server, Synthetics or APM."
values={{
outputType: item.type,
}}
/>
) : undefined
),
disabled: !isPolicyPerOutputAllowed || isOutputTypeUnsupported,
};
}),
return {
value: item.id,
inputDisplay: getOutputLabel(
item.name,
isOutputTypeUnsupported ? (
<FormattedMessage
id="xpack.fleet.agentPolicyForm.outputOptionDisabledTypeNotSupportedText"
defaultMessage="{outputType} output for agent integration is not supported for Fleet Server, Synthetics or APM."
values={{
outputType: item.type,
}}
/>
) : undefined
),
disabled: !isPolicyPerOutputAllowed || isOutputTypeUnsupported,
};
}),
];
}, [outputsRequest, isPolicyPerOutputAllowed, allowedOutputTypes]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,6 @@ export const EditOutputFlyout: React.FunctionComponent<EditOutputFlyoutProps> =
}}
/>
}
disabled={isRemoteESOutput}
/>
</EuiFormRow>
<EuiFormRow fullWidth {...inputs.defaultMonitoringOutputInput.formRowProps}>
Expand Down
16 changes: 6 additions & 10 deletions x-pack/plugins/fleet/server/services/output.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -705,12 +705,12 @@ describe('Output Service', () => {
);
});

it('should throw when a remote es output is attempted to be created as default data output', async () => {
it('should not throw when a remote es output is attempted to be created as default data output', async () => {
const soClient = getMockedSoClient({
defaultOutputId: 'output-test',
});

await expect(
expect(
outputService.create(
soClient,
esClientMock,
Expand All @@ -722,9 +722,7 @@ describe('Output Service', () => {
},
{ id: 'output-1' }
)
).rejects.toThrow(
`Remote elasticsearch output cannot be set as default output for integration data. Please set "is_default" to false.`
);
).resolves.not.toThrow();
});

it('should set preset: balanced by default when creating a new ES output', async () => {
Expand Down Expand Up @@ -1644,21 +1642,19 @@ describe('Output Service', () => {
);
});

it('should throw when a remote es output is attempted to be updated as default data output', async () => {
it('should not throw when a remote es output is attempted to be updated as default data output', async () => {
const soClient = getMockedSoClient({
defaultOutputId: 'output-test',
});

await expect(
expect(
outputService.update(soClient, esClientMock, 'output-test', {
is_default: true,
is_default_monitoring: false,
name: 'Test',
type: 'remote_elasticsearch',
})
).rejects.toThrow(
`Remote elasticsearch output cannot be set as default output for integration data. Please set "is_default" to false.`
);
).resolves.not.toThrow();
});
});

Expand Down
15 changes: 0 additions & 15 deletions x-pack/plugins/fleet/server/services/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -441,13 +441,6 @@ class OutputService {
logger.debug(`Creating new output`);

const data: OutputSOAttributes = { ...omit(output, ['ssl', 'secrets']) };
if (output.type === outputType.RemoteElasticsearch) {
if (data.is_default) {
throw new OutputInvalidError(
'Remote elasticsearch output cannot be set as default output for integration data. Please set "is_default" to false.'
);
}
}

if (outputTypeSupportPresets(data.type)) {
if (
Expand Down Expand Up @@ -767,14 +760,6 @@ class OutputService {
const logger = appContextService.getLogger();
logger.debug(`Updating output ${id}`);

if (data.type === outputType.RemoteElasticsearch) {
if (data.is_default) {
throw new OutputInvalidError(
'Remote elasticsearch output cannot be set as default output for integration data. Please set "is_default" to false.'
);
}
}

let secretsToDelete: PolicySecretReference[] = [];
const originalOutput = await this.get(soClient, id);

Expand Down

0 comments on commit efa5a6a

Please sign in to comment.