diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/settings/components/edit_output_flyout/output_form_kafka_partitioning.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/settings/components/edit_output_flyout/output_form_kafka_partitioning.tsx index c2695660aa52..6acb44fe33af 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/settings/components/edit_output_flyout/output_form_kafka_partitioning.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/settings/components/edit_output_flyout/output_form_kafka_partitioning.tsx @@ -55,6 +55,7 @@ export const OutputFormKafkaPartitioning: React.FunctionComponent<{ defaultMessage="Number of events" /> } + {...inputs.kafkaPartitionTypeRandomInput.formRowProps} > } + {...inputs.kafkaPartitionTypeRoundRobinInput.formRowProps} > void, output?: Output) { ); const kafkaPartitionTypeRandomInput = useInput( - kafkaOutput?.random?.group_events ? `${kafkaOutput.random.group_events}` : undefined, - undefined, + kafkaOutput?.random?.group_events ? `${kafkaOutput.random.group_events}` : '1', + kafkaPartitionTypeInput.value === kafkaPartitionType.Random + ? validateKafkaPartitioningGroupEvents + : undefined, isDisabled('partition') ); const kafkaPartitionTypeHashInput = useInput( @@ -352,8 +355,10 @@ export function useOutputForm(onSucess: () => void, output?: Output) { isDisabled('partition') ); const kafkaPartitionTypeRoundRobinInput = useInput( - kafkaOutput?.round_robin?.group_events ? `${kafkaOutput.round_robin.group_events}` : undefined, - undefined, + kafkaOutput?.round_robin?.group_events ? `${kafkaOutput.round_robin.group_events}` : '1', + kafkaPartitionTypeInput.value === kafkaPartitionType.RoundRobin + ? validateKafkaPartitioningGroupEvents + : undefined, isDisabled('partition') ); @@ -492,6 +497,8 @@ export function useOutputForm(onSucess: () => void, output?: Output) { const sslCertificateValid = sslCertificateInput.validate(); const sslKeyValid = sslKeyInput.validate(); const diskQueuePathValid = diskQueuePathInput.validate(); + const partitioningRandomGroupEventsValid = kafkaPartitionTypeRandomInput.validate(); + const partitioningRoundRobinGroupEventsValid = kafkaPartitionTypeRoundRobinInput.validate(); if (isLogstash) { // validate logstash @@ -516,7 +523,9 @@ export function useOutputForm(onSucess: () => void, output?: Output) { kafkaDefaultTopicValid && kafkaTopicsValid && additionalYamlConfigValid && - kafkaClientIDValid + kafkaClientIDValid && + partitioningRandomGroupEventsValid && + partitioningRoundRobinGroupEventsValid ); } else { // validate ES @@ -546,6 +555,8 @@ export function useOutputForm(onSucess: () => void, output?: Output) { sslCertificateInput, sslKeyInput, diskQueuePathInput, + kafkaPartitionTypeRandomInput, + kafkaPartitionTypeRoundRobinInput, isLogstash, isKafka, ]); @@ -674,7 +685,8 @@ export function useOutputForm(onSucess: () => void, output?: Output) { : {}), partition: kafkaPartitionTypeInput.value, - ...(kafkaPartitionTypeRandomInput.value + ...(kafkaPartitionTypeInput.value === kafkaPartitionType.Random && + kafkaPartitionTypeRandomInput.value ? { random: { group_events: parseIntegerIfStringDefined( @@ -683,7 +695,8 @@ export function useOutputForm(onSucess: () => void, output?: Output) { }, } : {}), - ...(kafkaPartitionTypeRoundRobinInput.value + ...(kafkaPartitionTypeInput.value === kafkaPartitionType.RoundRobin && + kafkaPartitionTypeRoundRobinInput.value ? { round_robin: { group_events: parseIntegerIfStringDefined( @@ -692,7 +705,8 @@ export function useOutputForm(onSucess: () => void, output?: Output) { }, } : {}), - ...(kafkaPartitionTypeHashInput.value + ...(kafkaPartitionTypeInput.value === kafkaPartitionType.Hash && + kafkaPartitionTypeHashInput.value ? { hash: { hash: kafkaPartitionTypeHashInput.value,