Skip to content

Commit

Permalink
removed restriction to set remote_elasticsearch data output on agent …
Browse files Browse the repository at this point in the history
…policy with apm
  • Loading branch information
juliaElastic committed Dec 14, 2023
1 parent efa5a6a commit 6178650
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
4 changes: 2 additions & 2 deletions x-pack/plugins/fleet/common/services/output_helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('getAllowedOutputTypeForPolicy', () => {
expect(res).toContain('logstash');
});

it('should return only elasticsearch for an agent policy with APM', () => {
it('should return only elasticsearch types for an agent policy with APM', () => {
const res = getAllowedOutputTypeForPolicy({
package_policies: [
{
Expand All @@ -35,7 +35,7 @@ describe('getAllowedOutputTypeForPolicy', () => {
],
} as any);

expect(res).toEqual(['elasticsearch']);
expect(res).toEqual(['elasticsearch', 'remote_elasticsearch']);
});

it('should return only elasticsearch for an agent policy with Fleet Server', () => {
Expand Down
12 changes: 9 additions & 3 deletions x-pack/plugins/fleet/common/services/output_helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,21 @@ export function getAllowedOutputTypeForPolicy(agentPolicy: AgentPolicy) {
agentPolicy.package_policies &&
agentPolicy.package_policies.some(
(p) =>
p.package?.name === FLEET_APM_PACKAGE ||
p.package?.name === FLEET_SERVER_PACKAGE ||
p.package?.name === FLEET_SYNTHETICS_PACKAGE
p.package?.name === FLEET_SERVER_PACKAGE || p.package?.name === FLEET_SYNTHETICS_PACKAGE
);

if (isRestrictedToSameClusterES) {
return [outputType.Elasticsearch];
}

const isRestrictedToESType =
agentPolicy.package_policies &&
agentPolicy.package_policies.some((p) => p.package?.name === FLEET_APM_PACKAGE);

if (isRestrictedToESType) {
return [outputType.Elasticsearch, outputType.RemoteElasticsearch];
}

return Object.values(outputType);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ describe('useOutputOptions', () => {
size="s"
>
<FormattedMessage
defaultMessage="{outputType} output for agent integration is not supported for Fleet Server, Synthetics or APM."
defaultMessage="{outputType} output for agent integration is not supported for Fleet Server, Synthetics. APM is only supported for elasticsearch types."
id="xpack.fleet.agentPolicyForm.outputOptionDisabledTypeNotSupportedText"
values={
Object {
Expand All @@ -182,7 +182,7 @@ describe('useOutputOptions', () => {
size="s"
>
<FormattedMessage
defaultMessage="{outputType} output for agent integration is not supported for Fleet Server, Synthetics or APM."
defaultMessage="{outputType} output for agent integration is not supported for Fleet Server, Synthetics. APM is only supported for elasticsearch types."
id="xpack.fleet.agentPolicyForm.outputOptionDisabledTypeNotSupportedText"
values={
Object {
Expand All @@ -209,7 +209,7 @@ describe('useOutputOptions', () => {
size="s"
>
<FormattedMessage
defaultMessage="{outputType} output for agent integration is not supported for Fleet Server, Synthetics or APM."
defaultMessage="{outputType} output for agent integration is not supported for Fleet Server, Synthetics. APM is only supported for elasticsearch types."
id="xpack.fleet.agentPolicyForm.outputOptionDisabledTypeNotSupportedText"
values={
Object {
Expand Down Expand Up @@ -283,7 +283,7 @@ describe('useOutputOptions', () => {
size="s"
>
<FormattedMessage
defaultMessage="{outputType} output for agent integration is not supported for Fleet Server, Synthetics or APM."
defaultMessage="{outputType} output for agent integration is not supported for Fleet Server, Synthetics. APM is only supported for elasticsearch types."
id="xpack.fleet.agentPolicyForm.outputOptionDisabledTypeNotSupportedText"
values={
Object {
Expand All @@ -310,7 +310,7 @@ describe('useOutputOptions', () => {
size="s"
>
<FormattedMessage
defaultMessage="{outputType} output for agent integration is not supported for Fleet Server, Synthetics or APM."
defaultMessage="{outputType} output for agent integration is not supported for Fleet Server, Synthetics. APM is only supported for elasticsearch types."
id="xpack.fleet.agentPolicyForm.outputOptionDisabledTypeNotSupportedText"
values={
Object {
Expand All @@ -337,7 +337,7 @@ describe('useOutputOptions', () => {
size="s"
>
<FormattedMessage
defaultMessage="{outputType} output for agent integration is not supported for Fleet Server, Synthetics or APM."
defaultMessage="{outputType} output for agent integration is not supported for Fleet Server, Synthetics. APM is only supported for elasticsearch types."
id="xpack.fleet.agentPolicyForm.outputOptionDisabledTypeNotSupportedText"
values={
Object {
Expand Down Expand Up @@ -466,7 +466,7 @@ describe('useOutputOptions', () => {
size="s"
>
<FormattedMessage
defaultMessage="{outputType} output for agent integration is not supported for Fleet Server, Synthetics or APM."
defaultMessage="{outputType} output for agent integration is not supported for Fleet Server, Synthetics. APM is only supported for elasticsearch types."
id="xpack.fleet.agentPolicyForm.outputOptionDisableOutputTypeText"
values={
Object {
Expand Down Expand Up @@ -498,7 +498,7 @@ describe('useOutputOptions', () => {
size="s"
>
<FormattedMessage
defaultMessage="{outputType} output for agent integration is not supported for Fleet Server, Synthetics or APM."
defaultMessage="{outputType} output for agent integration is not supported for Fleet Server, Synthetics. APM is only supported for elasticsearch types."
id="xpack.fleet.agentPolicyForm.outputOptionDisabledTypeNotSupportedText"
values={
Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export function useOutputOptions(agentPolicy: Partial<NewAgentPolicy | AgentPoli
const defaultOutputDisabledMessage = defaultOutputDisabled ? (
<FormattedMessage
id="xpack.fleet.agentPolicyForm.outputOptionDisableOutputTypeText"
defaultMessage="{outputType} output for agent integration is not supported for Fleet Server, Synthetics or APM."
defaultMessage="{outputType} output for agent integration is not supported for Fleet Server, Synthetics. APM is only supported for elasticsearch types."
values={{
outputType: defaultOutput.type,
}}
Expand All @@ -109,7 +109,7 @@ export function useOutputOptions(agentPolicy: Partial<NewAgentPolicy | AgentPoli
isOutputTypeUnsupported ? (
<FormattedMessage
id="xpack.fleet.agentPolicyForm.outputOptionDisabledTypeNotSupportedText"
defaultMessage="{outputType} output for agent integration is not supported for Fleet Server, Synthetics or APM."
defaultMessage="{outputType} output for agent integration is not supported for Fleet Server, Synthetics. APM is only supported for elasticsearch types."
values={{
outputType: item.type,
}}
Expand Down

0 comments on commit 6178650

Please sign in to comment.