Skip to content

Commit

Permalink
Merge branch 'master' into elasticsearch-config-deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
jportner committed Jan 9, 2020
2 parents 7c247ef + 6826368 commit f5e8de0
Show file tree
Hide file tree
Showing 15 changed files with 84 additions and 29 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
"@babel/core": "^7.5.5",
"@babel/register": "^7.7.0",
"@elastic/apm-rum": "^4.6.0",
"@elastic/charts": "^16.0.2",
"@elastic/charts": "^16.1.0",
"@elastic/datemath": "5.0.2",
"@elastic/ems-client": "1.0.5",
"@elastic/eui": "17.3.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,18 +135,15 @@ export function KbnAggTable(config, RecursionHelper) {
}

const isDate =
_.get(dimension, 'format.id') === 'date' ||
_.get(dimension, 'format.params.id') === 'date';
const isNumeric =
_.get(dimension, 'format.id') === 'number' ||
_.get(dimension, 'format.params.id') === 'number';
dimension.format?.id === 'date' || dimension.format?.params?.id === 'date';
const allowsNumericalAggregations = formatter?.allowsNumericalAggregations;

let { totalFunc } = $scope;
if (typeof totalFunc === 'undefined' && showPercentage) {
totalFunc = 'sum';
}

if (isNumeric || isDate || totalFunc === 'count') {
if (allowsNumericalAggregations || isDate || totalFunc === 'count') {
const sum = tableRows => {
return _.reduce(
tableRows,
Expand All @@ -161,7 +158,6 @@ export function KbnAggTable(config, RecursionHelper) {
};

formattedColumn.sumTotal = sum(table.rows);

switch (totalFunc) {
case 'sum': {
if (!isDate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,14 @@ export class TimeseriesVisualization extends Component {
static getYAxisDomain = model => {
const axisMin = get(model, 'axis_min', '').toString();
const axisMax = get(model, 'axis_max', '').toString();
const fit = model.series
? model.series.filter(({ hidden }) => !hidden).every(({ fill }) => fill === '0')
: model.fill === '0';

return {
min: axisMin.length ? Number(axisMin) : undefined,
max: axisMax.length ? Number(axisMax) : undefined,
fit,
};
};

Expand Down
1 change: 1 addition & 0 deletions src/plugins/data/common/field_formats/converters/bytes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ export class BytesFormat extends NumeralFormat {

id = BytesFormat.id;
title = BytesFormat.title;
allowsNumericalAggregations = true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ export class DurationFormat extends FieldFormat {
static fieldType = KBN_FIELD_TYPES.NUMBER;
static inputFormats = inputFormats;
static outputFormats = outputFormats;
allowsNumericalAggregations = true;

isHuman() {
return this.param('outputFormat') === HUMAN_FRIENDLY;
Expand Down
1 change: 1 addition & 0 deletions src/plugins/data/common/field_formats/converters/number.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ export class NumberFormat extends NumeralFormat {

id = NumberFormat.id;
title = NumberFormat.title;
allowsNumericalAggregations = true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export class PercentFormat extends NumeralFormat {

id = PercentFormat.id;
title = PercentFormat.title;
allowsNumericalAggregations = true;

getParamDefaults = () => ({
pattern: this.getConfig!('format:percent:defaultPattern'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import * as React from 'react';
import { EuiPage, EuiPageBody } from '@elastic/eui';
import { EuiPage, EuiPageBody, EuiPageSideBar } from '@elastic/eui';
import { I18nProvider } from '@kbn/i18n/react';
import { ManagementSidebarNav } from '../management_sidebar_nav';
import { LegacySection } from '../../types';
Expand All @@ -42,12 +42,14 @@ export class ManagementChrome extends React.Component<Props> {
return (
<I18nProvider>
<EuiPage>
<ManagementSidebarNav
getSections={this.props.getSections}
legacySections={this.props.legacySections}
selectedId={this.props.selectedId}
/>
<EuiPageBody>
<EuiPageSideBar>
<ManagementSidebarNav
getSections={this.props.getSections}
legacySections={this.props.legacySections}
selectedId={this.props.selectedId}
/>
</EuiPageSideBar>
<EuiPageBody restrictWidth={true} className="mgtPage__body">
<div ref={this.container} />
</EuiPageBody>
</EuiPage>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ import {
INDEX_ALERTS,
} from '../../../common/constants';

export function getIndexPatterns(server, additionalPatterns = {}) {
// wildcard means to search _all_ clusters
const ccs = '*';
export function getIndexPatterns(server, additionalPatterns = {}, ccs = '*') {
const config = server.config();
const esIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_ELASTICSEARCH, ccs);
const kbnIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_KIBANA, ccs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export function clusterSetupStatusRoute(server) {
skipLiveData: Joi.boolean().default(false),
}),
payload: Joi.object({
ccs: Joi.string().optional(),
timeRange: Joi.object({
min: Joi.date().required(),
max: Joi.date().required(),
Expand All @@ -49,7 +50,7 @@ export function clusterSetupStatusRoute(server) {
// the monitoring data. `try/catch` makes it a little more explicit.
try {
await verifyMonitoringAuth(req);
const indexPatterns = getIndexPatterns(server);
const indexPatterns = getIndexPatterns(server, {}, req.payload.ccs);
status = await getCollectionStatus(
req,
indexPatterns,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export function nodeSetupStatusRoute(server) {
skipLiveData: Joi.boolean().default(false),
}),
payload: Joi.object({
ccs: Joi.string().optional(),
timeRange: Joi.object({
min: Joi.date().required(),
max: Joi.date().required(),
Expand All @@ -49,7 +50,7 @@ export function nodeSetupStatusRoute(server) {
// the monitoring data. `try/catch` makes it a little more explicit.
try {
await verifyMonitoringAuth(req);
const indexPatterns = getIndexPatterns(server);
const indexPatterns = getIndexPatterns(server, {}, req.payload.ccs);
status = await getCollectionStatus(
req,
indexPatterns,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* 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 default function({ getService }) {
const supertest = getService('supertest');
const esArchiver = getService('esArchiver');

describe('ccs', () => {
const archive = 'monitoring/setup/collection/detect_apm';
const timeRange = {
min: '2019-04-16T00:00:00.741Z',
max: '2019-04-16T23:59:59.741Z',
};

before('load archive', () => {
return esArchiver.load(archive);
});

after('unload archive', () => {
return esArchiver.unload(archive);
});

it('should not fail with a ccs parameter for cluster', async () => {
await supertest
.post('/api/monitoring/v1/setup/collection/cluster?skipLiveData=true')
.set('kbn-xsrf', 'xxx')
.send({ timeRange, ccs: '*' })
.expect(200);
});

it('should not fail with a ccs parameter for node', async () => {
await supertest
.post('/api/monitoring/v1/setup/collection/node/123?skipLiveData=true')
.set('kbn-xsrf', 'xxx')
.send({ timeRange, ccs: '*' })
.expect(200);
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ export default function({ loadTestFile }) {
loadTestFile(require.resolve('./detect_logstash_management'));
loadTestFile(require.resolve('./detect_apm'));
loadTestFile(require.resolve('./security'));
loadTestFile(require.resolve('./ccs'));
});
}
16 changes: 11 additions & 5 deletions x-pack/test/api_integration/apis/uptime/rest/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@ import { FtrProviderContext } from '../../../ftr_provider_context';
export default function({ getService, loadTestFile }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
describe('uptime REST endpoints', () => {
before('load heartbeat data', () => esArchiver.load('uptime/blank'));
after('unload', () => esArchiver.unload('uptime/blank'));
loadTestFile(require.resolve('./snapshot'));
loadTestFile(require.resolve('./monitor_latest_status'));
loadTestFile(require.resolve('./selected_monitor'));
describe('with generated data', () => {
before('load heartbeat data', () => esArchiver.load('uptime/blank'));
after('unload', () => esArchiver.unload('uptime/blank'));
loadTestFile(require.resolve('./snapshot'));
});
describe('with real-world data', () => {
before('load heartbeat data', () => esArchiver.load('uptime/full_heartbeat'));
after('unload', () => esArchiver.unload('uptime/full_heartbeat'));
loadTestFile(require.resolve('./monitor_latest_status'));
loadTestFile(require.resolve('./selected_monitor'));
});
});
}
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1361,10 +1361,10 @@
dependencies:
"@elastic/apm-rum-core" "^4.7.0"

"@elastic/charts@^16.0.2":
version "16.0.2"
resolved "https://registry.yarnpkg.com/@elastic/charts/-/charts-16.0.2.tgz#35068a08a19534da62e9bcad700cc7b2a15bc55a"
integrity sha512-0tVyltAmAPOAfiRU1iKYk3b9++4oTn6IXvyM4SSj7Ukh5Y90XXmOtGEUPnZTiRPmup9MJi4srrm9ra9k/Kq4UQ==
"@elastic/charts@^16.1.0":
version "16.1.0"
resolved "https://registry.yarnpkg.com/@elastic/charts/-/charts-16.1.0.tgz#67cf11625dcd7e1c2cf16ef53349e6a68a73f5b1"
integrity sha512-0jZ7thhGmYC0ZdEVkxfg6M66epCD7k7BfYIi12FnrmIK+mUD2IPhR8b2TJXvaojPryN4YTNreGRncQ9R58fOoQ==
dependencies:
"@types/d3-shape" "^1.3.1"
classnames "^2.2.6"
Expand Down

0 comments on commit f5e8de0

Please sign in to comment.