diff --git a/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/WatcherIndexingListener.java b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/WatcherIndexingListener.java index bb3045a0d36..37836ca94f8 100644 --- a/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/WatcherIndexingListener.java +++ b/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/WatcherIndexingListener.java @@ -5,6 +5,7 @@ */ package org.elasticsearch.xpack.watcher; +import org.apache.logging.log4j.message.ParameterizedMessage; import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.cluster.ClusterChangedEvent; import org.elasticsearch.cluster.ClusterState; @@ -115,16 +116,21 @@ final class WatcherIndexingListener extends AbstractComponent implements Indexin // part of an execution, so we can exit early boolean isWatchExecutionOperation = watch.status().version() != -1; if (isWatchExecutionOperation) { + logger.debug("not updating trigger for watch [{}], watch has been updated as part of an execution", watch.id()); return operation; } boolean shouldBeTriggered = shardAllocationConfiguration.shouldBeTriggered(watch.id()); if (shouldBeTriggered) { if (watch.status().state().isActive()) { + logger.debug("adding watch [{}] to trigger", watch.id()); triggerService.add(watch); } else { + logger.debug("removing watch [{}] to trigger", watch.id()); triggerService.remove(watch.id()); } + } else { + logger.debug("watch [{}] should not be triggered", watch.id()); } } catch (IOException e) { throw new ElasticsearchParseException("Could not parse watch with id [{}]", e, operation.id()); @@ -152,6 +158,7 @@ final class WatcherIndexingListener extends AbstractComponent implements Indexin @Override public void postIndex(ShardId shardId, Engine.Index index, Exception ex) { if (isWatchDocument(shardId.getIndexName(), index.type())) { + logger.debug(() -> new ParameterizedMessage("removing watch [{}] from trigger", index.id()), ex); triggerService.remove(index.id()); } } diff --git a/qa/smoke-test-watcher/build.gradle b/qa/smoke-test-watcher/build.gradle index f17e3f8ecd6..46a974afa11 100644 --- a/qa/smoke-test-watcher/build.gradle +++ b/qa/smoke-test-watcher/build.gradle @@ -22,6 +22,7 @@ integTestCluster { setting 'xpack.security.enabled', 'false' setting 'xpack.monitoring.enabled', 'false' setting 'xpack.ml.enabled', 'false' + setting 'logger.org.elasticsearch.xpack.watcher', 'DEBUG' // // JIRA integration test settings