Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):
OpenSearch 2.x
I see OpenSearch has a query profiling feature but this returns a lot more information than I need and adds significant overhead. Is there a lightweight way to return just CPU time spent? I see thread cpu time is tracked via the search backpressure mechanism so the data exists but I wasn’t able to figure out if it could be returned to the requester.
If not, is this a feature that would be worth implementing?
Call tasks api with setting the parameter detailed to true can show the resource stats for each task , like this:
GET _tasks?detailed=true
, the response contains resource stats for each task:
"resource_stats": {
"average": {
"cpu_time_in_nanos": 0,
"memory_in_bytes": 0
},
"total": {
"cpu_time_in_nanos": 0,
"memory_in_bytes": 0
},
"min": {
"cpu_time_in_nanos": 0,
"memory_in_bytes": 0
},
"max": {
"cpu_time_in_nanos": 0,
"memory_in_bytes": 0
},
"thread_info": {
"thread_executions": 0,
"active_threads": 0
}
}
},
you can only fetch the search tasks by specifying the action parameter:
GET _tasks?actions=*search&detailed
And if you can make do with the time spent on all queries of an index you can use the Indices Stats API.