Rename model_debug_output to model_plot

The model debug output is 1 result type of the autodetect (anomaly detection) process reporting bounds/statistics/state - not anomalies - It's main usage as of time of writing is visualization in the UI, naming the 'blue shadow' under the result graph. Rename in order to remove 'debug' in the name

Original commit: elastic/x-pack-elasticsearch@86de428512
This commit is contained in:
Hendrik Muhs 2017-03-19 11:55:06 +01:00 committed by GitHub
parent a76232f5e4
commit 7832783122
36 changed files with 490 additions and 493 deletions

View File

@ -154,7 +154,6 @@
<suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]job[/\\]config[/\\]Job.java" checks="LineLength" /> <suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]job[/\\]config[/\\]Job.java" checks="LineLength" />
<suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]job[/\\]config[/\\]JobUpdate.java" checks="LineLength" /> <suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]job[/\\]config[/\\]JobUpdate.java" checks="LineLength" />
<suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]job[/\\]config[/\\]MlFilter.java" checks="LineLength" /> <suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]job[/\\]config[/\\]MlFilter.java" checks="LineLength" />
<suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]job[/\\]config[/\\]ModelDebugConfig.java" checks="LineLength" />
<suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]job[/\\]config[/\\]RuleCondition.java" checks="LineLength" /> <suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]job[/\\]config[/\\]RuleCondition.java" checks="LineLength" />
<suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]job[/\\]messages[/\\]Messages.java" checks="LineLength" /> <suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]job[/\\]messages[/\\]Messages.java" checks="LineLength" />
<suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]job[/\\]persistence[/\\]BatchedBucketsIterator.java" checks="LineLength" /> <suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]job[/\\]persistence[/\\]BatchedBucketsIterator.java" checks="LineLength" />
@ -204,7 +203,6 @@
<suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]job[/\\]process[/\\]autodetect[/\\]writer[/\\]DoubleDateTransformer.java" checks="LineLength" /> <suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]job[/\\]process[/\\]autodetect[/\\]writer[/\\]DoubleDateTransformer.java" checks="LineLength" />
<suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]job[/\\]process[/\\]autodetect[/\\]writer[/\\]FieldConfigWriter.java" checks="LineLength" /> <suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]job[/\\]process[/\\]autodetect[/\\]writer[/\\]FieldConfigWriter.java" checks="LineLength" />
<suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]job[/\\]process[/\\]autodetect[/\\]writer[/\\]JsonDataToProcessWriter.java" checks="LineLength" /> <suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]job[/\\]process[/\\]autodetect[/\\]writer[/\\]JsonDataToProcessWriter.java" checks="LineLength" />
<suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]job[/\\]process[/\\]autodetect[/\\]writer[/\\]ModelDebugConfigWriter.java" checks="LineLength" />
<suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]job[/\\]process[/\\]autodetect[/\\]writer[/\\]SimpleJsonRecordReader.java" checks="LineLength" /> <suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]job[/\\]process[/\\]autodetect[/\\]writer[/\\]SimpleJsonRecordReader.java" checks="LineLength" />
<suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]job[/\\]process[/\\]logging[/\\]CppLogMessage.java" checks="LineLength" /> <suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]job[/\\]process[/\\]logging[/\\]CppLogMessage.java" checks="LineLength" />
<suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]job[/\\]process[/\\]logging[/\\]CppLogMessageHandler.java" checks="LineLength" /> <suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]job[/\\]process[/\\]logging[/\\]CppLogMessageHandler.java" checks="LineLength" />
@ -227,7 +225,6 @@
<suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]job[/\\]results[/\\]CategoryDefinition.java" checks="LineLength" /> <suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]job[/\\]results[/\\]CategoryDefinition.java" checks="LineLength" />
<suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]job[/\\]results[/\\]Influence.java" checks="LineLength" /> <suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]job[/\\]results[/\\]Influence.java" checks="LineLength" />
<suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]job[/\\]results[/\\]Influencer.java" checks="LineLength" /> <suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]job[/\\]results[/\\]Influencer.java" checks="LineLength" />
<suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]job[/\\]results[/\\]ModelDebugOutput.java" checks="LineLength" />
<suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]job[/\\]results[/\\]PartitionScore.java" checks="LineLength" /> <suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]job[/\\]results[/\\]PartitionScore.java" checks="LineLength" />
<suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]job[/\\]results[/\\]PerPartitionMaxProbabilities.java" checks="LineLength" /> <suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]job[/\\]results[/\\]PerPartitionMaxProbabilities.java" checks="LineLength" />
<suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]job[/\\]results[/\\]ReservedFieldNames.java" checks="LineLength" /> <suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]job[/\\]results[/\\]ReservedFieldNames.java" checks="LineLength" />

View File

@ -200,7 +200,7 @@ public class UpdateJobAction extends Action<UpdateJobAction.Request, PutJobActio
ActionListener<PutJobAction.Response> listener) { ActionListener<PutJobAction.Response> listener) {
UpdateProcessAction.Request updateProcessRequest = new UpdateProcessAction.Request(request.getJobId(), UpdateProcessAction.Request updateProcessRequest = new UpdateProcessAction.Request(request.getJobId(),
request.getJobUpdate().getModelDebugConfig(), request.getJobUpdate().getDetectorUpdates()); request.getJobUpdate().getModelPlotConfig(), request.getJobUpdate().getDetectorUpdates());
client.execute(UpdateProcessAction.INSTANCE, updateProcessRequest, new ActionListener<UpdateProcessAction.Response>() { client.execute(UpdateProcessAction.INSTANCE, updateProcessRequest, new ActionListener<UpdateProcessAction.Response>() {
@Override @Override

View File

@ -25,7 +25,7 @@ import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService; import org.elasticsearch.transport.TransportService;
import org.elasticsearch.xpack.ml.MachineLearning; import org.elasticsearch.xpack.ml.MachineLearning;
import org.elasticsearch.xpack.ml.job.config.JobUpdate; import org.elasticsearch.xpack.ml.job.config.JobUpdate;
import org.elasticsearch.xpack.ml.job.config.ModelDebugConfig; import org.elasticsearch.xpack.ml.job.config.ModelPlotConfig;
import org.elasticsearch.xpack.ml.job.process.autodetect.AutodetectProcessManager; import org.elasticsearch.xpack.ml.job.process.autodetect.AutodetectProcessManager;
import java.io.IOException; import java.io.IOException;
@ -113,20 +113,20 @@ public class UpdateProcessAction extends
public static class Request extends TransportJobTaskAction.JobTaskRequest<Request> { public static class Request extends TransportJobTaskAction.JobTaskRequest<Request> {
private ModelDebugConfig modelDebugConfig; private ModelPlotConfig modelPlotConfig;
private List<JobUpdate.DetectorUpdate> detectorUpdates; private List<JobUpdate.DetectorUpdate> detectorUpdates;
Request() { Request() {
} }
public Request(String jobId, ModelDebugConfig modelDebugConfig, List<JobUpdate.DetectorUpdate> detectorUpdates) { public Request(String jobId, ModelPlotConfig modelPlotConfig, List<JobUpdate.DetectorUpdate> detectorUpdates) {
super(jobId); super(jobId);
this.modelDebugConfig = modelDebugConfig; this.modelPlotConfig = modelPlotConfig;
this.detectorUpdates = detectorUpdates; this.detectorUpdates = detectorUpdates;
} }
public ModelDebugConfig getModelDebugConfig() { public ModelPlotConfig getModelPlotConfig() {
return modelDebugConfig; return modelPlotConfig;
} }
public List<JobUpdate.DetectorUpdate> getDetectorUpdates() { public List<JobUpdate.DetectorUpdate> getDetectorUpdates() {
@ -136,7 +136,7 @@ public class UpdateProcessAction extends
@Override @Override
public void readFrom(StreamInput in) throws IOException { public void readFrom(StreamInput in) throws IOException {
super.readFrom(in); super.readFrom(in);
modelDebugConfig = in.readOptionalWriteable(ModelDebugConfig::new); modelPlotConfig = in.readOptionalWriteable(ModelPlotConfig::new);
if (in.readBoolean()) { if (in.readBoolean()) {
in.readList(JobUpdate.DetectorUpdate::new); in.readList(JobUpdate.DetectorUpdate::new);
} }
@ -145,7 +145,7 @@ public class UpdateProcessAction extends
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out); super.writeTo(out);
out.writeOptionalWriteable(modelDebugConfig); out.writeOptionalWriteable(modelPlotConfig);
boolean hasDetectorUpdates = detectorUpdates != null; boolean hasDetectorUpdates = detectorUpdates != null;
out.writeBoolean(hasDetectorUpdates); out.writeBoolean(hasDetectorUpdates);
if (hasDetectorUpdates) { if (hasDetectorUpdates) {
@ -155,7 +155,7 @@ public class UpdateProcessAction extends
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(getJobId(), modelDebugConfig, detectorUpdates); return Objects.hash(getJobId(), modelPlotConfig, detectorUpdates);
} }
@Override @Override
@ -169,7 +169,7 @@ public class UpdateProcessAction extends
Request other = (Request) obj; Request other = (Request) obj;
return Objects.equals(getJobId(), other.getJobId()) && return Objects.equals(getJobId(), other.getJobId()) &&
Objects.equals(modelDebugConfig, other.modelDebugConfig) && Objects.equals(modelPlotConfig, other.modelPlotConfig) &&
Objects.equals(detectorUpdates, other.detectorUpdates); Objects.equals(detectorUpdates, other.detectorUpdates);
} }
} }
@ -196,7 +196,7 @@ public class UpdateProcessAction extends
threadPool.executor(MachineLearning.THREAD_POOL_NAME).execute(() -> { threadPool.executor(MachineLearning.THREAD_POOL_NAME).execute(() -> {
try { try {
processManager.writeUpdateProcessMessage(request.getJobId(), request.getDetectorUpdates(), processManager.writeUpdateProcessMessage(request.getJobId(), request.getDetectorUpdates(),
request.getModelDebugConfig()); request.getModelPlotConfig());
listener.onResponse(new Response()); listener.onResponse(new Response());
} catch (Exception e) { } catch (Exception e) {
listener.onFailure(e); listener.onFailure(e);

View File

@ -57,7 +57,7 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContent
public static final ParseField DESCRIPTION = new ParseField("description"); public static final ParseField DESCRIPTION = new ParseField("description");
public static final ParseField FINISHED_TIME = new ParseField("finished_time"); public static final ParseField FINISHED_TIME = new ParseField("finished_time");
public static final ParseField LAST_DATA_TIME = new ParseField("last_data_time"); public static final ParseField LAST_DATA_TIME = new ParseField("last_data_time");
public static final ParseField MODEL_DEBUG_CONFIG = new ParseField("model_debug_config"); public static final ParseField MODEL_PLOT_CONFIG = new ParseField("model_plot_config");
public static final ParseField RENORMALIZATION_WINDOW_DAYS = new ParseField("renormalization_window_days"); public static final ParseField RENORMALIZATION_WINDOW_DAYS = new ParseField("renormalization_window_days");
public static final ParseField BACKGROUND_PERSIST_INTERVAL = new ParseField("background_persist_interval"); public static final ParseField BACKGROUND_PERSIST_INTERVAL = new ParseField("background_persist_interval");
public static final ParseField MODEL_SNAPSHOT_RETENTION_DAYS = new ParseField("model_snapshot_retention_days"); public static final ParseField MODEL_SNAPSHOT_RETENTION_DAYS = new ParseField("model_snapshot_retention_days");
@ -108,7 +108,7 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContent
PARSER.declareObject(Builder::setAnalysisConfig, AnalysisConfig.PARSER, ANALYSIS_CONFIG); PARSER.declareObject(Builder::setAnalysisConfig, AnalysisConfig.PARSER, ANALYSIS_CONFIG);
PARSER.declareObject(Builder::setAnalysisLimits, AnalysisLimits.PARSER, ANALYSIS_LIMITS); PARSER.declareObject(Builder::setAnalysisLimits, AnalysisLimits.PARSER, ANALYSIS_LIMITS);
PARSER.declareObject(Builder::setDataDescription, DataDescription.PARSER, DATA_DESCRIPTION); PARSER.declareObject(Builder::setDataDescription, DataDescription.PARSER, DATA_DESCRIPTION);
PARSER.declareObject(Builder::setModelDebugConfig, ModelDebugConfig.PARSER, MODEL_DEBUG_CONFIG); PARSER.declareObject(Builder::setModelPlotConfig, ModelPlotConfig.PARSER, MODEL_PLOT_CONFIG);
PARSER.declareLong(Builder::setRenormalizationWindowDays, RENORMALIZATION_WINDOW_DAYS); PARSER.declareLong(Builder::setRenormalizationWindowDays, RENORMALIZATION_WINDOW_DAYS);
PARSER.declareString((builder, val) -> builder.setBackgroundPersistInterval( PARSER.declareString((builder, val) -> builder.setBackgroundPersistInterval(
TimeValue.parseTimeValue(val, BACKGROUND_PERSIST_INTERVAL.getPreferredName())), BACKGROUND_PERSIST_INTERVAL); TimeValue.parseTimeValue(val, BACKGROUND_PERSIST_INTERVAL.getPreferredName())), BACKGROUND_PERSIST_INTERVAL);
@ -129,7 +129,7 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContent
private final AnalysisConfig analysisConfig; private final AnalysisConfig analysisConfig;
private final AnalysisLimits analysisLimits; private final AnalysisLimits analysisLimits;
private final DataDescription dataDescription; private final DataDescription dataDescription;
private final ModelDebugConfig modelDebugConfig; private final ModelPlotConfig modelPlotConfig;
private final Long renormalizationWindowDays; private final Long renormalizationWindowDays;
private final TimeValue backgroundPersistInterval; private final TimeValue backgroundPersistInterval;
private final Long modelSnapshotRetentionDays; private final Long modelSnapshotRetentionDays;
@ -141,7 +141,7 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContent
private Job(String jobId, String description, Date createTime, Date finishedTime, Date lastDataTime, private Job(String jobId, String description, Date createTime, Date finishedTime, Date lastDataTime,
AnalysisConfig analysisConfig, AnalysisLimits analysisLimits, DataDescription dataDescription, AnalysisConfig analysisConfig, AnalysisLimits analysisLimits, DataDescription dataDescription,
ModelDebugConfig modelDebugConfig, Long renormalizationWindowDays, TimeValue backgroundPersistInterval, ModelPlotConfig modelPlotConfig, Long renormalizationWindowDays, TimeValue backgroundPersistInterval,
Long modelSnapshotRetentionDays, Long resultsRetentionDays, Map<String, Object> customSettings, Long modelSnapshotRetentionDays, Long resultsRetentionDays, Map<String, Object> customSettings,
String modelSnapshotId, String resultsIndexName, boolean deleted) { String modelSnapshotId, String resultsIndexName, boolean deleted) {
@ -153,7 +153,7 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContent
this.analysisConfig = analysisConfig; this.analysisConfig = analysisConfig;
this.analysisLimits = analysisLimits; this.analysisLimits = analysisLimits;
this.dataDescription = dataDescription; this.dataDescription = dataDescription;
this.modelDebugConfig = modelDebugConfig; this.modelPlotConfig = modelPlotConfig;
this.renormalizationWindowDays = renormalizationWindowDays; this.renormalizationWindowDays = renormalizationWindowDays;
this.backgroundPersistInterval = backgroundPersistInterval; this.backgroundPersistInterval = backgroundPersistInterval;
this.modelSnapshotRetentionDays = modelSnapshotRetentionDays; this.modelSnapshotRetentionDays = modelSnapshotRetentionDays;
@ -173,7 +173,7 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContent
analysisConfig = new AnalysisConfig(in); analysisConfig = new AnalysisConfig(in);
analysisLimits = in.readOptionalWriteable(AnalysisLimits::new); analysisLimits = in.readOptionalWriteable(AnalysisLimits::new);
dataDescription = in.readOptionalWriteable(DataDescription::new); dataDescription = in.readOptionalWriteable(DataDescription::new);
modelDebugConfig = in.readOptionalWriteable(ModelDebugConfig::new); modelPlotConfig = in.readOptionalWriteable(ModelPlotConfig::new);
renormalizationWindowDays = in.readOptionalLong(); renormalizationWindowDays = in.readOptionalLong();
backgroundPersistInterval = in.readOptionalWriteable(TimeValue::new); backgroundPersistInterval = in.readOptionalWriteable(TimeValue::new);
modelSnapshotRetentionDays = in.readOptionalLong(); modelSnapshotRetentionDays = in.readOptionalLong();
@ -277,8 +277,8 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContent
return analysisLimits; return analysisLimits;
} }
public ModelDebugConfig getModelDebugConfig() { public ModelPlotConfig getModelPlotConfig() {
return modelDebugConfig; return modelPlotConfig;
} }
/** /**
@ -378,7 +378,7 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContent
analysisConfig.writeTo(out); analysisConfig.writeTo(out);
out.writeOptionalWriteable(analysisLimits); out.writeOptionalWriteable(analysisLimits);
out.writeOptionalWriteable(dataDescription); out.writeOptionalWriteable(dataDescription);
out.writeOptionalWriteable(modelDebugConfig); out.writeOptionalWriteable(modelPlotConfig);
out.writeOptionalLong(renormalizationWindowDays); out.writeOptionalLong(renormalizationWindowDays);
out.writeOptionalWriteable(backgroundPersistInterval); out.writeOptionalWriteable(backgroundPersistInterval);
out.writeOptionalLong(modelSnapshotRetentionDays); out.writeOptionalLong(modelSnapshotRetentionDays);
@ -420,8 +420,8 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContent
if (dataDescription != null) { if (dataDescription != null) {
builder.field(DATA_DESCRIPTION.getPreferredName(), dataDescription, params); builder.field(DATA_DESCRIPTION.getPreferredName(), dataDescription, params);
} }
if (modelDebugConfig != null) { if (modelPlotConfig != null) {
builder.field(MODEL_DEBUG_CONFIG.getPreferredName(), modelDebugConfig, params); builder.field(MODEL_PLOT_CONFIG.getPreferredName(), modelPlotConfig, params);
} }
if (renormalizationWindowDays != null) { if (renormalizationWindowDays != null) {
builder.field(RENORMALIZATION_WINDOW_DAYS.getPreferredName(), renormalizationWindowDays); builder.field(RENORMALIZATION_WINDOW_DAYS.getPreferredName(), renormalizationWindowDays);
@ -465,7 +465,7 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContent
&& Objects.equals(this.lastDataTime, that.lastDataTime) && Objects.equals(this.lastDataTime, that.lastDataTime)
&& Objects.equals(this.analysisConfig, that.analysisConfig) && Objects.equals(this.analysisConfig, that.analysisConfig)
&& Objects.equals(this.analysisLimits, that.analysisLimits) && Objects.equals(this.dataDescription, that.dataDescription) && Objects.equals(this.analysisLimits, that.analysisLimits) && Objects.equals(this.dataDescription, that.dataDescription)
&& Objects.equals(this.modelDebugConfig, that.modelDebugConfig) && Objects.equals(this.modelPlotConfig, that.modelPlotConfig)
&& Objects.equals(this.renormalizationWindowDays, that.renormalizationWindowDays) && Objects.equals(this.renormalizationWindowDays, that.renormalizationWindowDays)
&& Objects.equals(this.backgroundPersistInterval, that.backgroundPersistInterval) && Objects.equals(this.backgroundPersistInterval, that.backgroundPersistInterval)
&& Objects.equals(this.modelSnapshotRetentionDays, that.modelSnapshotRetentionDays) && Objects.equals(this.modelSnapshotRetentionDays, that.modelSnapshotRetentionDays)
@ -479,7 +479,7 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContent
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(jobId, description, createTime, finishedTime, lastDataTime, analysisConfig, return Objects.hash(jobId, description, createTime, finishedTime, lastDataTime, analysisConfig,
analysisLimits, dataDescription, modelDebugConfig, renormalizationWindowDays, analysisLimits, dataDescription, modelPlotConfig, renormalizationWindowDays,
backgroundPersistInterval, modelSnapshotRetentionDays, resultsRetentionDays, customSettings, backgroundPersistInterval, modelSnapshotRetentionDays, resultsRetentionDays, customSettings,
modelSnapshotId, resultsIndexName, deleted); modelSnapshotId, resultsIndexName, deleted);
} }
@ -507,7 +507,7 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContent
private Date createTime; private Date createTime;
private Date finishedTime; private Date finishedTime;
private Date lastDataTime; private Date lastDataTime;
private ModelDebugConfig modelDebugConfig; private ModelPlotConfig modelPlotConfig;
private Long renormalizationWindowDays; private Long renormalizationWindowDays;
private TimeValue backgroundPersistInterval; private TimeValue backgroundPersistInterval;
private Long modelSnapshotRetentionDays = 1L; private Long modelSnapshotRetentionDays = 1L;
@ -533,7 +533,7 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContent
this.createTime = job.getCreateTime(); this.createTime = job.getCreateTime();
this.finishedTime = job.getFinishedTime(); this.finishedTime = job.getFinishedTime();
this.lastDataTime = job.getLastDataTime(); this.lastDataTime = job.getLastDataTime();
this.modelDebugConfig = job.getModelDebugConfig(); this.modelPlotConfig = job.getModelPlotConfig();
this.renormalizationWindowDays = job.getRenormalizationWindowDays(); this.renormalizationWindowDays = job.getRenormalizationWindowDays();
this.backgroundPersistInterval = job.getBackgroundPersistInterval(); this.backgroundPersistInterval = job.getBackgroundPersistInterval();
this.modelSnapshotRetentionDays = job.getModelSnapshotRetentionDays(); this.modelSnapshotRetentionDays = job.getModelSnapshotRetentionDays();
@ -610,8 +610,8 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContent
return this; return this;
} }
public Builder setModelDebugConfig(ModelDebugConfig modelDebugConfig) { public Builder setModelPlotConfig(ModelPlotConfig modelPlotConfig) {
this.modelDebugConfig = modelDebugConfig; this.modelPlotConfig = modelPlotConfig;
return this; return this;
} }
@ -693,7 +693,7 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContent
return new Job( return new Job(
id, description, createTime, finishedTime, lastDataTime, analysisConfig, analysisLimits, id, description, createTime, finishedTime, lastDataTime, analysisConfig, analysisLimits,
dataDescription, modelDebugConfig, renormalizationWindowDays, backgroundPersistInterval, dataDescription, modelPlotConfig, renormalizationWindowDays, backgroundPersistInterval,
modelSnapshotRetentionDays, resultsRetentionDays, customSettings, modelSnapshotId, modelSnapshotRetentionDays, resultsRetentionDays, customSettings, modelSnapshotId,
resultsIndexName, deleted); resultsIndexName, deleted);
} }

View File

@ -29,7 +29,7 @@ public class JobUpdate implements Writeable, ToXContent {
static { static {
PARSER.declareStringOrNull(Builder::setDescription, Job.DESCRIPTION); PARSER.declareStringOrNull(Builder::setDescription, Job.DESCRIPTION);
PARSER.declareObjectArray(Builder::setDetectorUpdates, DetectorUpdate.PARSER, DETECTORS); PARSER.declareObjectArray(Builder::setDetectorUpdates, DetectorUpdate.PARSER, DETECTORS);
PARSER.declareObject(Builder::setModelDebugConfig, ModelDebugConfig.PARSER, Job.MODEL_DEBUG_CONFIG); PARSER.declareObject(Builder::setModelPlotConfig, ModelPlotConfig.PARSER, Job.MODEL_PLOT_CONFIG);
PARSER.declareObject(Builder::setAnalysisLimits, AnalysisLimits.PARSER, Job.ANALYSIS_LIMITS); PARSER.declareObject(Builder::setAnalysisLimits, AnalysisLimits.PARSER, Job.ANALYSIS_LIMITS);
PARSER.declareString((builder, val) -> builder.setBackgroundPersistInterval( PARSER.declareString((builder, val) -> builder.setBackgroundPersistInterval(
TimeValue.parseTimeValue(val, Job.BACKGROUND_PERSIST_INTERVAL.getPreferredName())), Job.BACKGROUND_PERSIST_INTERVAL); TimeValue.parseTimeValue(val, Job.BACKGROUND_PERSIST_INTERVAL.getPreferredName())), Job.BACKGROUND_PERSIST_INTERVAL);
@ -43,7 +43,7 @@ public class JobUpdate implements Writeable, ToXContent {
private final String description; private final String description;
private final List<DetectorUpdate> detectorUpdates; private final List<DetectorUpdate> detectorUpdates;
private final ModelDebugConfig modelDebugConfig; private final ModelPlotConfig modelPlotConfig;
private final AnalysisLimits analysisLimits; private final AnalysisLimits analysisLimits;
private final Long renormalizationWindowDays; private final Long renormalizationWindowDays;
private final TimeValue backgroundPersistInterval; private final TimeValue backgroundPersistInterval;
@ -54,14 +54,14 @@ public class JobUpdate implements Writeable, ToXContent {
private final String modelSnapshotId; private final String modelSnapshotId;
private JobUpdate(@Nullable String description, @Nullable List<DetectorUpdate> detectorUpdates, private JobUpdate(@Nullable String description, @Nullable List<DetectorUpdate> detectorUpdates,
@Nullable ModelDebugConfig modelDebugConfig, @Nullable AnalysisLimits analysisLimits, @Nullable ModelPlotConfig modelPlotConfig, @Nullable AnalysisLimits analysisLimits,
@Nullable TimeValue backgroundPersistInterval, @Nullable Long renormalizationWindowDays, @Nullable TimeValue backgroundPersistInterval, @Nullable Long renormalizationWindowDays,
@Nullable Long resultsRetentionDays, @Nullable Long modelSnapshotRetentionDays, @Nullable Long resultsRetentionDays, @Nullable Long modelSnapshotRetentionDays,
@Nullable List<String> categorisationFilters, @Nullable Map<String, Object> customSettings, @Nullable List<String> categorisationFilters, @Nullable Map<String, Object> customSettings,
@Nullable String modelSnapshotId) { @Nullable String modelSnapshotId) {
this.description = description; this.description = description;
this.detectorUpdates = detectorUpdates; this.detectorUpdates = detectorUpdates;
this.modelDebugConfig = modelDebugConfig; this.modelPlotConfig = modelPlotConfig;
this.analysisLimits = analysisLimits; this.analysisLimits = analysisLimits;
this.renormalizationWindowDays = renormalizationWindowDays; this.renormalizationWindowDays = renormalizationWindowDays;
this.backgroundPersistInterval = backgroundPersistInterval; this.backgroundPersistInterval = backgroundPersistInterval;
@ -79,7 +79,7 @@ public class JobUpdate implements Writeable, ToXContent {
} else { } else {
detectorUpdates = null; detectorUpdates = null;
} }
modelDebugConfig = in.readOptionalWriteable(ModelDebugConfig::new); modelPlotConfig = in.readOptionalWriteable(ModelPlotConfig::new);
analysisLimits = in.readOptionalWriteable(AnalysisLimits::new); analysisLimits = in.readOptionalWriteable(AnalysisLimits::new);
renormalizationWindowDays = in.readOptionalLong(); renormalizationWindowDays = in.readOptionalLong();
backgroundPersistInterval = in.readOptionalWriteable(TimeValue::new); backgroundPersistInterval = in.readOptionalWriteable(TimeValue::new);
@ -100,7 +100,7 @@ public class JobUpdate implements Writeable, ToXContent {
if (detectorUpdates != null) { if (detectorUpdates != null) {
out.writeList(detectorUpdates); out.writeList(detectorUpdates);
} }
out.writeOptionalWriteable(modelDebugConfig); out.writeOptionalWriteable(modelPlotConfig);
out.writeOptionalWriteable(analysisLimits); out.writeOptionalWriteable(analysisLimits);
out.writeOptionalLong(renormalizationWindowDays); out.writeOptionalLong(renormalizationWindowDays);
out.writeOptionalWriteable(backgroundPersistInterval); out.writeOptionalWriteable(backgroundPersistInterval);
@ -122,8 +122,8 @@ public class JobUpdate implements Writeable, ToXContent {
return detectorUpdates; return detectorUpdates;
} }
public ModelDebugConfig getModelDebugConfig() { public ModelPlotConfig getModelPlotConfig() {
return modelDebugConfig; return modelPlotConfig;
} }
public AnalysisLimits getAnalysisLimits() { public AnalysisLimits getAnalysisLimits() {
@ -159,7 +159,7 @@ public class JobUpdate implements Writeable, ToXContent {
} }
public boolean isAutodetectProcessUpdate() { public boolean isAutodetectProcessUpdate() {
return modelDebugConfig != null || detectorUpdates != null; return modelPlotConfig != null || detectorUpdates != null;
} }
@Override @Override
@ -171,8 +171,8 @@ public class JobUpdate implements Writeable, ToXContent {
if (detectorUpdates != null) { if (detectorUpdates != null) {
builder.field(DETECTORS.getPreferredName(), detectorUpdates); builder.field(DETECTORS.getPreferredName(), detectorUpdates);
} }
if (modelDebugConfig != null) { if (modelPlotConfig != null) {
builder.field(Job.MODEL_DEBUG_CONFIG.getPreferredName(), modelDebugConfig); builder.field(Job.MODEL_PLOT_CONFIG.getPreferredName(), modelPlotConfig);
} }
if (analysisLimits != null) { if (analysisLimits != null) {
builder.field(Job.ANALYSIS_LIMITS.getPreferredName(), analysisLimits); builder.field(Job.ANALYSIS_LIMITS.getPreferredName(), analysisLimits);
@ -234,8 +234,8 @@ public class JobUpdate implements Writeable, ToXContent {
AnalysisConfig.Builder acBuilder = new AnalysisConfig.Builder(ac); AnalysisConfig.Builder acBuilder = new AnalysisConfig.Builder(ac);
builder.setAnalysisConfig(acBuilder); builder.setAnalysisConfig(acBuilder);
} }
if (modelDebugConfig != null) { if (modelPlotConfig != null) {
builder.setModelDebugConfig(modelDebugConfig); builder.setModelPlotConfig(modelPlotConfig);
} }
if (analysisLimits != null) { if (analysisLimits != null) {
builder.setAnalysisLimits(analysisLimits); builder.setAnalysisLimits(analysisLimits);
@ -281,7 +281,7 @@ public class JobUpdate implements Writeable, ToXContent {
return Objects.equals(this.description, that.description) return Objects.equals(this.description, that.description)
&& Objects.equals(this.detectorUpdates, that.detectorUpdates) && Objects.equals(this.detectorUpdates, that.detectorUpdates)
&& Objects.equals(this.modelDebugConfig, that.modelDebugConfig) && Objects.equals(this.modelPlotConfig, that.modelPlotConfig)
&& Objects.equals(this.analysisLimits, that.analysisLimits) && Objects.equals(this.analysisLimits, that.analysisLimits)
&& Objects.equals(this.renormalizationWindowDays, that.renormalizationWindowDays) && Objects.equals(this.renormalizationWindowDays, that.renormalizationWindowDays)
&& Objects.equals(this.backgroundPersistInterval, that.backgroundPersistInterval) && Objects.equals(this.backgroundPersistInterval, that.backgroundPersistInterval)
@ -294,7 +294,7 @@ public class JobUpdate implements Writeable, ToXContent {
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(description, detectorUpdates, modelDebugConfig, analysisLimits, renormalizationWindowDays, return Objects.hash(description, detectorUpdates, modelPlotConfig, analysisLimits, renormalizationWindowDays,
backgroundPersistInterval, modelSnapshotRetentionDays, resultsRetentionDays, categorizationFilters, customSettings, backgroundPersistInterval, modelSnapshotRetentionDays, resultsRetentionDays, categorizationFilters, customSettings,
modelSnapshotId); modelSnapshotId);
} }
@ -395,7 +395,7 @@ public class JobUpdate implements Writeable, ToXContent {
public static class Builder { public static class Builder {
private String description; private String description;
private List<DetectorUpdate> detectorUpdates; private List<DetectorUpdate> detectorUpdates;
private ModelDebugConfig modelDebugConfig; private ModelPlotConfig modelPlotConfig;
private AnalysisLimits analysisLimits; private AnalysisLimits analysisLimits;
private Long renormalizationWindowDays; private Long renormalizationWindowDays;
private TimeValue backgroundPersistInterval; private TimeValue backgroundPersistInterval;
@ -417,8 +417,8 @@ public class JobUpdate implements Writeable, ToXContent {
return this; return this;
} }
public Builder setModelDebugConfig(ModelDebugConfig modelDebugConfig) { public Builder setModelPlotConfig(ModelPlotConfig modelPlotConfig) {
this.modelDebugConfig = modelDebugConfig; this.modelPlotConfig = modelPlotConfig;
return this; return this;
} }
@ -463,7 +463,7 @@ public class JobUpdate implements Writeable, ToXContent {
} }
public JobUpdate build() { public JobUpdate build() {
return new JobUpdate(description, detectorUpdates, modelDebugConfig, analysisLimits, backgroundPersistInterval, return new JobUpdate(description, detectorUpdates, modelPlotConfig, analysisLimits, backgroundPersistInterval,
renormalizationWindowDays, resultsRetentionDays, modelSnapshotRetentionDays, categorizationFilters, customSettings, renormalizationWindowDays, resultsRetentionDays, modelSnapshotRetentionDays, categorizationFilters, customSettings,
modelSnapshotId); modelSnapshotId);
} }

View File

@ -16,14 +16,15 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
import java.io.IOException; import java.io.IOException;
import java.util.Objects; import java.util.Objects;
public class ModelDebugConfig extends ToXContentToBytes implements Writeable { public class ModelPlotConfig extends ToXContentToBytes implements Writeable {
private static final ParseField TYPE_FIELD = new ParseField("model_debug_config"); private static final ParseField TYPE_FIELD = new ParseField("model_plot_config");
private static final ParseField ENABLED_FIELD = new ParseField("enabled"); private static final ParseField ENABLED_FIELD = new ParseField("enabled");
public static final ParseField TERMS_FIELD = new ParseField("terms"); public static final ParseField TERMS_FIELD = new ParseField("terms");
public static final ConstructingObjectParser<ModelDebugConfig, Void> PARSER = new ConstructingObjectParser<>( public static final ConstructingObjectParser<ModelPlotConfig, Void> PARSER =
TYPE_FIELD.getPreferredName(), a -> new ModelDebugConfig((boolean) a[0], (String) a[1])); new ConstructingObjectParser<>(TYPE_FIELD.getPreferredName(),
a -> new ModelPlotConfig((boolean) a[0], (String) a[1]));
static { static {
PARSER.declareBoolean(ConstructingObjectParser.constructorArg(), ENABLED_FIELD); PARSER.declareBoolean(ConstructingObjectParser.constructorArg(), ENABLED_FIELD);
@ -33,20 +34,20 @@ public class ModelDebugConfig extends ToXContentToBytes implements Writeable {
private final boolean enabled; private final boolean enabled;
private final String terms; private final String terms;
public ModelDebugConfig() { public ModelPlotConfig() {
this(true, null); this(true, null);
} }
public ModelDebugConfig(boolean enabled) { public ModelPlotConfig(boolean enabled) {
this(false, null); this(false, null);
} }
public ModelDebugConfig(boolean enabled, String terms) { public ModelPlotConfig(boolean enabled, String terms) {
this.enabled = enabled; this.enabled = enabled;
this.terms = terms; this.terms = terms;
} }
public ModelDebugConfig(StreamInput in) throws IOException { public ModelPlotConfig(StreamInput in) throws IOException {
enabled = in.readBoolean(); enabled = in.readBoolean();
terms = in.readOptionalString(); terms = in.readOptionalString();
} }
@ -82,11 +83,11 @@ public class ModelDebugConfig extends ToXContentToBytes implements Writeable {
return true; return true;
} }
if (other instanceof ModelDebugConfig == false) { if (other instanceof ModelPlotConfig == false) {
return false; return false;
} }
ModelDebugConfig that = (ModelDebugConfig) other; ModelPlotConfig that = (ModelPlotConfig) other;
return this.enabled == that.enabled && Objects.equals(this.terms, that.terms); return this.enabled == that.enabled && Objects.equals(this.terms, that.terms);
} }

View File

@ -20,7 +20,7 @@ import org.elasticsearch.xpack.ml.job.results.BucketInfluencer;
import org.elasticsearch.xpack.ml.job.results.CategoryDefinition; import org.elasticsearch.xpack.ml.job.results.CategoryDefinition;
import org.elasticsearch.xpack.ml.job.results.Influence; import org.elasticsearch.xpack.ml.job.results.Influence;
import org.elasticsearch.xpack.ml.job.results.Influencer; import org.elasticsearch.xpack.ml.job.results.Influencer;
import org.elasticsearch.xpack.ml.job.results.ModelDebugOutput; import org.elasticsearch.xpack.ml.job.results.ModelPlot;
import org.elasticsearch.xpack.ml.job.results.PerPartitionMaxProbabilities; import org.elasticsearch.xpack.ml.job.results.PerPartitionMaxProbabilities;
import org.elasticsearch.xpack.ml.job.results.ReservedFieldNames; import org.elasticsearch.xpack.ml.job.results.ReservedFieldNames;
import org.elasticsearch.xpack.ml.job.results.Result; import org.elasticsearch.xpack.ml.job.results.Result;
@ -236,17 +236,17 @@ public class ElasticsearchMappings {
.endObject() .endObject()
.endObject() .endObject()
// Model Debug Output // Model Plot Output
.startObject(ModelDebugOutput.DEBUG_FEATURE.getPreferredName()) .startObject(ModelPlot.MODEL_FEATURE.getPreferredName())
.field(TYPE, KEYWORD) .field(TYPE, KEYWORD)
.endObject() .endObject()
.startObject(ModelDebugOutput.DEBUG_LOWER.getPreferredName()) .startObject(ModelPlot.MODEL_LOWER.getPreferredName())
.field(TYPE, DOUBLE) .field(TYPE, DOUBLE)
.endObject() .endObject()
.startObject(ModelDebugOutput.DEBUG_UPPER.getPreferredName()) .startObject(ModelPlot.MODEL_UPPER.getPreferredName())
.field(TYPE, DOUBLE) .field(TYPE, DOUBLE)
.endObject() .endObject()
.startObject(ModelDebugOutput.DEBUG_MEDIAN.getPreferredName()) .startObject(ModelPlot.MODEL_MEDIAN.getPreferredName())
.field(TYPE, DOUBLE) .field(TYPE, DOUBLE)
.endObject(); .endObject();

View File

@ -71,7 +71,7 @@ import org.elasticsearch.xpack.ml.job.results.AnomalyRecord;
import org.elasticsearch.xpack.ml.job.results.Bucket; import org.elasticsearch.xpack.ml.job.results.Bucket;
import org.elasticsearch.xpack.ml.job.results.CategoryDefinition; import org.elasticsearch.xpack.ml.job.results.CategoryDefinition;
import org.elasticsearch.xpack.ml.job.results.Influencer; import org.elasticsearch.xpack.ml.job.results.Influencer;
import org.elasticsearch.xpack.ml.job.results.ModelDebugOutput; import org.elasticsearch.xpack.ml.job.results.ModelPlot;
import org.elasticsearch.xpack.ml.job.results.PerPartitionMaxProbabilities; import org.elasticsearch.xpack.ml.job.results.PerPartitionMaxProbabilities;
import org.elasticsearch.xpack.ml.job.results.Result; import org.elasticsearch.xpack.ml.job.results.Result;
import org.elasticsearch.xpack.security.support.Exceptions; import org.elasticsearch.xpack.security.support.Exceptions;
@ -961,32 +961,32 @@ public class JobProvider {
stream.write(0); stream.write(0);
} }
public QueryPage<ModelDebugOutput> modelDebugOutput(String jobId, int from, int size) { public QueryPage<ModelPlot> modelPlot(String jobId, int from, int size) {
SearchResponse searchResponse; SearchResponse searchResponse;
String indexName = AnomalyDetectorsIndex.jobResultsAliasedName(jobId); String indexName = AnomalyDetectorsIndex.jobResultsAliasedName(jobId);
LOGGER.trace("ES API CALL: search result type {} from index {} from {}, size {}", LOGGER.trace("ES API CALL: search result type {} from index {} from {}, size {}",
ModelDebugOutput.RESULT_TYPE_VALUE, indexName, from, size); ModelPlot.RESULT_TYPE_VALUE, indexName, from, size);
searchResponse = client.prepareSearch(indexName) searchResponse = client.prepareSearch(indexName)
.setIndicesOptions(addIgnoreUnavailable(SearchRequest.DEFAULT_INDICES_OPTIONS)) .setIndicesOptions(addIgnoreUnavailable(SearchRequest.DEFAULT_INDICES_OPTIONS))
.setTypes(Result.TYPE.getPreferredName()) .setTypes(Result.TYPE.getPreferredName())
.setQuery(new TermsQueryBuilder(Result.RESULT_TYPE.getPreferredName(), ModelDebugOutput.RESULT_TYPE_VALUE)) .setQuery(new TermsQueryBuilder(Result.RESULT_TYPE.getPreferredName(), ModelPlot.RESULT_TYPE_VALUE))
.setFrom(from).setSize(size) .setFrom(from).setSize(size)
.get(); .get();
List<ModelDebugOutput> results = new ArrayList<>(); List<ModelPlot> results = new ArrayList<>();
for (SearchHit hit : searchResponse.getHits().getHits()) { for (SearchHit hit : searchResponse.getHits().getHits()) {
BytesReference source = hit.getSourceRef(); BytesReference source = hit.getSourceRef();
try (XContentParser parser = XContentFactory.xContent(source).createParser(NamedXContentRegistry.EMPTY, source)) { try (XContentParser parser = XContentFactory.xContent(source).createParser(NamedXContentRegistry.EMPTY, source)) {
ModelDebugOutput modelDebugOutput = ModelDebugOutput.PARSER.apply(parser, null); ModelPlot modelPlot = ModelPlot.PARSER.apply(parser, null);
results.add(modelDebugOutput); results.add(modelPlot);
} catch (IOException e) { } catch (IOException e) {
throw new ElasticsearchParseException("failed to parse modelDebugOutput", e); throw new ElasticsearchParseException("failed to parse modelPlot", e);
} }
} }
return new QueryPage<>(results, searchResponse.getHits().getTotalHits(), ModelDebugOutput.RESULTS_FIELD); return new QueryPage<>(results, searchResponse.getHits().getTotalHits(), ModelPlot.RESULTS_FIELD);
} }
/** /**

View File

@ -25,7 +25,7 @@ import org.elasticsearch.xpack.ml.job.results.Bucket;
import org.elasticsearch.xpack.ml.job.results.BucketInfluencer; import org.elasticsearch.xpack.ml.job.results.BucketInfluencer;
import org.elasticsearch.xpack.ml.job.results.CategoryDefinition; import org.elasticsearch.xpack.ml.job.results.CategoryDefinition;
import org.elasticsearch.xpack.ml.job.results.Influencer; import org.elasticsearch.xpack.ml.job.results.Influencer;
import org.elasticsearch.xpack.ml.job.results.ModelDebugOutput; import org.elasticsearch.xpack.ml.job.results.ModelPlot;
import org.elasticsearch.xpack.ml.job.results.PerPartitionMaxProbabilities; import org.elasticsearch.xpack.ml.job.results.PerPartitionMaxProbabilities;
import org.elasticsearch.xpack.ml.job.results.Result; import org.elasticsearch.xpack.ml.job.results.Result;
@ -270,11 +270,11 @@ public class JobResultsPersister extends AbstractComponent {
} }
/** /**
* Persist model debug output * Persist model plot output
*/ */
public void persistModelDebugOutput(ModelDebugOutput modelDebugOutput) { public void persistModelPlot(ModelPlot modelPlot) {
Persistable persistable = new Persistable(modelDebugOutput.getJobId(), modelDebugOutput, Result.TYPE.getPreferredName(), null); Persistable persistable = new Persistable(modelPlot.getJobId(), modelPlot, Result.TYPE.getPreferredName(), null);
persistable.persist(AnomalyDetectorsIndex.jobResultsAliasedName(modelDebugOutput.getJobId())); persistable.persist(AnomalyDetectorsIndex.jobResultsAliasedName(modelPlot.getJobId()));
// Don't commit as we expect masses of these updates and they're not // Don't commit as we expect masses of these updates and they're not
// read again by this process // read again by this process
} }

View File

@ -10,13 +10,13 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.Environment; import org.elasticsearch.env.Environment;
import org.elasticsearch.xpack.ml.job.config.AnalysisLimits; import org.elasticsearch.xpack.ml.job.config.AnalysisLimits;
import org.elasticsearch.xpack.ml.job.config.Job; import org.elasticsearch.xpack.ml.job.config.Job;
import org.elasticsearch.xpack.ml.job.config.ModelDebugConfig; import org.elasticsearch.xpack.ml.job.config.ModelPlotConfig;
import org.elasticsearch.xpack.ml.job.process.NativeController; import org.elasticsearch.xpack.ml.job.process.NativeController;
import org.elasticsearch.xpack.ml.job.process.ProcessCtrl; import org.elasticsearch.xpack.ml.job.process.ProcessCtrl;
import org.elasticsearch.xpack.ml.job.process.ProcessPipes; import org.elasticsearch.xpack.ml.job.process.ProcessPipes;
import org.elasticsearch.xpack.ml.job.process.autodetect.writer.AnalysisLimitsWriter; import org.elasticsearch.xpack.ml.job.process.autodetect.writer.AnalysisLimitsWriter;
import org.elasticsearch.xpack.ml.job.process.autodetect.writer.FieldConfigWriter; import org.elasticsearch.xpack.ml.job.process.autodetect.writer.FieldConfigWriter;
import org.elasticsearch.xpack.ml.job.process.autodetect.writer.ModelDebugConfigWriter; import org.elasticsearch.xpack.ml.job.process.autodetect.writer.ModelPlotConfigWriter;
import org.elasticsearch.xpack.ml.job.process.autodetect.state.Quantiles; import org.elasticsearch.xpack.ml.job.process.autodetect.state.Quantiles;
import org.elasticsearch.xpack.ml.job.config.MlFilter; import org.elasticsearch.xpack.ml.job.config.MlFilter;
@ -37,7 +37,7 @@ import java.util.concurrent.TimeoutException;
public class AutodetectBuilder { public class AutodetectBuilder {
private static final String CONF_EXTENSION = ".conf"; private static final String CONF_EXTENSION = ".conf";
private static final String LIMIT_CONFIG_ARG = "--limitconfig="; private static final String LIMIT_CONFIG_ARG = "--limitconfig=";
private static final String MODEL_DEBUG_CONFIG_ARG = "--modeldebugconfig="; private static final String MODEL_PLOT_CONFIG_ARG = "--modelplotconfig=";
private static final String FIELD_CONFIG_ARG = "--fieldconfig="; private static final String FIELD_CONFIG_ARG = "--fieldconfig=";
private Job job; private Job job;
@ -106,7 +106,7 @@ public class AutodetectBuilder {
List<String> command = ProcessCtrl.buildAutodetectCommand(env, settings, job, logger, ignoreDowntime, controller.getPid()); List<String> command = ProcessCtrl.buildAutodetectCommand(env, settings, job, logger, ignoreDowntime, controller.getPid());
buildLimits(command); buildLimits(command);
buildModelDebugConfig(command); buildModelPlotConfig(command);
buildQuantiles(command); buildQuantiles(command);
buildFieldConfig(command); buildFieldConfig(command);
@ -134,22 +134,22 @@ public class AutodetectBuilder {
} }
} }
private void buildModelDebugConfig(List<String> command) throws IOException { private void buildModelPlotConfig(List<String> command) throws IOException {
if (job.getModelDebugConfig() != null) { if (job.getModelPlotConfig() != null) {
Path modelDebugConfigFile = Files.createTempFile(env.tmpFile(), "modeldebugconfig", CONF_EXTENSION); Path modelPlotConfigFile = Files.createTempFile(env.tmpFile(), "modelplotconfig", CONF_EXTENSION);
filesToDelete.add(modelDebugConfigFile); filesToDelete.add(modelPlotConfigFile);
writeModelDebugConfig(job.getModelDebugConfig(), modelDebugConfigFile); writeModelPlotConfig(job.getModelPlotConfig(), modelPlotConfigFile);
String modelDebugConfig = MODEL_DEBUG_CONFIG_ARG + modelDebugConfigFile.toString(); String modelPlotConfig = MODEL_PLOT_CONFIG_ARG + modelPlotConfigFile.toString();
command.add(modelDebugConfig); command.add(modelPlotConfig);
} }
} }
private static void writeModelDebugConfig(ModelDebugConfig config, Path emptyConfFile) private static void writeModelPlotConfig(ModelPlotConfig config, Path emptyConfFile)
throws IOException { throws IOException {
try (OutputStreamWriter osw = new OutputStreamWriter( try (OutputStreamWriter osw = new OutputStreamWriter(
Files.newOutputStream(emptyConfFile), Files.newOutputStream(emptyConfFile),
StandardCharsets.UTF_8)) { StandardCharsets.UTF_8)) {
new ModelDebugConfigWriter(config, osw).write(); new ModelPlotConfigWriter(config, osw).write();
} }
} }

View File

@ -15,7 +15,7 @@ import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.xpack.ml.job.config.DataDescription; import org.elasticsearch.xpack.ml.job.config.DataDescription;
import org.elasticsearch.xpack.ml.job.config.DetectionRule; import org.elasticsearch.xpack.ml.job.config.DetectionRule;
import org.elasticsearch.xpack.ml.job.config.Job; import org.elasticsearch.xpack.ml.job.config.Job;
import org.elasticsearch.xpack.ml.job.config.ModelDebugConfig; import org.elasticsearch.xpack.ml.job.config.ModelPlotConfig;
import org.elasticsearch.xpack.ml.job.messages.Messages; import org.elasticsearch.xpack.ml.job.messages.Messages;
import org.elasticsearch.xpack.ml.job.process.CountingInputStream; import org.elasticsearch.xpack.ml.job.process.CountingInputStream;
import org.elasticsearch.xpack.ml.job.process.DataCountsReporter; import org.elasticsearch.xpack.ml.job.process.DataCountsReporter;
@ -111,9 +111,9 @@ public class AutodetectCommunicator implements Closeable {
} }
public void writeUpdateModelDebugMessage(ModelDebugConfig config) throws IOException { public void writeUpdateModelPlotMessage(ModelPlotConfig config) throws IOException {
checkAndRun(() -> Messages.getMessage(Messages.JOB_DATA_CONCURRENT_USE_UPDATE, job.getId()), () -> { checkAndRun(() -> Messages.getMessage(Messages.JOB_DATA_CONCURRENT_USE_UPDATE, job.getId()), () -> {
autodetectProcess.writeUpdateModelDebugMessage(config); autodetectProcess.writeUpdateModelPlotMessage(config);
return null; return null;
}, false); }, false);
} }

View File

@ -6,7 +6,7 @@
package org.elasticsearch.xpack.ml.job.process.autodetect; package org.elasticsearch.xpack.ml.job.process.autodetect;
import org.elasticsearch.xpack.ml.job.config.DetectionRule; import org.elasticsearch.xpack.ml.job.config.DetectionRule;
import org.elasticsearch.xpack.ml.job.config.ModelDebugConfig; import org.elasticsearch.xpack.ml.job.config.ModelPlotConfig;
import org.elasticsearch.xpack.ml.job.process.autodetect.params.DataLoadParams; import org.elasticsearch.xpack.ml.job.process.autodetect.params.DataLoadParams;
import org.elasticsearch.xpack.ml.job.process.autodetect.params.InterimResultsParams; import org.elasticsearch.xpack.ml.job.process.autodetect.params.InterimResultsParams;
import org.elasticsearch.xpack.ml.job.results.AutodetectResult; import org.elasticsearch.xpack.ml.job.results.AutodetectResult;
@ -41,12 +41,12 @@ public interface AutodetectProcess extends Closeable {
void writeResetBucketsControlMessage(DataLoadParams params) throws IOException; void writeResetBucketsControlMessage(DataLoadParams params) throws IOException;
/** /**
* Update the model debug configuration * Update the model plot configuration
* *
* @param modelDebugConfig New model debug config * @param modelPlotConfig New model plot config
* @throws IOException If the write fails * @throws IOException If the write fails
*/ */
void writeUpdateModelDebugMessage(ModelDebugConfig modelDebugConfig) throws IOException; void writeUpdateModelPlotMessage(ModelPlotConfig modelPlotConfig) throws IOException;
/** /**
* Write message to update the detector rules * Write message to update the detector rules

View File

@ -23,7 +23,7 @@ import org.elasticsearch.xpack.ml.job.config.Job;
import org.elasticsearch.xpack.ml.job.config.JobState; import org.elasticsearch.xpack.ml.job.config.JobState;
import org.elasticsearch.xpack.ml.job.config.JobUpdate; import org.elasticsearch.xpack.ml.job.config.JobUpdate;
import org.elasticsearch.xpack.ml.job.config.MlFilter; import org.elasticsearch.xpack.ml.job.config.MlFilter;
import org.elasticsearch.xpack.ml.job.config.ModelDebugConfig; import org.elasticsearch.xpack.ml.job.config.ModelPlotConfig;
import org.elasticsearch.xpack.ml.job.persistence.JobDataCountsPersister; import org.elasticsearch.xpack.ml.job.persistence.JobDataCountsPersister;
import org.elasticsearch.xpack.ml.job.persistence.JobProvider; import org.elasticsearch.xpack.ml.job.persistence.JobProvider;
import org.elasticsearch.xpack.ml.job.persistence.JobRenormalizedResultsPersister; import org.elasticsearch.xpack.ml.job.persistence.JobRenormalizedResultsPersister;
@ -174,7 +174,7 @@ public class AutodetectProcessManager extends AbstractComponent {
} }
} }
public void writeUpdateProcessMessage(String jobId, List<JobUpdate.DetectorUpdate> updates, ModelDebugConfig config) public void writeUpdateProcessMessage(String jobId, List<JobUpdate.DetectorUpdate> updates, ModelPlotConfig config)
throws IOException { throws IOException {
AutodetectCommunicator communicator = autoDetectCommunicatorByJob.get(jobId); AutodetectCommunicator communicator = autoDetectCommunicatorByJob.get(jobId);
if (communicator == null) { if (communicator == null) {
@ -183,7 +183,7 @@ public class AutodetectProcessManager extends AbstractComponent {
} }
if (config != null) { if (config != null) {
communicator.writeUpdateModelDebugMessage(config); communicator.writeUpdateModelPlotMessage(config);
} }
if (updates != null) { if (updates != null) {

View File

@ -6,7 +6,7 @@
package org.elasticsearch.xpack.ml.job.process.autodetect; package org.elasticsearch.xpack.ml.job.process.autodetect;
import org.elasticsearch.xpack.ml.job.config.DetectionRule; import org.elasticsearch.xpack.ml.job.config.DetectionRule;
import org.elasticsearch.xpack.ml.job.config.ModelDebugConfig; import org.elasticsearch.xpack.ml.job.config.ModelPlotConfig;
import org.elasticsearch.xpack.ml.job.process.autodetect.output.FlushAcknowledgement; import org.elasticsearch.xpack.ml.job.process.autodetect.output.FlushAcknowledgement;
import org.elasticsearch.xpack.ml.job.process.autodetect.params.DataLoadParams; import org.elasticsearch.xpack.ml.job.process.autodetect.params.DataLoadParams;
import org.elasticsearch.xpack.ml.job.process.autodetect.params.InterimResultsParams; import org.elasticsearch.xpack.ml.job.process.autodetect.params.InterimResultsParams;
@ -48,7 +48,7 @@ public class BlackHoleAutodetectProcess implements AutodetectProcess {
} }
@Override @Override
public void writeUpdateModelDebugMessage(ModelDebugConfig modelDebugConfig) throws IOException { public void writeUpdateModelPlotMessage(ModelPlotConfig modelPlotConfig) throws IOException {
} }
@Override @Override

View File

@ -9,7 +9,7 @@ import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.ParameterizedMessage; import org.apache.logging.log4j.message.ParameterizedMessage;
import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.xpack.ml.job.config.DetectionRule; import org.elasticsearch.xpack.ml.job.config.DetectionRule;
import org.elasticsearch.xpack.ml.job.config.ModelDebugConfig; import org.elasticsearch.xpack.ml.job.config.ModelPlotConfig;
import org.elasticsearch.xpack.ml.job.process.autodetect.output.AutodetectResultsParser; import org.elasticsearch.xpack.ml.job.process.autodetect.output.AutodetectResultsParser;
import org.elasticsearch.xpack.ml.job.process.autodetect.output.StateProcessor; import org.elasticsearch.xpack.ml.job.process.autodetect.output.StateProcessor;
import org.elasticsearch.xpack.ml.job.process.autodetect.params.DataLoadParams; import org.elasticsearch.xpack.ml.job.process.autodetect.params.DataLoadParams;
@ -91,9 +91,9 @@ class NativeAutodetectProcess implements AutodetectProcess {
} }
@Override @Override
public void writeUpdateModelDebugMessage(ModelDebugConfig modelDebugConfig) throws IOException { public void writeUpdateModelPlotMessage(ModelPlotConfig modelPlotConfig) throws IOException {
ControlMsgToProcessWriter writer = new ControlMsgToProcessWriter(recordWriter, numberOfAnalysisFields); ControlMsgToProcessWriter writer = new ControlMsgToProcessWriter(recordWriter, numberOfAnalysisFields);
writer.writeUpdateModelDebugMessage(modelDebugConfig); writer.writeUpdateModelPlotMessage(modelPlotConfig);
} }
@Override @Override

View File

@ -25,7 +25,7 @@ import org.elasticsearch.xpack.ml.job.results.AutodetectResult;
import org.elasticsearch.xpack.ml.job.results.Bucket; import org.elasticsearch.xpack.ml.job.results.Bucket;
import org.elasticsearch.xpack.ml.job.results.CategoryDefinition; import org.elasticsearch.xpack.ml.job.results.CategoryDefinition;
import org.elasticsearch.xpack.ml.job.results.Influencer; import org.elasticsearch.xpack.ml.job.results.Influencer;
import org.elasticsearch.xpack.ml.job.results.ModelDebugOutput; import org.elasticsearch.xpack.ml.job.results.ModelPlot;
import org.elasticsearch.xpack.ml.job.results.PerPartitionMaxProbabilities; import org.elasticsearch.xpack.ml.job.results.PerPartitionMaxProbabilities;
import java.time.Duration; import java.time.Duration;
@ -143,9 +143,9 @@ public class AutoDetectResultProcessor {
if (categoryDefinition != null) { if (categoryDefinition != null) {
persister.persistCategoryDefinition(categoryDefinition); persister.persistCategoryDefinition(categoryDefinition);
} }
ModelDebugOutput modelDebugOutput = result.getModelDebugOutput(); ModelPlot modelPlot = result.getModelPlot();
if (modelDebugOutput != null) { if (modelPlot != null) {
persister.persistModelDebugOutput(modelDebugOutput); persister.persistModelPlot(modelPlot);
} }
ModelSizeStats modelSizeStats = result.getModelSizeStats(); ModelSizeStats modelSizeStats = result.getModelSizeStats();
if (modelSizeStats != null) { if (modelSizeStats != null) {

View File

@ -18,7 +18,7 @@ import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.json.JsonXContent; import org.elasticsearch.common.xcontent.json.JsonXContent;
import org.elasticsearch.xpack.ml.job.config.DetectionRule; import org.elasticsearch.xpack.ml.job.config.DetectionRule;
import org.elasticsearch.xpack.ml.job.config.ModelDebugConfig; import org.elasticsearch.xpack.ml.job.config.ModelPlotConfig;
import org.elasticsearch.xpack.ml.job.process.autodetect.params.DataLoadParams; import org.elasticsearch.xpack.ml.job.process.autodetect.params.DataLoadParams;
import org.elasticsearch.xpack.ml.job.process.autodetect.params.InterimResultsParams; import org.elasticsearch.xpack.ml.job.process.autodetect.params.InterimResultsParams;
@ -149,10 +149,10 @@ public class ControlMsgToProcessWriter {
writeMessage(message.toString()); writeMessage(message.toString());
} }
public void writeUpdateModelDebugMessage(ModelDebugConfig modelDebugConfig) throws IOException { public void writeUpdateModelPlotMessage(ModelPlotConfig modelPlotConfig) throws IOException {
StringWriter configWriter = new StringWriter(); StringWriter configWriter = new StringWriter();
configWriter.append(UPDATE_MESSAGE_CODE).append("[modelDebugConfig]\n"); configWriter.append(UPDATE_MESSAGE_CODE).append("[modelPlotConfig]\n");
new ModelDebugConfigWriter(modelDebugConfig, configWriter).write(); new ModelPlotConfigWriter(modelPlotConfig, configWriter).write();
writeMessage(configWriter.toString()); writeMessage(configWriter.toString());
} }

View File

@ -5,7 +5,7 @@
*/ */
package org.elasticsearch.xpack.ml.job.process.autodetect.writer; package org.elasticsearch.xpack.ml.job.process.autodetect.writer;
import org.elasticsearch.xpack.ml.job.config.ModelDebugConfig; import org.elasticsearch.xpack.ml.job.config.ModelPlotConfig;
import java.io.IOException; import java.io.IOException;
import java.io.Writer; import java.io.Writer;
@ -14,16 +14,16 @@ import java.util.Objects;
import static org.elasticsearch.xpack.ml.job.process.autodetect.writer.WriterConstants.EQUALS; import static org.elasticsearch.xpack.ml.job.process.autodetect.writer.WriterConstants.EQUALS;
import static org.elasticsearch.xpack.ml.job.process.autodetect.writer.WriterConstants.NEW_LINE; import static org.elasticsearch.xpack.ml.job.process.autodetect.writer.WriterConstants.NEW_LINE;
public class ModelDebugConfigWriter { public class ModelPlotConfigWriter {
private static final double BOUNDS_PERCENTILE_DEFAULT = 95.0; private static final double BOUNDS_PERCENTILE_DEFAULT = 95.0;
private static final double BOUNDS_PERCENTILE_DISABLE_VALUE = -1.0; private static final double BOUNDS_PERCENTILE_DISABLE_VALUE = -1.0;
private final ModelDebugConfig modelDebugConfig; private final ModelPlotConfig modelPlotConfig;
private final Writer writer; private final Writer writer;
public ModelDebugConfigWriter(ModelDebugConfig modelDebugConfig, Writer writer) { public ModelPlotConfigWriter(ModelPlotConfig modelPlotConfig, Writer writer) {
this.modelDebugConfig = Objects.requireNonNull(modelDebugConfig); this.modelPlotConfig = Objects.requireNonNull(modelPlotConfig);
this.writer = Objects.requireNonNull(writer); this.writer = Objects.requireNonNull(writer);
} }
@ -32,11 +32,12 @@ public class ModelDebugConfigWriter {
contents.append("boundspercentile") contents.append("boundspercentile")
.append(EQUALS) .append(EQUALS)
.append(modelDebugConfig.isEnabled() ? BOUNDS_PERCENTILE_DEFAULT : BOUNDS_PERCENTILE_DISABLE_VALUE) .append(modelPlotConfig.isEnabled() ?
BOUNDS_PERCENTILE_DEFAULT : BOUNDS_PERCENTILE_DISABLE_VALUE)
.append(NEW_LINE); .append(NEW_LINE);
String terms = modelDebugConfig.getTerms(); String terms = modelPlotConfig.getTerms();
contents.append(ModelDebugConfig.TERMS_FIELD.getPreferredName()) contents.append(ModelPlotConfig.TERMS_FIELD.getPreferredName())
.append(EQUALS) .append(EQUALS)
.append(terms == null ? "" : terms) .append(terms == null ? "" : terms)
.append(NEW_LINE); .append(NEW_LINE);

View File

@ -30,7 +30,7 @@ public class AutodetectResult extends ToXContentToBytes implements Writeable {
public static final ConstructingObjectParser<AutodetectResult, Void> PARSER = new ConstructingObjectParser<>( public static final ConstructingObjectParser<AutodetectResult, Void> PARSER = new ConstructingObjectParser<>(
TYPE.getPreferredName(), a -> new AutodetectResult((Bucket) a[0], (List<AnomalyRecord>) a[1], (List<Influencer>) a[2], TYPE.getPreferredName(), a -> new AutodetectResult((Bucket) a[0], (List<AnomalyRecord>) a[1], (List<Influencer>) a[2],
(Quantiles) a[3], (ModelSnapshot) a[4], a[5] == null ? null : ((ModelSizeStats.Builder) a[5]).build(), (Quantiles) a[3], (ModelSnapshot) a[4], a[5] == null ? null : ((ModelSizeStats.Builder) a[5]).build(),
(ModelDebugOutput) a[6], (CategoryDefinition) a[7], (FlushAcknowledgement) a[8])); (ModelPlot) a[6], (CategoryDefinition) a[7], (FlushAcknowledgement) a[8]));
static { static {
PARSER.declareObject(ConstructingObjectParser.optionalConstructorArg(), Bucket.PARSER, Bucket.RESULT_TYPE_FIELD); PARSER.declareObject(ConstructingObjectParser.optionalConstructorArg(), Bucket.PARSER, Bucket.RESULT_TYPE_FIELD);
@ -40,7 +40,7 @@ public class AutodetectResult extends ToXContentToBytes implements Writeable {
PARSER.declareObject(ConstructingObjectParser.optionalConstructorArg(), ModelSnapshot.PARSER, ModelSnapshot.TYPE); PARSER.declareObject(ConstructingObjectParser.optionalConstructorArg(), ModelSnapshot.PARSER, ModelSnapshot.TYPE);
PARSER.declareObject(ConstructingObjectParser.optionalConstructorArg(), ModelSizeStats.PARSER, PARSER.declareObject(ConstructingObjectParser.optionalConstructorArg(), ModelSizeStats.PARSER,
ModelSizeStats.RESULT_TYPE_FIELD); ModelSizeStats.RESULT_TYPE_FIELD);
PARSER.declareObject(ConstructingObjectParser.optionalConstructorArg(), ModelDebugOutput.PARSER, ModelDebugOutput.RESULTS_FIELD); PARSER.declareObject(ConstructingObjectParser.optionalConstructorArg(), ModelPlot.PARSER, ModelPlot.RESULTS_FIELD);
PARSER.declareObject(ConstructingObjectParser.optionalConstructorArg(), CategoryDefinition.PARSER, CategoryDefinition.TYPE); PARSER.declareObject(ConstructingObjectParser.optionalConstructorArg(), CategoryDefinition.PARSER, CategoryDefinition.TYPE);
PARSER.declareObject(ConstructingObjectParser.optionalConstructorArg(), FlushAcknowledgement.PARSER, FlushAcknowledgement.TYPE); PARSER.declareObject(ConstructingObjectParser.optionalConstructorArg(), FlushAcknowledgement.PARSER, FlushAcknowledgement.TYPE);
} }
@ -51,12 +51,12 @@ public class AutodetectResult extends ToXContentToBytes implements Writeable {
private final Quantiles quantiles; private final Quantiles quantiles;
private final ModelSnapshot modelSnapshot; private final ModelSnapshot modelSnapshot;
private final ModelSizeStats modelSizeStats; private final ModelSizeStats modelSizeStats;
private final ModelDebugOutput modelDebugOutput; private final ModelPlot modelPlot;
private final CategoryDefinition categoryDefinition; private final CategoryDefinition categoryDefinition;
private final FlushAcknowledgement flushAcknowledgement; private final FlushAcknowledgement flushAcknowledgement;
public AutodetectResult(Bucket bucket, List<AnomalyRecord> records, List<Influencer> influencers, Quantiles quantiles, public AutodetectResult(Bucket bucket, List<AnomalyRecord> records, List<Influencer> influencers, Quantiles quantiles,
ModelSnapshot modelSnapshot, ModelSizeStats modelSizeStats, ModelDebugOutput modelDebugOutput, ModelSnapshot modelSnapshot, ModelSizeStats modelSizeStats, ModelPlot modelPlot,
CategoryDefinition categoryDefinition, FlushAcknowledgement flushAcknowledgement) { CategoryDefinition categoryDefinition, FlushAcknowledgement flushAcknowledgement) {
this.bucket = bucket; this.bucket = bucket;
this.records = records; this.records = records;
@ -64,7 +64,7 @@ public class AutodetectResult extends ToXContentToBytes implements Writeable {
this.quantiles = quantiles; this.quantiles = quantiles;
this.modelSnapshot = modelSnapshot; this.modelSnapshot = modelSnapshot;
this.modelSizeStats = modelSizeStats; this.modelSizeStats = modelSizeStats;
this.modelDebugOutput = modelDebugOutput; this.modelPlot = modelPlot;
this.categoryDefinition = categoryDefinition; this.categoryDefinition = categoryDefinition;
this.flushAcknowledgement = flushAcknowledgement; this.flushAcknowledgement = flushAcknowledgement;
} }
@ -101,9 +101,9 @@ public class AutodetectResult extends ToXContentToBytes implements Writeable {
this.modelSizeStats = null; this.modelSizeStats = null;
} }
if (in.readBoolean()) { if (in.readBoolean()) {
this.modelDebugOutput = new ModelDebugOutput(in); this.modelPlot = new ModelPlot(in);
} else { } else {
this.modelDebugOutput = null; this.modelPlot = null;
} }
if (in.readBoolean()) { if (in.readBoolean()) {
this.categoryDefinition = new CategoryDefinition(in); this.categoryDefinition = new CategoryDefinition(in);
@ -125,7 +125,7 @@ public class AutodetectResult extends ToXContentToBytes implements Writeable {
writeNullable(quantiles, out); writeNullable(quantiles, out);
writeNullable(modelSnapshot, out); writeNullable(modelSnapshot, out);
writeNullable(modelSizeStats, out); writeNullable(modelSizeStats, out);
writeNullable(modelDebugOutput, out); writeNullable(modelPlot, out);
writeNullable(categoryDefinition, out); writeNullable(categoryDefinition, out);
writeNullable(flushAcknowledgement, out); writeNullable(flushAcknowledgement, out);
} }
@ -155,7 +155,7 @@ public class AutodetectResult extends ToXContentToBytes implements Writeable {
addNullableField(Quantiles.TYPE, quantiles, builder); addNullableField(Quantiles.TYPE, quantiles, builder);
addNullableField(ModelSnapshot.TYPE, modelSnapshot, builder); addNullableField(ModelSnapshot.TYPE, modelSnapshot, builder);
addNullableField(ModelSizeStats.RESULT_TYPE_FIELD, modelSizeStats, builder); addNullableField(ModelSizeStats.RESULT_TYPE_FIELD, modelSizeStats, builder);
addNullableField(ModelDebugOutput.RESULTS_FIELD, modelDebugOutput, builder); addNullableField(ModelPlot.RESULTS_FIELD, modelPlot, builder);
addNullableField(CategoryDefinition.TYPE, categoryDefinition, builder); addNullableField(CategoryDefinition.TYPE, categoryDefinition, builder);
addNullableField(FlushAcknowledgement.TYPE, flushAcknowledgement, builder); addNullableField(FlushAcknowledgement.TYPE, flushAcknowledgement, builder);
builder.endObject(); builder.endObject();
@ -198,8 +198,8 @@ public class AutodetectResult extends ToXContentToBytes implements Writeable {
return modelSizeStats; return modelSizeStats;
} }
public ModelDebugOutput getModelDebugOutput() { public ModelPlot getModelPlot() {
return modelDebugOutput; return modelPlot;
} }
public CategoryDefinition getCategoryDefinition() { public CategoryDefinition getCategoryDefinition() {
@ -212,7 +212,7 @@ public class AutodetectResult extends ToXContentToBytes implements Writeable {
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(bucket, records, influencers, categoryDefinition, flushAcknowledgement, modelDebugOutput, modelSizeStats, return Objects.hash(bucket, records, influencers, categoryDefinition, flushAcknowledgement, modelPlot, modelSizeStats,
modelSnapshot, quantiles); modelSnapshot, quantiles);
} }
@ -230,7 +230,7 @@ public class AutodetectResult extends ToXContentToBytes implements Writeable {
Objects.equals(influencers, other.influencers) && Objects.equals(influencers, other.influencers) &&
Objects.equals(categoryDefinition, other.categoryDefinition) && Objects.equals(categoryDefinition, other.categoryDefinition) &&
Objects.equals(flushAcknowledgement, other.flushAcknowledgement) && Objects.equals(flushAcknowledgement, other.flushAcknowledgement) &&
Objects.equals(modelDebugOutput, other.modelDebugOutput) && Objects.equals(modelPlot, other.modelPlot) &&
Objects.equals(modelSizeStats, other.modelSizeStats) && Objects.equals(modelSizeStats, other.modelSizeStats) &&
Objects.equals(modelSnapshot, other.modelSnapshot) && Objects.equals(modelSnapshot, other.modelSnapshot) &&
Objects.equals(quantiles, other.quantiles); Objects.equals(quantiles, other.quantiles);

View File

@ -22,16 +22,13 @@ import java.util.Date;
import java.util.Objects; import java.util.Objects;
/** /**
* Model Debug POJO. * Model Plot POJO.
* Some of the fields being with the word "debug". This avoids creation of
* reserved words that are likely to clash with fields in the input data (due to
* the restrictions on Elasticsearch mappings).
*/ */
public class ModelDebugOutput extends ToXContentToBytes implements Writeable { public class ModelPlot extends ToXContentToBytes implements Writeable {
/** /**
* Result type * Result type
*/ */
public static final String RESULT_TYPE_VALUE = "model_debug_output"; public static final String RESULT_TYPE_VALUE = "model_plot";
public static final ParseField RESULTS_FIELD = new ParseField(RESULT_TYPE_VALUE); public static final ParseField RESULTS_FIELD = new ParseField(RESULT_TYPE_VALUE);
public static final ParseField PARTITION_FIELD_NAME = new ParseField("partition_field_name"); public static final ParseField PARTITION_FIELD_NAME = new ParseField("partition_field_name");
@ -40,19 +37,19 @@ public class ModelDebugOutput extends ToXContentToBytes implements Writeable {
public static final ParseField OVER_FIELD_VALUE = new ParseField("over_field_value"); public static final ParseField OVER_FIELD_VALUE = new ParseField("over_field_value");
public static final ParseField BY_FIELD_NAME = new ParseField("by_field_name"); public static final ParseField BY_FIELD_NAME = new ParseField("by_field_name");
public static final ParseField BY_FIELD_VALUE = new ParseField("by_field_value"); public static final ParseField BY_FIELD_VALUE = new ParseField("by_field_value");
public static final ParseField DEBUG_FEATURE = new ParseField("debug_feature"); public static final ParseField MODEL_FEATURE = new ParseField("model_feature");
public static final ParseField DEBUG_LOWER = new ParseField("debug_lower"); public static final ParseField MODEL_LOWER = new ParseField("model_lower");
public static final ParseField DEBUG_UPPER = new ParseField("debug_upper"); public static final ParseField MODEL_UPPER = new ParseField("model_upper");
public static final ParseField DEBUG_MEDIAN = new ParseField("debug_median"); public static final ParseField MODEL_MEDIAN = new ParseField("model_median");
public static final ParseField ACTUAL = new ParseField("actual"); public static final ParseField ACTUAL = new ParseField("actual");
public static final ConstructingObjectParser<ModelDebugOutput, Void> PARSER = public static final ConstructingObjectParser<ModelPlot, Void> PARSER =
new ConstructingObjectParser<>(RESULT_TYPE_VALUE, a -> new ModelDebugOutput((String) a[0])); new ConstructingObjectParser<>(RESULT_TYPE_VALUE, a -> new ModelPlot((String) a[0]));
static { static {
PARSER.declareString(ConstructingObjectParser.constructorArg(), Job.ID); PARSER.declareString(ConstructingObjectParser.constructorArg(), Job.ID);
PARSER.declareString((modelDebugOutput, s) -> {}, Result.RESULT_TYPE); PARSER.declareString((modelPlot, s) -> {}, Result.RESULT_TYPE);
PARSER.declareField(ModelDebugOutput::setTimestamp, p -> { PARSER.declareField(ModelPlot::setTimestamp, p -> {
if (p.currentToken() == Token.VALUE_NUMBER) { if (p.currentToken() == Token.VALUE_NUMBER) {
return new Date(p.longValue()); return new Date(p.longValue());
} else if (p.currentToken() == Token.VALUE_STRING) { } else if (p.currentToken() == Token.VALUE_STRING) {
@ -61,17 +58,17 @@ public class ModelDebugOutput extends ToXContentToBytes implements Writeable {
throw new IllegalArgumentException("unexpected token [" + p.currentToken() + "] for [" throw new IllegalArgumentException("unexpected token [" + p.currentToken() + "] for ["
+ Result.TIMESTAMP.getPreferredName() + "]"); + Result.TIMESTAMP.getPreferredName() + "]");
}, Result.TIMESTAMP, ValueType.VALUE); }, Result.TIMESTAMP, ValueType.VALUE);
PARSER.declareString(ModelDebugOutput::setPartitionFieldName, PARTITION_FIELD_NAME); PARSER.declareString(ModelPlot::setPartitionFieldName, PARTITION_FIELD_NAME);
PARSER.declareString(ModelDebugOutput::setPartitionFieldValue, PARTITION_FIELD_VALUE); PARSER.declareString(ModelPlot::setPartitionFieldValue, PARTITION_FIELD_VALUE);
PARSER.declareString(ModelDebugOutput::setOverFieldName, OVER_FIELD_NAME); PARSER.declareString(ModelPlot::setOverFieldName, OVER_FIELD_NAME);
PARSER.declareString(ModelDebugOutput::setOverFieldValue, OVER_FIELD_VALUE); PARSER.declareString(ModelPlot::setOverFieldValue, OVER_FIELD_VALUE);
PARSER.declareString(ModelDebugOutput::setByFieldName, BY_FIELD_NAME); PARSER.declareString(ModelPlot::setByFieldName, BY_FIELD_NAME);
PARSER.declareString(ModelDebugOutput::setByFieldValue, BY_FIELD_VALUE); PARSER.declareString(ModelPlot::setByFieldValue, BY_FIELD_VALUE);
PARSER.declareString(ModelDebugOutput::setDebugFeature, DEBUG_FEATURE); PARSER.declareString(ModelPlot::setModelFeature, MODEL_FEATURE);
PARSER.declareDouble(ModelDebugOutput::setDebugLower, DEBUG_LOWER); PARSER.declareDouble(ModelPlot::setModelLower, MODEL_LOWER);
PARSER.declareDouble(ModelDebugOutput::setDebugUpper, DEBUG_UPPER); PARSER.declareDouble(ModelPlot::setModelUpper, MODEL_UPPER);
PARSER.declareDouble(ModelDebugOutput::setDebugMedian, DEBUG_MEDIAN); PARSER.declareDouble(ModelPlot::setModelMedian, MODEL_MEDIAN);
PARSER.declareDouble(ModelDebugOutput::setActual, ACTUAL); PARSER.declareDouble(ModelPlot::setActual, ACTUAL);
} }
private final String jobId; private final String jobId;
@ -83,17 +80,17 @@ public class ModelDebugOutput extends ToXContentToBytes implements Writeable {
private String overFieldValue; private String overFieldValue;
private String byFieldName; private String byFieldName;
private String byFieldValue; private String byFieldValue;
private String debugFeature; private String modelFeature;
private double debugLower; private double modelLower;
private double debugUpper; private double modelUpper;
private double debugMedian; private double modelMedian;
private double actual; private double actual;
public ModelDebugOutput(String jobId) { public ModelPlot(String jobId) {
this.jobId = jobId; this.jobId = jobId;
} }
public ModelDebugOutput(StreamInput in) throws IOException { public ModelPlot(StreamInput in) throws IOException {
jobId = in.readString(); jobId = in.readString();
if (in.readBoolean()) { if (in.readBoolean()) {
timestamp = new Date(in.readLong()); timestamp = new Date(in.readLong());
@ -105,10 +102,10 @@ public class ModelDebugOutput extends ToXContentToBytes implements Writeable {
overFieldValue = in.readOptionalString(); overFieldValue = in.readOptionalString();
byFieldName = in.readOptionalString(); byFieldName = in.readOptionalString();
byFieldValue = in.readOptionalString(); byFieldValue = in.readOptionalString();
debugFeature = in.readOptionalString(); modelFeature = in.readOptionalString();
debugLower = in.readDouble(); modelLower = in.readDouble();
debugUpper = in.readDouble(); modelUpper = in.readDouble();
debugMedian = in.readDouble(); modelMedian = in.readDouble();
actual = in.readDouble(); actual = in.readDouble();
} }
@ -127,10 +124,10 @@ public class ModelDebugOutput extends ToXContentToBytes implements Writeable {
out.writeOptionalString(overFieldValue); out.writeOptionalString(overFieldValue);
out.writeOptionalString(byFieldName); out.writeOptionalString(byFieldName);
out.writeOptionalString(byFieldValue); out.writeOptionalString(byFieldValue);
out.writeOptionalString(debugFeature); out.writeOptionalString(modelFeature);
out.writeDouble(debugLower); out.writeDouble(modelLower);
out.writeDouble(debugUpper); out.writeDouble(modelUpper);
out.writeDouble(debugMedian); out.writeDouble(modelMedian);
out.writeDouble(actual); out.writeDouble(actual);
} }
@ -140,7 +137,8 @@ public class ModelDebugOutput extends ToXContentToBytes implements Writeable {
builder.field(Job.ID.getPreferredName(), jobId); builder.field(Job.ID.getPreferredName(), jobId);
builder.field(Result.RESULT_TYPE.getPreferredName(), RESULT_TYPE_VALUE); builder.field(Result.RESULT_TYPE.getPreferredName(), RESULT_TYPE_VALUE);
if (timestamp != null) { if (timestamp != null) {
builder.dateField(Result.TIMESTAMP.getPreferredName(), Result.TIMESTAMP.getPreferredName() + "_string", timestamp.getTime()); builder.dateField(Result.TIMESTAMP.getPreferredName(),
Result.TIMESTAMP.getPreferredName() + "_string", timestamp.getTime());
} }
if (partitionFieldName != null) { if (partitionFieldName != null) {
builder.field(PARTITION_FIELD_NAME.getPreferredName(), partitionFieldName); builder.field(PARTITION_FIELD_NAME.getPreferredName(), partitionFieldName);
@ -160,12 +158,12 @@ public class ModelDebugOutput extends ToXContentToBytes implements Writeable {
if (byFieldValue != null) { if (byFieldValue != null) {
builder.field(BY_FIELD_VALUE.getPreferredName(), byFieldValue); builder.field(BY_FIELD_VALUE.getPreferredName(), byFieldValue);
} }
if (debugFeature != null) { if (modelFeature != null) {
builder.field(DEBUG_FEATURE.getPreferredName(), debugFeature); builder.field(MODEL_FEATURE.getPreferredName(), modelFeature);
} }
builder.field(DEBUG_LOWER.getPreferredName(), debugLower); builder.field(MODEL_LOWER.getPreferredName(), modelLower);
builder.field(DEBUG_UPPER.getPreferredName(), debugUpper); builder.field(MODEL_UPPER.getPreferredName(), modelUpper);
builder.field(DEBUG_MEDIAN.getPreferredName(), debugMedian); builder.field(MODEL_MEDIAN.getPreferredName(), modelMedian);
builder.field(ACTUAL.getPreferredName(), actual); builder.field(ACTUAL.getPreferredName(), actual);
builder.endObject(); builder.endObject();
return builder; return builder;
@ -239,36 +237,36 @@ public class ModelDebugOutput extends ToXContentToBytes implements Writeable {
this.byFieldValue = byFieldValue; this.byFieldValue = byFieldValue;
} }
public String getDebugFeature() { public String getModelFeature() {
return debugFeature; return modelFeature;
} }
public void setDebugFeature(String debugFeature) { public void setModelFeature(String modelFeature) {
this.debugFeature = debugFeature; this.modelFeature = modelFeature;
} }
public double getDebugLower() { public double getModelLower() {
return debugLower; return modelLower;
} }
public void setDebugLower(double debugLower) { public void setModelLower(double modelLower) {
this.debugLower = debugLower; this.modelLower = modelLower;
} }
public double getDebugUpper() { public double getModelUpper() {
return debugUpper; return modelUpper;
} }
public void setDebugUpper(double debugUpper) { public void setModelUpper(double modelUpper) {
this.debugUpper = debugUpper; this.modelUpper = modelUpper;
} }
public double getDebugMedian() { public double getModelMedian() {
return debugMedian; return modelMedian;
} }
public void setDebugMedian(double debugMedian) { public void setModelMedian(double modelMedian) {
this.debugMedian = debugMedian; this.modelMedian = modelMedian;
} }
public double getActual() { public double getActual() {
@ -284,11 +282,11 @@ public class ModelDebugOutput extends ToXContentToBytes implements Writeable {
if (this == other) { if (this == other) {
return true; return true;
} }
if (other instanceof ModelDebugOutput == false) { if (other instanceof ModelPlot == false) {
return false; return false;
} }
// id excluded here as it is generated by the datastore // id excluded here as it is generated by the datastore
ModelDebugOutput that = (ModelDebugOutput) other; ModelPlot that = (ModelPlot) other;
return Objects.equals(this.jobId, that.jobId) && return Objects.equals(this.jobId, that.jobId) &&
Objects.equals(this.timestamp, that.timestamp) && Objects.equals(this.timestamp, that.timestamp) &&
Objects.equals(this.partitionFieldValue, that.partitionFieldValue) && Objects.equals(this.partitionFieldValue, that.partitionFieldValue) &&
@ -297,10 +295,10 @@ public class ModelDebugOutput extends ToXContentToBytes implements Writeable {
Objects.equals(this.overFieldName, that.overFieldName) && Objects.equals(this.overFieldName, that.overFieldName) &&
Objects.equals(this.byFieldValue, that.byFieldValue) && Objects.equals(this.byFieldValue, that.byFieldValue) &&
Objects.equals(this.byFieldName, that.byFieldName) && Objects.equals(this.byFieldName, that.byFieldName) &&
Objects.equals(this.debugFeature, that.debugFeature) && Objects.equals(this.modelFeature, that.modelFeature) &&
this.debugLower == that.debugLower && this.modelLower == that.modelLower &&
this.debugUpper == that.debugUpper && this.modelUpper == that.modelUpper &&
this.debugMedian == that.debugMedian && this.modelMedian == that.modelMedian &&
this.actual == that.actual; this.actual == that.actual;
} }
@ -309,6 +307,6 @@ public class ModelDebugOutput extends ToXContentToBytes implements Writeable {
// id excluded here as it is generated by the datastore // id excluded here as it is generated by the datastore
return Objects.hash(jobId, timestamp, partitionFieldName, partitionFieldValue, return Objects.hash(jobId, timestamp, partitionFieldName, partitionFieldValue,
overFieldName, overFieldValue, byFieldName, byFieldValue, overFieldName, overFieldValue, byFieldName, byFieldValue,
debugFeature, debugLower, debugUpper, debugMedian, actual); modelFeature, modelLower, modelUpper, modelMedian, actual);
} }
} }

View File

@ -126,12 +126,12 @@ public final class ReservedFieldNames {
Influencer.BUCKET_SPAN.getPreferredName(), Influencer.BUCKET_SPAN.getPreferredName(),
Influencer.SEQUENCE_NUM.getPreferredName(), Influencer.SEQUENCE_NUM.getPreferredName(),
ModelDebugOutput.PARTITION_FIELD_NAME.getPreferredName(), ModelDebugOutput.PARTITION_FIELD_VALUE.getPreferredName(), ModelPlot.PARTITION_FIELD_NAME.getPreferredName(), ModelPlot.PARTITION_FIELD_VALUE.getPreferredName(),
ModelDebugOutput.OVER_FIELD_NAME.getPreferredName(), ModelDebugOutput.OVER_FIELD_VALUE.getPreferredName(), ModelPlot.OVER_FIELD_NAME.getPreferredName(), ModelPlot.OVER_FIELD_VALUE.getPreferredName(),
ModelDebugOutput.BY_FIELD_NAME.getPreferredName(), ModelDebugOutput.BY_FIELD_VALUE.getPreferredName(), ModelPlot.BY_FIELD_NAME.getPreferredName(), ModelPlot.BY_FIELD_VALUE.getPreferredName(),
ModelDebugOutput.DEBUG_FEATURE.getPreferredName(), ModelDebugOutput.DEBUG_LOWER.getPreferredName(), ModelPlot.MODEL_FEATURE.getPreferredName(), ModelPlot.MODEL_LOWER.getPreferredName(),
ModelDebugOutput.DEBUG_UPPER.getPreferredName(), ModelDebugOutput.DEBUG_MEDIAN.getPreferredName(), ModelPlot.MODEL_UPPER.getPreferredName(), ModelPlot.MODEL_MEDIAN.getPreferredName(),
ModelDebugOutput.ACTUAL.getPreferredName(), ModelPlot.ACTUAL.getPreferredName(),
ModelSizeStats.MODEL_BYTES_FIELD.getPreferredName(), ModelSizeStats.MODEL_BYTES_FIELD.getPreferredName(),
ModelSizeStats.TOTAL_BY_FIELD_COUNT_FIELD.getPreferredName(), ModelSizeStats.TOTAL_BY_FIELD_COUNT_FIELD.getPreferredName(),

View File

@ -6,7 +6,7 @@
package org.elasticsearch.xpack.ml.action; package org.elasticsearch.xpack.ml.action;
import org.elasticsearch.xpack.ml.job.config.JobUpdate; import org.elasticsearch.xpack.ml.job.config.JobUpdate;
import org.elasticsearch.xpack.ml.job.config.ModelDebugConfig; import org.elasticsearch.xpack.ml.job.config.ModelPlotConfig;
import org.elasticsearch.xpack.ml.support.AbstractStreamableTestCase; import org.elasticsearch.xpack.ml.support.AbstractStreamableTestCase;
import java.util.List; import java.util.List;
@ -16,9 +16,9 @@ public class UpdateProcessActionRequestTests extends AbstractStreamableTestCase<
@Override @Override
protected UpdateProcessAction.Request createTestInstance() { protected UpdateProcessAction.Request createTestInstance() {
ModelDebugConfig config = null; ModelPlotConfig config = null;
if (randomBoolean()) { if (randomBoolean()) {
config = new ModelDebugConfig(randomBoolean(), randomAsciiOfLength(10)); config = new ModelPlotConfig(randomBoolean(), randomAsciiOfLength(10));
} }
List<JobUpdate.DetectorUpdate> updates = null; List<JobUpdate.DetectorUpdate> updates = null;
if (randomBoolean()) { if (randomBoolean()) {

View File

@ -37,8 +37,8 @@ import org.elasticsearch.xpack.ml.job.results.BucketTests;
import org.elasticsearch.xpack.ml.job.results.CategoryDefinition; import org.elasticsearch.xpack.ml.job.results.CategoryDefinition;
import org.elasticsearch.xpack.ml.job.results.CategoryDefinitionTests; import org.elasticsearch.xpack.ml.job.results.CategoryDefinitionTests;
import org.elasticsearch.xpack.ml.job.results.Influencer; import org.elasticsearch.xpack.ml.job.results.Influencer;
import org.elasticsearch.xpack.ml.job.results.ModelDebugOutput; import org.elasticsearch.xpack.ml.job.results.ModelPlot;
import org.elasticsearch.xpack.ml.job.results.ModelDebugOutputTests; import org.elasticsearch.xpack.ml.job.results.ModelPlotTests;
import org.junit.Before; import org.junit.Before;
import java.util.ArrayList; import java.util.ArrayList;
@ -98,8 +98,8 @@ public class AutodetectResultProcessorIT extends ESSingleNodeTestCase {
builder.addInfluencers(influencers); builder.addInfluencers(influencers);
CategoryDefinition categoryDefinition = createCategoryDefinition(); CategoryDefinition categoryDefinition = createCategoryDefinition();
builder.addCategoryDefinition(categoryDefinition); builder.addCategoryDefinition(categoryDefinition);
ModelDebugOutput modelDebugOutput = createModelDebugOutput(); ModelPlot modelPlot = createmodelPlot();
builder.addModelDebugOutput(modelDebugOutput); builder.addmodelPlot(modelPlot);
ModelSizeStats modelSizeStats = createModelSizeStats(); ModelSizeStats modelSizeStats = createModelSizeStats();
builder.addModelSizeStats(modelSizeStats); builder.addModelSizeStats(modelSizeStats);
ModelSnapshot modelSnapshot = createModelSnapshot(); ModelSnapshot modelSnapshot = createModelSnapshot();
@ -129,9 +129,9 @@ public class AutodetectResultProcessorIT extends ESSingleNodeTestCase {
assertEquals(1, persistedDefinition.count()); assertEquals(1, persistedDefinition.count());
assertEquals(categoryDefinition, persistedDefinition.results().get(0)); assertEquals(categoryDefinition, persistedDefinition.results().get(0));
QueryPage<ModelDebugOutput> persistedModelDebugOutput = jobProvider.modelDebugOutput(JOB_ID, 0, 100); QueryPage<ModelPlot> persistedmodelPlot = jobProvider.modelPlot(JOB_ID, 0, 100);
assertEquals(1, persistedModelDebugOutput.count()); assertEquals(1, persistedmodelPlot.count());
assertEquals(modelDebugOutput, persistedModelDebugOutput.results().get(0)); assertEquals(modelPlot, persistedmodelPlot.results().get(0));
ModelSizeStats persistedModelSizeStats = getModelSizeStats(); ModelSizeStats persistedModelSizeStats = getModelSizeStats();
assertEquals(modelSizeStats, persistedModelSizeStats); assertEquals(modelSizeStats, persistedModelSizeStats);
@ -286,8 +286,8 @@ public class AutodetectResultProcessorIT extends ESSingleNodeTestCase {
return new CategoryDefinitionTests().createTestInstance(JOB_ID); return new CategoryDefinitionTests().createTestInstance(JOB_ID);
} }
private ModelDebugOutput createModelDebugOutput() { private ModelPlot createmodelPlot() {
return new ModelDebugOutputTests().createTestInstance(JOB_ID); return new ModelPlotTests().createTestInstance(JOB_ID);
} }
private ModelSizeStats createModelSizeStats() { private ModelSizeStats createModelSizeStats() {
@ -343,8 +343,8 @@ public class AutodetectResultProcessorIT extends ESSingleNodeTestCase {
return this; return this;
} }
ResultsBuilder addModelDebugOutput(ModelDebugOutput modelDebugOutput) { ResultsBuilder addmodelPlot(ModelPlot modelPlot) {
results.add(new AutodetectResult(null, null, null, null, null, null, modelDebugOutput, null, null)); results.add(new AutodetectResult(null, null, null, null, null, null, modelPlot, null, null));
return this; return this;
} }

View File

@ -52,7 +52,7 @@ public class JobTests extends AbstractSerializingTestCase<Job> {
assertNull(job.getDescription()); assertNull(job.getDescription());
assertNull(job.getFinishedTime()); assertNull(job.getFinishedTime());
assertNull(job.getLastDataTime()); assertNull(job.getLastDataTime());
assertNull(job.getModelDebugConfig()); assertNull(job.getModelPlotConfig());
assertNull(job.getRenormalizationWindowDays()); assertNull(job.getRenormalizationWindowDays());
assertNull(job.getBackgroundPersistInterval()); assertNull(job.getBackgroundPersistInterval());
assertThat(job.getModelSnapshotRetentionDays(), equalTo(1L)); assertThat(job.getModelSnapshotRetentionDays(), equalTo(1L));
@ -392,7 +392,7 @@ public class JobTests extends AbstractSerializingTestCase<Job> {
builder.setDataDescription(dataDescription); builder.setDataDescription(dataDescription);
} }
if (randomBoolean()) { if (randomBoolean()) {
builder.setModelDebugConfig(new ModelDebugConfig(randomBoolean(), randomAsciiOfLength(10))); builder.setModelPlotConfig(new ModelPlotConfig(randomBoolean(), randomAsciiOfLength(10)));
} }
if (randomBoolean()) { if (randomBoolean()) {
builder.setRenormalizationWindowDays(randomNonNegativeLong()); builder.setRenormalizationWindowDays(randomNonNegativeLong());

View File

@ -48,7 +48,7 @@ public class JobUpdateTests extends AbstractSerializingTestCase<JobUpdate> {
update.setDetectorUpdates(detectorUpdates); update.setDetectorUpdates(detectorUpdates);
} }
if (randomBoolean()) { if (randomBoolean()) {
update.setModelDebugConfig(new ModelDebugConfig(randomBoolean(), randomAsciiOfLength(10))); update.setModelPlotConfig(new ModelPlotConfig(randomBoolean(), randomAsciiOfLength(10)));
} }
if (randomBoolean()) { if (randomBoolean()) {
update.setAnalysisLimits(new AnalysisLimits(randomNonNegativeLong(), randomNonNegativeLong())); update.setAnalysisLimits(new AnalysisLimits(randomNonNegativeLong(), randomNonNegativeLong()));
@ -99,7 +99,7 @@ public class JobUpdateTests extends AbstractSerializingTestCase<JobUpdate> {
new RuleCondition(RuleConditionType.NUMERICAL_ACTUAL, null, null, new Condition(Operator.GT, "5"), null)))); new RuleCondition(RuleConditionType.NUMERICAL_ACTUAL, null, null, new Condition(Operator.GT, "5"), null))));
detectorUpdates.add(new JobUpdate.DetectorUpdate(1, "description-2", detectionRules2)); detectorUpdates.add(new JobUpdate.DetectorUpdate(1, "description-2", detectionRules2));
ModelDebugConfig modelDebugConfig = new ModelDebugConfig(randomBoolean(), randomAsciiOfLength(10)); ModelPlotConfig modelPlotConfig = new ModelPlotConfig(randomBoolean(), randomAsciiOfLength(10));
AnalysisLimits analysisLimits = new AnalysisLimits(randomNonNegativeLong(), randomNonNegativeLong()); AnalysisLimits analysisLimits = new AnalysisLimits(randomNonNegativeLong(), randomNonNegativeLong());
List<String> categorizationFilters = Arrays.asList(generateRandomStringArray(10, 10, false)); List<String> categorizationFilters = Arrays.asList(generateRandomStringArray(10, 10, false));
Map<String, Object> customSettings = Collections.singletonMap(randomAsciiOfLength(10), randomAsciiOfLength(10)); Map<String, Object> customSettings = Collections.singletonMap(randomAsciiOfLength(10), randomAsciiOfLength(10));
@ -107,7 +107,7 @@ public class JobUpdateTests extends AbstractSerializingTestCase<JobUpdate> {
JobUpdate.Builder updateBuilder = new JobUpdate.Builder(); JobUpdate.Builder updateBuilder = new JobUpdate.Builder();
updateBuilder.setDescription("updated_description"); updateBuilder.setDescription("updated_description");
updateBuilder.setDetectorUpdates(detectorUpdates); updateBuilder.setDetectorUpdates(detectorUpdates);
updateBuilder.setModelDebugConfig(modelDebugConfig); updateBuilder.setModelPlotConfig(modelPlotConfig);
updateBuilder.setAnalysisLimits(analysisLimits); updateBuilder.setAnalysisLimits(analysisLimits);
updateBuilder.setBackgroundPersistInterval(TimeValue.timeValueHours(randomIntBetween(1, 24))); updateBuilder.setBackgroundPersistInterval(TimeValue.timeValueHours(randomIntBetween(1, 24)));
updateBuilder.setResultsRetentionDays(randomNonNegativeLong()); updateBuilder.setResultsRetentionDays(randomNonNegativeLong());
@ -131,7 +131,7 @@ public class JobUpdateTests extends AbstractSerializingTestCase<JobUpdate> {
Job updatedJob = update.mergeWithJob(jobBuilder.build()); Job updatedJob = update.mergeWithJob(jobBuilder.build());
assertEquals(update.getDescription(), updatedJob.getDescription()); assertEquals(update.getDescription(), updatedJob.getDescription());
assertEquals(update.getModelDebugConfig(), updatedJob.getModelDebugConfig()); assertEquals(update.getModelPlotConfig(), updatedJob.getModelPlotConfig());
assertEquals(update.getAnalysisLimits(), updatedJob.getAnalysisLimits()); assertEquals(update.getAnalysisLimits(), updatedJob.getAnalysisLimits());
assertEquals(update.getRenormalizationWindowDays(), updatedJob.getRenormalizationWindowDays()); assertEquals(update.getRenormalizationWindowDays(), updatedJob.getRenormalizationWindowDays());
assertEquals(update.getBackgroundPersistInterval(), updatedJob.getBackgroundPersistInterval()); assertEquals(update.getBackgroundPersistInterval(), updatedJob.getBackgroundPersistInterval());
@ -153,7 +153,7 @@ public class JobUpdateTests extends AbstractSerializingTestCase<JobUpdate> {
public void testIsAutodetectProcessUpdate() { public void testIsAutodetectProcessUpdate() {
JobUpdate update = new JobUpdate.Builder().build(); JobUpdate update = new JobUpdate.Builder().build();
assertFalse(update.isAutodetectProcessUpdate()); assertFalse(update.isAutodetectProcessUpdate());
update = new JobUpdate.Builder().setModelDebugConfig(new ModelDebugConfig(true, "ff")).build(); update = new JobUpdate.Builder().setModelPlotConfig(new ModelPlotConfig(true, "ff")).build();
assertTrue(update.isAutodetectProcessUpdate()); assertTrue(update.isAutodetectProcessUpdate());
update = new JobUpdate.Builder().setDetectorUpdates(Arrays.asList(mock(JobUpdate.DetectorUpdate.class))).build(); update = new JobUpdate.Builder().setDetectorUpdates(Arrays.asList(mock(JobUpdate.DetectorUpdate.class))).build();
assertTrue(update.isAutodetectProcessUpdate()); assertTrue(update.isAutodetectProcessUpdate());

View File

@ -12,25 +12,25 @@ import org.elasticsearch.xpack.ml.support.AbstractSerializingTestCase;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.Matchers.nullValue;
public class ModelDebugConfigTests extends AbstractSerializingTestCase<ModelDebugConfig> { public class ModelPlotConfigTests extends AbstractSerializingTestCase<ModelPlotConfig> {
public void testConstructorDefaults() { public void testConstructorDefaults() {
assertThat(new ModelDebugConfig().isEnabled(), is(true)); assertThat(new ModelPlotConfig().isEnabled(), is(true));
assertThat(new ModelDebugConfig().getTerms(), is(nullValue())); assertThat(new ModelPlotConfig().getTerms(), is(nullValue()));
} }
@Override @Override
protected ModelDebugConfig createTestInstance() { protected ModelPlotConfig createTestInstance() {
return new ModelDebugConfig(randomBoolean(), randomAsciiOfLengthBetween(1, 30)); return new ModelPlotConfig(randomBoolean(), randomAsciiOfLengthBetween(1, 30));
} }
@Override @Override
protected Reader<ModelDebugConfig> instanceReader() { protected Reader<ModelPlotConfig> instanceReader() {
return ModelDebugConfig::new; return ModelPlotConfig::new;
} }
@Override @Override
protected ModelDebugConfig parseInstance(XContentParser parser) { protected ModelPlotConfig parseInstance(XContentParser parser) {
return ModelDebugConfig.PARSER.apply(parser, null); return ModelPlotConfig.PARSER.apply(parser, null);
} }
} }

View File

@ -13,7 +13,7 @@ import org.elasticsearch.xpack.ml.job.config.DataDescription;
import org.elasticsearch.xpack.ml.job.config.DetectionRule; import org.elasticsearch.xpack.ml.job.config.DetectionRule;
import org.elasticsearch.xpack.ml.job.config.Detector; import org.elasticsearch.xpack.ml.job.config.Detector;
import org.elasticsearch.xpack.ml.job.config.Job; import org.elasticsearch.xpack.ml.job.config.Job;
import org.elasticsearch.xpack.ml.job.config.ModelDebugConfig; import org.elasticsearch.xpack.ml.job.config.ModelPlotConfig;
import org.elasticsearch.xpack.ml.job.process.DataCountsReporter; import org.elasticsearch.xpack.ml.job.process.DataCountsReporter;
import org.elasticsearch.xpack.ml.job.process.autodetect.output.AutoDetectResultProcessor; import org.elasticsearch.xpack.ml.job.process.autodetect.output.AutoDetectResultProcessor;
import org.elasticsearch.xpack.ml.job.process.autodetect.params.DataLoadParams; import org.elasticsearch.xpack.ml.job.process.autodetect.params.DataLoadParams;
@ -53,12 +53,12 @@ public class AutodetectCommunicatorTests extends ESTestCase {
} }
} }
public void tesWriteUpdateModelDebugMessage() throws IOException { public void tesWriteUpdateModelPlotMessage() throws IOException {
AutodetectProcess process = mockAutodetectProcessWithOutputStream(); AutodetectProcess process = mockAutodetectProcessWithOutputStream();
try (AutodetectCommunicator communicator = createAutodetectCommunicator(process, mock(AutoDetectResultProcessor.class))) { try (AutodetectCommunicator communicator = createAutodetectCommunicator(process, mock(AutoDetectResultProcessor.class))) {
ModelDebugConfig config = new ModelDebugConfig(); ModelPlotConfig config = new ModelPlotConfig();
communicator.writeUpdateModelDebugMessage(config); communicator.writeUpdateModelPlotMessage(config);
Mockito.verify(process).writeUpdateModelDebugMessage(config); Mockito.verify(process).writeUpdateModelPlotMessage(config);
} }
} }
@ -195,16 +195,16 @@ public class AutodetectCommunicatorTests extends ESTestCase {
communicator.close(); communicator.close();
} }
public void testWriteUpdateModelDebugConfigMessageInUse() throws Exception { public void testWriteUpdateModelPlotConfigMessageInUse() throws Exception {
AutodetectProcess process = mockAutodetectProcessWithOutputStream(); AutodetectProcess process = mockAutodetectProcessWithOutputStream();
AutoDetectResultProcessor resultProcessor = mock(AutoDetectResultProcessor.class); AutoDetectResultProcessor resultProcessor = mock(AutoDetectResultProcessor.class);
AutodetectCommunicator communicator = createAutodetectCommunicator(process, resultProcessor); AutodetectCommunicator communicator = createAutodetectCommunicator(process, resultProcessor);
communicator.inUse.set(new CountDownLatch(1)); communicator.inUse.set(new CountDownLatch(1));
expectThrows(ElasticsearchStatusException.class, () -> communicator.writeUpdateModelDebugMessage(mock(ModelDebugConfig.class))); expectThrows(ElasticsearchStatusException.class, () -> communicator.writeUpdateModelPlotMessage(mock(ModelPlotConfig.class)));
communicator.inUse.set(null); communicator.inUse.set(null);
communicator.writeUpdateModelDebugMessage(mock(ModelDebugConfig.class)); communicator.writeUpdateModelPlotMessage(mock(ModelPlotConfig.class));
} }
public void testWriteUpdateDetectorRulesMessageInUse() throws Exception { public void testWriteUpdateDetectorRulesMessageInUse() throws Exception {

View File

@ -23,7 +23,7 @@ import org.elasticsearch.xpack.ml.job.config.Job;
import org.elasticsearch.xpack.ml.job.config.JobState; import org.elasticsearch.xpack.ml.job.config.JobState;
import org.elasticsearch.xpack.ml.job.config.JobUpdate; import org.elasticsearch.xpack.ml.job.config.JobUpdate;
import org.elasticsearch.xpack.ml.job.config.MlFilter; import org.elasticsearch.xpack.ml.job.config.MlFilter;
import org.elasticsearch.xpack.ml.job.config.ModelDebugConfig; import org.elasticsearch.xpack.ml.job.config.ModelPlotConfig;
import org.elasticsearch.xpack.ml.job.persistence.JobDataCountsPersister; import org.elasticsearch.xpack.ml.job.persistence.JobDataCountsPersister;
import org.elasticsearch.xpack.ml.job.persistence.JobProvider; import org.elasticsearch.xpack.ml.job.persistence.JobProvider;
import org.elasticsearch.xpack.ml.job.persistence.JobResultsPersister; import org.elasticsearch.xpack.ml.job.persistence.JobResultsPersister;
@ -272,11 +272,11 @@ public class AutodetectProcessManagerTests extends ESTestCase {
public void testwriteUpdateProcessMessage() throws IOException { public void testwriteUpdateProcessMessage() throws IOException {
AutodetectCommunicator communicator = mock(AutodetectCommunicator.class); AutodetectCommunicator communicator = mock(AutodetectCommunicator.class);
AutodetectProcessManager manager = createManagerAndCallProcessData(communicator, "foo"); AutodetectProcessManager manager = createManagerAndCallProcessData(communicator, "foo");
ModelDebugConfig debugConfig = mock(ModelDebugConfig.class); ModelPlotConfig modelConfig = mock(ModelPlotConfig.class);
List<DetectionRule> rules = Collections.singletonList(mock(DetectionRule.class)); List<DetectionRule> rules = Collections.singletonList(mock(DetectionRule.class));
List<JobUpdate.DetectorUpdate> detectorUpdates = Collections.singletonList(new JobUpdate.DetectorUpdate(2, null, rules)); List<JobUpdate.DetectorUpdate> detectorUpdates = Collections.singletonList(new JobUpdate.DetectorUpdate(2, null, rules));
manager.writeUpdateProcessMessage("foo", detectorUpdates, debugConfig); manager.writeUpdateProcessMessage("foo", detectorUpdates, modelConfig);
verify(communicator).writeUpdateModelDebugMessage(debugConfig); verify(communicator).writeUpdateModelPlotMessage(modelConfig);
verify(communicator).writeUpdateDetectorRulesMessage(2, rules); verify(communicator).writeUpdateDetectorRulesMessage(2, rules);
} }

View File

@ -7,7 +7,7 @@ package org.elasticsearch.xpack.ml.job.process.autodetect;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.xpack.ml.job.config.ModelDebugConfig; import org.elasticsearch.xpack.ml.job.config.ModelPlotConfig;
import org.elasticsearch.xpack.ml.job.process.autodetect.output.AutodetectResultsParser; import org.elasticsearch.xpack.ml.job.process.autodetect.output.AutodetectResultsParser;
import org.elasticsearch.xpack.ml.job.process.autodetect.output.StateProcessor; import org.elasticsearch.xpack.ml.job.process.autodetect.output.StateProcessor;
import org.elasticsearch.xpack.ml.job.process.autodetect.params.DataLoadParams; import org.elasticsearch.xpack.ml.job.process.autodetect.params.DataLoadParams;
@ -145,7 +145,7 @@ public class NativeAutodetectProcessTests extends ESTestCase {
new AutodetectResultsParser(Settings.EMPTY))) { new AutodetectResultsParser(Settings.EMPTY))) {
process.start(executorService, mock(StateProcessor.class), mock(InputStream.class)); process.start(executorService, mock(StateProcessor.class), mock(InputStream.class));
process.writeUpdateModelDebugMessage(new ModelDebugConfig()); process.writeUpdateModelPlotMessage(new ModelPlotConfig());
process.flushStream(); process.flushStream();
String message = new String(bos.toByteArray(), StandardCharsets.UTF_8); String message = new String(bos.toByteArray(), StandardCharsets.UTF_8);

View File

@ -20,7 +20,7 @@ import org.elasticsearch.xpack.ml.job.results.AutodetectResult;
import org.elasticsearch.xpack.ml.job.results.Bucket; import org.elasticsearch.xpack.ml.job.results.Bucket;
import org.elasticsearch.xpack.ml.job.results.CategoryDefinition; import org.elasticsearch.xpack.ml.job.results.CategoryDefinition;
import org.elasticsearch.xpack.ml.job.results.Influencer; import org.elasticsearch.xpack.ml.job.results.Influencer;
import org.elasticsearch.xpack.ml.job.results.ModelDebugOutput; import org.elasticsearch.xpack.ml.job.results.ModelPlot;
import org.elasticsearch.xpack.ml.job.results.PerPartitionMaxProbabilities; import org.elasticsearch.xpack.ml.job.results.PerPartitionMaxProbabilities;
import org.junit.Before; import org.junit.Before;
import org.mockito.InOrder; import org.mockito.InOrder;
@ -227,17 +227,17 @@ public class AutoDetectResultProcessorTests extends ESTestCase {
assertTrue(context.deleteInterimRequired); assertTrue(context.deleteInterimRequired);
} }
public void testProcessResult_modelDebugOutput() { public void testProcessResult_modelPlot() {
JobResultsPersister.Builder bulkBuilder = mock(JobResultsPersister.Builder.class); JobResultsPersister.Builder bulkBuilder = mock(JobResultsPersister.Builder.class);
AutoDetectResultProcessor.Context context = new AutoDetectResultProcessor.Context(JOB_ID, false, bulkBuilder); AutoDetectResultProcessor.Context context = new AutoDetectResultProcessor.Context(JOB_ID, false, bulkBuilder);
context.deleteInterimRequired = false; context.deleteInterimRequired = false;
AutodetectResult result = mock(AutodetectResult.class); AutodetectResult result = mock(AutodetectResult.class);
ModelDebugOutput modelDebugOutput = mock(ModelDebugOutput.class); ModelPlot modelPlot = mock(ModelPlot.class);
when(result.getModelDebugOutput()).thenReturn(modelDebugOutput); when(result.getModelPlot()).thenReturn(modelPlot);
processorUnderTest.processResult(context, result); processorUnderTest.processResult(context, result);
verify(persister, times(1)).persistModelDebugOutput(modelDebugOutput); verify(persister, times(1)).persistModelPlot(modelPlot);
verifyNoMoreInteractions(persister); verifyNoMoreInteractions(persister);
} }

View File

@ -20,7 +20,7 @@ import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.xpack.ml.job.config.Condition; import org.elasticsearch.xpack.ml.job.config.Condition;
import org.elasticsearch.xpack.ml.job.config.Connective; import org.elasticsearch.xpack.ml.job.config.Connective;
import org.elasticsearch.xpack.ml.job.config.DetectionRule; import org.elasticsearch.xpack.ml.job.config.DetectionRule;
import org.elasticsearch.xpack.ml.job.config.ModelDebugConfig; import org.elasticsearch.xpack.ml.job.config.ModelPlotConfig;
import org.elasticsearch.xpack.ml.job.config.Operator; import org.elasticsearch.xpack.ml.job.config.Operator;
import org.elasticsearch.xpack.ml.job.config.RuleCondition; import org.elasticsearch.xpack.ml.job.config.RuleCondition;
import org.elasticsearch.xpack.ml.job.config.RuleConditionType; import org.elasticsearch.xpack.ml.job.config.RuleConditionType;
@ -148,15 +148,15 @@ public class ControlMsgToProcessWriterTests extends ESTestCase {
verifyNoMoreInteractions(lengthEncodedWriter); verifyNoMoreInteractions(lengthEncodedWriter);
} }
public void testWriteUpdateModelDebugMessage() throws IOException { public void testWriteUpdateModelPlotMessage() throws IOException {
ControlMsgToProcessWriter writer = new ControlMsgToProcessWriter(lengthEncodedWriter, 2); ControlMsgToProcessWriter writer = new ControlMsgToProcessWriter(lengthEncodedWriter, 2);
writer.writeUpdateModelDebugMessage(new ModelDebugConfig(true, "foo,bar")); writer.writeUpdateModelPlotMessage(new ModelPlotConfig(true, "foo,bar"));
InOrder inOrder = inOrder(lengthEncodedWriter); InOrder inOrder = inOrder(lengthEncodedWriter);
inOrder.verify(lengthEncodedWriter).writeNumFields(4); inOrder.verify(lengthEncodedWriter).writeNumFields(4);
inOrder.verify(lengthEncodedWriter, times(3)).writeField(""); inOrder.verify(lengthEncodedWriter, times(3)).writeField("");
inOrder.verify(lengthEncodedWriter).writeField("u[modelDebugConfig]\nboundspercentile = 95.0\nterms = foo,bar\n"); inOrder.verify(lengthEncodedWriter).writeField("u[modelPlotConfig]\nboundspercentile = 95.0\nterms = foo,bar\n");
verifyNoMoreInteractions(lengthEncodedWriter); verifyNoMoreInteractions(lengthEncodedWriter);
} }

View File

@ -6,7 +6,7 @@
package org.elasticsearch.xpack.ml.job.process.autodetect.writer; package org.elasticsearch.xpack.ml.job.process.autodetect.writer;
import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.xpack.ml.job.config.ModelDebugConfig; import org.elasticsearch.xpack.ml.job.config.ModelPlotConfig;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.mockito.Mockito; import org.mockito.Mockito;
@ -17,7 +17,7 @@ import java.io.OutputStreamWriter;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
public class ModelDebugConfigWriterTests extends ESTestCase { public class ModelPlotConfigWriterTests extends ESTestCase {
private OutputStreamWriter writer; private OutputStreamWriter writer;
@Before @Before
@ -31,8 +31,8 @@ public class ModelDebugConfigWriterTests extends ESTestCase {
} }
public void testWrite_GivenEnabledConfigWithoutTerms() throws IOException { public void testWrite_GivenEnabledConfigWithoutTerms() throws IOException {
ModelDebugConfig modelDebugConfig = new ModelDebugConfig(); ModelPlotConfig modelPlotConfig = new ModelPlotConfig();
ModelDebugConfigWriter writer = new ModelDebugConfigWriter(modelDebugConfig, this.writer); ModelPlotConfigWriter writer = new ModelPlotConfigWriter(modelPlotConfig, this.writer);
writer.write(); writer.write();
@ -40,8 +40,8 @@ public class ModelDebugConfigWriterTests extends ESTestCase {
} }
public void testWrite_GivenEnabledConfigWithTerms() throws IOException { public void testWrite_GivenEnabledConfigWithTerms() throws IOException {
ModelDebugConfig modelDebugConfig = new ModelDebugConfig(true, "foo,bar"); ModelPlotConfig modelPlotConfig = new ModelPlotConfig(true, "foo,bar");
ModelDebugConfigWriter writer = new ModelDebugConfigWriter(modelDebugConfig, this.writer); ModelPlotConfigWriter writer = new ModelPlotConfigWriter(modelPlotConfig, this.writer);
writer.write(); writer.write();
@ -49,8 +49,8 @@ public class ModelDebugConfigWriterTests extends ESTestCase {
} }
public void testWrite_GivenDisabledConfigWithTerms() throws IOException { public void testWrite_GivenDisabledConfigWithTerms() throws IOException {
ModelDebugConfig modelDebugConfig = new ModelDebugConfig(false, "foo,bar"); ModelPlotConfig modelPlotConfig = new ModelPlotConfig(false, "foo,bar");
ModelDebugConfigWriter writer = new ModelDebugConfigWriter(modelDebugConfig, this.writer); ModelPlotConfigWriter writer = new ModelPlotConfigWriter(modelPlotConfig, this.writer);
writer.write(); writer.write();

View File

@ -32,7 +32,7 @@ public class AutodetectResultTests extends AbstractSerializingTestCase<Autodetec
Quantiles quantiles; Quantiles quantiles;
ModelSnapshot modelSnapshot; ModelSnapshot modelSnapshot;
ModelSizeStats.Builder modelSizeStats; ModelSizeStats.Builder modelSizeStats;
ModelDebugOutput modelDebugOutput; ModelPlot modelPlot;
CategoryDefinition categoryDefinition; CategoryDefinition categoryDefinition;
FlushAcknowledgement flushAcknowledgement; FlushAcknowledgement flushAcknowledgement;
String jobId = "foo"; String jobId = "foo";
@ -79,10 +79,10 @@ public class AutodetectResultTests extends AbstractSerializingTestCase<Autodetec
modelSizeStats = null; modelSizeStats = null;
} }
if (randomBoolean()) { if (randomBoolean()) {
modelDebugOutput = new ModelDebugOutput(jobId); modelPlot = new ModelPlot(jobId);
modelDebugOutput.setId(randomAsciiOfLengthBetween(1, 20)); modelPlot.setId(randomAsciiOfLengthBetween(1, 20));
} else { } else {
modelDebugOutput = null; modelPlot = null;
} }
if (randomBoolean()) { if (randomBoolean()) {
categoryDefinition = new CategoryDefinition(jobId); categoryDefinition = new CategoryDefinition(jobId);
@ -96,7 +96,7 @@ public class AutodetectResultTests extends AbstractSerializingTestCase<Autodetec
flushAcknowledgement = null; flushAcknowledgement = null;
} }
return new AutodetectResult(bucket, records, influencers, quantiles, modelSnapshot, return new AutodetectResult(bucket, records, influencers, quantiles, modelSnapshot,
modelSizeStats == null ? null : modelSizeStats.build(), modelDebugOutput, categoryDefinition, flushAcknowledgement); modelSizeStats == null ? null : modelSizeStats.build(), modelPlot, categoryDefinition, flushAcknowledgement);
} }
@Override @Override

View File

@ -1,210 +0,0 @@
/*
* 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.
*/
package org.elasticsearch.xpack.ml.job.results;
import org.elasticsearch.common.io.stream.Writeable.Reader;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.xpack.ml.support.AbstractSerializingTestCase;
import java.util.Date;
public class ModelDebugOutputTests extends AbstractSerializingTestCase<ModelDebugOutput> {
@Override
protected ModelDebugOutput createTestInstance() {
return createTestInstance("foo");
}
public ModelDebugOutput createTestInstance(String jobId) {
ModelDebugOutput modelDebugOutput = new ModelDebugOutput(jobId);
if (randomBoolean()) {
modelDebugOutput.setByFieldName(randomAsciiOfLengthBetween(1, 20));
}
if (randomBoolean()) {
modelDebugOutput.setByFieldValue(randomAsciiOfLengthBetween(1, 20));
}
if (randomBoolean()) {
modelDebugOutput.setPartitionFieldName(randomAsciiOfLengthBetween(1, 20));
}
if (randomBoolean()) {
modelDebugOutput.setPartitionFieldValue(randomAsciiOfLengthBetween(1, 20));
}
if (randomBoolean()) {
modelDebugOutput.setDebugFeature(randomAsciiOfLengthBetween(1, 20));
}
if (randomBoolean()) {
modelDebugOutput.setDebugLower(randomDouble());
}
if (randomBoolean()) {
modelDebugOutput.setDebugUpper(randomDouble());
}
if (randomBoolean()) {
modelDebugOutput.setDebugMedian(randomDouble());
}
if (randomBoolean()) {
modelDebugOutput.setActual(randomDouble());
}
if (randomBoolean()) {
modelDebugOutput.setTimestamp(new Date(randomLong()));
}
return modelDebugOutput;
}
@Override
protected Reader<ModelDebugOutput> instanceReader() {
return ModelDebugOutput::new;
}
@Override
protected ModelDebugOutput parseInstance(XContentParser parser) {
return ModelDebugOutput.PARSER.apply(parser, null);
}
public void testEquals_GivenSameObject() {
ModelDebugOutput modelDebugOutput = new ModelDebugOutput(randomAsciiOfLength(15));
assertTrue(modelDebugOutput.equals(modelDebugOutput));
}
public void testEquals_GivenObjectOfDifferentClass() {
ModelDebugOutput modelDebugOutput = new ModelDebugOutput(randomAsciiOfLength(15));
assertFalse(modelDebugOutput.equals("a string"));
}
public void testEquals_GivenDifferentTimestamp() {
ModelDebugOutput modelDebugOutput1 = createFullyPopulated();
ModelDebugOutput modelDebugOutput2 = createFullyPopulated();
modelDebugOutput2.setTimestamp(new Date(0L));
assertFalse(modelDebugOutput1.equals(modelDebugOutput2));
assertFalse(modelDebugOutput2.equals(modelDebugOutput1));
}
public void testEquals_GivenDifferentPartitionFieldName() {
ModelDebugOutput modelDebugOutput1 = createFullyPopulated();
ModelDebugOutput modelDebugOutput2 = createFullyPopulated();
modelDebugOutput2.setPartitionFieldName("another");
assertFalse(modelDebugOutput1.equals(modelDebugOutput2));
assertFalse(modelDebugOutput2.equals(modelDebugOutput1));
}
public void testEquals_GivenDifferentPartitionFieldValue() {
ModelDebugOutput modelDebugOutput1 = createFullyPopulated();
ModelDebugOutput modelDebugOutput2 = createFullyPopulated();
modelDebugOutput2.setPartitionFieldValue("another");
assertFalse(modelDebugOutput1.equals(modelDebugOutput2));
assertFalse(modelDebugOutput2.equals(modelDebugOutput1));
}
public void testEquals_GivenDifferentByFieldName() {
ModelDebugOutput modelDebugOutput1 = createFullyPopulated();
ModelDebugOutput modelDebugOutput2 = createFullyPopulated();
modelDebugOutput2.setByFieldName("another");
assertFalse(modelDebugOutput1.equals(modelDebugOutput2));
assertFalse(modelDebugOutput2.equals(modelDebugOutput1));
}
public void testEquals_GivenDifferentByFieldValue() {
ModelDebugOutput modelDebugOutput1 = createFullyPopulated();
ModelDebugOutput modelDebugOutput2 = createFullyPopulated();
modelDebugOutput2.setByFieldValue("another");
assertFalse(modelDebugOutput1.equals(modelDebugOutput2));
assertFalse(modelDebugOutput2.equals(modelDebugOutput1));
}
public void testEquals_GivenDifferentOverFieldName() {
ModelDebugOutput modelDebugOutput1 = createFullyPopulated();
ModelDebugOutput modelDebugOutput2 = createFullyPopulated();
modelDebugOutput2.setOverFieldName("another");
assertFalse(modelDebugOutput1.equals(modelDebugOutput2));
assertFalse(modelDebugOutput2.equals(modelDebugOutput1));
}
public void testEquals_GivenDifferentOverFieldValue() {
ModelDebugOutput modelDebugOutput1 = createFullyPopulated();
ModelDebugOutput modelDebugOutput2 = createFullyPopulated();
modelDebugOutput2.setOverFieldValue("another");
assertFalse(modelDebugOutput1.equals(modelDebugOutput2));
assertFalse(modelDebugOutput2.equals(modelDebugOutput1));
}
public void testEquals_GivenDifferentDebugFeature() {
ModelDebugOutput modelDebugOutput1 = createFullyPopulated();
ModelDebugOutput modelDebugOutput2 = createFullyPopulated();
modelDebugOutput2.setDebugFeature("another");
assertFalse(modelDebugOutput1.equals(modelDebugOutput2));
assertFalse(modelDebugOutput2.equals(modelDebugOutput1));
}
public void testEquals_GivenDifferentDebugLower() {
ModelDebugOutput modelDebugOutput1 = createFullyPopulated();
ModelDebugOutput modelDebugOutput2 = createFullyPopulated();
modelDebugOutput2.setDebugLower(-1.0);
assertFalse(modelDebugOutput1.equals(modelDebugOutput2));
assertFalse(modelDebugOutput2.equals(modelDebugOutput1));
}
public void testEquals_GivenDifferentDebugUpper() {
ModelDebugOutput modelDebugOutput1 = createFullyPopulated();
ModelDebugOutput modelDebugOutput2 = createFullyPopulated();
modelDebugOutput2.setDebugUpper(-1.0);
assertFalse(modelDebugOutput1.equals(modelDebugOutput2));
assertFalse(modelDebugOutput2.equals(modelDebugOutput1));
}
public void testEquals_GivenDifferentDebugMean() {
ModelDebugOutput modelDebugOutput1 = createFullyPopulated();
ModelDebugOutput modelDebugOutput2 = createFullyPopulated();
modelDebugOutput2.setDebugMedian(-1.0);
assertFalse(modelDebugOutput1.equals(modelDebugOutput2));
assertFalse(modelDebugOutput2.equals(modelDebugOutput1));
}
public void testEquals_GivenDifferentActual() {
ModelDebugOutput modelDebugOutput1 = createFullyPopulated();
ModelDebugOutput modelDebugOutput2 = createFullyPopulated();
modelDebugOutput2.setActual(-1.0);
assertFalse(modelDebugOutput1.equals(modelDebugOutput2));
assertFalse(modelDebugOutput2.equals(modelDebugOutput1));
}
public void testEquals_GivenEqualModelDebugOutputs() {
ModelDebugOutput modelDebugOutput1 = createFullyPopulated();
ModelDebugOutput modelDebugOutput2 = createFullyPopulated();
assertTrue(modelDebugOutput1.equals(modelDebugOutput2));
assertTrue(modelDebugOutput2.equals(modelDebugOutput1));
assertEquals(modelDebugOutput1.hashCode(), modelDebugOutput2.hashCode());
}
private ModelDebugOutput createFullyPopulated() {
ModelDebugOutput modelDebugOutput = new ModelDebugOutput("foo");
modelDebugOutput.setByFieldName("by");
modelDebugOutput.setByFieldValue("by_val");
modelDebugOutput.setPartitionFieldName("part");
modelDebugOutput.setPartitionFieldValue("part_val");
modelDebugOutput.setDebugFeature("sum");
modelDebugOutput.setDebugLower(7.9);
modelDebugOutput.setDebugUpper(34.5);
modelDebugOutput.setDebugMedian(12.7);
modelDebugOutput.setActual(100.0);
modelDebugOutput.setTimestamp(new Date(12345678L));
return modelDebugOutput;
}
}

View File

@ -0,0 +1,210 @@
/*
* 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.
*/
package org.elasticsearch.xpack.ml.job.results;
import org.elasticsearch.common.io.stream.Writeable.Reader;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.xpack.ml.support.AbstractSerializingTestCase;
import java.util.Date;
public class ModelPlotTests extends AbstractSerializingTestCase<ModelPlot> {
@Override
protected ModelPlot createTestInstance() {
return createTestInstance("foo");
}
public ModelPlot createTestInstance(String jobId) {
ModelPlot modelPlot = new ModelPlot(jobId);
if (randomBoolean()) {
modelPlot.setByFieldName(randomAsciiOfLengthBetween(1, 20));
}
if (randomBoolean()) {
modelPlot.setByFieldValue(randomAsciiOfLengthBetween(1, 20));
}
if (randomBoolean()) {
modelPlot.setPartitionFieldName(randomAsciiOfLengthBetween(1, 20));
}
if (randomBoolean()) {
modelPlot.setPartitionFieldValue(randomAsciiOfLengthBetween(1, 20));
}
if (randomBoolean()) {
modelPlot.setModelFeature(randomAsciiOfLengthBetween(1, 20));
}
if (randomBoolean()) {
modelPlot.setModelLower(randomDouble());
}
if (randomBoolean()) {
modelPlot.setModelUpper(randomDouble());
}
if (randomBoolean()) {
modelPlot.setModelMedian(randomDouble());
}
if (randomBoolean()) {
modelPlot.setActual(randomDouble());
}
if (randomBoolean()) {
modelPlot.setTimestamp(new Date(randomLong()));
}
return modelPlot;
}
@Override
protected Reader<ModelPlot> instanceReader() {
return ModelPlot::new;
}
@Override
protected ModelPlot parseInstance(XContentParser parser) {
return ModelPlot.PARSER.apply(parser, null);
}
public void testEquals_GivenSameObject() {
ModelPlot modelPlot = new ModelPlot(randomAsciiOfLength(15));
assertTrue(modelPlot.equals(modelPlot));
}
public void testEquals_GivenObjectOfDifferentClass() {
ModelPlot modelPlot = new ModelPlot(randomAsciiOfLength(15));
assertFalse(modelPlot.equals("a string"));
}
public void testEquals_GivenDifferentTimestamp() {
ModelPlot modelPlot1 = createFullyPopulated();
ModelPlot modelPlot2 = createFullyPopulated();
modelPlot2.setTimestamp(new Date(0L));
assertFalse(modelPlot1.equals(modelPlot2));
assertFalse(modelPlot2.equals(modelPlot1));
}
public void testEquals_GivenDifferentPartitionFieldName() {
ModelPlot modelPlot1 = createFullyPopulated();
ModelPlot modelPlot2 = createFullyPopulated();
modelPlot2.setPartitionFieldName("another");
assertFalse(modelPlot1.equals(modelPlot2));
assertFalse(modelPlot2.equals(modelPlot1));
}
public void testEquals_GivenDifferentPartitionFieldValue() {
ModelPlot modelPlot1 = createFullyPopulated();
ModelPlot modelPlot2 = createFullyPopulated();
modelPlot2.setPartitionFieldValue("another");
assertFalse(modelPlot1.equals(modelPlot2));
assertFalse(modelPlot2.equals(modelPlot1));
}
public void testEquals_GivenDifferentByFieldName() {
ModelPlot modelPlot1 = createFullyPopulated();
ModelPlot modelPlot2 = createFullyPopulated();
modelPlot2.setByFieldName("another");
assertFalse(modelPlot1.equals(modelPlot2));
assertFalse(modelPlot2.equals(modelPlot1));
}
public void testEquals_GivenDifferentByFieldValue() {
ModelPlot modelPlot1 = createFullyPopulated();
ModelPlot modelPlot2 = createFullyPopulated();
modelPlot2.setByFieldValue("another");
assertFalse(modelPlot1.equals(modelPlot2));
assertFalse(modelPlot2.equals(modelPlot1));
}
public void testEquals_GivenDifferentOverFieldName() {
ModelPlot modelPlot1 = createFullyPopulated();
ModelPlot modelPlot2 = createFullyPopulated();
modelPlot2.setOverFieldName("another");
assertFalse(modelPlot1.equals(modelPlot2));
assertFalse(modelPlot2.equals(modelPlot1));
}
public void testEquals_GivenDifferentOverFieldValue() {
ModelPlot modelPlot1 = createFullyPopulated();
ModelPlot modelPlot2 = createFullyPopulated();
modelPlot2.setOverFieldValue("another");
assertFalse(modelPlot1.equals(modelPlot2));
assertFalse(modelPlot2.equals(modelPlot1));
}
public void testEquals_GivenDifferentModelFeature() {
ModelPlot modelPlot1 = createFullyPopulated();
ModelPlot modelPlot2 = createFullyPopulated();
modelPlot2.setModelFeature("another");
assertFalse(modelPlot1.equals(modelPlot2));
assertFalse(modelPlot2.equals(modelPlot1));
}
public void testEquals_GivenDifferentModelLower() {
ModelPlot modelPlot1 = createFullyPopulated();
ModelPlot modelPlot2 = createFullyPopulated();
modelPlot2.setModelLower(-1.0);
assertFalse(modelPlot1.equals(modelPlot2));
assertFalse(modelPlot2.equals(modelPlot1));
}
public void testEquals_GivenDifferentModelUpper() {
ModelPlot modelPlot1 = createFullyPopulated();
ModelPlot modelPlot2 = createFullyPopulated();
modelPlot2.setModelUpper(-1.0);
assertFalse(modelPlot1.equals(modelPlot2));
assertFalse(modelPlot2.equals(modelPlot1));
}
public void testEquals_GivenDifferentModelMean() {
ModelPlot modelPlot1 = createFullyPopulated();
ModelPlot modelPlot2 = createFullyPopulated();
modelPlot2.setModelMedian(-1.0);
assertFalse(modelPlot1.equals(modelPlot2));
assertFalse(modelPlot2.equals(modelPlot1));
}
public void testEquals_GivenDifferentActual() {
ModelPlot modelPlot1 = createFullyPopulated();
ModelPlot modelPlot2 = createFullyPopulated();
modelPlot2.setActual(-1.0);
assertFalse(modelPlot1.equals(modelPlot2));
assertFalse(modelPlot2.equals(modelPlot1));
}
public void testEquals_GivenEqualmodelPlots() {
ModelPlot modelPlot1 = createFullyPopulated();
ModelPlot modelPlot2 = createFullyPopulated();
assertTrue(modelPlot1.equals(modelPlot2));
assertTrue(modelPlot2.equals(modelPlot1));
assertEquals(modelPlot1.hashCode(), modelPlot2.hashCode());
}
private ModelPlot createFullyPopulated() {
ModelPlot modelPlot = new ModelPlot("foo");
modelPlot.setByFieldName("by");
modelPlot.setByFieldValue("by_val");
modelPlot.setPartitionFieldName("part");
modelPlot.setPartitionFieldValue("part_val");
modelPlot.setModelFeature("sum");
modelPlot.setModelLower(7.9);
modelPlot.setModelUpper(34.5);
modelPlot.setModelMedian(12.7);
modelPlot.setActual(100.0);
modelPlot.setTimestamp(new Date(12345678L));
return modelPlot;
}
}

View File

@ -189,7 +189,7 @@
"data_description" : { "data_description" : {
"field_delimiter":"," "field_delimiter":","
}, },
"model_debug_config": { "model_plot_config": {
"enabled": true, "enabled": true,
"terms": "foo,bar" "terms": "foo,bar"
}, },
@ -221,7 +221,7 @@
"rule_conditions": [ { "condition_type": "numerical_actual", "rule_conditions": [ { "condition_type": "numerical_actual",
"condition": {"operator": "gt", "value": "10" } } ] } }, "condition": {"operator": "gt", "value": "10" } } ] } },
{"index": 1, "description": "updated description"}], {"index": 1, "description": "updated description"}],
"model_debug_config": { "model_plot_config": {
"enabled": false, "enabled": false,
"terms": "foobar" "terms": "foobar"
}, },
@ -239,8 +239,8 @@
} }
- match: { job_id: "to-update" } - match: { job_id: "to-update" }
- match: { description: "Post update description" } - match: { description: "Post update description" }
- match: { model_debug_config.enabled: false } - match: { model_plot_config.enabled: false }
- match: { model_debug_config.terms: "foobar" } - match: { model_plot_config.terms: "foobar" }
- match: { analysis_limits.model_memory_limit: 20 } - match: { analysis_limits.model_memory_limit: 20 }
- match: { analysis_config.categorization_filters: ["cat3.*"] } - match: { analysis_config.categorization_filters: ["cat3.*"] }
- match: { analysis_config.detectors.0.detector_rules.0.target_field_name: "airline" } - match: { analysis_config.detectors.0.detector_rules.0.target_field_name: "airline" }