If I understand correctly, you want a histogram of the duration metric as the x-axis, and the Y-axis to be a percentage of the count of documents with that duration, out of the total number of documents. So if you add up all the percentage data values, you'd have 100%. Therefore, the count of documents is normalized to a percentage of the total.
This is a bit of a hard challenge technically, and something that Kibana doesn't currently support. Although, you might want to try to dig up more information talking to Elasticsearch experts.
For more background, Elasticsearch has a concept of pipeline aggregations, where you can take buckets from one kind of aggregation (in your case a
histogram aggregation across
duration) and pipe them through to another aggregation, such as a
bucket_script aggregation, which would let you have a math operation over values of the buckets. However, in getting the references to values in a pipeline aggregation, you can refer to a sibling aggregation (
"buckets_path": "parent>child") or a parent aggregation (
"buckets_path": "parent") . But in this case, when we have a metric aggregation (total number of documents) that is sibling to the parent aggregation (histogram), your requirement is to reference something like an aunt/uncle metric aggregation, which Elasticsearch currently doesn't support.