Skip to content

Commit 1e24dbf

Browse files
committed
Merge branch 'master' of https://github.com/elastic/kibana into actions/placeholders
2 parents dea3c34 + c78cf35 commit 1e24dbf

73 files changed

Lines changed: 1717 additions & 2070 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

x-pack/examples/alerting_example/public/alert_types/astros.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ export const PeopleinSpaceExpression: React.FunctionComponent<PeopleinSpaceParam
127127
});
128128

129129
const errorsCallout = flatten(
130-
Object.entries(errors).map(([field, errs]: [string, string[]]) =>
131-
errs.map((e) => (
132-
<p>
130+
Object.entries(errors).map(([field, errs]: [string, string[]], fieldIndex) =>
131+
errs.map((e, index) => (
132+
<p key={`astros-error-${fieldIndex}-${index}`}>
133133
<EuiTextColor color="accent">{field}:</EuiTextColor>`: ${errs}`
134134
</p>
135135
))

x-pack/examples/alerting_example/server/alert_types/always_firing.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,31 @@
55
*/
66

77
import uuid from 'uuid';
8-
import { range } from 'lodash';
8+
import { range, random } from 'lodash';
99
import { AlertType } from '../../../../plugins/alerts/server';
1010
import { DEFAULT_INSTANCES_TO_GENERATE, ALERTING_EXAMPLE_APP_ID } from '../../common/constants';
1111

12+
const ACTION_GROUPS = [
13+
{ id: 'small', name: 'small' },
14+
{ id: 'medium', name: 'medium' },
15+
{ id: 'large', name: 'large' },
16+
];
17+
1218
export const alertType: AlertType = {
1319
id: 'example.always-firing',
1420
name: 'Always firing',
15-
actionGroups: [{ id: 'default', name: 'default' }],
16-
defaultActionGroupId: 'default',
21+
actionGroups: ACTION_GROUPS,
22+
defaultActionGroupId: 'small',
1723
async executor({ services, params: { instances = DEFAULT_INSTANCES_TO_GENERATE }, state }) {
1824
const count = (state.count ?? 0) + 1;
1925

2026
range(instances)
21-
.map(() => ({ id: uuid.v4() }))
22-
.forEach((instance: { id: string }) => {
27+
.map(() => ({ id: uuid.v4(), tshirtSize: ACTION_GROUPS[random(0, 2)].id! }))
28+
.forEach((instance: { id: string; tshirtSize: string }) => {
2329
services
2430
.alertInstanceFactory(instance.id)
2531
.replaceState({ triggerdOnCycle: count })
26-
.scheduleActions('default');
32+
.scheduleActions(instance.tshirtSize);
2733
});
2834

2935
return {

x-pack/plugins/apm/server/lib/helpers/create_es_client/create_apm_event_client/index.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@
77
import { ValuesType } from 'utility-types';
88
import { APMBaseDoc } from '../../../../../typings/es_schemas/raw/apm_base_doc';
99
import { APMError } from '../../../../../typings/es_schemas/ui/apm_error';
10-
import { KibanaRequest } from '../../../../../../../../src/core/server';
10+
import {
11+
KibanaRequest,
12+
LegacyScopedClusterClient,
13+
} from '../../../../../../../../src/core/server';
1114
import { ProcessorEvent } from '../../../../../common/processor_event';
1215
import {
1316
ESSearchRequest,
1417
ESSearchResponse,
1518
} from '../../../../../typings/elasticsearch';
1619
import { ApmIndicesConfig } from '../../../settings/apm_indices/get_apm_indices';
17-
import { APMRequestHandlerContext } from '../../../../routes/typings';
1820
import { addFilterToExcludeLegacyData } from './add_filter_to_exclude_legacy_data';
1921
import { callClientWithDebug } from '../call_client_with_debug';
2022
import { Transaction } from '../../../../../typings/es_schemas/ui/transaction';
@@ -51,20 +53,23 @@ type TypedSearchResponse<
5153
export type APMEventClient = ReturnType<typeof createApmEventClient>;
5254

5355
export function createApmEventClient({
54-
context,
56+
esClient,
57+
debug,
5558
request,
5659
indices,
5760
options: { includeFrozen } = { includeFrozen: false },
5861
}: {
59-
context: APMRequestHandlerContext;
62+
esClient: Pick<
63+
LegacyScopedClusterClient,
64+
'callAsInternalUser' | 'callAsCurrentUser'
65+
>;
66+
debug: boolean;
6067
request: KibanaRequest;
6168
indices: ApmIndicesConfig;
6269
options: {
6370
includeFrozen: boolean;
6471
};
6572
}) {
66-
const client = context.core.elasticsearch.legacy.client;
67-
6873
return {
6974
search<TParams extends APMEventESSearchRequest>(
7075
params: TParams,
@@ -77,14 +82,14 @@ export function createApmEventClient({
7782
: withProcessorEventFilter;
7883

7984
return callClientWithDebug({
80-
apiCaller: client.callAsCurrentUser,
85+
apiCaller: esClient.callAsCurrentUser,
8186
operationName: 'search',
8287
params: {
8388
...withPossibleLegacyDataFilter,
8489
ignore_throttled: !includeFrozen,
8590
},
8691
request,
87-
debug: context.params.query._debug,
92+
debug,
8893
});
8994
},
9095
};

x-pack/plugins/apm/server/lib/helpers/setup_request.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ export async function setupRequest<TParams extends SetupRequestParams>(
8888
const coreSetupRequest = {
8989
indices,
9090
apmEventClient: createApmEventClient({
91-
context,
91+
esClient: context.core.elasticsearch.legacy.client,
92+
debug: context.params.query._debug,
9293
request,
9394
indices,
9495
options: { includeFrozen },

x-pack/plugins/apm/server/plugin.ts

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@ import { map, take } from 'rxjs/operators';
1010
import {
1111
CoreSetup,
1212
CoreStart,
13+
KibanaRequest,
1314
Logger,
1415
Plugin,
1516
PluginInitializerContext,
17+
RequestHandlerContext,
1618
} from 'src/core/server';
1719
import { APMConfig, APMXPackConfig, mergeConfigs } from '.';
1820
import { APMOSSPluginSetup } from '../../../../src/plugins/apm_oss/server';
1921
import { HomeServerPluginSetup } from '../../../../src/plugins/home/server';
2022
import { UsageCollectionSetup } from '../../../../src/plugins/usage_collection/server';
23+
import { UI_SETTINGS } from '../../../../src/plugins/data/common';
2124
import { ActionsPlugin } from '../../actions/server';
2225
import { AlertingPlugin } from '../../alerts/server';
2326
import { CloudSetup } from '../../cloud/server';
@@ -30,6 +33,7 @@ import { TaskManagerSetupContract } from '../../task_manager/server';
3033
import { APM_FEATURE, registerFeaturesUsage } from './feature';
3134
import { registerApmAlerts } from './lib/alerts/register_apm_alerts';
3235
import { createApmTelemetry } from './lib/apm_telemetry';
36+
import { createApmEventClient } from './lib/helpers/create_es_client/create_apm_event_client';
3337
import { getInternalSavedObjectsClient } from './lib/helpers/get_internal_saved_objects_client';
3438
import { createApmAgentConfigurationIndex } from './lib/settings/agent_configuration/create_agent_config_index';
3539
import { getApmIndices } from './lib/settings/apm_indices/get_apm_indices';
@@ -42,6 +46,11 @@ import { uiSettings } from './ui_settings';
4246
export interface APMPluginSetup {
4347
config$: Observable<APMConfig>;
4448
getApmIndices: () => ReturnType<typeof getApmIndices>;
49+
createApmEventClient: (params: {
50+
debug?: boolean;
51+
request: KibanaRequest;
52+
context: RequestHandlerContext;
53+
}) => Promise<ReturnType<typeof createApmEventClient>>;
4554
}
4655

4756
export class APMPlugin implements Plugin<APMPluginSetup> {
@@ -141,13 +150,41 @@ export class APMPlugin implements Plugin<APMPluginSetup> {
141150
},
142151
});
143152

153+
const boundGetApmIndices = async () =>
154+
getApmIndices({
155+
savedObjectsClient: await getInternalSavedObjectsClient(core),
156+
config: await mergedConfig$.pipe(take(1)).toPromise(),
157+
});
158+
144159
return {
145160
config$: mergedConfig$,
146-
getApmIndices: async () =>
147-
getApmIndices({
148-
savedObjectsClient: await getInternalSavedObjectsClient(core),
149-
config: await mergedConfig$.pipe(take(1)).toPromise(),
150-
}),
161+
getApmIndices: boundGetApmIndices,
162+
createApmEventClient: async ({
163+
request,
164+
context,
165+
debug,
166+
}: {
167+
debug?: boolean;
168+
request: KibanaRequest;
169+
context: RequestHandlerContext;
170+
}) => {
171+
const [indices, includeFrozen] = await Promise.all([
172+
boundGetApmIndices(),
173+
context.core.uiSettings.client.get(UI_SETTINGS.SEARCH_INCLUDE_FROZEN),
174+
]);
175+
176+
const esClient = context.core.elasticsearch.legacy.client;
177+
178+
return createApmEventClient({
179+
debug: debug ?? false,
180+
esClient,
181+
request,
182+
indices,
183+
options: {
184+
includeFrozen,
185+
},
186+
});
187+
},
151188
};
152189
}
153190

x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/edit_policy.helpers.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,11 @@ export const setup = async () => {
221221
setFreeze,
222222
setIndexPriority: setIndexPriority('cold'),
223223
},
224+
delete: {
225+
enable: enable('delete'),
226+
setMinAgeValue: setMinAgeValue('delete'),
227+
setMinAgeUnits: setMinAgeUnits('delete'),
228+
},
224229
},
225230
};
226231
};

x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/edit_policy.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,6 @@ describe('<EditPolicy />', () => {
367367
expect(testBed.find('snapshotPolicyCombobox').prop('data-currentvalue')).toEqual([
368368
{
369369
label: DELETE_PHASE_POLICY.policy.phases.delete?.actions.wait_for_snapshot?.policy,
370-
value: DELETE_PHASE_POLICY.policy.phases.delete?.actions.wait_for_snapshot?.policy,
371370
},
372371
]);
373372
});
@@ -412,7 +411,7 @@ describe('<EditPolicy />', () => {
412411
test('wait for snapshot field should delete action if field is empty', async () => {
413412
const { actions } = testBed;
414413

415-
actions.setWaitForSnapshotPolicy('');
414+
await actions.setWaitForSnapshotPolicy('');
416415
await actions.savePolicy();
417416

418417
const expected = {

0 commit comments

Comments
 (0)