Fix querying for model size stats (elastic/elasticsearch#465)
* Add test to read model size stats * Most recent model_size_stats document should have the name ‘model_size_stats’ Original commit: elastic/x-pack-elasticsearch@e192d4c34d
This commit is contained in:
parent
2785cc727d
commit
d3b4261759
|
@ -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));
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue