From 126cb869e02ad70a2f075ba39781521a2a33f93e Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Mon, 30 Apr 2018 11:07:45 -0400 Subject: [PATCH] Log (at warn level) query body of long-running ES queries --- service/search.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/service/search.js b/service/search.js index 1db7cef6..357e428e 100644 --- a/service/search.js +++ b/service/search.js @@ -13,7 +13,12 @@ function service( esclient, cmd, cb ){ // log total ms elasticsearch reported the query took to execute if( data && data.took ){ - logger.verbose( 'time elasticsearch reported:', data.took / 1000 ); + const seconds = data.took / 1000; + logger.verbose( 'time elasticsearch reported:', seconds ); + + if (seconds > 3) { + logger.warn(`elasticsearch query took ${seconds} seconds! ${JSON.stringify(cmd)}`); + } } // handle elasticsearch errors