Skip to content

Commit 95559eb

Browse files
Merge branch 'convert-typescript' of github.com:ashikmeerankutty/kibana into convert-typescript
2 parents 3f6838a + d6d03cb commit 95559eb

File tree

43 files changed

+1235
-223
lines changed

Some content is hidden

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

43 files changed

+1235
-223
lines changed
2.71 MB
Loading

src/plugins/home/server/services/tutorials/lib/tutorials_registry_types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export interface TutorialSchema {
8282
name: string;
8383
isBeta?: boolean;
8484
shortDescription: string;
85-
euiIconType?: IconType; // EUI icon type string, one of https://elastic.github.io/eui/#/icon;
85+
euiIconType?: IconType; // EUI icon type string, one of https://elastic.github.io/eui/#/display/icons;
8686
longDescription: string;
8787
completionTimeMinutes?: number;
8888
previewImagePath?: string;
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import { i18n } from '@kbn/i18n';
21+
import { TutorialsCategory } from '../../services/tutorials';
22+
import {
23+
onPremInstructions,
24+
cloudInstructions,
25+
onPremCloudInstructions,
26+
} from '../instructions/metricbeat_instructions';
27+
import {
28+
TutorialContext,
29+
TutorialSchema,
30+
} from '../../services/tutorials/lib/tutorials_registry_types';
31+
32+
export function googlecloudMetricsSpecProvider(context: TutorialContext): TutorialSchema {
33+
const moduleName = 'googlecloud';
34+
return {
35+
id: 'googlecloudMetrics',
36+
name: i18n.translate('home.tutorials.googlecloudMetrics.nameTitle', {
37+
defaultMessage: 'Google Cloud metrics',
38+
}),
39+
category: TutorialsCategory.METRICS,
40+
shortDescription: i18n.translate('home.tutorials.googlecloudMetrics.shortDescription', {
41+
defaultMessage:
42+
'Fetch monitoring metrics from Google Cloud Platform using Stackdriver Monitoring API.',
43+
}),
44+
longDescription: i18n.translate('home.tutorials.googlecloudMetrics.longDescription', {
45+
defaultMessage:
46+
'The `googlecloud` Metricbeat module fetches monitoring metrics from Google Cloud Platform using Stackdriver Monitoring API. \
47+
[Learn more]({learnMoreLink}).',
48+
values: {
49+
learnMoreLink: '{config.docs.beats.metricbeat}/metricbeat-module-googlecloud.html',
50+
},
51+
}),
52+
euiIconType: 'logoGCP',
53+
isBeta: false,
54+
artifacts: {
55+
dashboards: [
56+
{
57+
id: 'f40ee870-5e4a-11ea-a4f6-717338406083',
58+
linkLabel: i18n.translate(
59+
'home.tutorials.googlecloudMetrics.artifacts.dashboards.linkLabel',
60+
{
61+
defaultMessage: 'Google Cloud metrics dashboard',
62+
}
63+
),
64+
isOverview: true,
65+
},
66+
],
67+
exportedFields: {
68+
documentationUrl: '{config.docs.beats.metricbeat}/exported-fields-googlecloud.html',
69+
},
70+
},
71+
completionTimeMinutes: 10,
72+
previewImagePath: '/plugins/home/assets/googlecloud_metrics/screenshot.png',
73+
onPrem: onPremInstructions(moduleName, context),
74+
elasticCloud: cloudInstructions(moduleName),
75+
onPremElasticCloud: onPremCloudInstructions(moduleName),
76+
};
77+
}

src/plugins/home/server/tutorials/register.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ import { openmetricsMetricsSpecProvider } from './openmetrics_metrics';
9191
import { oracleMetricsSpecProvider } from './oracle_metrics';
9292
import { iisMetricsSpecProvider } from './iis_metrics';
9393
import { azureLogsSpecProvider } from './azure_logs';
94+
import { googlecloudMetricsSpecProvider } from './googlecloud_metrics';
9495

9596
export const builtInTutorials = [
9697
systemLogsSpecProvider,
@@ -168,4 +169,5 @@ export const builtInTutorials = [
168169
oracleMetricsSpecProvider,
169170
iisMetricsSpecProvider,
170171
azureLogsSpecProvider,
172+
googlecloudMetricsSpecProvider,
171173
];

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/canvas/public/components/workpad_templates/workpad_templates.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { EuiBasicTableColumn } from '@elastic/eui';
2424
import { Paginate, PaginateChildProps } from '../paginate';
2525
import { TagList } from '../tag_list';
2626
import { getTagsFilter } from '../../lib/get_tags_filter';
27-
// @ts-ignore untyped local
27+
// @ts-expect-error
2828
import { extractSearch } from '../../lib/extract_search';
2929
import { ComponentStrings } from '../../../i18n';
3030
import { CanvasTemplate } from '../../../types';
@@ -61,7 +61,7 @@ export class WorkpadTemplates extends React.PureComponent<
6161
WorkpadTemplatesState
6262
> {
6363
static propTypes = {
64-
createFromTemplate: PropTypes.func.isRequired,
64+
onCreateFromTemplate: PropTypes.func.isRequired,
6565
onClose: PropTypes.func.isRequired,
6666
templates: PropTypes.object,
6767
};

x-pack/plugins/canvas/server/templates/index.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,21 @@ import { light } from './theme_light';
1313

1414
import { TEMPLATE_TYPE } from '../../common/lib/constants';
1515

16-
export const templates = [pitch, status, summary, dark, light];
16+
export const templates = [status, summary, dark, light, pitch];
1717

1818
export async function initializeTemplates(
19-
client: Pick<SavedObjectsRepository, 'bulkCreate' | 'find'>
19+
client: Pick<SavedObjectsRepository, 'bulkCreate' | 'create' | 'find'>
2020
) {
2121
const existingTemplates = await client.find({ type: TEMPLATE_TYPE, perPage: 1 });
2222

2323
if (existingTemplates.total === 0) {
24-
const templateObjects = templates.map((template) => ({
25-
id: template.id,
26-
type: TEMPLATE_TYPE,
27-
attributes: template,
28-
}));
29-
30-
client.bulkCreate(templateObjects);
24+
// Some devs were seeing timeouts that would cause an unhandled promise rejection
25+
// likely because the pitch template is so huge.
26+
// So, rather than doing a bulk create of templates, we're going to fire off individual
27+
// creates and catch and throw-away any errors that happen.
28+
// Once packages are ready, we should probably move that pitch that is so large to a package
29+
for (const template of templates) {
30+
client.create(TEMPLATE_TYPE, template, { id: template.id }).catch((err) => undefined);
31+
}
3132
}
3233
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
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+
7+
export const DEFAULT_SOURCE_ID = 'default';

0 commit comments

Comments
 (0)