[Fleet] Remove deprecated topics property for kafka output in favor of topic (#199226)

This commit is contained in:
Nicolas Chaulet 2024-11-08 10:45:09 -05:00 committed by GitHub
parent 186bf6a6e1
commit 4a568964e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 94 additions and 819 deletions

View file

@ -23782,39 +23782,6 @@
"topic": {
"type": "string"
},
"topics": {
"items": {
"additionalProperties": true,
"properties": {
"topic": {
"type": "string"
},
"when": {
"additionalProperties": true,
"properties": {
"condition": {
"type": "string"
},
"type": {
"enum": [
"equals",
"contains",
"regexp"
],
"type": "string"
}
},
"type": "object"
}
},
"required": [
"topic"
],
"type": "object"
},
"minItems": 1,
"type": "array"
},
"type": {
"enum": [
"kafka"
@ -24917,39 +24884,6 @@
"topic": {
"type": "string"
},
"topics": {
"items": {
"additionalProperties": false,
"properties": {
"topic": {
"type": "string"
},
"when": {
"additionalProperties": false,
"properties": {
"condition": {
"type": "string"
},
"type": {
"enum": [
"equals",
"contains",
"regexp"
],
"type": "string"
}
},
"type": "object"
}
},
"required": [
"topic"
],
"type": "object"
},
"minItems": 1,
"type": "array"
},
"type": {
"enum": [
"kafka"
@ -25978,39 +25912,6 @@
"topic": {
"type": "string"
},
"topics": {
"items": {
"additionalProperties": true,
"properties": {
"topic": {
"type": "string"
},
"when": {
"additionalProperties": true,
"properties": {
"condition": {
"type": "string"
},
"type": {
"enum": [
"equals",
"contains",
"regexp"
],
"type": "string"
}
},
"type": "object"
}
},
"required": [
"topic"
],
"type": "object"
},
"minItems": 1,
"type": "array"
},
"type": {
"enum": [
"kafka"
@ -27213,39 +27114,6 @@
"topic": {
"type": "string"
},
"topics": {
"items": {
"additionalProperties": true,
"properties": {
"topic": {
"type": "string"
},
"when": {
"additionalProperties": true,
"properties": {
"condition": {
"type": "string"
},
"type": {
"enum": [
"equals",
"contains",
"regexp"
],
"type": "string"
}
},
"type": "object"
}
},
"required": [
"topic"
],
"type": "object"
},
"minItems": 1,
"type": "array"
},
"type": {
"enum": [
"kafka"
@ -28321,39 +28189,6 @@
"topic": {
"type": "string"
},
"topics": {
"items": {
"additionalProperties": false,
"properties": {
"topic": {
"type": "string"
},
"when": {
"additionalProperties": false,
"properties": {
"condition": {
"type": "string"
},
"type": {
"enum": [
"equals",
"contains",
"regexp"
],
"type": "string"
}
},
"type": "object"
}
},
"required": [
"topic"
],
"type": "object"
},
"minItems": 1,
"type": "array"
},
"type": {
"enum": [
"kafka"
@ -29379,39 +29214,6 @@
"topic": {
"type": "string"
},
"topics": {
"items": {
"additionalProperties": true,
"properties": {
"topic": {
"type": "string"
},
"when": {
"additionalProperties": true,
"properties": {
"condition": {
"type": "string"
},
"type": {
"enum": [
"equals",
"contains",
"regexp"
],
"type": "string"
}
},
"type": "object"
}
},
"required": [
"topic"
],
"type": "object"
},
"minItems": 1,
"type": "array"
},
"type": {
"enum": [
"kafka"

View file

@ -23782,39 +23782,6 @@
"topic": {
"type": "string"
},
"topics": {
"items": {
"additionalProperties": true,
"properties": {
"topic": {
"type": "string"
},
"when": {
"additionalProperties": true,
"properties": {
"condition": {
"type": "string"
},
"type": {
"enum": [
"equals",
"contains",
"regexp"
],
"type": "string"
}
},
"type": "object"
}
},
"required": [
"topic"
],
"type": "object"
},
"minItems": 1,
"type": "array"
},
"type": {
"enum": [
"kafka"
@ -24917,39 +24884,6 @@
"topic": {
"type": "string"
},
"topics": {
"items": {
"additionalProperties": false,
"properties": {
"topic": {
"type": "string"
},
"when": {
"additionalProperties": false,
"properties": {
"condition": {
"type": "string"
},
"type": {
"enum": [
"equals",
"contains",
"regexp"
],
"type": "string"
}
},
"type": "object"
}
},
"required": [
"topic"
],
"type": "object"
},
"minItems": 1,
"type": "array"
},
"type": {
"enum": [
"kafka"
@ -25978,39 +25912,6 @@
"topic": {
"type": "string"
},
"topics": {
"items": {
"additionalProperties": true,
"properties": {
"topic": {
"type": "string"
},
"when": {
"additionalProperties": true,
"properties": {
"condition": {
"type": "string"
},
"type": {
"enum": [
"equals",
"contains",
"regexp"
],
"type": "string"
}
},
"type": "object"
}
},
"required": [
"topic"
],
"type": "object"
},
"minItems": 1,
"type": "array"
},
"type": {
"enum": [
"kafka"
@ -27213,39 +27114,6 @@
"topic": {
"type": "string"
},
"topics": {
"items": {
"additionalProperties": true,
"properties": {
"topic": {
"type": "string"
},
"when": {
"additionalProperties": true,
"properties": {
"condition": {
"type": "string"
},
"type": {
"enum": [
"equals",
"contains",
"regexp"
],
"type": "string"
}
},
"type": "object"
}
},
"required": [
"topic"
],
"type": "object"
},
"minItems": 1,
"type": "array"
},
"type": {
"enum": [
"kafka"
@ -28321,39 +28189,6 @@
"topic": {
"type": "string"
},
"topics": {
"items": {
"additionalProperties": false,
"properties": {
"topic": {
"type": "string"
},
"when": {
"additionalProperties": false,
"properties": {
"condition": {
"type": "string"
},
"type": {
"enum": [
"equals",
"contains",
"regexp"
],
"type": "string"
}
},
"type": "object"
}
},
"required": [
"topic"
],
"type": "object"
},
"minItems": 1,
"type": "array"
},
"type": {
"enum": [
"kafka"
@ -29379,39 +29214,6 @@
"topic": {
"type": "string"
},
"topics": {
"items": {
"additionalProperties": true,
"properties": {
"topic": {
"type": "string"
},
"when": {
"additionalProperties": true,
"properties": {
"condition": {
"type": "string"
},
"type": {
"enum": [
"equals",
"contains",
"regexp"
],
"type": "string"
}
},
"type": "object"
}
},
"required": [
"topic"
],
"type": "object"
},
"minItems": 1,
"type": "array"
},
"type": {
"enum": [
"kafka"

View file

@ -22419,29 +22419,6 @@ paths:
type: number
topic:
type: string
topics:
items:
additionalProperties: true
type: object
properties:
topic:
type: string
when:
additionalProperties: true
type: object
properties:
condition:
type: string
type:
enum:
- equals
- contains
- regexp
type: string
required:
- topic
minItems: 1
type: array
type:
enum:
- kafka
@ -23176,29 +23153,6 @@ paths:
type: number
topic:
type: string
topics:
items:
additionalProperties: false
type: object
properties:
topic:
type: string
when:
additionalProperties: false
type: object
properties:
condition:
type: string
type:
enum:
- equals
- contains
- regexp
type: string
required:
- topic
minItems: 1
type: array
type:
enum:
- kafka
@ -23888,29 +23842,6 @@ paths:
type: number
topic:
type: string
topics:
items:
additionalProperties: true
type: object
properties:
topic:
type: string
when:
additionalProperties: true
type: object
properties:
condition:
type: string
type:
enum:
- equals
- contains
- regexp
type: string
required:
- topic
minItems: 1
type: array
type:
enum:
- kafka
@ -24710,29 +24641,6 @@ paths:
type: number
topic:
type: string
topics:
items:
additionalProperties: true
type: object
properties:
topic:
type: string
when:
additionalProperties: true
type: object
properties:
condition:
type: string
type:
enum:
- equals
- contains
- regexp
type: string
required:
- topic
minItems: 1
type: array
type:
enum:
- kafka
@ -25444,29 +25352,6 @@ paths:
type: number
topic:
type: string
topics:
items:
additionalProperties: false
type: object
properties:
topic:
type: string
when:
additionalProperties: false
type: object
properties:
condition:
type: string
type:
enum:
- equals
- contains
- regexp
type: string
required:
- topic
minItems: 1
type: array
type:
enum:
- kafka
@ -26153,29 +26038,6 @@ paths:
type: number
topic:
type: string
topics:
items:
additionalProperties: true
type: object
properties:
topic:
type: string
when:
additionalProperties: true
type: object
properties:
condition:
type: string
type:
enum:
- equals
- contains
- regexp
type: string
required:
- topic
minItems: 1
type: array
type:
enum:
- kafka

View file

@ -25852,29 +25852,6 @@ paths:
type: number
topic:
type: string
topics:
items:
additionalProperties: true
type: object
properties:
topic:
type: string
when:
additionalProperties: true
type: object
properties:
condition:
type: string
type:
enum:
- equals
- contains
- regexp
type: string
required:
- topic
minItems: 1
type: array
type:
enum:
- kafka
@ -26609,29 +26586,6 @@ paths:
type: number
topic:
type: string
topics:
items:
additionalProperties: false
type: object
properties:
topic:
type: string
when:
additionalProperties: false
type: object
properties:
condition:
type: string
type:
enum:
- equals
- contains
- regexp
type: string
required:
- topic
minItems: 1
type: array
type:
enum:
- kafka
@ -27321,29 +27275,6 @@ paths:
type: number
topic:
type: string
topics:
items:
additionalProperties: true
type: object
properties:
topic:
type: string
when:
additionalProperties: true
type: object
properties:
condition:
type: string
type:
enum:
- equals
- contains
- regexp
type: string
required:
- topic
minItems: 1
type: array
type:
enum:
- kafka
@ -28143,29 +28074,6 @@ paths:
type: number
topic:
type: string
topics:
items:
additionalProperties: true
type: object
properties:
topic:
type: string
when:
additionalProperties: true
type: object
properties:
condition:
type: string
type:
enum:
- equals
- contains
- regexp
type: string
required:
- topic
minItems: 1
type: array
type:
enum:
- kafka
@ -28877,29 +28785,6 @@ paths:
type: number
topic:
type: string
topics:
items:
additionalProperties: false
type: object
properties:
topic:
type: string
when:
additionalProperties: false
type: object
properties:
condition:
type: string
type:
enum:
- equals
- contains
- regexp
type: string
required:
- topic
minItems: 1
type: array
type:
enum:
- kafka
@ -29586,29 +29471,6 @@ paths:
type: number
topic:
type: string
topics:
items:
additionalProperties: true
type: object
properties:
topic:
type: string
when:
additionalProperties: true
type: object
properties:
condition:
type: string
type:
enum:
- equals
- contains
- regexp
type: string
required:
- topic
minItems: 1
type: array
type:
enum:
- kafka

View file

@ -122,7 +122,7 @@ describe('checking migration metadata changes on all registered SO types', () =>
"infrastructure-ui-source": "113182d6895764378dfe7fa9fa027244f3a457c4",
"ingest-agent-policies": "5e95e539826a40ad08fd0c1d161da0a4d86ffc6d",
"ingest-download-sources": "279a68147e62e4d8858c09ad1cf03bd5551ce58d",
"ingest-outputs": "daafff49255ab700e07491376fe89f04fc998b91",
"ingest-outputs": "55988d5f778bbe0e76caa7e6468707a0a056bdd8",
"ingest-package-policies": "53a94064674835fdb35e5186233bcd7052eabd22",
"ingest_manager_settings": "111a616eb72627c002029c19feb9e6c439a10505",
"inventory-view": "b8683c8e352a286b4aca1ab21003115a4800af83",

View file

@ -127,13 +127,6 @@ export interface KafkaOutput extends NewBaseOutput {
random?: boolean;
};
topic?: string;
topics?: Array<{
topic: string;
when?: {
type?: ValueOf<KafkaTopicWhenType>;
condition?: string;
};
}>;
headers?: Array<{
key: string;
value: string;

View file

@ -66,7 +66,7 @@ export const kafkaOutputBody = {
type: 'kafka',
is_default: false,
hosts: ['example.com:2000'],
topics: [{ topic: 'test' }],
topic: 'test',
auth_type: 'user_pass',
username: 'kafka',
password: 'kafka',

View file

@ -207,7 +207,7 @@ describe('EditOutputFlyout', () => {
is_default: false,
is_default_monitoring: false,
hosts: ['kafka:443'],
topics: [{ topic: 'topic' }],
topic: 'topic',
auth_type: 'ssl',
version: '1.0.0',
ssl: { certificate: 'cert', key: 'key', verification_mode: 'full' },
@ -247,7 +247,7 @@ describe('EditOutputFlyout', () => {
is_default: false,
is_default_monitoring: false,
hosts: ['kafka:443'],
topics: [{ topic: 'topic' }],
topic: 'topic',
auth_type: 'user_pass',
version: '1.0.0',
username: 'user',

View file

@ -12,7 +12,7 @@ import {
describe('use_output_form', () => {
describe('extractDefaultDynamicKafkaTopics', () => {
it('should return empty array if not topics are passed', () => {
it('should return empty array if not topic are passed', () => {
const res = extractDefaultDynamicKafkaTopics({
type: 'kafka',
name: 'new',
@ -23,37 +23,25 @@ describe('use_output_form', () => {
expect(res).toEqual([]);
});
it('should return empty array if topics have length == 0', () => {
it('should return empty array if topic do not include %{[', () => {
const res = extractDefaultDynamicKafkaTopics({
type: 'kafka',
name: 'new',
is_default: false,
is_default_monitoring: false,
topics: [],
topic: 'something',
});
expect(res).toEqual([]);
});
it('should return empty array if topics do not include %{[', () => {
it('should return options for combobox if topic include %{[', () => {
const res = extractDefaultDynamicKafkaTopics({
type: 'kafka',
name: 'new',
is_default: false,
is_default_monitoring: false,
topics: [{ topic: 'something' }],
});
expect(res).toEqual([]);
});
it('should return options for combobox if topics include %{[', () => {
const res = extractDefaultDynamicKafkaTopics({
type: 'kafka',
name: 'new',
is_default: false,
is_default_monitoring: false,
topics: [{ topic: '%{[default.dataset]}' }],
topic: '%{[default.dataset]}',
});
expect(res).toEqual([
@ -64,13 +52,13 @@ describe('use_output_form', () => {
]);
});
it('should return options for combobox if topics include %{[ and some special characters', () => {
it('should return options for combobox if topic include %{[ and some special characters', () => {
const res = extractDefaultDynamicKafkaTopics({
type: 'kafka',
name: 'new',
is_default: false,
is_default_monitoring: false,
topics: [{ topic: '%{[@timestamp]}' }],
topic: '%{[@timestamp]}',
});
expect(res).toEqual([
@ -81,13 +69,13 @@ describe('use_output_form', () => {
]);
});
it('should return options for combobox if topics include %{[ and a custom name', () => {
it('should return options for combobox if topic include %{[ and a custom name', () => {
const res = extractDefaultDynamicKafkaTopics({
type: 'kafka',
name: 'new',
is_default: false,
is_default_monitoring: false,
topics: [{ topic: '%{[something]}' }],
topic: '%{[something]}',
});
expect(res).toEqual([
@ -100,7 +88,7 @@ describe('use_output_form', () => {
});
describe('extractDefaultStaticKafkaTopic', () => {
it('should return empty array if not topics are passed', () => {
it('should return empty array if not topic are passed', () => {
const res = extractDefaultStaticKafkaTopic({
type: 'kafka',
name: 'new',
@ -111,52 +99,28 @@ describe('use_output_form', () => {
expect(res).toEqual('');
});
it('should return empty array if topics have length == 0', () => {
it('should return empty string if topic include %{[', () => {
const res = extractDefaultStaticKafkaTopic({
type: 'kafka',
name: 'new',
is_default: false,
is_default_monitoring: false,
topics: [],
topic: '%{[something]}',
});
expect(res).toEqual('');
});
it('should return empty string if topics include %{[', () => {
it('should return the topic if topic field is defined', () => {
const res = extractDefaultStaticKafkaTopic({
type: 'kafka',
name: 'new',
is_default: false,
is_default_monitoring: false,
topics: [{ topic: '%{[something]}' }],
});
expect(res).toEqual('');
});
it('should return the topic if topics field is defined', () => {
const res = extractDefaultStaticKafkaTopic({
type: 'kafka',
name: 'new',
is_default: false,
is_default_monitoring: false,
topics: [{ topic: 'something' }],
topic: 'something',
});
expect(res).toEqual('something');
});
it('should return the last topic if topics field is defined and has multiple', () => {
const res = extractDefaultStaticKafkaTopic({
type: 'kafka',
name: 'new',
is_default: false,
is_default_monitoring: false,
topics: [{ topic: 'something_1' }, { topic: 'something_2' }, { topic: 'something_3' }],
});
expect(res).toEqual('something_3');
});
});
});

View file

@ -162,25 +162,20 @@ function extractKafkaOutputSecrets(
}
export function extractDefaultStaticKafkaTopic(o: KafkaOutput): string {
if (
!o?.topics ||
o.topics?.length === 0 ||
(o.topics && o?.topics.length > 0 && o.topics[0].topic?.includes('%{['))
) {
if (o?.topic?.includes('%{[')) {
return '';
}
const lastTopic = o.topics[o.topics.length - 1].topic;
return lastTopic || '';
return o?.topic || '';
}
export function extractDefaultDynamicKafkaTopics(
o: KafkaOutput
): Array<EuiComboBoxOptionOption<string>> {
if (!o?.topics || o.topics?.length === 0 || (o.topics && !o.topics[0]?.topic?.includes('%{['))) {
if (!o?.topic || (o?.topic && !o.topic?.includes('%{['))) {
return [];
}
const matched = o.topics[0].topic.match(/(%\{\[)(\S*)(\]\})/);
const matched = o.topic.match(/(%\{\[)(\S*)(\]\})/);
const parsed = matched?.length ? matched[2] : '';
return [
@ -470,23 +465,23 @@ export function useOutputForm(onSucess: () => void, output?: Output, defaultOupu
);
const kafkaTopicsInput = useRadioInput(
kafkaOutput?.topics && kafkaOutput?.topics[0].topic?.includes('%{[')
kafkaOutput?.topic && kafkaOutput?.topic?.includes('%{[')
? kafkaTopicsType.Dynamic
: kafkaTopicsType.Static,
isDisabled('topics')
isDisabled('topic')
);
const kafkaStaticTopicInput = useInput(
extractDefaultStaticKafkaTopic(kafkaOutput),
kafkaTopicsInput.value === kafkaTopicsType.Static ? validateKafkaStaticTopic : undefined,
isDisabled('topics')
isDisabled('topic')
);
const kafkaDynamicTopicInput = useComboBoxWithCustomInput(
'kafkaDynamicTopicComboBox',
extractDefaultDynamicKafkaTopics(kafkaOutput),
kafkaTopicsInput.value === kafkaTopicsType.Dynamic ? validateDynamicKafkaTopics : undefined,
isDisabled('topics')
isDisabled('topic')
);
const kafkaHeadersInput = useKeyValueInput(
@ -874,19 +869,11 @@ export function useOutputForm(onSucess: () => void, output?: Output, defaultOupu
: {}),
...(kafkaTopicsInput.value === kafkaTopicsType.Static && kafkaStaticTopicInput.value
? {
topics: [
{
topic: kafkaStaticTopicInput.value,
},
],
topic: kafkaStaticTopicInput.value,
}
: kafkaTopicsInput.value === kafkaTopicsType.Dynamic && kafkaDynamicTopicInput.value
? {
topics: [
{
topic: `%{[${kafkaDynamicTopicInput.value}]}`,
},
],
topic: `%{[${kafkaDynamicTopicInput.value}]}`,
}
: {}),
headers: kafkaHeadersInput.value,

View file

@ -101,6 +101,7 @@ import {
migratePackagePolicySetRequiresRootToV8150,
} from './migrations/to_v8_15_0';
import { backfillAgentPolicyToV4 } from './model_versions/agent_policy_v4';
import { backfillOutputPolicyToV7 } from './model_versions/outputs';
/*
* Saved object types and mappings
@ -558,6 +559,18 @@ export const getSavedObjectTypes = (
},
],
},
'7': {
changes: [
{
type: 'mappings_deprecation',
deprecatedMappings: ['topics'],
},
{
type: 'data_backfill',
backfillFn: backfillOutputPolicyToV7,
},
],
},
},
migrations: {
'7.13.0': migrateOutputToV7130,

View file

@ -0,0 +1,32 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import type { SavedObjectModelDataBackfillFn } from '@kbn/core-saved-objects-server';
import type { Output } from '../../../common';
export const backfillOutputPolicyToV7: SavedObjectModelDataBackfillFn<
Output & {
topics?: Array<{
topic: string;
when?: {
type?: string;
condition?: string;
};
}>;
},
Output
> = (outputDoc) => {
if (outputDoc.attributes.type === 'kafka' && outputDoc.attributes.topics) {
if (!outputDoc.attributes.topic) {
outputDoc.attributes.topic = outputDoc.attributes.topics?.filter((t) => !t.when)?.[0]?.topic;
}
delete outputDoc.attributes.topics;
}
return outputDoc;
};

View file

@ -1198,16 +1198,7 @@ ssl.test: 123
const policyOutput = transformOutputToFullPolicyOutput({
id: 'id123',
hosts: ['test:9999'],
topics: [
{
topic: 'test',
},
// Deprecated conditionnal topic
{
topic: 'deprecated',
when: { condition: 'test:100', type: 'equals' },
},
],
topic: 'test',
is_default: false,
is_default_monitoring: false,
name: 'test output',

View file

@ -386,15 +386,12 @@ export function transformOutputToFullPolicyOutput(
round_robin,
hash,
topic,
topics,
headers,
timeout,
broker_timeout,
required_acks,
} = output;
const kafkaTopic = topic ? topic : topics?.filter((t) => !t.when)?.[0]?.topic;
const transformPartition = () => {
if (!partition) return {};
switch (partition) {
@ -431,7 +428,7 @@ export function transformOutputToFullPolicyOutput(
...(password ? { password } : {}),
...(sasl ? { sasl } : {}),
partition: transformPartition(),
topic: kafkaTopic,
topic,
headers: (headers ?? []).filter((item) => item.key !== '' || item.value !== ''),
timeout,
broker_timeout,

View file

@ -824,7 +824,7 @@ describe('Output Service', () => {
is_default_monitoring: false,
name: 'Test',
type: 'kafka',
topics: [{ topic: 'test' }],
topic: 'test',
},
{ id: 'output-test' }
)
@ -1206,7 +1206,6 @@ describe('Output Service', () => {
ssl: null,
timeout: null,
topic: null,
topics: null,
headers: null,
username: null,
version: null,
@ -1330,7 +1329,6 @@ describe('Output Service', () => {
sasl: null,
timeout: null,
topic: null,
topics: null,
headers: null,
username: null,
version: null,

View file

@ -919,7 +919,6 @@ class OutputService {
target.random = null;
target.round_robin = null;
target.hash = null;
target.topics = null;
target.topic = null;
target.headers = null;
target.timeout = null;

View file

@ -318,7 +318,6 @@ async function isPreconfiguredOutputDifferentFromCurrent(
isDifferent(existingOutput.round_robin, preconfiguredOutput.round_robin) ||
isDifferent(existingOutput.hash, preconfiguredOutput.hash) ||
isDifferent(existingOutput.topic, preconfiguredOutput.topic) ||
isDifferent(existingOutput.topics, preconfiguredOutput.topics) ||
isDifferent(existingOutput.headers, preconfiguredOutput.headers) ||
isDifferent(existingOutput.timeout, preconfiguredOutput.timeout) ||
isDifferent(existingOutput.broker_timeout, preconfiguredOutput.broker_timeout) ||

View file

@ -13,7 +13,6 @@ import {
kafkaConnectionType,
kafkaPartitionType,
kafkaSaslMechanism,
kafkaTopicWhenType,
kafkaVerificationModes,
outputType,
} from '../../../common/constants';
@ -196,29 +195,6 @@ const LogstashUpdateSchema = {
),
};
/**
* Kafka schemas
*/
const KafkaTopicsSchema = schema.arrayOf(
schema.object({
topic: schema.string(),
when: schema.maybe(
schema.object({
type: schema.maybe(
schema.oneOf([
schema.literal(kafkaTopicWhenType.Equals),
schema.literal(kafkaTopicWhenType.Contains),
schema.literal(kafkaTopicWhenType.Regexp),
])
),
condition: schema.maybe(schema.string()),
})
),
}),
{ minSize: 1 }
);
export const KafkaSchema = {
...BaseSchema,
type: schema.literal(outputType.Kafka),
@ -303,7 +279,6 @@ export const KafkaSchema = {
schema.object({ hash: schema.maybe(schema.string()), random: schema.maybe(schema.boolean()) })
),
topic: schema.maybe(schema.string()),
topics: schema.maybe(KafkaTopicsSchema),
headers: schema.maybe(
schema.arrayOf(schema.object({ key: schema.string(), value: schema.string() }))
),
@ -335,7 +310,6 @@ const KafkaUpdateSchema = {
schema.literal(kafkaAuthType.Kerberos),
])
),
topics: schema.maybe(KafkaTopicsSchema),
};
export const OutputSchema = schema.oneOf([

View file

@ -119,7 +119,7 @@ describe('Test preconfiguration schema', () => {
type: 'kafka',
hosts: ['localhost:9200'],
auth_type: 'ssl',
topics: [{ topic: 'topic1' }],
topic: 'topic1',
secrets: {
password: 'mypassword',
ssl: {

View file

@ -445,7 +445,7 @@ export default function (providerContext: FtrProviderContext) {
password: 'pass',
is_default: true,
is_default_monitoring: true,
topics: [{ topic: 'topic1' }],
topic: 'topic1',
})
.expect(400);
expect(body.message).to.eql(
@ -727,7 +727,7 @@ export default function (providerContext: FtrProviderContext) {
type: 'kafka',
hosts: ['test.fr:2000'],
auth_type: 'ssl',
topics: [{ topic: 'topic1' }],
topic: 'topic1',
config_yaml: 'shipper: {}',
shipper: {
disk_queue_enabled: true,
@ -760,7 +760,7 @@ export default function (providerContext: FtrProviderContext) {
type: 'kafka',
hosts: ['test.fr:2000'],
auth_type: 'ssl',
topics: [{ topic: 'topic1' }],
topic: 'topic1',
config_yaml: 'shipper: {}',
shipper: {
disk_queue_enabled: true,
@ -1107,7 +1107,7 @@ export default function (providerContext: FtrProviderContext) {
auth_type: 'user_pass',
username: 'user',
password: 'pass',
topics: [{ topic: 'topic1' }],
topic: 'topic1',
})
.expect(200);
@ -1121,7 +1121,7 @@ export default function (providerContext: FtrProviderContext) {
auth_type: 'user_pass',
username: 'user',
password: 'pass',
topics: [{ topic: 'topic1' }],
topic: 'topic1',
broker_timeout: 10,
required_acks: 1,
client_id: 'Elastic',
@ -1147,7 +1147,7 @@ export default function (providerContext: FtrProviderContext) {
auth_type: 'user_pass',
username: 'user',
password: 'pass',
topics: [{ topic: 'topic1' }],
topic: 'topic1',
is_default: true,
})
.expect(200);
@ -1160,7 +1160,7 @@ export default function (providerContext: FtrProviderContext) {
auth_type: 'user_pass',
username: 'user',
password: 'pass',
topics: [{ topic: 'topic1' }],
topic: 'topic1',
is_default: true,
is_default_monitoring: false,
broker_timeout: 10,
@ -1388,7 +1388,7 @@ export default function (providerContext: FtrProviderContext) {
auth_type: 'user_pass',
username: 'user',
password: 'pass',
topics: [{ topic: 'topic1' }],
topic: 'topic1',
config_yaml: 'shipper: {}',
shipper: {
disk_queue_enabled: true,
@ -1448,7 +1448,7 @@ export default function (providerContext: FtrProviderContext) {
auth_type: 'user_pass',
username: 'user',
password: 'pass',
topics: [{ topic: 'topic1' }],
topic: 'topic1',
config_yaml: 'shipper: {}',
shipper: {
disk_queue_enabled: true,
@ -1469,7 +1469,7 @@ export default function (providerContext: FtrProviderContext) {
type: 'kafka',
hosts: ['test.fr:2000'],
auth_type: 'ssl',
topics: [{ topic: 'topic1' }],
topic: 'topic1',
config_yaml: 'shipper: {}',
shipper: {
disk_queue_enabled: true,
@ -1501,7 +1501,7 @@ export default function (providerContext: FtrProviderContext) {
type: 'kafka',
hosts: ['test.fr:2000'],
auth_type: 'ssl',
topics: [{ topic: 'topic1' }],
topic: 'topic1',
config_yaml: 'shipper: {}',
shipper: {
disk_queue_enabled: true,
@ -1536,7 +1536,7 @@ export default function (providerContext: FtrProviderContext) {
hosts: ['test.fr:2000'],
auth_type: 'user_pass',
username: 'user',
topics: [{ topic: 'topic1' }],
topic: 'topic1',
config_yaml: 'shipper: {}',
shipper: {
disk_queue_enabled: true,
@ -1811,7 +1811,7 @@ export default function (providerContext: FtrProviderContext) {
username: 'user',
password: 'pass',
is_default: true,
topics: [{ topic: 'topic1' }],
topic: 'topic1',
};
before(async () => {
@ -1858,7 +1858,7 @@ export default function (providerContext: FtrProviderContext) {
type: 'kafka',
hosts: ['test.fr:2000'],
auth_type: 'ssl',
topics: [{ topic: 'topic1' }],
topic: 'topic1',
config_yaml: 'shipper: {}',
shipper: {
disk_queue_enabled: true,
@ -1905,7 +1905,7 @@ export default function (providerContext: FtrProviderContext) {
type: 'kafka',
hosts: ['test.fr:2000'],
auth_type: 'ssl',
topics: [{ topic: 'topic1' }],
topic: 'topic1',
config_yaml: '',
compression: 'none',
client_id: 'Elastic',
@ -1943,7 +1943,7 @@ export default function (providerContext: FtrProviderContext) {
.expect(200);
expect(updateRes.body.item.type).to.eql('logstash');
expect(updateRes.body.item.topics).to.eql(null);
expect(updateRes.body.item.topic).to.eql(null);
await supertest
.delete(`/api/fleet/outputs/${outputWithSecretsId}`)

View file

@ -231,7 +231,7 @@ export default function (providerContext: FtrProviderContext) {
hosts: ['test.fr:2000'],
auth_type: 'user_pass',
username: 'user',
topics: [{ topic: 'topic1' }],
topic: 'topic1',
config_yaml: 'shipper: {}',
shipper: {
disk_queue_enabled: true,