Calculate average mean time to resolve?

Describe the issue:
I want to create a metric visualization for a dashboard that shows the average mean time to resolve a case. Each document in the index is a case that has a created date and a resolved date (say case.created and case.resolved), and I want to display the average mean time to resolve cases, calculated as average(case.resolved - case.created)
Anyone have any idea how to do this?

You can use a script as the source of your avg aggregation so that it gets calculated on that difference. I’m not sure if/how to surface that in the dashboard, though.

But I think it’s better to pre-compute this difference at index time (e.g. in an ingest pipeline) and then you’d just do the average aggregation on top of this new value.