diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/process/autodetect/state/ModelSnapshot.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/process/autodetect/state/ModelSnapshot.java index 035579b2243b0..c028bd220df0a 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/process/autodetect/state/ModelSnapshot.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/process/autodetect/state/ModelSnapshot.java @@ -89,6 +89,10 @@ private static ObjectParser createParser(boolean ignoreUnknownFie */ private final Version minVersion; + /** + * This is model snapshot's creation wall clock time. + * Use {@code latestResultTimeStamp} if you need model time instead. + */ private final Date timestamp; private final String description; private final String snapshotId; diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/AutodetectResultProcessor.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/AutodetectResultProcessor.java index 49a687b264bd2..fe2b94d294665 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/AutodetectResultProcessor.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/AutodetectResultProcessor.java @@ -332,8 +332,8 @@ private Annotation createModelSnapshotAnnotation(ModelSnapshot modelSnapshot) { Messages.getMessage(Messages.JOB_AUDIT_SNAPSHOT_STORED, modelSnapshot.getSnapshotId()), currentTime, XPackUser.NAME, - modelSnapshot.getTimestamp(), - modelSnapshot.getTimestamp(), + modelSnapshot.getLatestResultTimeStamp(), + modelSnapshot.getLatestResultTimeStamp(), jobId, currentTime, XPackUser.NAME, diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/AutodetectResultProcessorIT.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/AutodetectResultProcessorIT.java index dc68c69251272..d493ecbf4539f 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/AutodetectResultProcessorIT.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/AutodetectResultProcessorIT.java @@ -480,7 +480,8 @@ private static ModelSizeStats createModelSizeStats() { private static ModelSnapshot createModelSnapshot() { return new ModelSnapshot.Builder(JOB_ID) .setSnapshotId(randomAlphaOfLength(12)) - .setTimestamp(Date.from(Instant.ofEpochMilli(1000000000))) + .setLatestResultTimeStamp(Date.from(Instant.ofEpochMilli(1000_000_000))) + .setTimestamp(Date.from(Instant.ofEpochMilli(2000_000_000))) .build(); } diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/AutodetectResultProcessorTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/AutodetectResultProcessorTests.java index 116a9b773a07a..689debf005b65 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/AutodetectResultProcessorTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/output/AutodetectResultProcessorTests.java @@ -365,7 +365,8 @@ public void testProcessResult_modelSnapshot() { AutodetectResult result = mock(AutodetectResult.class); ModelSnapshot modelSnapshot = new ModelSnapshot.Builder(JOB_ID) .setSnapshotId("a_snapshot_id") - .setTimestamp(Date.from(Instant.ofEpochMilli(1000000000))) + .setLatestResultTimeStamp(Date.from(Instant.ofEpochMilli(1000_000_000))) + .setTimestamp(Date.from(Instant.ofEpochMilli(2000_000_000))) .setMinVersion(Version.CURRENT) .build(); when(result.getModelSnapshot()).thenReturn(modelSnapshot); @@ -389,8 +390,8 @@ public void testProcessResult_modelSnapshot() { "Job model snapshot with id [a_snapshot_id] stored", Date.from(CURRENT_TIME), XPackUser.NAME, - modelSnapshot.getTimestamp(), - modelSnapshot.getTimestamp(), + Date.from(Instant.ofEpochMilli(1000_000_000)), + Date.from(Instant.ofEpochMilli(1000_000_000)), JOB_ID, Date.from(CURRENT_TIME), XPackUser.NAME,