Skip to content

Commit

Permalink
Merge branch 'convert-typescript' of github.com:ashikmeerankutty/kiba…
Browse files Browse the repository at this point in the history
…na into convert-typescript
  • Loading branch information
ashikmeerankutty committed Jul 3, 2020
2 parents 3f6838a + d6d03cb commit 95559eb
Show file tree
Hide file tree
Showing 43 changed files with 1,235 additions and 223 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export interface TutorialSchema {
name: string;
isBeta?: boolean;
shortDescription: string;
euiIconType?: IconType; // EUI icon type string, one of https://elastic.github.io/eui/#/icon;
euiIconType?: IconType; // EUI icon type string, one of https://elastic.github.io/eui/#/display/icons;
longDescription: string;
completionTimeMinutes?: number;
previewImagePath?: string;
Expand Down
77 changes: 77 additions & 0 deletions src/plugins/home/server/tutorials/googlecloud_metrics/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { i18n } from '@kbn/i18n';
import { TutorialsCategory } from '../../services/tutorials';
import {
onPremInstructions,
cloudInstructions,
onPremCloudInstructions,
} from '../instructions/metricbeat_instructions';
import {
TutorialContext,
TutorialSchema,
} from '../../services/tutorials/lib/tutorials_registry_types';

export function googlecloudMetricsSpecProvider(context: TutorialContext): TutorialSchema {
const moduleName = 'googlecloud';
return {
id: 'googlecloudMetrics',
name: i18n.translate('home.tutorials.googlecloudMetrics.nameTitle', {
defaultMessage: 'Google Cloud metrics',
}),
category: TutorialsCategory.METRICS,
shortDescription: i18n.translate('home.tutorials.googlecloudMetrics.shortDescription', {
defaultMessage:
'Fetch monitoring metrics from Google Cloud Platform using Stackdriver Monitoring API.',
}),
longDescription: i18n.translate('home.tutorials.googlecloudMetrics.longDescription', {
defaultMessage:
'The `googlecloud` Metricbeat module fetches monitoring metrics from Google Cloud Platform using Stackdriver Monitoring API. \
[Learn more]({learnMoreLink}).',
values: {
learnMoreLink: '{config.docs.beats.metricbeat}/metricbeat-module-googlecloud.html',
},
}),
euiIconType: 'logoGCP',
isBeta: false,
artifacts: {
dashboards: [
{
id: 'f40ee870-5e4a-11ea-a4f6-717338406083',
linkLabel: i18n.translate(
'home.tutorials.googlecloudMetrics.artifacts.dashboards.linkLabel',
{
defaultMessage: 'Google Cloud metrics dashboard',
}
),
isOverview: true,
},
],
exportedFields: {
documentationUrl: '{config.docs.beats.metricbeat}/exported-fields-googlecloud.html',
},
},
completionTimeMinutes: 10,
previewImagePath: '/plugins/home/assets/googlecloud_metrics/screenshot.png',
onPrem: onPremInstructions(moduleName, context),
elasticCloud: cloudInstructions(moduleName),
onPremElasticCloud: onPremCloudInstructions(moduleName),
};
}
2 changes: 2 additions & 0 deletions src/plugins/home/server/tutorials/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ import { openmetricsMetricsSpecProvider } from './openmetrics_metrics';
import { oracleMetricsSpecProvider } from './oracle_metrics';
import { iisMetricsSpecProvider } from './iis_metrics';
import { azureLogsSpecProvider } from './azure_logs';
import { googlecloudMetricsSpecProvider } from './googlecloud_metrics';

export const builtInTutorials = [
systemLogsSpecProvider,
Expand Down Expand Up @@ -168,4 +169,5 @@ export const builtInTutorials = [
oracleMetricsSpecProvider,
iisMetricsSpecProvider,
azureLogsSpecProvider,
googlecloudMetricsSpecProvider,
];
2 changes: 1 addition & 1 deletion src/plugins/kibana_usage_collection/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This plugin registers the basic usage collectors from Kibana:

- Application Usage
- [Application Usage](./server/collectors/application_usage/README.md)
- UI Metrics
- Ops stats
- Number of Saved Objects per type
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Application Usage

This collector reports the number of general clicks and minutes on screen for each registered application in Kibana.

The final payload matches the following contract:

```JSON
{
"application_usage": {
"application_ID": {
"clicks_7_days": 10,
"clicks_30_days": 100,
"clicks_90_days": 300,
"clicks_total": 600,
"minutes_on_screen_7_days": 10.40,
"minutes_on_screen_30_days": 20.0,
"minutes_on_screen_90_days": 110.1,
"minutes_on_screen_total": 112.5
}
}
}
```

Where `application_ID` matches the `id` registered when calling the method `core.application.register`.
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.

**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.

## Developer notes

In order to keep the count of the events, this collector uses 2 Saved Objects:

1. `application_usage_transactional`: It stores each individually reported event (up to 90 days old). Grouped by `timestamp` and `appId`.
2. `application_usage_totals`: It stores the sum of all the events older than 90 days old per `appId`.

Both of them use the shared fields `appId: 'keyword'`, `numberOfClicks: 'long'` and `minutesOnScreen: 'float'`. `application_usage_transactional` also stores `timestamp: { type: 'date' }`.
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)).
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,10 @@ export function registerMappings(registerType: SavedObjectsServiceSetup['registe
hidden: false,
namespaceType: 'agnostic',
mappings: {
// Not indexing any of its contents because we use them "as-is" and don't search by these fields
// for more info, see the README.md for application_usage
dynamic: false,
properties: {
// Disabled the mapping of these fields since they are not searched and we need to reduce the amount of indexed fields (#43673)
// appId: { type: 'keyword' },
// numberOfClicks: { type: 'long' },
// minutesOnScreen: { type: 'float' },
},
properties: {},
},
});

Expand All @@ -53,10 +50,6 @@ export function registerMappings(registerType: SavedObjectsServiceSetup['registe
dynamic: false,
properties: {
timestamp: { type: 'date' },
// Disabled the mapping of these fields since they are not searched and we need to reduce the amount of indexed fields (#43673)
// appId: { type: 'keyword' },
// numberOfClicks: { type: 'long' },
// minutesOnScreen: { type: 'float' },
},
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { EuiBasicTableColumn } from '@elastic/eui';
import { Paginate, PaginateChildProps } from '../paginate';
import { TagList } from '../tag_list';
import { getTagsFilter } from '../../lib/get_tags_filter';
// @ts-ignore untyped local
// @ts-expect-error
import { extractSearch } from '../../lib/extract_search';
import { ComponentStrings } from '../../../i18n';
import { CanvasTemplate } from '../../../types';
Expand Down Expand Up @@ -61,7 +61,7 @@ export class WorkpadTemplates extends React.PureComponent<
WorkpadTemplatesState
> {
static propTypes = {
createFromTemplate: PropTypes.func.isRequired,
onCreateFromTemplate: PropTypes.func.isRequired,
onClose: PropTypes.func.isRequired,
templates: PropTypes.object,
};
Expand Down
19 changes: 10 additions & 9 deletions x-pack/plugins/canvas/server/templates/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,21 @@ import { light } from './theme_light';

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

export const templates = [pitch, status, summary, dark, light];
export const templates = [status, summary, dark, light, pitch];

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

if (existingTemplates.total === 0) {
const templateObjects = templates.map((template) => ({
id: template.id,
type: TEMPLATE_TYPE,
attributes: template,
}));

client.bulkCreate(templateObjects);
// Some devs were seeing timeouts that would cause an unhandled promise rejection
// likely because the pitch template is so huge.
// So, rather than doing a bulk create of templates, we're going to fire off individual
// creates and catch and throw-away any errors that happen.
// Once packages are ready, we should probably move that pitch that is so large to a package
for (const template of templates) {
client.create(TEMPLATE_TYPE, template, { id: template.id }).catch((err) => undefined);
}
}
}
7 changes: 7 additions & 0 deletions x-pack/plugins/infra/common/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

export const DEFAULT_SOURCE_ID = 'default';
Loading

0 comments on commit 95559eb

Please sign in to comment.