Versions (relevant - OpenSearch 2.17):
Describe the issue:
Hi everyone, I am trying to write a query where I calculate percentile on an day value for an attribute event_metricValueDouble for all the assets. But since this metric is available for every 10 min for every asset, I have to sum it up per day first and then calculate the percentile.
What I am noticing is that it is not creating buckets for days when there is no data (in this case I select window from 7 Jan 2025 to 22 Jan 2025), thereby calculating the percentile bucket aggregation wrongly. I tried adding missing_doc_count but it didn’t create bucket in that case as well as show in screenshot below.
"aggs": {
"usage_by_asset": {
"aggs": {
"childAsset": {
"aggs": {
"usage_per_day": {
"aggs": {
"maxCustomCodeTotalDuration": {
"aggs": {
"usage": {
"sum": {
"field": "event_metricValueDouble"
}
}
},
"filter": {
"term": {
"event_metricName": {
"value": "maxCustomCodeTotalDuration"
}
}
}
}
},
"date_histogram": {
"field": "eventDateTime",
"fixed_interval": "1d",
"min_doc_count": 0
}
},
"percentiles_maxCustomCodeTotalDuration_usage": {
"percentiles_bucket": {
"percents": [
90
],
"buckets_path": "usage_per_day>maxCustomCodeTotalDuration>usage"
}
}
},
"terms": {
"field": "event_assetId",
"size": 10000
}
}
},
"filter": {
"term": {
"event_metricName": {
"value": "maxCustomCodeTotalDuration"
}
}
}
}
}
Can you provide another approach that I can use?
Thank you
Configuration:
Relevant Logs or Screenshots: