Skip to content

Commit

Permalink
Merge branch 'main' into 47477-shorten-ml-job-ids
Browse files Browse the repository at this point in the history
  • Loading branch information
miltonhultgren authored Nov 15, 2023
2 parents 73e6c31 + 214f209 commit cb25844
Show file tree
Hide file tree
Showing 41 changed files with 451 additions and 129 deletions.
105 changes: 57 additions & 48 deletions packages/kbn-check-mappings-update-cli/current_mappings.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@
}
}
},
"metrics-data-source": {
"dynamic": false,
"properties": {}
},
"url": {
"dynamic": false,
"properties": {
Expand Down Expand Up @@ -1473,6 +1469,10 @@
}
}
},
"metrics-data-source": {
"dynamic": false,
"properties": {}
},
"canvas-element": {
"dynamic": false,
"properties": {
Expand Down Expand Up @@ -2168,6 +2168,9 @@
"interval": {
"type": "keyword"
},
"timeout": {
"type": "short"
},
"ecs_mapping": {
"dynamic": false,
"properties": {}
Expand Down Expand Up @@ -2216,6 +2219,9 @@
"interval": {
"type": "text"
},
"timeout": {
"type": "short"
},
"platform": {
"type": "keyword"
},
Expand Down Expand Up @@ -2258,6 +2264,9 @@
"interval": {
"type": "text"
},
"timeout": {
"type": "short"
},
"platform": {
"type": "keyword"
},
Expand Down Expand Up @@ -2679,50 +2688,6 @@
}
}
},
"apm-telemetry": {
"dynamic": false,
"properties": {}
},
"apm-server-schema": {
"properties": {
"schemaJson": {
"type": "text",
"index": false
}
}
},
"apm-service-group": {
"properties": {
"groupName": {
"type": "keyword"
},
"kuery": {
"type": "text"
},
"description": {
"type": "text"
},
"color": {
"type": "text"
}
}
},
"apm-custom-dashboards": {
"properties": {
"dashboardSavedObjectId": {
"type": "keyword"
},
"kuery": {
"type": "text"
},
"serviceEnvironmentFilterEnabled": {
"type": "boolean"
},
"serviceNameFilterEnabled": {
"type": "boolean"
}
}
},
"enterprise_search_telemetry": {
"dynamic": false,
"properties": {}
Expand Down Expand Up @@ -3196,5 +3161,49 @@
"index": false
}
}
},
"apm-telemetry": {
"dynamic": false,
"properties": {}
},
"apm-server-schema": {
"properties": {
"schemaJson": {
"type": "text",
"index": false
}
}
},
"apm-service-group": {
"properties": {
"groupName": {
"type": "keyword"
},
"kuery": {
"type": "text"
},
"description": {
"type": "text"
},
"color": {
"type": "text"
}
}
},
"apm-custom-dashboards": {
"properties": {
"dashboardSavedObjectId": {
"type": "keyword"
},
"kuery": {
"type": "text"
},
"serviceEnvironmentFilterEnabled": {
"type": "boolean"
},
"serviceNameFilterEnabled": {
"type": "boolean"
}
}
}
}
6 changes: 6 additions & 0 deletions packages/kbn-osquery-io-ts-types/src/live_query/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import * as t from 'io-ts';
import { inRangeRt } from '@kbn/io-ts-utils';

export const id = t.string;
export type Id = t.TypeOf<typeof id>;
Expand Down Expand Up @@ -49,6 +50,11 @@ export type Interval = t.TypeOf<typeof interval>;
export const intervalOrUndefined = t.union([interval, t.undefined]);
export type IntervalOrUndefined = t.TypeOf<typeof intervalOrUndefined>;

export const timeout = inRangeRt(60, 60 * 15);
export type Timeout = t.TypeOf<typeof timeout>;
export const timeoutOrUndefined = t.union([timeout, t.undefined]);
export type TimeoutOrUndefined = t.TypeOf<typeof timeoutOrUndefined>;

export const snapshot = t.boolean;
export type Snapshot = t.TypeOf<typeof snapshot>;
export const snapshotOrUndefined = t.union([snapshot, t.undefined]);
Expand Down
3 changes: 3 additions & 0 deletions packages/kbn-osquery-io-ts-types/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@
],
"exclude": [
"target/**/*",
],
"kbn_references": [
"@kbn/io-ts-utils",
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -1180,7 +1180,7 @@ Rounds down a date to the closest interval.
\`\`\`
FROM employees
| EVAL year_hired = DATE_TRUNC(hire_date, 1 year)
| EVAL year_hired = DATE_TRUNC(1 year, hire_date)
| STATS count(emp_no) BY year_hired
| SORT year_hired
\`\`\`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

.unifiedFieldList__fieldPopover__fieldPopoverPanel {
min-width: $euiSizeXXL * 6.5 !important; /* 1 */
max-width: $euiSizeXXL * 7.5 !important;
max-width: $euiSizeXXL * 10 !important;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
EuiFlexItem,
EuiProgress,
EuiText,
EuiTextBlockTruncate,
EuiToolTip,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
Expand Down Expand Up @@ -84,14 +85,18 @@ const FieldTopValuesBucket: React.FC<FieldTopValuesBucketProps> = ({
<EuiFlexGroup alignItems="stretch" gutterSize="s" responsive={false}>
<EuiFlexItem
grow={true}
className="eui-textTruncate"
data-test-subj={`${dataTestSubject}-topValues-formattedFieldValue`}
css={css`
overflow-wrap: break-word;
`}
>
{(formattedFieldValue?.length ?? 0) > 0 ? (
<EuiToolTip content={formattedFieldValue} delay="long">
<EuiText size="xs" className="eui-textTruncate" color={'subdued'} {...textProps}>
{formattedFieldValue}
</EuiText>
<EuiTextBlockTruncate lines={3}>
<EuiText size="xs" color={'subdued'} {...textProps}>
{formattedFieldValue}
</EuiText>
</EuiTextBlockTruncate>
</EuiToolTip>
) : (
<EuiText size="xs">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ import { filter, firstValueFrom, from, concatMap } from 'rxjs';
import { REPO_ROOT } from '@kbn/repo-info';
import { getConfigDirectory } from '@kbn/utils';

describe('cli serverless project type', () => {
// Failing: See https://github.com/elastic/kibana/issues/163257
// Failing: See https://github.com/elastic/kibana/issues/163258
// Failing: See https://github.com/elastic/kibana/issues/163259
describe.skip('cli serverless project type', () => {
let child: ChildProcessWithoutNullStreams | undefined;

afterEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ describe('checking migration metadata changes on all registered SO types', () =>
"monitoring-telemetry": "5d91bf75787d9d4dd2fae954d0b3f76d33d2e559",
"observability-onboarding-state": "b16064c516aac64ae699c737d7d10b6e199bfded",
"osquery-manager-usage-metric": "983bcbc3b7dda0aad29b20907db233abba709bcc",
"osquery-pack": "6ab4358ca4304a12dcfc1777c8135b75cffb4397",
"osquery-pack-asset": "b14101d3172c4b60eb5404696881ce5275c84152",
"osquery-saved-query": "44f1161e165defe3f9b6ad643c68c542a765fcdb",
"osquery-pack": "702e86b1a936153b39f65b0781bdc136e186e123",
"osquery-pack-asset": "cd140bc2e4b092e93692b587bf6e38051ef94c75",
"osquery-saved-query": "6095e288750aa3164dfe186c74bc5195c2bf2bd4",
"policy-settings-protection-updates-note": "33924bb246f9e5bcb876109cc83e3c7a28308352",
"query": "21cbbaa09abb679078145ce90087b1e88b7eae95",
"risk-engine-configuration": "b105d4a3c6adce40708d729d12e5ef3c8fbd9508",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
packIdOrUndefined,
queryOrUndefined,
arrayQueries,
timeoutOrUndefined,
} from '@kbn/osquery-io-ts-types';

export const createLiveQueryRequestBodySchema = t.partial({
Expand All @@ -23,6 +24,7 @@ export const createLiveQueryRequestBodySchema = t.partial({
query: queryOrUndefined,
queries: arrayQueries,
saved_query_id: savedQueryIdOrUndefined,
timeout: timeoutOrUndefined,
ecs_mapping: ecsMappingOrUndefined,
pack_id: packIdOrUndefined,
alert_ids: t.array(t.string),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
snapshotOrUndefined,
removedOrUndefined,
ecsMappingOrUndefined,
timeoutOrUndefined,
} from '@kbn/osquery-io-ts-types';

export const createSavedQueryRequestSchema = t.type({
Expand All @@ -27,6 +28,7 @@ export const createSavedQueryRequestSchema = t.type({
query,
version: versionOrUndefined,
interval,
timeout: timeoutOrUndefined,
snapshot: snapshotOrUndefined,
removed: removedOrUndefined,
ecs_mapping: ecsMappingOrUndefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@

import * as t from 'io-ts';
import { toNumberRt } from '@kbn/io-ts-utils';
import { timeoutOrUndefined } from '@kbn/osquery-io-ts-types';

export const updateSavedQueryRequestBodySchema = t.type({
id: t.string,
query: t.string,
description: t.union([t.string, t.undefined]),
interval: t.union([toNumberRt, t.undefined]),
timeout: timeoutOrUndefined,
snapshot: t.union([t.boolean, t.undefined]),
removed: t.union([t.boolean, t.undefined]),
platform: t.union([t.string, t.undefined]),
Expand Down
5 changes: 5 additions & 0 deletions x-pack/plugins/osquery/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,8 @@ export const API_VERSIONS = {
v1: '1',
},
};

export enum QUERY_TIMEOUT {
DEFAULT = 60, // 60 seconds
MAX = 60 * 15,
}
16 changes: 15 additions & 1 deletion x-pack/plugins/osquery/cypress/e2e/all/live_query.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import { navigateTo } from '../../tasks/navigation';
import {
checkResults,
fillInQueryTimeout,
inputQuery,
selectAllAgents,
submitQuery,
Expand Down Expand Up @@ -36,13 +37,26 @@ describe('ALL - Live Query', { tags: ['@ess', '@serverless'] }, () => {
cy.contains('Query is a required field').should('not.exist');
checkResults();
getAdvancedButton().click();
fillInQueryTimeout('91');
submitQuery();
cy.contains('Timeout value must be lower than 900 seconds.');
fillInQueryTimeout('89');
submitQuery();
cy.contains('Timeout value must be lower than 900 seconds.').should('not.exist');
typeInOsqueryFieldInput('days{downArrow}{enter}');
submitQuery();
cy.contains('ECS field is required.');
typeInECSFieldInput('message{downArrow}{enter}');

cy.intercept('POST', '/api/osquery/live_queries').as('postQuery');
submitQuery();
cy.contains('ECS field is required.').should('not.exist');

cy.wait('@postQuery').then((interception) => {
expect(interception.request.body).to.have.property('query', 'select * from uptime;');
expect(interception.request.body).to.have.property('timeout', 890);
expect(interception.response?.statusCode).to.eq(200);
expect(interception.response?.body.data.queries[0]).to.have.property('timeout', 890);
});
checkResults();
cy.get('[data-gridcell-column-index="0"][data-gridcell-row-index="0"]').should('exist').click();
cy.url().should('include', 'app/fleet/agents/');
Expand Down
3 changes: 3 additions & 0 deletions x-pack/plugins/osquery/cypress/e2e/all/live_query_packs.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,21 @@ describe('ALL - Live Query Packs', { tags: ['@ess', '@serverless'] }, () => {
system_memory_linux_elastic: {
ecs_mapping: {},
interval: 3600,
timeout: 700,
platform: 'linux',
query: 'SELECT * FROM memory_info;',
},
system_info_elastic: {
ecs_mapping: {},
interval: 3600,
timeout: 200,
platform: 'linux,windows,darwin',
query: 'SELECT * FROM system_info;',
},
failingQuery: {
ecs_mapping: {},
interval: 10,
timeout: 90,
query: 'select opera_extensions.* from users join opera_extensions using (uid);',
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,18 +197,21 @@ describe('Packs - Create and Edit', { tags: ['@ess', '@serverless'] }, () => {
const queries = {
Query1: {
interval: 3600,
timeout: 60,
query: 'select * from uptime;',
removed: true,
snapshot: false,
},
Query2: {
interval: 3600,
timeout: 60,
query: 'select * from uptime;',
removed: false,
snapshot: false,
},
Query3: {
interval: 3600,
timeout: 60,
query: 'select * from uptime;',
},
};
Expand Down
Loading

0 comments on commit cb25844

Please sign in to comment.