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

Co-authored-by: James Rodewig <40268737+jrodewig@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
Ernesto Reig 2020-12-08 15:22:22 +01:00 committed by GitHub
parent 691f85e5a3
commit 43fa468076
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 23 additions and 23 deletions

View File

@ -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>

View File

@ -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"
}
]

View File

@ -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}}"
}
}
}

View File

@ -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/<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\" ]
}",

View File

@ -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.

View File

@ -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"
}
}
}

View File

@ -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" : {

View File

@ -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

View File

@ -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"))))

View File

@ -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>
}
]
}