Thank you Alex. @spinscale
I was working on creating scripts that would generate desired results. Didn't put anything into watcher section . However, below are my queries tried so far.
-
Removed indent to save space here
This gives me result of total messages in all status broken with each message type and recipient domain for the main domain.
And if use "value_count" instead of "terms" for message type aggs then i get total value of all 3 message types under each recipient domain.
{"aggs":{"RecipientDomain":{"terms":{"field":"recipientDomain.keyword"},"aggs":{"MessageTypes":{"terms":{"field":"messageType.keyword"}}}}},"size":0,"_source":{"excludes":},
"script_fields":{},"docvalue_fields":[{"field":"@timestamp","format":"date_time"}],"query":{"bool":{"must":[{"match_all":{}},{"match_phrase":{"sendingDomain":
{"query":"main.domain.com"}}},{"range":{"@timestamp":{"format":"strict_date_optional_time","gte":"2022-03-24T15:49:42.890Z","lte":"2022-03-24T15:55:42.891Z"}}}]}}}
My result for this is:
"aggregations" : {
"recipient_domain" : {
"doc_count_error_upper_bound" : 12,
"sum_other_doc_count" : 576,
"buckets" : [
{
"key" : "ABC.com",
"doc_count" : 3479,
"Delivered_Message" : {
"buckets" : {
"messageType:Delivered" : {
"doc_count" : 3420
}
}
},
"Transient_Message" : {
"buckets" : {
"messageType:Transient" : {
"doc_count" : 32
}
}
},
"Failed_Message" : {
"buckets" : {
"messageType:Failed" : {
"doc_count" : 27
}
}
}
},
How can i add script condition to calculate % of failures?
-
Removed indent to save space here
This case, i get results again on total messages under each domain and under each status.
{"size":0,"query":{"bool":{"must":[{"match_phrase":{"sendingDomain":{"query":"main.domain.com"}}},{"range":{"@timestamp":{"gte":"2022-03-25T19:44:09.034Z",
"lte":"2022-03-25T19:50:09.034Z"}}}],"must_not":}},"aggs":{"recipient_domain":{"terms":{"field":"recipientDomain.keyword","min_doc_count":20,"size":10,"order":{"_count":"desc"}},
"aggs":
{"Failed_Message":{"filters":{"filters":{"messageType:Failed":{"bool":{"must":,"filter":[{"bool":{"should":[{"match":{"messageType":"Failed"}}],"minimum_should_match":1}}],"should":,"must_not":}}}}},
"Delivered_Message":{"filters":{"filters":{"messageType:Delivered":{"bool":{"must":,"filter":[{"bool":{"should":[{"match":{"messageType":"Delivered"}}],"minimum_should_match":1}}],"should":,"must_not":}}}}},
"Transient_Message":{"filters":{"filters":{"messageType:Transient":{"bool":{"must":,"filter":[{"bool":{"should":[{"match":{"messageType":"Transient"}}],"minimum_should_match":1}}],"should":,"must_not":}}}}},
To this when i add script condition to compute % calculation, i get same results as above but nothing for below condition. As in, i get results for total records in each domain and each status but computing % script part does not show any reference at all. What am i missing here?
I test these in Kibana DevTools.
"ComputePercentage":{"bucket_script":{"buckets_path":{"TD":"Delivered_Message.doc_count","TT":"Transient_Message.doc_count","TF":"Failed_Message.doc_count"},
"script":"(params.TF / (params.TD + params.TT + params.TF)) * 100"}}}}}}
My result for this is:
"aggregations" : {
"RD" : {
"doc_count_error_upper_bound" : 15,
"sum_other_doc_count" : 882,
"buckets" : [
{
"key" : "ABC.com",
"doc_count" : 3651,
"MT" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" : [
{
"key" : "Delivered",
"doc_count" : 3573
},
{
"key" : "Transient",
"doc_count" : 51
},
{
"key" : "Failed",
"doc_count" : 27
}
]
}
},
How can i add script condition to calculate % of failures?