Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TSVB] Replace deprecated moving_avg by moving_fn aggregation #36624

Merged
merged 48 commits into from
Jun 19, 2019
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
f03037f
Take model options away in a separate file
May 16, 2019
23fd119
Connect user scripting to models
May 16, 2019
f7d0181
Add inputs to the panel for managing alpha, beta, gamma params
May 17, 2019
fa139ae
Cover model types and scripts by tests
May 17, 2019
5a55fd4
Change default export of the bucket transform to the permanent one an…
May 17, 2019
18e7987
Add a migration script from mov_avg to mov_fn
May 17, 2019
90e1df3
Merge branch 'master' into replace-moving_avg-aggregation
May 17, 2019
8bd3abd
Merge branch 'master' into replace-moving_avg-aggregation
May 20, 2019
cfe619d
Remove redundant translations
May 20, 2019
6d58865
Remove old tests
May 20, 2019
8a64409
Merge branch 'master' into replace-moving_avg-aggregation
May 20, 2019
e726be5
Fix issues of PR
May 21, 2019
54f0009
Revert yarn.lock
May 21, 2019
418d61b
Fix issues regarding localization
May 21, 2019
f3afdc1
Merge branch 'master' into replace-moving_avg-aggregation
May 22, 2019
6636332
Merge remote-tracking branch 'upstream/master' into replace-moving_av…
May 22, 2019
f4b2dc4
Remove extra license
May 22, 2019
edbf88c
Merge branch 'master' into replace-moving_avg-aggregation
May 23, 2019
02db896
Merge remote-tracking branch 'upstream/master' into replace-moving_av…
May 23, 2019
be1701c
Remove redundant translations
May 23, 2019
b026ec3
Merge branch 'master' into replace-moving_avg-aggregation
May 24, 2019
82bee4e
Move the replaceMovAvgToMovFn hook to 7.3.0
May 24, 2019
6297542
Merge remote-tracking branch 'upstream/master' into replace-moving_av…
May 24, 2019
75607a3
Merge remote-tracking branch 'upstream/master' into replace-moving_av…
May 24, 2019
9e17b4a
Merge remote-tracking branch 'upstream/master' into replace-moving_av…
May 24, 2019
ba623e2
Merge branch 'master' into replace-moving_avg-aggregation
May 27, 2019
a4748be
Merge branch 'master' into replace-moving_avg-aggregation
May 28, 2019
56712f8
Merge remote-tracking branch 'upstream/master' into replace-moving_av…
May 28, 2019
4cf7c84
Merge branch 'master' into replace-moving_avg-aggregation
May 31, 2019
e1ef92f
Merge branch 'master' into replace-moving_avg-aggregation
Jun 6, 2019
d7498ce
Fix reviews
Jun 6, 2019
727ebd5
Merge branch 'master' into replace-moving_avg-aggregation
Jun 7, 2019
d9133ef
Merge branch 'master' into replace-moving_avg-aggregation
Jun 7, 2019
1f3e428
Add a migration test
Jun 7, 2019
dd002e1
Merge remote-tracking branch 'upstream/master' into replace-moving_av…
Jun 7, 2019
5097980
Merge branch 'master' into replace-moving_avg-aggregation
Jun 10, 2019
02913bd
Merge branch 'master' into replace-moving_avg-aggregation
Jun 11, 2019
0489960
Set proper default values and turn hint on for holt-winter only
Jun 11, 2019
1e33be6
Merge branch 'master' into replace-moving_avg-aggregation
Jun 12, 2019
42a6f9f
Merge branch 'master' into replace-moving_avg-aggregation
Jun 14, 2019
5fca443
Merge branch 'replace-moving_avg-aggregation' of github.com:Avinar-24…
Jun 14, 2019
c94d829
Format touched files by Prettier
Jun 14, 2019
45a7959
Import settings from moving_avg
Jun 14, 2019
28fe4fc
Merge remote-tracking branch 'upstream/master' into replace-moving_av…
Jun 14, 2019
6145d4f
Merge branch 'master' into replace-moving_avg-aggregation
Jun 17, 2019
bb7cf9e
Wrap changes to the try/catch statement and log exceptions
Jun 17, 2019
e0c8644
Merge branch 'master' into replace-moving_avg-aggregation
Jun 19, 2019
e29b2d9
Merge remote-tracking branch 'upstream/master' into replace-moving_av…
Jun 19, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 47 additions & 1 deletion src/legacy/core_plugins/kibana/migrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ const migrateDateHistogramAggregation = doc => {
};

const executeMigrations720 = flow(migratePercentileRankAggregation, migrateDateHistogramAggregation);
const executeMigrations730 = flow(migrateGaugeVerticalSplitToAlignment, replaceMovAvgToMovFn);

function removeDateHistogramTimeZones(doc) {
const visStateJSON = get(doc, 'attributes.visState');
Expand Down Expand Up @@ -190,6 +191,51 @@ function migrateGaugeVerticalSplitToAlignment(doc) {
return doc;
}

function replaceMovAvgToMovFn(doc) {
const visState = get(doc, 'attributes.visState');
let newVisState;

if (visState) {
try {
newVisState = JSON.parse(visState);
} catch (e) {
// Let it go, the data is invalid and we'll leave it as is
}
gospodarsky marked this conversation as resolved.
Show resolved Hide resolved

if (newVisState.type === 'metrics') {
gospodarsky marked this conversation as resolved.
Show resolved Hide resolved
const series = get(newVisState, 'params.series', []);

series.forEach(part => {
(part.metrics || []).forEach(metric => {
gospodarsky marked this conversation as resolved.
Show resolved Hide resolved
if (metric.type === 'moving_average') {
metric.model_type = metric.model;
metric.alpha = 0;
metric.beta = 0;
metric.gamma = 0;
metric.period = 1;
metric.multiplicative = true;

delete metric.minimize;
delete metric.model;
delete metric.settings;
delete metric.predict;
}
});
});

return {
...doc,
attributes: {
...doc.attributes,
visState: JSON.stringify(newVisState),
},
};
}
}

return doc;
}

export const migrations = {
'index-pattern': {
'6.5.0': (doc) => {
Expand Down Expand Up @@ -292,7 +338,7 @@ export const migrations = {
},
'7.0.1': removeDateHistogramTimeZones,
'7.2.0': doc => executeMigrations720(doc),
'7.3.0': migrateGaugeVerticalSplitToAlignment
'7.3.0': doc => executeMigrations730(doc),
},
dashboard: {
'7.0.0': (doc) => {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions src/legacy/core_plugins/metrics/common/model_options.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* 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.
*/

export const MODEL_TYPES = {
UNWEIGHTED: 'simple',
WEIGHTED_EXPONENTIAL: 'ewma',
WEIGHTED_EXPONENTIAL_DOUBLE: 'holt',
WEIGHTED_EXPONENTIAL_TRIPLE: 'holt_winters',
WEIGHTED_LINEAR: 'linear',
};
29 changes: 29 additions & 0 deletions src/legacy/core_plugins/metrics/common/model_options.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* 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 { MODEL_TYPES } from './model_options';

describe('src/legacy/core_plugins/metrics/common/model_options.js', () => {
describe('MODEL_TYPES', () => {
test('should match a snapshot of constants', () => {
expect(MODEL_TYPES).toMatchSnapshot();
gospodarsky marked this conversation as resolved.
Show resolved Hide resolved
});
});
});

Loading