Skip to content

Commit c426139

Browse files
committed
Merge branch 'master' into alerting/consumer-based-rbac
* master: [Lens] Fitting functions (elastic#69820) [Telemetry] Add documentation about Application Usage (elastic#70624) [Ingest Manager] Improve agent unenrollment with unenroll action (elastic#70031) Handle timeouts on creating templates (elastic#70635) [Lens] Add ability to set colors for y-axis series (elastic#70311) [Uptime] Use elastic charts donut (elastic#70364) [Ingest Manager] Update registry URL to point to snapshot registry (elastic#70687) [Composable template] Create / Edit wizard (elastic#70220) [APM] Optimize services overview (elastic#69648)
2 parents f0f82f3 + bbda3f9 commit c426139

File tree

119 files changed

+3963
-733
lines changed

Some content is hidden

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

119 files changed

+3963
-733
lines changed

src/plugins/es_ui_shared/public/forms/form_wizard/form_wizard_context.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { WithMultiContent, useMultiContentContext, HookProps } from '../multi_co
2323

2424
export interface Props<T extends object> {
2525
onSave: (data: T) => void | Promise<void>;
26-
children: JSX.Element | JSX.Element[];
26+
children: JSX.Element | Array<JSX.Element | null | false>;
2727
isEditing?: boolean;
2828
defaultActiveStep?: number;
2929
defaultValue?: HookProps<T>['defaultValue'];

src/plugins/es_ui_shared/public/forms/multi_content/multi_content_context.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export function useMultiContentContext<T extends object = { [key: string]: any }
5454
*
5555
* @param contentId The content id to be added to the "contents" map
5656
*/
57-
export function useContent<T extends object = { [key: string]: any }>(contentId: keyof T) {
57+
export function useContent<T extends object, K extends keyof T>(contentId: K) {
5858
const { updateContentAt, saveSnapshotAndRemoveContent, getData } = useMultiContentContext<T>();
5959

6060
const updateContent = useCallback(
@@ -71,8 +71,11 @@ export function useContent<T extends object = { [key: string]: any }>(contentId:
7171
};
7272
}, [contentId, saveSnapshotAndRemoveContent]);
7373

74+
const data = getData();
75+
const defaultValue = data[contentId];
76+
7477
return {
75-
defaultValue: getData()[contentId]!,
78+
defaultValue,
7679
updateContent,
7780
getData,
7881
};

src/plugins/es_ui_shared/public/forms/multi_content/use_multi_content.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ export function useMultiContent<T extends object>({
150150
* Validate the multi-content active content(s) in the DOM
151151
*/
152152
const validate = useCallback(async () => {
153+
if (Object.keys(contents.current).length === 0) {
154+
return Boolean(validation.isValid);
155+
}
156+
153157
const updatedValidation = {} as { [key in keyof T]?: boolean | undefined };
154158

155159
for (const [id, _content] of Object.entries(contents.current)) {

src/plugins/es_ui_shared/public/index.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
* In the future, each top level folder should be exported like that to avoid naming collision
2323
*/
2424
import * as Forms from './forms';
25+
import * as Monaco from './monaco';
2526

2627
export { JsonEditor, OnJsonEditorUpdateHandler } from './components/json_editor';
2728

@@ -53,10 +54,6 @@ export {
5354
expandLiteralStrings,
5455
} from './console_lang';
5556

56-
import * as Monaco from './monaco';
57-
58-
export { Monaco };
59-
6057
export {
6158
AuthorizationContext,
6259
AuthorizationProvider,
@@ -69,7 +66,7 @@ export {
6966
useAuthorizationContext,
7067
} from './authorization';
7168

72-
export { Forms };
69+
export { Monaco, Forms };
7370

7471
/** dummy plugin, we just want esUiShared to have its own bundle */
7572
export function plugin() {

src/plugins/es_ui_shared/static/forms/helpers/field_validators/is_json.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ import { ValidationFunc } from '../../hook_form_lib';
2121
import { isJSON } from '../../../validators/string';
2222
import { ERROR_CODE } from './types';
2323

24-
export const isJsonField = (message: string) => (
25-
...args: Parameters<ValidationFunc>
26-
): ReturnType<ValidationFunc<any, ERROR_CODE>> => {
24+
export const isJsonField = (
25+
message: string,
26+
{ allowEmptyString = false }: { allowEmptyString?: boolean } = {}
27+
) => (...args: Parameters<ValidationFunc>): ReturnType<ValidationFunc<any, ERROR_CODE>> => {
2728
const [{ value }] = args;
2829

29-
if (typeof value !== 'string') {
30+
if (typeof value !== 'string' || (allowEmptyString && value.trim() === '')) {
3031
return;
3132
}
3233

src/plugins/kibana_usage_collection/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This plugin registers the basic usage collectors from Kibana:
44

5-
- Application Usage
5+
- [Application Usage](./server/collectors/application_usage/README.md)
66
- UI Metrics
77
- Ops stats
88
- Number of Saved Objects per type
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Application Usage
2+
3+
This collector reports the number of general clicks and minutes on screen for each registered application in Kibana.
4+
5+
The final payload matches the following contract:
6+
7+
```JSON
8+
{
9+
"application_usage": {
10+
"application_ID": {
11+
"clicks_7_days": 10,
12+
"clicks_30_days": 100,
13+
"clicks_90_days": 300,
14+
"clicks_total": 600,
15+
"minutes_on_screen_7_days": 10.40,
16+
"minutes_on_screen_30_days": 20.0,
17+
"minutes_on_screen_90_days": 110.1,
18+
"minutes_on_screen_total": 112.5
19+
}
20+
}
21+
}
22+
```
23+
24+
Where `application_ID` matches the `id` registered when calling the method `core.application.register`.
25+
This collection occurs by default for every application registered via the mentioned method and there is no need to do anything else to enable it or _opt-in_ for your plugin.
26+
27+
**Note to maintainers in the Kibana repo:** At the moment of writing, the `usageCollector.schema` is not updated automatically ([#70622](https://github.com/elastic/kibana/issues/70622)) so, if you are adding a new app to Kibana, you'll need to give the Kibana Telemetry team a heads up to update the mappings in the Telemetry Cluster accordingly.
28+
29+
## Developer notes
30+
31+
In order to keep the count of the events, this collector uses 2 Saved Objects:
32+
33+
1. `application_usage_transactional`: It stores each individually reported event (up to 90 days old). Grouped by `timestamp` and `appId`.
34+
2. `application_usage_totals`: It stores the sum of all the events older than 90 days old per `appId`.
35+
36+
Both of them use the shared fields `appId: 'keyword'`, `numberOfClicks: 'long'` and `minutesOnScreen: 'float'`. `application_usage_transactional` also stores `timestamp: { type: 'date' }`.
37+
but they are currently not added in the mappings because we don't use them for search purposes, and we need to be thoughtful with the number of mapped fields in the SavedObjects index ([#43673](https://github.com/elastic/kibana/issues/43673)).

src/plugins/kibana_usage_collection/server/collectors/application_usage/saved_objects_types.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,10 @@ export function registerMappings(registerType: SavedObjectsServiceSetup['registe
3535
hidden: false,
3636
namespaceType: 'agnostic',
3737
mappings: {
38+
// Not indexing any of its contents because we use them "as-is" and don't search by these fields
39+
// for more info, see the README.md for application_usage
3840
dynamic: false,
39-
properties: {
40-
// Disabled the mapping of these fields since they are not searched and we need to reduce the amount of indexed fields (#43673)
41-
// appId: { type: 'keyword' },
42-
// numberOfClicks: { type: 'long' },
43-
// minutesOnScreen: { type: 'float' },
44-
},
41+
properties: {},
4542
},
4643
});
4744

@@ -53,10 +50,6 @@ export function registerMappings(registerType: SavedObjectsServiceSetup['registe
5350
dynamic: false,
5451
properties: {
5552
timestamp: { type: 'date' },
56-
// Disabled the mapping of these fields since they are not searched and we need to reduce the amount of indexed fields (#43673)
57-
// appId: { type: 'keyword' },
58-
// numberOfClicks: { type: 'long' },
59-
// minutesOnScreen: { type: 'float' },
6053
},
6154
},
6255
});

x-pack/plugins/apm/common/projections/services.ts

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,37 @@ import { rangeFilter } from '../utils/range_filter';
1616

1717
export function getServicesProjection({
1818
setup,
19+
noEvents,
1920
}: {
2021
setup: Setup & SetupTimeRange & SetupUIFilters;
22+
noEvents?: boolean;
2123
}) {
2224
const { start, end, uiFiltersES, indices } = setup;
2325

2426
return {
25-
index: [
26-
indices['apm_oss.metricsIndices'],
27-
indices['apm_oss.errorIndices'],
28-
indices['apm_oss.transactionIndices'],
29-
],
27+
...(noEvents
28+
? {}
29+
: {
30+
index: [
31+
indices['apm_oss.metricsIndices'],
32+
indices['apm_oss.errorIndices'],
33+
indices['apm_oss.transactionIndices'],
34+
],
35+
}),
3036
body: {
3137
size: 0,
3238
query: {
3339
bool: {
3440
filter: [
35-
{
36-
terms: { [PROCESSOR_EVENT]: ['transaction', 'error', 'metric'] },
37-
},
41+
...(noEvents
42+
? []
43+
: [
44+
{
45+
terms: {
46+
[PROCESSOR_EVENT]: ['transaction', 'error', 'metric'],
47+
},
48+
},
49+
]),
3850
{ range: rangeFilter(start, end) },
3951
...uiFiltersES,
4052
],
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
import { ValuesType } from 'utility-types';
7+
8+
// work around a TypeScript limitation described in https://stackoverflow.com/posts/49511416
9+
10+
export const arrayUnionToCallable = <T extends any[]>(
11+
array: T
12+
): Array<ValuesType<T>> => {
13+
return array;
14+
};

0 commit comments

Comments
 (0)