Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fleet] Support Elasticsearch output performance presets #172359

Merged
merged 38 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
a0d0024
Add initial logic for output presets
kpollich Dec 1, 2023
e9ceb17
Disable dropdown + fix full agent policy logic
kpollich Dec 1, 2023
1f3501d
Fix some tests
kpollich Dec 1, 2023
efaa9e7
Update SO snapshot
kpollich Dec 1, 2023
1a2fe05
Fix FTR assertion
kpollich Dec 1, 2023
3b1cc9b
[CI] Auto-commit changed files from 'node scripts/check_mappings_upda…
kibanamachine Dec 1, 2023
7979402
Don't show UI or attempt to backfill non-ES outputs
kpollich Dec 4, 2023
8d279dd
Fix AAD exclusion + preset defaulting when updating
kpollich Dec 4, 2023
759fa06
Fix cloud preconfiguration assertion
kpollich Dec 4, 2023
3965d6d
Fix typo + FTR assertions
kpollich Dec 4, 2023
7b0440c
Fix output service tests
kpollich Dec 4, 2023
9f59844
Add unit tests for output service
kpollich Dec 4, 2023
3c24b1b
Add cypress tests
kpollich Dec 4, 2023
b3a19bb
Add FTR tests
kpollich Dec 4, 2023
264ec72
Update OpenAPI spec
kpollich Dec 4, 2023
4da753d
Fix openAPI
kpollich Dec 4, 2023
1679582
Merge branch 'main' into fleet/166870-output-presets
kpollich Dec 4, 2023
fd150b8
Add all preset type + improve cypress tests
kpollich Dec 5, 2023
a8a8a98
Merge branch 'main' into fleet/166870-output-presets
kpollich Dec 5, 2023
b495938
Fixup cypress tests
kpollich Dec 5, 2023
66347d4
Merge branch 'main' into fleet/166870-output-presets
kibanamachine Dec 5, 2023
5f18e93
Ignore 404 in output health + fixup cypress
kpollich Dec 5, 2023
a5c24e1
Fix preconfiguration check
kpollich Dec 5, 2023
5f8de5c
Fix type
kpollich Dec 5, 2023
3217e0d
Parse YML when validating
kpollich Dec 5, 2023
ebee7b9
Fix type again
kpollich Dec 5, 2023
d78a6f7
Fix YML validation on plain strings
kpollich Dec 5, 2023
61c4d3b
Update OpenAPI
kpollich Dec 5, 2023
c39d310
Fix test case names
kpollich Dec 5, 2023
0e6bf4d
Fix output service test
kpollich Dec 5, 2023
e85edf3
Merge branch 'main' into fleet/166870-output-presets
kibanamachine Dec 5, 2023
08f3d12
Lazy load output flyout to save bundle size
kpollich Dec 6, 2023
06f4ecd
Merge branch 'main' into fleet/166870-output-presets
kibanamachine Dec 6, 2023
76c75b8
Fix missing suspense boundary
kpollich Dec 6, 2023
6bb7594
Try only importing safeload
kpollich Dec 6, 2023
bd9979e
Revert lazy conversion to stop creating separate chunk
kpollich Dec 6, 2023
0b90335
Add DI for safeload in output helpers
kpollich Dec 6, 2023
3f985ac
Fix tests
kpollich Dec 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@
"output_id",
"partition",
"password",
"preset",
"proxy_id",
"random",
"random.group_events",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1854,6 +1854,10 @@
}
}
}
},
"preset": {
juliaElastic marked this conversation as resolved.
Show resolved Hide resolved
"type": "keyword",
"index": false
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ describe('checking migration metadata changes on all registered SO types', () =>
"infrastructure-ui-source": "113182d6895764378dfe7fa9fa027244f3a457c4",
"ingest-agent-policies": "7633e578f60c074f8267bc50ec4763845e431437",
"ingest-download-sources": "279a68147e62e4d8858c09ad1cf03bd5551ce58d",
"ingest-outputs": "20bd44ce6016079c3b28f1b2bc241e7715be48f8",
"ingest-outputs": "e36a25e789f22b4494be728321f4304a040e286b",
"ingest-package-policies": "f4c2767e852b700a8b82678925b86bac08958b43",
"ingest_manager_settings": "64955ef1b7a9ffa894d4bb9cf863b5602bfa6885",
"inventory-view": "b8683c8e352a286b4aca1ab21003115a4800af83",
Expand Down
17 changes: 16 additions & 1 deletion x-pack/plugins/fleet/common/constants/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import type { NewOutput } from '../types';
import type { NewOutput, OutputType, ValueOf } from '../types';

export const OUTPUT_SAVED_OBJECT_TYPE = 'ingest-outputs';

Expand Down Expand Up @@ -120,4 +120,19 @@ export const kafkaSupportedVersions = [
'2.6.0',
];

export const RESERVED_CONFIG_YML_KEYS = [
'bulk_max_size',
'workers',
'queue.mem.events',
'flush.min_events',
'flush.timeout',
'compression',
'idle_timeout',
];

export const OUTPUT_TYPES_WITH_PRESET_SUPPORT: Array<ValueOf<OutputType>> = [
outputType.Elasticsearch,
outputType.RemoteElasticsearch,
];

export const OUTPUT_HEALTH_DATA_STREAM = 'logs-fleet_server.output_health-default';
14 changes: 14 additions & 0 deletions x-pack/plugins/fleet/common/openapi/bundled.json
Original file line number Diff line number Diff line change
Expand Up @@ -7952,6 +7952,13 @@
"config": {
"type": "object"
},
"preset": {
"type": "string",
"enum": [
"balanced",
"custom"
]
},
"config_yaml": {
"type": "string"
},
Expand Down Expand Up @@ -8442,6 +8449,13 @@
"config": {
"type": "object"
},
"preset": {
"type": "string",
"enum": [
"balanced",
"custom"
]
},
"config_yaml": {
"type": "string"
},
Expand Down
10 changes: 10 additions & 0 deletions x-pack/plugins/fleet/common/openapi/bundled.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5130,6 +5130,11 @@ components:
type: string
config:
type: object
preset:
type: string
enum:
- balanced
- custom
config_yaml:
type: string
ssl:
Expand Down Expand Up @@ -5451,6 +5456,11 @@ components:
type: string
config:
type: object
preset:
type: string
enum:
- balanced
- custom
config_yaml:
type: string
ssl:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ properties:
type: string
config:
type: object
preset:
type: string
enum: ['balanced', 'custom']
config_yaml:
type: string
ssl:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ properties:
type: string
config:
type: object
preset:
type: string
enum: ['balanced', 'custom']
config_yaml:
type: string
ssl:
Expand Down
20 changes: 19 additions & 1 deletion x-pack/plugins/fleet/common/services/output_helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
* 2.0.
*/

import type { AgentPolicy } from '../types';
import type { AgentPolicy, OutputType, ValueOf } from '../types';
import {
FLEET_APM_PACKAGE,
FLEET_SERVER_PACKAGE,
FLEET_SYNTHETICS_PACKAGE,
outputType,
OUTPUT_TYPES_WITH_PRESET_SUPPORT,
RESERVED_CONFIG_YML_KEYS,
} from '../constants';

/**
Expand All @@ -33,3 +35,19 @@ export function getAllowedOutputTypeForPolicy(agentPolicy: AgentPolicy) {

return Object.values(outputType);
}

export function outputYmlIncludesReservedPerformanceKey(configYml: string) {
return RESERVED_CONFIG_YML_KEYS.some((key) => configYml.includes(key));
}

export function getDefaultPresetForEsOutput(configYaml: string): 'balanced' | 'custom' {
if (outputYmlIncludesReservedPerformanceKey(configYaml)) {
return 'custom';
}

return 'balanced';
}

export function outputTypeSupportPresets(type: ValueOf<OutputType>) {
return OUTPUT_TYPES_WITH_PRESET_SUPPORT.includes(type);
}
3 changes: 3 additions & 0 deletions x-pack/plugins/fleet/common/types/models/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@ interface NewBaseOutput {
shipper?: ShipperOutput | null;
allow_edit?: string[];
secrets?: {};
preset?: 'custom' | 'balanced';
kpollich marked this conversation as resolved.
Show resolved Hide resolved
}

export type OutputPreset = 'custom' | 'balanced' | 'throughput' | 'scale' | 'latency';

export interface NewElasticsearchOutput extends NewBaseOutput {
type: OutputType['Elasticsearch'];
}
Expand Down
96 changes: 93 additions & 3 deletions x-pack/plugins/fleet/cypress/e2e/fleet_settings_outputs.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ import {
loadKafkaOutput,
loadLogstashOutput,
resetKafkaOutputForm,
selectESOutput,
selectKafkaOutput,
selectRemoteESOutput,
shouldDisplayError,
validateOutputTypeChangeToKafka,
validateSavedKafkaOutputForm,
Expand All @@ -37,6 +39,94 @@ describe('Outputs', () => {
login();
});

describe('Elasticsearch', () => {
describe('Preset input', () => {
it('is set to balanced by default', () => {
selectESOutput();

cy.getBySel(SETTINGS_OUTPUTS.PRESET_INPUT).should('have.value', 'balanced');
});

it('forces custom when reserved key is included in config YAML box', () => {
selectESOutput();

cy.getBySel('kibanaCodeEditor').click().focused().type('bulk_max_size: 1000');

cy.getBySel(SETTINGS_OUTPUTS.PRESET_INPUT)
.should('have.value', 'custom')
.should('be.disabled');
});

it('allows balanced when reserved key is not included in config yaml box', () => {
selectESOutput();

cy.getBySel('kibanaCodeEditor').click().focused().type('some_random_key: foo');

cy.getBySel(SETTINGS_OUTPUTS.PRESET_INPUT)
.should('have.value', 'balanced')
.should('be.enabled');
});

const cases = [
{
name: 'Preset: Balanced',
preset: 'balanced',
},
{
name: 'Preset: Custom',
preset: 'custom',
},
{
name: 'Preset: Throughput',
preset: 'throughput',
},
{
name: 'Preset: Scale',
preset: 'scale',
},
{
name: 'Preset: Latency',
preset: 'latency',
},
];

for (const type of ['elasticsearch', 'remote_elasticsearch']) {
for (const testCase of cases) {
describe(`When type is ${type} and preset is ${testCase.name}`, () => {
it('successfully creates output', () => {
if (type === 'elasticsearch') {
selectESOutput();
} else if (type === 'remote_elasticsearch') {
selectRemoteESOutput();
}

cy.getBySel(SETTINGS_OUTPUTS.NAME_INPUT).type(testCase.name);
cy.get(`[placeholder="Specify host URL"]`).type(
`http://${testCase.preset}.elasticsearch.com:9200`
);
cy.getBySel(SETTINGS_OUTPUTS.PRESET_INPUT).select(testCase.preset);

cy.intercept('POST', '**/api/fleet/outputs').as('saveOutput');
cy.getBySel(SETTINGS_SAVE_BTN).click();

cy.wait('@saveOutput').then((interception) => {
const responseBody = interception.response?.body;
cy.visit(`/app/fleet/settings/outputs/${responseBody?.item?.id}`);
});

cy.getBySel(SETTINGS_OUTPUTS.NAME_INPUT).should('have.value', testCase.name);
cy.get(`[placeholder="Specify host URL"]`).should(
'have.value',
`http://${testCase.preset}.elasticsearch.com:9200`
);
cy.getBySel(SETTINGS_OUTPUTS.PRESET_INPUT).should('have.value', testCase.preset);
});
});
}
}
});
});

describe('Kafka', () => {
describe('Form validation', () => {
it('renders all form fields', () => {
Expand Down Expand Up @@ -204,7 +294,7 @@ describe('Outputs', () => {
cy.contains('Name is required');
cy.contains('Host is required');
cy.contains('Username is required');
// cy.contains('Password is required'); // TODO
cy.contains('Password is required');
cy.contains('Default topic is required');
cy.contains('Topic is required');
cy.contains(
Expand All @@ -213,7 +303,7 @@ describe('Outputs', () => {
cy.contains('Must be a key, value pair i.e. "http.response.code: 200"');
shouldDisplayError(SETTINGS_OUTPUTS.NAME_INPUT);
shouldDisplayError(SETTINGS_OUTPUTS_KAFKA.AUTHENTICATION_USERNAME_INPUT);
// shouldDisplayError(SETTINGS_OUTPUTS_KAFKA.AUTHENTICATION_PASSWORD_INPUT); // TODO
shouldDisplayError(SETTINGS_OUTPUTS_KAFKA.AUTHENTICATION_PASSWORD_INPUT);
shouldDisplayError(SETTINGS_OUTPUTS_KAFKA.TOPICS_DEFAULT_TOPIC_INPUT);
shouldDisplayError(SETTINGS_OUTPUTS_KAFKA.TOPICS_CONDITION_INPUT);
shouldDisplayError(SETTINGS_OUTPUTS_KAFKA.TOPICS_TOPIC_INPUT);
Expand Down Expand Up @@ -271,7 +361,7 @@ describe('Outputs', () => {
it('saves the output', () => {
selectKafkaOutput();

fillInKafkaOutputForm(true);
fillInKafkaOutputForm();

cy.intercept('POST', '**/api/fleet/outputs').as('saveOutput');

Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/fleet/cypress/screens/fleet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export const SETTINGS_OUTPUTS = {
ADD_HOST_ROW_BTN: 'fleetServerHosts.multiRowInput.addRowButton',
WARNING_KAFKA_CALLOUT: 'settingsOutputsFlyout.kafkaOutputTypeCallout',
WARNING_ELASTICSEARCH_CALLOUT: 'settingsOutputsFlyout.elasticsearchOutputTypeCallout',
PRESET_INPUT: 'settingsOutputsFlyout.presetInput',
};

export const getSpecificSelectorId = (selector: string, id: number) => {
Expand Down
12 changes: 12 additions & 0 deletions x-pack/plugins/fleet/cypress/screens/fleet_outputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ import {
SETTINGS_SAVE_BTN,
} from './fleet';

export const selectESOutput = () => {
visit('/app/fleet/settings');
cy.getBySel(SETTINGS_OUTPUTS.ADD_BTN).click();
cy.getBySel(SETTINGS_OUTPUTS.TYPE_INPUT).select('elasticsearch');
};

export const selectRemoteESOutput = () => {
visit('/app/fleet/settings');
cy.getBySel(SETTINGS_OUTPUTS.ADD_BTN).click();
cy.getBySel(SETTINGS_OUTPUTS.TYPE_INPUT).select('remote_elasticsearch');
};

export const selectKafkaOutput = () => {
visit('/app/fleet/settings');
cy.getBySel(SETTINGS_OUTPUTS.ADD_BTN).click();
Expand Down
Loading