How to get the derived metric based on the calculated metric

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

metric expression is onlh available in time series visual builder.
you could also use timelion to do something like that,
however both with only work with time series data

ok , thanks a lot . I'll try it later

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.