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

[ML] Use a new ML endpoint to estimate a model memory #60376

Merged
merged 18 commits into from Mar 19, 2020
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions x-pack/plugins/ml/common/types/anomaly_detection_jobs/job.ts
Expand Up @@ -81,7 +81,7 @@ export interface ModelPlotConfig {

// TODO, finish this when it's needed
export interface CustomRule {
actions: any;
scope: object;
conditions: object;
actions: string[];
scope?: object;
conditions: any[];
}
Expand Up @@ -88,16 +88,13 @@ export class MultiMetricJobCreator extends JobCreator {

// called externally to set the model memory limit based current detector configuration
public async calculateModelMemoryLimit() {
if (this._splitField === null) {
// not split field, use the default
if (this.jobConfig.analysis_config.detectors.length === 0) {
this.modelMemoryLimit = DEFAULT_MODEL_MEMORY_LIMIT;
} else {
const { modelMemoryLimit } = await ml.calculateModelMemoryLimit({
analysisConfig: this.jobConfig.analysis_config,
indexPattern: this._indexPatternTitle,
splitFieldName: this._splitField.name,
query: this._datafeed_config.query,
fieldNames: this.fields.map(f => f.id),
influencerNames: this._influencers,
timeFieldName: this._job_config.data_description.time_field,
earliestMs: this._start,
latestMs: this._end,
Expand Down
Expand Up @@ -22,6 +22,7 @@ import {
Datafeed,
CombinedJob,
Detector,
AnalysisConfig,
} from '../../../../common/types/anomaly_detection_jobs';
import { ES_AGGREGATION } from '../../../../common/constants/aggregation_types';
import { FieldRequestConfig } from '../../datavisualizer/index_based/common';
Expand Down Expand Up @@ -532,30 +533,24 @@ export const ml = {
},

calculateModelMemoryLimit({
analysisConfig,
indexPattern,
splitFieldName,
query,
fieldNames,
influencerNames,
timeFieldName,
earliestMs,
latestMs,
}: {
analysisConfig: AnalysisConfig;
indexPattern: string;
splitFieldName: string;
query: any;
fieldNames: string[];
influencerNames: string[];
timeFieldName: string;
earliestMs: number;
latestMs: number;
}) {
const body = JSON.stringify({
analysisConfig,
indexPattern,
splitFieldName,
query,
fieldNames,
influencerNames,
timeFieldName,
earliestMs,
latestMs,
Expand Down
8 changes: 8 additions & 0 deletions x-pack/plugins/ml/server/client/elasticsearch_ml.ts
Expand Up @@ -413,6 +413,14 @@ export const elasticsearchJsPlugin = (Client: any, config: any, components: any)
method: 'POST',
});

ml.estimateModelMemory = ca({
url: {
fmt: '/_ml/anomaly_detectors/_estimate_model_memory',
},
needBody: true,
method: 'POST',
});

ml.datafeedPreview = ca({
url: {
fmt: '/_ml/datafeeds/<%=datafeedId%>/_preview',
Expand Down

This file was deleted.

This file was deleted.