Skip to content

Commit 5c62e55

Browse files
szaffaranokibanamachineelasticmachine
authored
[Security Solution] Add telemetry query configuration for timelines (#233771)
## Summary - Add telemetry.queryConfig schema to server config - Implement TelemetryQueryConfiguration interface with pageSize, maxResponseSize, and maxCompressedResponseSize - Add query configuration management to TelemetryConfigurationDTO - Update timeline telemetry tasks to use configurable query parameters - Add comprehensive test coverage for configuration functionality - Set sensible defaults: pageSize=500, maxResponseSize=10MB, maxCompressedResponseSize=8MB ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) - [ ] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. --------- Co-authored-by: kibanamachine <[email protected]> Co-authored-by: Elastic Machine <[email protected]>
1 parent 94d4efd commit 5c62e55

File tree

15 files changed

+675
-404
lines changed

15 files changed

+675
-404
lines changed

x-pack/solutions/security/plugins/security_solution/server/config.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,15 @@ export const configSchema = schema.object({
206206
publicKey: schema.maybe(schema.string()),
207207
})
208208
),
209+
telemetry: schema.maybe(
210+
schema.object({
211+
queryConfig: schema.object({
212+
pageSize: schema.maybe(schema.number()),
213+
maxResponseSize: schema.maybe(schema.number()),
214+
maxCompressedResponseSize: schema.maybe(schema.number()),
215+
}),
216+
})
217+
),
209218
});
210219

211220
export type ConfigSchema = TypeOf<typeof configSchema>;

x-pack/solutions/security/plugins/security_solution/server/integration_tests/receiver.test.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ describe('ITelemetryReceiver', () => {
8282
const docs = mockedDocs(numOfDocs);
8383
await bulkInsert(esClient, TEST_INDEX, docs);
8484

85-
const results = telemetryReceiver.paginate(TEST_INDEX, testQuery());
85+
const results = telemetryReceiver.paginate(TEST_INDEX, testQuery(), undefined);
8686

8787
const pages = await getPages(results);
8888

@@ -103,7 +103,7 @@ describe('ITelemetryReceiver', () => {
103103
await bulkInsert(esClient, TEST_INDEX, batchTwo);
104104
await bulkInsert(esClient, TEST_INDEX, batchOne);
105105

106-
const results = telemetryReceiver.paginate(TEST_INDEX, testQuery(from, to));
106+
const results = telemetryReceiver.paginate(TEST_INDEX, testQuery(from, to), undefined);
107107

108108
const pages = await getPages(results);
109109

@@ -115,7 +115,11 @@ describe('ITelemetryReceiver', () => {
115115
it('should manage empty response', async () => {
116116
await bulkInsert(esClient, TEST_INDEX, mockedDocs(numOfDocs));
117117

118-
const results = telemetryReceiver.paginate(TEST_INDEX, testQuery('now-2d', 'now-1d'));
118+
const results = telemetryReceiver.paginate(
119+
TEST_INDEX,
120+
testQuery('now-2d', 'now-1d'),
121+
undefined
122+
);
119123

120124
const pages = await getPages(results);
121125
expect(pages.length).toEqual(0);

x-pack/solutions/security/plugins/security_solution/server/lib/telemetry/__mocks__/index.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import type { ConcreteTaskInstance } from '@kbn/task-manager-plugin/server';
1111
import type { TelemetryPluginSetup, TelemetryPluginStart } from '@kbn/telemetry-plugin/server';
1212
import { TaskStatus } from '@kbn/task-manager-plugin/server';
1313
import type { TelemetryEventsSender } from '../sender';
14-
import type { ITelemetryReceiver, TelemetryReceiver } from '../receiver';
14+
import type { ITelemetryReceiver } from '../receiver';
1515
import type { SecurityTelemetryTaskConfig } from '../task';
1616
import type { PackagePolicy } from '@kbn/fleet-plugin/common/types/models/package_policy';
1717
import type { ITaskMetricsService } from '../task_metrics.types';
@@ -113,6 +113,7 @@ export const createMockTelemetryReceiver = (
113113

114114
return {
115115
start: jest.fn(),
116+
paginate: jest.fn(),
116117
fetchClusterInfo: jest.fn().mockReturnValue(stubClusterInfo),
117118
getClusterInfo: jest.fn().mockReturnValue(stubClusterInfo),
118119
fetchLicenseInfo: jest.fn().mockReturnValue(stubLicenseInfo),
@@ -137,11 +138,13 @@ export const createMockTelemetryReceiver = (
137138
.fn()
138139
.mockReturnValue({ body: { aggregations: { actionTypes: {} } } }),
139140
fetchEndpointMetadata: jest.fn().mockReturnValue(Promise.resolve(new Map())),
140-
fetchTimelineAlerts: jest.fn().mockReturnValue(Promise.resolve(stubEndpointAlertResponse())),
141+
fetchTimelineAlerts: jest.fn().mockImplementation(async function* () {
142+
yield stubEndpointAlertResponse();
143+
}),
141144
buildProcessTree: jest.fn().mockReturnValue(processTreeResponse),
142145
fetchTimelineEvents: jest.fn().mockReturnValue(Promise.resolve(stubFetchTimelineEvents())),
143146
fetchValueListMetaData: jest.fn(),
144-
} as unknown as jest.Mocked<TelemetryReceiver>;
147+
} as unknown as jest.Mocked<ITelemetryReceiver>;
145148
};
146149

147150
export const createMockPackagePolicy = (): jest.Mocked<PackagePolicy> => {

0 commit comments

Comments
 (0)