[ML] Improve logging while removing expired data (elastic/x-pack-elasticsearch#1554)
relates elastic/x-pack-elasticsearch#1286 Original commit: elastic/x-pack-elasticsearch@4f938fa14b
This commit is contained in:
parent
779e6f6dba
commit
9b655ce6f1
|
@ -184,8 +184,10 @@ public class DeleteModelSnapshotAction extends Action<DeleteModelSnapshotAction.
|
|||
deleter.deleteModelSnapshots(Collections.singletonList(deleteCandidate), new ActionListener<BulkResponse>() {
|
||||
@Override
|
||||
public void onResponse(BulkResponse bulkResponse) {
|
||||
auditor.info(request.getJobId(), Messages.getMessage(Messages.JOB_AUDIT_SNAPSHOT_DELETED,
|
||||
deleteCandidate.getDescription()));
|
||||
String msg = Messages.getMessage(Messages.JOB_AUDIT_SNAPSHOT_DELETED, deleteCandidate.getSnapshotId(),
|
||||
deleteCandidate.getDescription());
|
||||
auditor.info(request.getJobId(), msg);
|
||||
logger.debug("[{}] {}", request.getJobId(), msg);
|
||||
// We don't care about the bulk response, just that it succeeded
|
||||
listener.onResponse(new DeleteModelSnapshotAction.Response(true));
|
||||
}
|
||||
|
|
|
@ -274,7 +274,7 @@ public class JobManager extends AbstractComponent {
|
|||
// -------
|
||||
CheckedConsumer<Boolean, Exception> apiResponseHandler = jobDeleted -> {
|
||||
if (jobDeleted) {
|
||||
logger.info("Job [" + jobId + "] deleted.");
|
||||
logger.info("Job [" + jobId + "] deleted");
|
||||
auditor.info(jobId, Messages.getMessage(Messages.JOB_AUDIT_DELETED));
|
||||
actionListener.onResponse(new DeleteJobAction.Response(true));
|
||||
} else {
|
||||
|
|
|
@ -51,7 +51,7 @@ public final class Messages {
|
|||
public static final String JOB_AUDIT_DELETED = "Job deleted";
|
||||
public static final String JOB_AUDIT_OLD_RESULTS_DELETED = "Deleted results prior to {1}";
|
||||
public static final String JOB_AUDIT_REVERTED = "Job model snapshot reverted to ''{0}''";
|
||||
public static final String JOB_AUDIT_SNAPSHOT_DELETED = "Job model snapshot ''{0}'' deleted";
|
||||
public static final String JOB_AUDIT_SNAPSHOT_DELETED = "Model snapshot [{0}] with description ''{1}'' deleted";
|
||||
|
||||
public static final String JOB_CONFIG_BYFIELD_INCOMPATIBLE_FUNCTION = "by_field_name cannot be used with function ''{0}''";
|
||||
public static final String JOB_CONFIG_CATEGORIZATION_FILTERS_CONTAINS_DUPLICATES = "categorization_filters contain duplicates";
|
||||
|
|
|
@ -63,7 +63,7 @@ public class ExpiredModelSnapshotsRemover extends AbstractExpiredJobDataRemover
|
|||
onFinish.run();
|
||||
return;
|
||||
}
|
||||
LOGGER.info("Removing model snapshots of job [{}] that have a timestamp before [{}]", job.getId(), cutoffEpochMs);
|
||||
LOGGER.debug("Removing model snapshots of job [{}] that have a timestamp before [{}]", job.getId(), cutoffEpochMs);
|
||||
|
||||
SearchRequest searchRequest = new SearchRequest();
|
||||
searchRequest.indices(AnomalyDetectorsIndex.jobResultsAliasedName(job.getId()));
|
||||
|
@ -111,7 +111,6 @@ public class ExpiredModelSnapshotsRemover extends AbstractExpiredJobDataRemover
|
|||
client.execute(DeleteModelSnapshotAction.INSTANCE, deleteSnapshotRequest, new ActionListener<DeleteModelSnapshotAction.Response>() {
|
||||
@Override
|
||||
public void onResponse(DeleteModelSnapshotAction.Response response) {
|
||||
LOGGER.trace("[{}] Deleted expired snapshot [{}]", modelSnapshot.getJobId(), modelSnapshot.getSnapshotId());
|
||||
try {
|
||||
deleteModelSnapshots(modelSnapshotIterator, onFinish);
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -56,14 +56,16 @@ public class ExpiredResultsRemover extends AbstractExpiredJobDataRemover {
|
|||
|
||||
@Override
|
||||
protected void removeDataBefore(Job job, long cutoffEpochMs, Runnable onFinish) {
|
||||
LOGGER.info("Removing results of job [{}] that have a timestamp before [{}]", job.getId(), cutoffEpochMs);
|
||||
LOGGER.debug("Removing results of job [{}] that have a timestamp before [{}]", job.getId(), cutoffEpochMs);
|
||||
DeleteByQueryRequest request = createDBQRequest(job, cutoffEpochMs);
|
||||
|
||||
client.execute(DeleteByQueryAction.INSTANCE, request, new ActionListener<BulkByScrollResponse>() {
|
||||
@Override
|
||||
public void onResponse(BulkByScrollResponse bulkByScrollResponse) {
|
||||
try {
|
||||
if (bulkByScrollResponse.getDeleted() > 0) {
|
||||
auditResultsWereDeleted(job.getId(), cutoffEpochMs);
|
||||
}
|
||||
onFinish.run();
|
||||
} catch (Exception e) {
|
||||
onFailure(e);
|
||||
|
@ -99,6 +101,7 @@ public class ExpiredResultsRemover extends AbstractExpiredJobDataRemover {
|
|||
ZonedDateTime zonedDateTime = ZonedDateTime.ofInstant(instant, ZoneOffset.systemDefault());
|
||||
String formatted = DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(zonedDateTime);
|
||||
String msg = Messages.getMessage(Messages.JOB_AUDIT_OLD_RESULTS_DELETED, formatted);
|
||||
LOGGER.debug("[{}] {}", jobId, msg);
|
||||
auditor.info(jobId, msg);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ public class MessagesTests extends ESTestCase {
|
|||
String formattedMessage = Messages.getMessage(Messages.DATAFEED_CONFIG_INVALID_OPTION_VALUE, "field-name", "field-value");
|
||||
assertEquals("Invalid field-name value 'field-value' in datafeed configuration", formattedMessage);
|
||||
|
||||
formattedMessage = Messages.getMessage(Messages.JOB_AUDIT_SNAPSHOT_DELETED, "foo-job");
|
||||
assertEquals("Job model snapshot 'foo-job' deleted", formattedMessage);
|
||||
formattedMessage = Messages.getMessage(Messages.JOB_AUDIT_SNAPSHOT_DELETED, "snapshot_foo", "snapshot description");
|
||||
assertEquals("Model snapshot [snapshot_foo] with description 'snapshot description' deleted", formattedMessage);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue