From fde2adb1b3184ea7798e1267f37fba85af2446a7 Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Mon, 12 Feb 2018 16:03:02 +0100 Subject: [PATCH] increase watcher logging when delegating to trigger service Original commit: elastic/x-pack-elasticsearch@448ee71f37a8d1327ebb77c673ed2d325b055f18 --- .../xpack/watcher/WatcherIndexingListener.java | 7 +++++++ qa/smoke-test-watcher/build.gradle | 1 + 2 files changed, 8 insertions(+) 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