Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into new-nav
Browse files Browse the repository at this point in the history
  • Loading branch information
Michail Yasonik committed May 5, 2020
2 parents 5dbc9c8 + e5d7bb6 commit 153cf49
Show file tree
Hide file tree
Showing 441 changed files with 12,143 additions and 1,342 deletions.
2 changes: 1 addition & 1 deletion .ci/es-snapshots/Jenkinsfile_verify_es
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ currentBuild.description = "ES: ${SNAPSHOT_VERSION}<br />Kibana: ${params.branch

def SNAPSHOT_MANIFEST = "https://storage.googleapis.com/kibana-ci-es-snapshots-daily/${SNAPSHOT_VERSION}/archives/${SNAPSHOT_ID}/manifest.json"

kibanaPipeline(timeoutMinutes: 120) {
kibanaPipeline(timeoutMinutes: 150) {
catchErrors {
slackNotifications.onFailure(
title: ":broken_heart: *<${env.BUILD_URL}|[${SNAPSHOT_VERSION}] ES Snapshot Verification Failure>*",
Expand Down
3 changes: 1 addition & 2 deletions .github/paths-labeller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
- "Feature:ExpressionLanguage":
- "src/plugins/expressions/**/*.*"
- "src/plugins/bfetch/**/*.*"
- "Team:apm"
- "Team:apm":
- "x-pack/plugins/apm/**/*.*"
- "x-pack/plugins/apm/**/*.*"
- "Team:uptime":
- "x-pack/plugins/uptime/**/*.*"
- "x-pack/legacy/plugins/uptime/**/*.*"
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
"inert": "^5.1.0",
"inline-style": "^2.0.0",
"joi": "^13.5.2",
"jquery": "^3.4.1",
"jquery": "^3.5.0",
"js-yaml": "3.13.1",
"json-stable-stringify": "^1.0.1",
"json-stringify-pretty-compact": "1.2.0",
Expand Down Expand Up @@ -297,6 +297,7 @@
"@elastic/eslint-plugin-eui": "0.0.2",
"@elastic/github-checks-reporter": "0.0.20b3",
"@elastic/makelogs": "^5.0.1",
"@elastic/static-fs": "1.0.1",
"@kbn/dev-utils": "1.0.0",
"@kbn/es": "1.0.0",
"@kbn/eslint-import-resolver-kibana": "2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-ui-framework/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"html": "1.0.0",
"html-loader": "^0.5.5",
"imports-loader": "^0.8.0",
"jquery": "^3.4.1",
"jquery": "^3.5.0",
"keymirror": "0.1.1",
"moment": "^2.24.0",
"node-sass": "^4.13.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-ui-shared-deps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"core-js": "^3.6.4",
"custom-event-polyfill": "^0.3.0",
"elasticsearch-browser": "^16.7.0",
"jquery": "^3.4.1",
"jquery": "^3.5.0",
"moment": "^2.24.0",
"moment-timezone": "^0.5.27",
"monaco-editor": "~0.17.0",
Expand Down
2 changes: 1 addition & 1 deletion scripts/kibana.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
* under the License.
*/

require('../src/apm')(process.env.ELASTIC_APM_PROXY_SERVICE_NAME || 'kibana-proxy');
require('../src/setup_node_env');
require('../src/apm')(process.env.ELASTIC_APM_PROXY_SERVICE_NAME || 'kibana-proxy');
require('../src/cli/cli');
2 changes: 1 addition & 1 deletion src/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
* under the License.
*/

require('../apm')();
require('../setup_node_env');
require('../apm')();
require('./cli');
2 changes: 2 additions & 0 deletions src/dev/build/build_distributables.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import {
CreatePackageJsonTask,
CreateReadmeTask,
CreateRpmPackageTask,
CreateStaticFsWithNodeModulesTask,
DownloadNodeBuildsTask,
ExtractNodeBuildsTask,
InstallDependenciesTask,
Expand Down Expand Up @@ -126,6 +127,7 @@ export async function buildDistributables(options) {
await run(CleanTypescriptTask);
await run(CleanExtraFilesFromModulesTask);
await run(CleanEmptyFoldersTask);
await run(CreateStaticFsWithNodeModulesTask);

/**
* copy generic build outputs into platform-specific build
Expand Down
64 changes: 64 additions & 0 deletions src/dev/build/tasks/create_static_fs_with_node_modules_task.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* 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 del from 'del';
import globby from 'globby';
import { resolve } from 'path';
import { generateStaticFsVolume } from '@elastic/static-fs';

async function deletePathsList(list) {
for (const path of list) {
await del(path);
}
}

async function getTopLevelNodeModulesFolders(rootDir) {
const nodeModulesFoldersForCwd = await globby(['**/node_modules', '!**/node_modules/**/*'], {
cwd: rootDir,
onlyDirectories: true,
});

return nodeModulesFoldersForCwd.map(folder => resolve(rootDir, folder));
}

export const CreateStaticFsWithNodeModulesTask = {
description:
'Creating static filesystem with node_modules, patching entryPoints and deleting node_modules folder',

async run(config, log, build) {
const rootDir = build.resolvePath('.');

// Get all the top node_modules folders
const nodeModulesFolders = await getTopLevelNodeModulesFolders(rootDir);

// Define root entry points
const rootEntryPoints = [build.resolvePath('src/setup_node_env/index.js')];

// Creates the static filesystem with
// every node_module we have
const staticFsAddedPaths = await generateStaticFsVolume(
rootDir,
nodeModulesFolders,
rootEntryPoints
);

// Delete node_modules folder
await deletePathsList(staticFsAddedPaths);
},
};
1 change: 1 addition & 0 deletions src/dev/build/tasks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export * from './create_archives_task';
export * from './create_empty_dirs_and_files_task';
export * from './create_package_json_task';
export * from './create_readme_task';
export * from './create_static_fs_with_node_modules_task';
export * from './install_dependencies_task';
export * from './license_file_task';
export * from './nodejs';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
listing-limit="listingLimit"
hide-write-controls="hideWriteControls"
initial-filter="initialFilter"
/>
></dashboard-listing>
44 changes: 44 additions & 0 deletions src/plugins/data/public/search/aggs/agg_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,51 @@ import { aggHistogram } from './buckets/histogram_fn';
import { aggDateHistogram } from './buckets/date_histogram_fn';
import { aggTerms } from './buckets/terms_fn';

/** Metrics: **/
import { aggAvg } from './metrics/avg_fn';
import { aggBucketAvg } from './metrics/bucket_avg_fn';
import { aggBucketMax } from './metrics/bucket_max_fn';
import { aggBucketMin } from './metrics/bucket_min_fn';
import { aggBucketSum } from './metrics/bucket_sum_fn';
import { aggCardinality } from './metrics/cardinality_fn';
import { aggCount } from './metrics/count_fn';
import { aggCumulativeSum } from './metrics/cumulative_sum_fn';
import { aggDerivative } from './metrics/derivative_fn';
import { aggGeoBounds } from './metrics/geo_bounds_fn';
import { aggGeoCentroid } from './metrics/geo_centroid_fn';
import { aggMax } from './metrics/max_fn';
import { aggMedian } from './metrics/median_fn';
import { aggMin } from './metrics/min_fn';
import { aggMovingAvg } from './metrics/moving_avg_fn';
import { aggPercentileRanks } from './metrics/percentile_ranks_fn';
import { aggPercentiles } from './metrics/percentiles_fn';
import { aggSerialDiff } from './metrics/serial_diff_fn';
import { aggStdDeviation } from './metrics/std_deviation_fn';
import { aggSum } from './metrics/sum_fn';
import { aggTopHit } from './metrics/top_hit_fn';

export const getAggTypesFunctions = () => [
aggAvg,
aggBucketAvg,
aggBucketMax,
aggBucketMin,
aggBucketSum,
aggCardinality,
aggCount,
aggCumulativeSum,
aggDerivative,
aggGeoBounds,
aggGeoCentroid,
aggMax,
aggMedian,
aggMin,
aggMovingAvg,
aggPercentileRanks,
aggPercentiles,
aggSerialDiff,
aggStdDeviation,
aggSum,
aggTopHit,
aggFilter,
aggFilters,
aggSignificantTerms,
Expand Down
5 changes: 5 additions & 0 deletions src/plugins/data/public/search/aggs/metrics/avg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,16 @@ import { MetricAggType } from './metric_agg_type';
import { METRIC_TYPES } from './metric_agg_types';
import { KBN_FIELD_TYPES } from '../../../../common';
import { GetInternalStartServicesFn } from '../../../types';
import { BaseAggParams } from '../types';

const averageTitle = i18n.translate('data.search.aggs.metrics.averageTitle', {
defaultMessage: 'Average',
});

export interface AggParamsAvg extends BaseAggParams {
field: string;
}

export interface AvgMetricAggDependencies {
getInternalStartServices: GetInternalStartServicesFn;
}
Expand Down
64 changes: 64 additions & 0 deletions src/plugins/data/public/search/aggs/metrics/avg_fn.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* 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 { functionWrapper } from '../test_helpers';
import { aggAvg } from './avg_fn';

describe('agg_expression_functions', () => {
describe('aggAvg', () => {
const fn = functionWrapper(aggAvg());

test('required args are provided', () => {
const actual = fn({
field: 'machine.os.keyword',
});
expect(actual).toMatchInlineSnapshot(`
Object {
"type": "agg_type",
"value": Object {
"enabled": true,
"id": undefined,
"params": Object {
"customLabel": undefined,
"field": "machine.os.keyword",
"json": undefined,
},
"schema": undefined,
"type": "avg",
},
}
`);
});

test('correctly parses json string argument', () => {
const actual = fn({
field: 'machine.os.keyword',
json: '{ "foo": true }',
});

expect(actual.value.params.json).toEqual({ foo: true });
expect(() => {
fn({
field: 'machine.os.keyword',
json: '/// intentionally malformed json ///',
});
}).toThrowErrorMatchingInlineSnapshot(`"Unable to parse json argument string"`);
});
});
});
95 changes: 95 additions & 0 deletions src/plugins/data/public/search/aggs/metrics/avg_fn.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
* 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 { ExpressionFunctionDefinition } from '../../../../../expressions/public';
import { AggExpressionType, AggExpressionFunctionArgs, METRIC_TYPES } from '../';
import { getParsedValue } from '../utils/get_parsed_value';

const fnName = 'aggAvg';

type Input = any;
type AggArgs = AggExpressionFunctionArgs<typeof METRIC_TYPES.AVG>;
type Output = AggExpressionType;
type FunctionDefinition = ExpressionFunctionDefinition<typeof fnName, Input, AggArgs, Output>;

export const aggAvg = (): FunctionDefinition => ({
name: fnName,
help: i18n.translate('data.search.aggs.function.metrics.avg.help', {
defaultMessage: 'Generates a serialized agg config for a Avg agg',
}),
type: 'agg_type',
args: {
id: {
types: ['string'],
help: i18n.translate('data.search.aggs.metrics.avg.id.help', {
defaultMessage: 'ID for this aggregation',
}),
},
enabled: {
types: ['boolean'],
default: true,
help: i18n.translate('data.search.aggs.metrics.avg.enabled.help', {
defaultMessage: 'Specifies whether this aggregation should be enabled',
}),
},
schema: {
types: ['string'],
help: i18n.translate('data.search.aggs.metrics.avg.schema.help', {
defaultMessage: 'Schema to use for this aggregation',
}),
},
field: {
types: ['string'],
required: true,
help: i18n.translate('data.search.aggs.metrics.avg.field.help', {
defaultMessage: 'Field to use for this aggregation',
}),
},
json: {
types: ['string'],
help: i18n.translate('data.search.aggs.metrics.avg.json.help', {
defaultMessage: 'Advanced json to include when the agg is sent to Elasticsearch',
}),
},
customLabel: {
types: ['string'],
help: i18n.translate('data.search.aggs.metrics.avg.customLabel.help', {
defaultMessage: 'Represents a custom label for this aggregation',
}),
},
},
fn: (input, args) => {
const { id, enabled, schema, ...rest } = args;

return {
type: 'agg_type',
value: {
id,
enabled,
schema,
type: METRIC_TYPES.AVG,
params: {
...rest,
json: getParsedValue(args, 'json'),
},
},
};
},
});
Loading

0 comments on commit 153cf49

Please sign in to comment.