Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOCS] Change ctx.payload.hits.total.value to ctx.payload.hits.total #65874

Merged
merged 3 commits into from
Dec 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions x-pack/docs/en/watcher/actions/jira.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
4 changes: 2 additions & 2 deletions x-pack/docs/en/watcher/actions/slack.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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>
}
}
}
Expand Down Expand Up @@ -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"
}
]
Expand Down
6 changes: 3 additions & 3 deletions x-pack/docs/en/watcher/actions/webhook.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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>
}
}
}
Expand All @@ -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",
Expand Down Expand Up @@ -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}}"
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions x-pack/docs/en/watcher/customizing-watches.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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" : {
Expand Down Expand Up @@ -252,7 +252,7 @@ creates a new issue in GitHub
"url" : "https://api.github.com/repos/<owner>/<repo>/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\" ]
}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions x-pack/docs/en/watcher/getting-started.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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>
}
}
--------------------------------------------------
Expand Down Expand Up @@ -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"
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions x-pack/docs/en/watcher/how-watcher-works.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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" : {
Expand All @@ -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" : {
Expand Down
4 changes: 2 additions & 2 deletions x-pack/docs/en/watcher/input/search.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
}
...
}
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions x-pack/docs/en/watcher/java/put-watch.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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"))))
Expand Down
2 changes: 1 addition & 1 deletion x-pack/docs/en/watcher/transform/chain.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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>
}
]
}
Expand Down