diff --git a/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/persistence/JobResultsPersister.java b/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/persistence/JobResultsPersister.java index 4881a08b5b3..98fbb3e3f71 100644 --- a/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/persistence/JobResultsPersister.java +++ b/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/persistence/JobResultsPersister.java @@ -210,7 +210,7 @@ public class JobResultsPersister extends AbstractComponent { String jobId = modelSizeStats.getJobId(); logger.trace("[{}] Persisting model size stats, for size {}", jobId, modelSizeStats.getModelBytes()); Persistable persistable = new Persistable(modelSizeStats.getJobId(), modelSizeStats, ModelSizeStats.TYPE::getPreferredName, - () -> jobId, () -> toXContentBuilder(modelSizeStats)); + ModelSizeStats.TYPE::getPreferredName, () -> toXContentBuilder(modelSizeStats)); persistable.persist(); persistable = new Persistable(modelSizeStats.getJobId(), modelSizeStats, ModelSizeStats.TYPE::getPreferredName, () -> null, () -> toXContentBuilder(modelSizeStats)); diff --git a/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/process/autodetect/output/AutoDetectResultProcessor.java b/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/process/autodetect/output/AutoDetectResultProcessor.java index a59cab8efa6..38a58f9ced6 100644 --- a/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/process/autodetect/output/AutoDetectResultProcessor.java +++ b/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/process/autodetect/output/AutoDetectResultProcessor.java @@ -126,10 +126,10 @@ public class AutoDetectResultProcessor { } ModelSizeStats modelSizeStats = result.getModelSizeStats(); if (modelSizeStats != null) { - LOGGER.trace(String.format(Locale.ROOT, "[%s] Parsed ModelSizeStats: %d / %d / %d / %d / %d / %s", + LOGGER.trace("[{}] Parsed ModelSizeStats: {} / {} / {} / {} / {} / {}", context.jobId, modelSizeStats.getModelBytes(), modelSizeStats.getTotalByFieldCount(), modelSizeStats.getTotalOverFieldCount(), modelSizeStats.getTotalPartitionFieldCount(), - modelSizeStats.getBucketAllocationFailuresCount(), modelSizeStats.getMemoryStatus())); + modelSizeStats.getBucketAllocationFailuresCount(), modelSizeStats.getMemoryStatus()); latestModelSizeStats = modelSizeStats; persister.persistModelSizeStats(modelSizeStats); diff --git a/elasticsearch/src/test/resources/rest-api-spec/test/jobs_get_stats.yaml b/elasticsearch/src/test/resources/rest-api-spec/test/jobs_get_stats.yaml index 128c4636f23..c2b2effc81f 100644 --- a/elasticsearch/src/test/resources/rest-api-spec/test/jobs_get_stats.yaml +++ b/elasticsearch/src/test/resources/rest-api-spec/test/jobs_get_stats.yaml @@ -40,6 +40,19 @@ setup: } } + - do: + index: + index: prelertresults-job-stats-test + type: model_size_stats + id: model_size_stats + body: { + "job_id": "job-stats-test", + "log_time": 1480896000000, + "timestamp": 1480896000000, + "model_bytes": 100, + "total_by_field_count": 2 + } + --- "Test get job stats after uploading data prompting the creation of some stats": - do: @@ -70,13 +83,12 @@ setup: job_id: job-stats-test metric: data_counts + - match: { jobs.0.job_id : job-stats-test } - match: { jobs.0.data_counts.processed_record_count: 2 } - match: { jobs.0.data_counts.processed_field_count: 4} - match: { jobs.0.data_counts.input_field_count: 4 } # Test filters -# It's difficult to test for the presence of model_size_stats as they -# won't be created with such a small data sample - do: xpack.prelert.get_jobs: job_id: "job-stats-test" @@ -93,6 +105,7 @@ setup: - is_false: jobs.0.config - is_false: jobs.0.data_counts - is_false: jobs.0.scheduler_state + - match: { jobs.0.model_size_stats.model_bytes: 100 } - do: xpack.prelert.get_jobs: @@ -118,6 +131,7 @@ setup: - is_true: jobs.0.config - is_true: jobs.0.data_counts - is_false: jobs.0.scheduler_state + - match: { jobs.0.job_id: job-stats-test } - match: { jobs.0.status: RUNNING } - do: