Skip to content

Commit

Permalink
Merge branch 'main' into 191163-infra-remove-beta-badge-from-hosts
Browse files Browse the repository at this point in the history
  • Loading branch information
jennypavlova authored Aug 28, 2024
2 parents c58969c + dafce90 commit b20d560
Show file tree
Hide file tree
Showing 111 changed files with 1,340 additions and 1,477 deletions.
12 changes: 6 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ role_users.json
.devcontainer/.env

# Ignore temporary files in oas_docs
output/kibana.serverless.tmp1.yaml
output/kibana.serverless.tmp2.yaml
output/kibana.tmp1.yaml
output/kibana.tmp2.yaml
output/kibana.new.yaml
output/kibana.serverless.new.yaml
oas_docs/output/kibana.serverless.tmp1.yaml
oas_docs/output/kibana.serverless.tmp2.yaml
oas_docs/output/kibana.tmp1.yaml
oas_docs/output/kibana.tmp2.yaml
oas_docs/output/kibana.new.yaml
oas_docs/output/kibana.serverless.new.yaml
4 changes: 2 additions & 2 deletions oas_docs/kibana.info.serverless.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ info:
```
version: "1.0.2"
license:
name: Elastic License 2.0
url: https://www.elastic.co/licensing/elastic-license
name: Attribution-NonCommercial-NoDerivatives 4.0 International
url: https://creativecommons.org/licenses/by-nc-nd/4.0/
contact:
name: Kibana Team
x-feedbackLink:
Expand Down
4 changes: 2 additions & 2 deletions oas_docs/kibana.info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ info:
For more information about the console, refer to [Run API requests](https://www.elastic.co/guide/en/kibana/current/console-kibana.html).
version: '1.0.2'
license:
name: Elastic License 2.0
url: https://www.elastic.co/licensing/elastic-license
name: Attribution-NonCommercial-NoDerivatives 4.0 International
url: https://creativecommons.org/licenses/by-nc-nd/4.0/
contact:
name: Kibana Team
x-feedbackLink:
Expand Down
4 changes: 2 additions & 2 deletions oas_docs/output/kibana.serverless.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ info:

```
license:
name: Elastic License 2.0
url: 'https://www.elastic.co/licensing/elastic-license'
name: Attribution-NonCommercial-NoDerivatives 4.0 International
url: 'https://creativecommons.org/licenses/by-nc-nd/4.0/'
title: Kibana Serverless APIs
version: 1.0.2
x-feedbackLink:
Expand Down
4 changes: 2 additions & 2 deletions oas_docs/output/kibana.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ info:
For more information about the console, refer to [Run API
requests](https://www.elastic.co/guide/en/kibana/current/console-kibana.html).
license:
name: Elastic License 2.0
url: 'https://www.elastic.co/licensing/elastic-license'
name: Attribution-NonCommercial-NoDerivatives 4.0 International
url: 'https://creativecommons.org/licenses/by-nc-nd/4.0/'
title: Kibana APIs
version: 1.0.2
x-feedbackLink:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
*/

import * as t from 'io-ts';
import { investigationItemsSchema } from '../schema';
import { itemSchema } from '../schema';
import { investigationItemResponseSchema } from './investigation_item';

const createInvestigationItemParamsSchema = t.type({
path: t.type({
investigationId: t.string,
}),
body: investigationItemsSchema,
body: itemSchema,
});

const createInvestigationItemResponseSchema = investigationItemResponseSchema;
Expand Down
2 changes: 2 additions & 0 deletions packages/kbn-investigation-shared/src/rest_specs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export type * from './investigation_note';
export type * from './create_item';
export type * from './delete_item';
export type * from './get_items';
export type * from './investigation_item';

export * from './create';
export * from './create_note';
Expand All @@ -29,3 +30,4 @@ export * from './investigation_note';
export * from './create_item';
export * from './delete_item';
export * from './get_items';
export * from './investigation_item';
25 changes: 14 additions & 11 deletions packages/kbn-investigation-shared/src/schema/investigation_item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,23 @@

import * as t from 'io-ts';

const esqlItemSchema = t.type({
const itemSchema = t.type({
title: t.string,
type: t.literal('esql'),
params: t.type({
esql: t.string,
suggestion: t.any,
}),
type: t.string,
params: t.record(t.string, t.any),
});

const investigationItemsSchema = esqlItemSchema; // replace with union with various item types

const investigationItemSchema = t.intersection([
t.type({ id: t.string, createdAt: t.number, createdBy: t.string }),
investigationItemsSchema,
t.type({
id: t.string,
createdAt: t.number,
createdBy: t.string,
}),
itemSchema,
]);

export { investigationItemSchema, investigationItemsSchema, esqlItemSchema };
type Item = t.TypeOf<typeof itemSchema>;
type InvestigationItem = t.TypeOf<typeof investigationItemSchema>;

export type { Item, InvestigationItem };
export { investigationItemSchema, itemSchema };
57 changes: 43 additions & 14 deletions src/plugins/data/common/search/expressions/esql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,32 @@
import type { KibanaRequest } from '@kbn/core/server';
import { esFieldTypeToKibanaFieldType } from '@kbn/field-types';
import { i18n } from '@kbn/i18n';
import type { IKibanaSearchResponse, IKibanaSearchRequest } from '@kbn/search-types';
import type {
IKibanaSearchRequest,
IKibanaSearchResponse,
ISearchGeneric,
} from '@kbn/search-types';
import type { Datatable, ExpressionFunctionDefinition } from '@kbn/expressions-plugin/common';
import { RequestAdapter } from '@kbn/inspector-plugin/common';
import { getStartEndParams } from '@kbn/esql-utils';

import { zipObject } from 'lodash';
import { Observable, defer, throwError } from 'rxjs';
import { catchError, map, switchMap, tap } from 'rxjs';
import { buildEsQuery } from '@kbn/es-query';
import type { ISearchGeneric } from '@kbn/search-types';
import type { ESQLSearchResponse, ESQLSearchParams } from '@kbn/es-types';
import { catchError, defer, map, Observable, switchMap, tap, throwError } from 'rxjs';
import { buildEsQuery, type Filter } from '@kbn/es-query';
import type { ESQLSearchParams, ESQLSearchResponse } from '@kbn/es-types';
import { getEsQueryConfig } from '../../es_query';
import { getTime } from '../../query';
import { ESQL_ASYNC_SEARCH_STRATEGY, KibanaContext, ESQL_TABLE_TYPE } from '..';
import { ESQL_ASYNC_SEARCH_STRATEGY, ESQL_TABLE_TYPE, KibanaContext } from '..';
import { UiSettingsCommon } from '../..';

declare global {
interface Window {
/**
* Debug setting to make requests complete slower than normal. Only available on snapshots where `error_query` is enabled in ES.
*/
ELASTIC_ESQL_DELAY_SECONDS?: number;
}
}

type Input = KibanaContext | null;
type Output = Observable<Datatable>;

Expand Down Expand Up @@ -166,12 +176,31 @@ export const getEsqlFn = ({ getStartDependencies }: EsqlFnArguments) => {
fieldName: timeField,
});

params.filter = buildEsQuery(
undefined,
input.query || [],
[...(input.filters ?? []), ...(timeFilter ? [timeFilter] : [])],
esQueryConfigs
);
// Used for debugging & inside automated tests to simulate a slow query
const delayFilter: Filter | undefined = window.ELASTIC_ESQL_DELAY_SECONDS
? {
meta: {},
query: {
error_query: {
indices: [
{
name: '*',
error_type: 'warning',
stall_time_seconds: window.ELASTIC_ESQL_DELAY_SECONDS,
},
],
},
},
}
: undefined;

const filters = [
...(input.filters ?? []),
...(timeFilter ? [timeFilter] : []),
...(delayFilter ? [delayFilter] : []),
];

params.filter = buildEsQuery(undefined, input.query || [], filters, esQueryConfigs);
}

let startTime = Date.now();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ properties:
- enabled
policy_id:
type: string
nullable: true
deprecated: true
policy_ids:
type: array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@ properties:
type: string
description: The package policy namespace. Leave blank to inherit the agent policy's namespace.
example: 'customnamespace'
output_id:
type: string
description: Output ID to send package data to
example: 'output-id'
nullable: true
policy_id:
type: string
description: Agent policy ID where that package policy will be added
example: 'agent-policy-id'
deprecated: true
nullable: true
policy_ids:
type: array
items:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export type SimplifiedInputs = Record<

export interface SimplifiedPackagePolicy {
id?: string;
policy_id?: string;
policy_id?: string | null;
policy_ids: string[];
output_id?: string;
namespace: string;
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/fleet/common/types/models/package_policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ export interface NewPackagePolicy {
namespace?: string;
enabled: boolean;
is_managed?: boolean;
/** @deprecated */
policy_id?: string;
/** @deprecated Nullable to allow user to clear existing policy id */
policy_id?: string | null;
policy_ids: string[];
// Nullable to allow user to reset to default outputs
output_id?: string | null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export type PostDeletePackagePoliciesResponse = Array<{
name?: string;
success: boolean;
package?: PackagePolicyPackage;
policy_id?: string;
policy_id?: string | null;
policy_ids?: string[];
output_id?: string;
// Support generic errors
Expand Down
6 changes: 5 additions & 1 deletion x-pack/plugins/fleet/cypress/tasks/integrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ import { CONFIRM_MODAL } from '../screens/navigation';
import { request } from './common';

export const addIntegration = ({ useExistingPolicy } = { useExistingPolicy: false }) => {
cy.intercept('/api/fleet/agent_status?*').as('agentStatus');

cy.getBySel(ADD_INTEGRATION_POLICY_BTN).click();
if (useExistingPolicy) {
cy.getBySel(EXISTING_HOSTS_TAB).click();
cy.wait('@agentStatus');
} else {
// speeding up creating with unchecking system and agent integration
cy.getBySel(AGENT_POLICY_SYSTEM_MONITORING_CHECKBOX).uncheck({ force: true });
Expand All @@ -33,7 +36,8 @@ export const addIntegration = ({ useExistingPolicy } = { useExistingPolicy: fals
force: true,
});
}
cy.getBySel(CREATE_PACKAGE_POLICY_SAVE_BTN).click();
cy.getBySel(CREATE_PACKAGE_POLICY_SAVE_BTN).should('be.enabled').click();

// sometimes agent is assigned to default policy, sometimes not
cy.getBySel(CONFIRM_MODAL.CONFIRM_BUTTON).click();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,16 @@ describe('ConfirmDeployAgentPolicyModal', () => {
'Agent policies that will be updated to remove this integration policy:Agent policy 3'
);
});

it('should render no agent policies message when not adding/removing agent policies', () => {
testRenderer = createFleetTestRendererMock();
render({
agentCount: 0,
agentPolicies: [],
agentPoliciesToRemove: [],
});
const calloutText = renderResult.getByTestId('confirmNoPoliciesCallout').textContent;
expect(calloutText).toContain('No agent policies selected');
expect(calloutText).toContain('This integration will not be added to any agent policies.');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,46 @@ export const ConfirmDeployAgentPolicyModal: React.FunctionComponent<{
agentPoliciesToAdd = [],
agentPoliciesToRemove = [],
}) => {
return (
return agentPolicies.length === 0 && agentPoliciesToRemove.length === 0 ? (
<EuiConfirmModal
title={
<FormattedMessage
id="xpack.fleet.agentPolicy.noPolicies.confirmModalTitle"
defaultMessage="Save changes"
/>
}
onCancel={onCancel}
onConfirm={onConfirm}
cancelButtonText={
<FormattedMessage
id="xpack.fleet.agentPolicy.noPolicies.confirmModalCancelButtonLabel"
defaultMessage="Cancel"
/>
}
confirmButtonText={
<FormattedMessage
id="xpack.fleet.agentPolicy.noPolicies.confirmModalConfirmButtonLabel"
defaultMessage="Save changes"
/>
}
buttonColor="primary"
>
<EuiCallOut
iconType="iInCircle"
data-test-subj="confirmNoPoliciesCallout"
title={i18n.translate('xpack.fleet.agentPolicy.noPolicies.confirmModalCalloutTitle', {
defaultMessage: 'No agent policies selected',
})}
>
<div className="eui-textBreakWord">
<FormattedMessage
id="xpack.fleet.agentPolicy.noPolicies.confirmModalCalloutDescription"
defaultMessage="This integration will not be added to any agent policies."
/>
</div>
</EuiCallOut>
</EuiConfirmModal>
) : (
<EuiConfirmModal
title={
<FormattedMessage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ describe('step select agent policy', () => {
await act(async () => {
const select = renderResult.container.querySelector('[data-test-subj="agentPolicySelect"]');
expect((select as any)?.value).toEqual('');

expect(renderResult.getByText('At least one agent policy is required.')).toBeVisible();
});
});

Expand Down Expand Up @@ -179,8 +177,6 @@ describe('step select agent policy', () => {
'[data-test-subj="agentPolicyMultiSelect"]'
);
expect((select as any)?.value).toEqual(undefined);

expect(renderResult.getByText('At least one agent policy is required.')).toBeVisible();
});
});

Expand Down
Loading

0 comments on commit b20d560

Please sign in to comment.