I've already get both metrics max(dt) and min(dt) of each transID in the kibana. How shoud I get the duration of each transId by the calculation max(dt) - min(dt) ? I did it by the bucket script in the dev tools as the bottom scripts . But i donot know how to implent it in the kibana. Is there any metric expresson available?
POST /jun/_search
{
"size": "0",
"_source": {
"includes": [
"ct"
]
},
"aggs": {
"eachtransID": {
"terms": {
"field": "transID"
},
"aggs": {
"min_ct": {
"min": {
"field": "dt"
}
},
"max_ct": {
"max": {
"field": "dt"
}
},
"date_diff": {
"bucket_script": {
"buckets_path": {
"min_ct1": "min_ct",
"max_ct1": "max_ct"
},
"script": "params.min_ct1 - params.max_ct1"
}
}
}
},
"avg_ct": {
"avg_bucket": {
"buckets_path": "eachtransID>date_diff"
}
}
}
}
}