Skip to content

Commit

Permalink
Merge branch 'master' into elastic#63480
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored May 26, 2020
2 parents bfb0113 + c8b1fc5 commit e28dea8
Show file tree
Hide file tree
Showing 61 changed files with 797 additions and 246 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
73 changes: 73 additions & 0 deletions src/plugins/home/server/tutorials/iis_metrics/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* 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 iisMetricsSpecProvider(context: TutorialContext): TutorialSchema {
const moduleName = 'iis';
return {
id: 'iisMetrics',
name: i18n.translate('home.tutorials.iisMetrics.nameTitle', {
defaultMessage: 'IIS Metrics',
}),
category: TutorialsCategory.METRICS,
shortDescription: i18n.translate('home.tutorials.iisMetrics.shortDescription', {
defaultMessage: 'Collect IIS server related metrics.',
}),
longDescription: i18n.translate('home.tutorials.iisMetrics.longDescription', {
defaultMessage:
'The `iis` Metricbeat module collects metrics from IIS server and the application pools and websites running. \
[Learn more]({learnMoreLink}).',
values: {
learnMoreLink: '{config.docs.beats.metricbeat}/metricbeat-module-iis.html',
},
}),
isBeta: true,
euiIconType: '/plugins/home/assets/logos/iis.svg',
artifacts: {
dashboards: [
{
id: 'ebc23240-8572-11ea-91bc-ab084c7ec0e7',
linkLabel: i18n.translate('home.tutorials.iisMetrics.artifacts.dashboards.linkLabel', {
defaultMessage: 'IIS metrics dashboard',
}),
isOverview: true,
},
],
exportedFields: {
documentationUrl: '{config.docs.beats.metricbeat}/exported-fields-iis.html',
},
},
completionTimeMinutes: 10,
previewImagePath: '/plugins/home/assets/iis_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 @@ -89,6 +89,7 @@ import { statsdMetricsSpecProvider } from './statsd_metrics';
import { redisenterpriseMetricsSpecProvider } from './redisenterprise_metrics';
import { openmetricsMetricsSpecProvider } from './openmetrics_metrics';
import { oracleMetricsSpecProvider } from './oracle_metrics';
import { iisMetricsSpecProvider } from './iis_metrics';
import { azureLogsSpecProvider } from './azure_logs';

export const builtInTutorials = [
Expand Down Expand Up @@ -165,5 +166,6 @@ export const builtInTutorials = [
redisenterpriseMetricsSpecProvider,
openmetricsMetricsSpecProvider,
oracleMetricsSpecProvider,
iisMetricsSpecProvider,
azureLogsSpecProvider,
];
3 changes: 2 additions & 1 deletion x-pack/plugins/apm/server/lib/apm_telemetry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ export async function createApmTelemetry({

const collectAndStore = async () => {
const config = await config$.pipe(take(1)).toPromise();
const esClient = core.elasticsearch.dataClient;
const [{ elasticsearch }] = await core.getStartServices();
const esClient = elasticsearch.legacy.client;

const indices = await getApmIndices({
config,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,23 @@ export const EmbeddableExpressionType = 'embeddable';
export { EmbeddableTypes, EmbeddableInput };

export interface EmbeddableExpression<Input extends EmbeddableInput> {
/**
* The type of the expression result
*/
type: typeof EmbeddableExpressionType;
/**
* The input to be passed to the embeddable
*/
input: Input;
/**
* The type of embeddable
*/
embeddableType: string;
/**
* Timestamp. Needed to get a different result after each time the expression is evaluated
* to force a reload of the embeddables internal data
*/
generatedAt: number;
}

export const embeddableType = (): ExpressionTypeDefinition<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export function savedLens(): ExpressionFunctionDefinition<
disableTriggers: true,
},
embeddableType: EmbeddableTypes.lens,
generatedAt: Date.now(),
};
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export function savedMap(): ExpressionFunctionDefinition<
hiddenLayers: args.hideLayer || [],
},
embeddableType: EmbeddableTypes.map,
generatedAt: Date.now(),
};
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export function savedSearch(): ExpressionFunctionDefinition<
...buildEmbeddableFilters(filters),
},
embeddableType: EmbeddableTypes.search,
generatedAt: Date.now(),
};
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export function savedVisualization(): ExpressionFunctionDefinition<
vis: visOptions,
},
embeddableType: EmbeddableTypes.visualization,
generatedAt: Date.now(),
};
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export const embeddableRendererFactory = (core: CoreStart, plugins: StartDeps) =
});
} else {
embeddablesRegistry[uniqueId].updateInput(input);
embeddablesRegistry[uniqueId].reload();
}
},
});
Expand Down
19 changes: 13 additions & 6 deletions x-pack/plugins/canvas/public/application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,27 @@ import { CanvasStartDeps, CanvasSetupDeps } from './plugin';
// @ts-ignore Untyped local
import { App } from './components/app';
import { KibanaContextProvider } from '../../../../src/plugins/kibana_react/public';
import { initInterpreter, resetInterpreter } from './lib/run_interpreter';
import { initInterpreter } from './lib/run_interpreter';
import { registerLanguage } from './lib/monaco_language_def';
import { SetupRegistries } from './plugin_api';
import { initRegistries, populateRegistries, destroyRegistries } from './registries';
import { getDocumentationLinks } from './lib/documentation_links';
// @ts-ignore untyped component
import { HelpMenu } from './components/help_menu/help_menu';
import { createStore, destroyStore } from './store';
import { createStore } from './store';

/* eslint-enable */
import { init as initStatsReporter } from './lib/ui_metric';

import { CapabilitiesStrings } from '../i18n';

import { startServices, stopServices, services } from './services';
import { startServices, services } from './services';
// @ts-ignore Untyped local
import { destroyHistory } from './lib/history_provider';
// @ts-ignore Untyped local
import { stopRouter } from './lib/router_provider';
// @ts-ignore Untyped local
import { appUnload } from './state/actions/app';

import './style/index.scss';

Expand Down Expand Up @@ -68,6 +70,7 @@ export const renderApp = (
);
return () => {
ReactDOM.unmountComponentAtNode(element);
canvasStore.dispatch(appUnload());
};
};

Expand Down Expand Up @@ -129,10 +132,14 @@ export const initializeCanvas = async (
};

export const teardownCanvas = (coreStart: CoreStart, startPlugins: CanvasStartDeps) => {
stopServices();
destroyRegistries();
resetInterpreter();
destroyStore();

// TODO: Not cleaning these up temporarily.
// We have an issue where if requests are inflight, and you navigate away,
// those requests could still be trying to act on the store and possibly require services.
// stopServices();
// resetInterpreter();
// destroyStore();

coreStart.chrome.setBadge(undefined);
coreStart.chrome.setHelpExtension(undefined);
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/canvas/public/state/actions/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ import { createAction } from 'redux-actions';
// actions to set the application state
export const appReady = createAction('appReady');
export const appError = createAction('appError');
export const appUnload = createAction('appUnload');
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { getFullscreen } from '../selectors/app';
import { getInFlight } from '../selectors/resolved_args';
import { getWorkpad, getPages, getSelectedPageIndex, getAutoplay } from '../selectors/workpad';
// @ts-ignore untyped local
import { appUnload } from '../actions/app';
// @ts-ignore Untyped Local
import { routerProvider } from '../../lib/router_provider';
import { setAutoplayInterval } from '../../lib/app_state';
import { createTimeInterval } from '../../lib/time_interval';
Expand Down Expand Up @@ -83,5 +85,9 @@ export const workpadAutoplay: Middleware<{}, State> = ({ getState }) => (next) =
} else {
stopAutoUpdate();
}

if (action.type === appUnload.toString()) {
stopAutoUpdate();
}
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { State } from '../../../types';
import { fetchAllRenderables } from '../actions/elements';
// @ts-ignore Untyped Local
import { setRefreshInterval } from '../actions/workpad';
// @ts-ignore Untyped Local
import { appUnload } from '../actions/app';
import { inFlightComplete } from '../actions/resolved_args';
import { getInFlight } from '../selectors/resolved_args';
import { getRefreshInterval } from '../selectors/workpad';
Expand Down Expand Up @@ -81,5 +83,9 @@ export const workpadRefresh: Middleware<{}, State> = ({ dispatch, getState }) =>
startDelayedUpdate();
}
}

if (action.type === appUnload.toString()) {
cancelDelayedUpdate();
}
};
};
10 changes: 10 additions & 0 deletions x-pack/plugins/canvas/public/state/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ import { getRootReducer } from './reducers';

let store;

export function getStore() {
return store;
}

export function cloneStore() {
const state = store.getState();
store = undefined;
return createStore(state);
}

export function createStore(initialState) {
if (typeof store !== 'undefined') {
throw new Error('Redux store can only be initialized once');
Expand Down
17 changes: 15 additions & 2 deletions x-pack/plugins/canvas/public/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,28 @@
* you may not use this file except in compliance with the Elastic License.
*/

// @ts-ignore Untyped local
import { createStore as createReduxStore, destroyStore as destroy } from './state/store';
import {
createStore as createReduxStore,
destroyStore as destroy,
getStore,
cloneStore,
// @ts-ignore Untyped local
} from './state/store';
// @ts-ignore Untyped local
import { getInitialState } from './state/initial_state';

import { CoreSetup } from '../../../../src/core/public';
import { CanvasSetupDeps } from './plugin';

export async function createStore(core: CoreSetup, plugins: CanvasSetupDeps) {
if (getStore()) {
return cloneStore();
}

return createFreshStore(core, plugins);
}

export async function createFreshStore(core: CoreSetup, plugins: CanvasSetupDeps) {
const initialState = getInitialState();

const basePath = core.http.basePath.get();
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/event_log/server/es/documents.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('getIndexTemplate()', () => {
const indexTemplate = getIndexTemplate(esNames);
expect(indexTemplate.index_patterns).toEqual([esNames.indexPatternWithVersion]);
expect(indexTemplate.settings.number_of_shards).toBeGreaterThanOrEqual(0);
expect(indexTemplate.settings.number_of_replicas).toBeGreaterThanOrEqual(0);
expect(indexTemplate.settings.auto_expand_replicas).toBe('0-1');
expect(indexTemplate.settings['index.lifecycle.name']).toBe(esNames.ilmPolicy);
expect(indexTemplate.settings['index.lifecycle.rollover_alias']).toBe(esNames.alias);
expect(indexTemplate.mappings).toMatchObject({});
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/event_log/server/es/documents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function getIndexTemplate(esNames: EsNames) {
index_patterns: [esNames.indexPatternWithVersion],
settings: {
number_of_shards: 1,
number_of_replicas: 1,
auto_expand_replicas: '0-1',
'index.lifecycle.name': esNames.ilmPolicy,
'index.lifecycle.rollover_alias': esNames.alias,
},
Expand Down

This file was deleted.

7 changes: 0 additions & 7 deletions x-pack/plugins/file_upload/server/kibana_server_services.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/

let dataClient;

export const setElasticsearchClientServices = (elasticsearch) => {
({ dataClient } = elasticsearch);
};
export const getDataClient = () => dataClient;

let internalRepository;
export const setInternalRepository = (createInternalRepository) => {
internalRepository = createInternalRepository();
Expand Down
3 changes: 1 addition & 2 deletions x-pack/plugins/file_upload/server/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { initRoutes } from './routes/file_upload';
import { setElasticsearchClientServices, setInternalRepository } from './kibana_server_services';
import { setInternalRepository } from './kibana_server_services';
import { registerFileUploadUsageCollector, fileUploadTelemetryMappingsType } from './telemetry';

export class FileUploadPlugin {
Expand All @@ -15,7 +15,6 @@ export class FileUploadPlugin {

setup(core, plugins) {
core.savedObjects.registerType(fileUploadTelemetryMappingsType);
setElasticsearchClientServices(core.elasticsearch);
this.router = core.http.createRouter();
registerFileUploadUsageCollector(plugins.usageCollection);
}
Expand Down
3 changes: 1 addition & 2 deletions x-pack/plugins/file_upload/server/routes/file_upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { callWithRequestFactory } from '../client/call_with_request_factory';
import { importDataProvider } from '../models/import_data';
import { updateTelemetry } from '../telemetry/telemetry';
import { MAX_BYTES } from '../../common/constants/file_import';
Expand Down Expand Up @@ -86,7 +85,7 @@ const finishValidationAndProcessReq = () => {
let resp;
try {
const validIdReqData = idConditionalValidation(body, boolHasId);
const callWithRequest = callWithRequestFactory(req);
const callWithRequest = con.core.elasticsearch.dataClient.callAsCurrentUser;
const { importData: importDataFunc } = importDataProvider(callWithRequest);

const { index, settings, mappings, ingestPipeline, data } = validIdReqData;
Expand Down
Loading

0 comments on commit e28dea8

Please sign in to comment.