Hello,
In order to have the ratio Demand Done /Total Demand per provider, I have looked at the bucket aggregations.
Therefore, I have two question :
1- Can someone, help me for the aggregation script? I tried the script below but It don't work.
2- How can I manage to have the result of the ratio per provider in Kibana?
Thank you for the help.
> POST logs-/hr/_search
> {
> "size": 0,
> "aggs": {
> "ratio_per_provider": {
> "terms": {
> "field": "provider.keyword",
> "size": 10
> },
> "aggs": {
> "nb_demand": {
> "value_count": {
> "field": "DemandId.keyword"
> }
> },
> "nb_executedDemand": {
> "filter": {
> "term": {
> "Executed": "TRUE"
> }
> },
> "aggs": {
> "exedemand": {
> "value_count": {
> "field": "DemandId.keyword"
> }
> }
> }
> },
> "ratio-percentage": {
> "bucket_script": {
> "buckets_path": {
> "tExeDemand": "nb_executedDemand>exedemand",
> "totalDemand": "nb_demand"
> },
> "script": "params.tExeDemand / params.totalDemand * 100"
> }
> }
> }
> }
> }
> }