From 5cad64c6d113538b3c9069ff4cdc3edf41c9485b Mon Sep 17 00:00:00 2001 From: James Rodewig <40268737+jrodewig@users.noreply.github.com> Date: Tue, 8 Dec 2020 12:24:24 -0500 Subject: [PATCH] [DOCS] Change `ctx.payload.hits.total.value` to `ctx.payload.hits.total` (#65874) (#66031) Co-authored-by: James Rodewig <40268737+jrodewig@users.noreply.github.com> Co-authored-by: Elastic Machine Co-authored-by: Ernesto Reig --- x-pack/docs/en/watcher/actions/jira.asciidoc | 4 ++-- x-pack/docs/en/watcher/actions/slack.asciidoc | 4 ++-- x-pack/docs/en/watcher/actions/webhook.asciidoc | 6 +++--- x-pack/docs/en/watcher/customizing-watches.asciidoc | 6 +++--- .../example-watches/watching-time-series-data.asciidoc | 4 ++-- x-pack/docs/en/watcher/getting-started.asciidoc | 6 +++--- x-pack/docs/en/watcher/how-watcher-works.asciidoc | 6 +++--- x-pack/docs/en/watcher/input/search.asciidoc | 4 ++-- x-pack/docs/en/watcher/java/put-watch.asciidoc | 4 ++-- x-pack/docs/en/watcher/transform/chain.asciidoc | 2 +- 10 files changed, 23 insertions(+), 23 deletions(-) diff --git a/x-pack/docs/en/watcher/actions/jira.asciidoc b/x-pack/docs/en/watcher/actions/jira.asciidoc index e2c2a4824a10d..0819f50335625 100644 --- a/x-pack/docs/en/watcher/actions/jira.asciidoc +++ b/x-pack/docs/en/watcher/actions/jira.asciidoc @@ -28,8 +28,8 @@ The following snippet shows a simple jira action definition: "issuetype" : { "name": "Bug" <3> }, - "summary" : "Encountered {{ctx.payload.hits.total.value}} errors in the last 5 minutes", <4> - "description" : "Encountered {{ctx.payload.hits.total.value}} errors in the last 5 minutes (facepalm)", <5> + "summary" : "Encountered {{ctx.payload.hits.total}} errors in the last 5 minutes", <4> + "description" : "Encountered {{ctx.payload.hits.total}} errors in the last 5 minutes (facepalm)", <5> "labels" : ["auto"], <6> "priority" : { "name" : "High" <7> diff --git a/x-pack/docs/en/watcher/actions/slack.asciidoc b/x-pack/docs/en/watcher/actions/slack.asciidoc index 8ceb4698e16a0..e69d0bd86b020 100644 --- a/x-pack/docs/en/watcher/actions/slack.asciidoc +++ b/x-pack/docs/en/watcher/actions/slack.asciidoc @@ -24,7 +24,7 @@ The following snippet shows a simple slack action definition: "slack" : { "message" : { "to" : [ "#admins", "@chief-admin" ], <1> - "text" : "Encountered {{ctx.payload.hits.total.value}} errors in the last 5 minutes (facepalm)" <2> + "text" : "Encountered {{ctx.payload.hits.total}} errors in the last 5 minutes (facepalm)" <2> } } } @@ -59,7 +59,7 @@ The following snippet shows a standard message attachment: "attachments" : [ { "title" : "Errors Found", - "text" : "Encountered {{ctx.payload.hits.total.value}} errors in the last 5 minutes (facepalm)", + "text" : "Encountered {{ctx.payload.hits.total}} errors in the last 5 minutes (facepalm)", "color" : "danger" } ] diff --git a/x-pack/docs/en/watcher/actions/webhook.asciidoc b/x-pack/docs/en/watcher/actions/webhook.asciidoc index 5cac802fd3b0a..65e88425c8a71 100644 --- a/x-pack/docs/en/watcher/actions/webhook.asciidoc +++ b/x-pack/docs/en/watcher/actions/webhook.asciidoc @@ -25,7 +25,7 @@ The following snippet shows a simple webhook action definition: "host" : "mylisteningserver", <5> "port" : 9200, <6> "path": ":/{{ctx.watch_id}}", <7> - "body" : "{{ctx.watch_id}}:{{ctx.payload.hits.total.value}}" <8> + "body" : "{{ctx.watch_id}}:{{ctx.payload.hits.total}}" <8> } } } @@ -50,7 +50,7 @@ For example, the following `webhook` action creates a new issue in GitHub: "actions" : { "create_github_issue" : { "transform": { - "script": "return ['title':'Found errors in \\'contact.html\\'', 'body' : 'Found ' + ctx.payload.hits.total.value + ' errors in the last 5 minutes', 'assignee' : 'web-admin', 'labels' : ['bug','sev2']]" + "script": "return ['title':'Found errors in \\'contact.html\\'', 'body' : 'Found ' + ctx.payload.hits.total + ' errors in the last 5 minutes', 'assignee' : 'web-admin', 'labels' : ['bug','sev2']]" }, "webhook" : { "method" : "POST", @@ -127,7 +127,7 @@ the values serve as the header values: "headers" : { "Content-Type" : "application/yaml" <1> }, - "body" : "count: {{ctx.payload.hits.total.value}}" + "body" : "count: {{ctx.payload.hits.total}}" } } } diff --git a/x-pack/docs/en/watcher/customizing-watches.asciidoc b/x-pack/docs/en/watcher/customizing-watches.asciidoc index 4e4f0c08de499..33878918d24b7 100644 --- a/x-pack/docs/en/watcher/customizing-watches.asciidoc +++ b/x-pack/docs/en/watcher/customizing-watches.asciidoc @@ -147,7 +147,7 @@ returned any hits: [source,js] -------------------------------------------------- "condition" : { - "compare" : { "ctx.payload.hits.total.value" : { "gt" : 0 }} + "compare" : { "ctx.payload.hits.total" : { "gt" : 0 }} }, -------------------------------------------------- // NOTCONSOLE @@ -223,7 +223,7 @@ attaches the payload data to the message: "email" : { <2> "to" : "email@example.org", "subject" : "Watcher Notification", - "body" : "{{ctx.payload.hits.total.value}} error logs found", + "body" : "{{ctx.payload.hits.total}} error logs found", "attachments" : { "data_attachment" : { "data" : { @@ -252,7 +252,7 @@ creates a new issue in GitHub "url" : "https://api.github.com/repos///issues", <1> "body" : "{ \"title\": \"Found errors in 'contact.html'\", - \"body\": \"Found {{ctx.payload.hits.total.value}} errors in this page in the last 5 minutes\", + \"body\": \"Found {{ctx.payload.hits.total}} errors in this page in the last 5 minutes\", \"assignee\": \"web-admin\", \"labels\": [ \"bug\", \"sev2\" ] }", diff --git a/x-pack/docs/en/watcher/example-watches/watching-time-series-data.asciidoc b/x-pack/docs/en/watcher/example-watches/watching-time-series-data.asciidoc index 6a4acfd5add9f..421c69619cfea 100644 --- a/x-pack/docs/en/watcher/example-watches/watching-time-series-data.asciidoc +++ b/x-pack/docs/en/watcher/example-watches/watching-time-series-data.asciidoc @@ -107,7 +107,7 @@ You define the condition with the following script: + [source,text] -------------------------------------------------- -return ctx.payload.hits.total.value > threshold +return ctx.payload.hits.total > threshold -------------------------------------------------- + If you store the script in a file at `$ES_HOME/config/scripts/threshold_hits.painless`, @@ -204,7 +204,7 @@ PUT _watcher/watch/rss_watch } } -------------------------------------------------- -// TEST[s/"id" : "threshold_hits"/"source": "return ctx.payload.hits.total.value > params.threshold"/] +// TEST[s/"id" : "threshold_hits"/"source": "return ctx.payload.hits.total > params.threshold"/] <1> Replace `username@example.org` with your email address to receive notifications. diff --git a/x-pack/docs/en/watcher/getting-started.asciidoc b/x-pack/docs/en/watcher/getting-started.asciidoc index eb81b1b1b05b1..6fdf2e4b6de5f 100644 --- a/x-pack/docs/en/watcher/getting-started.asciidoc +++ b/x-pack/docs/en/watcher/getting-started.asciidoc @@ -103,7 +103,7 @@ PUT _watcher/watch/log_error_watch } }, "condition" : { - "compare" : { "ctx.payload.hits.total.value" : { "gt" : 0 }} <1> + "compare" : { "ctx.payload.hits.total" : { "gt" : 0 }} <1> } } -------------------------------------------------- @@ -180,12 +180,12 @@ PUT _watcher/watch/log_error_watch } }, "condition" : { - "compare" : { "ctx.payload.hits.total.value" : { "gt" : 0 }} + "compare" : { "ctx.payload.hits.total" : { "gt" : 0 }} }, "actions" : { "log_error" : { "logging" : { - "text" : "Found {{ctx.payload.hits.total.value}} errors in the logs" + "text" : "Found {{ctx.payload.hits.total}} errors in the logs" } } } diff --git a/x-pack/docs/en/watcher/how-watcher-works.asciidoc b/x-pack/docs/en/watcher/how-watcher-works.asciidoc index 6ad4413478391..862fce97c3f83 100644 --- a/x-pack/docs/en/watcher/how-watcher-works.asciidoc +++ b/x-pack/docs/en/watcher/how-watcher-works.asciidoc @@ -71,7 +71,7 @@ PUT _watcher/watch/log_errors } }, "condition" : { <4> - "compare" : { "ctx.payload.hits.total.value" : { "gt" : 5 }} + "compare" : { "ctx.payload.hits.total" : { "gt" : 5 }} }, "transform" : { <5> "search" : { @@ -90,13 +90,13 @@ PUT _watcher/watch/log_errors "host" : "mylisteninghost", "port" : 9200, "path" : "/{{watch_id}}", - "body" : "Encountered {{ctx.payload.hits.total.value}} errors" + "body" : "Encountered {{ctx.payload.hits.total}} errors" } }, "email_administrator" : { "email" : { "to" : "sys.admino@host.domain", - "subject" : "Encountered {{ctx.payload.hits.total.value}} errors", + "subject" : "Encountered {{ctx.payload.hits.total}} errors", "body" : "Too many error in the system, see attached data", "attachments" : { "attached_data" : { diff --git a/x-pack/docs/en/watcher/input/search.asciidoc b/x-pack/docs/en/watcher/input/search.asciidoc index 2fffe18f3a18c..3dbf59e35b9fc 100644 --- a/x-pack/docs/en/watcher/input/search.asciidoc +++ b/x-pack/docs/en/watcher/input/search.asciidoc @@ -129,7 +129,7 @@ a condition to check if the search returned more than five hits: } }, "condition" : { - "compare" : { "ctx.payload.hits.total.value" : { "gt" : 5 }} + "compare" : { "ctx.payload.hits.total" : { "gt" : 5 }} } ... } @@ -142,7 +142,7 @@ Conditions, transforms, and actions can access the search results through the watch execution context. For example: * To load all of the search hits into an email body, use `ctx.payload.hits`. -* To reference the total number of hits, use `ctx.payload.hits.total.value`. +* To reference the total number of hits, use `ctx.payload.hits.total`. * To access a particular hit, use its zero-based array index. For example, to get the third hit, use `ctx.payload.hits.hits.2`. * To get a field value from a particular hit, use diff --git a/x-pack/docs/en/watcher/java/put-watch.asciidoc b/x-pack/docs/en/watcher/java/put-watch.asciidoc index a3bc98583fc53..4958ddda4f046 100644 --- a/x-pack/docs/en/watcher/java/put-watch.asciidoc +++ b/x-pack/docs/en/watcher/java/put-watch.asciidoc @@ -46,7 +46,7 @@ SearchInput input = new SearchInput(new WatcherSearchTemplateRequest(new String[ watchSourceBuilder.input(input); // Set the condition -watchSourceBuilder.condition(new ScriptCondition(new Script("ctx.payload.hits.total.value > 1"))); +watchSourceBuilder.condition(new ScriptCondition(new Script("ctx.payload.hits.total > 1"))); // Create the email template to use for the action EmailTemplate.Builder emailBuilder = EmailTemplate.builder(); @@ -78,7 +78,7 @@ PutWatchResponse putWatchResponse2 = watcherClient.preparePutWatch("my-watch") .filter(rangeQuery("date").gt("{{ctx.trigger.scheduled_time}}")) .filter(rangeQuery("date").lt("{{ctx.execution_time}}")) ).buildAsBytes()))) - .condition(compareCondition("ctx.payload.hits.total.value", CompareCondition.Op.GT, 1L)) + .condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.GT, 1L)) .addAction("email_someone", emailAction(EmailTemplate.builder() .to("someone@domain.host.com") .subject("404 recently encountered")))) diff --git a/x-pack/docs/en/watcher/transform/chain.asciidoc b/x-pack/docs/en/watcher/transform/chain.asciidoc index e387071d6c334..a99458512a912 100644 --- a/x-pack/docs/en/watcher/transform/chain.asciidoc +++ b/x-pack/docs/en/watcher/transform/chain.asciidoc @@ -30,7 +30,7 @@ the other available transforms. For example, you can combine a } }, { - "script" : "return [ error_count : ctx.payload.hits.total.value ]" <3> + "script" : "return [ error_count : ctx.payload.hits.total ]" <3> } ] }