Closed deshsidd closed 2 months ago
This behavior is only when search.query.metrics.enabled
is true.
We append latency, cpu, memory data here based on shouldCollect()
which checks the individual metric flags OR search.query.metrics.enabled
:
private boolean shouldCollect(MetricType metricType) {
return queryInsightsService.isSearchQueryMetricsFeatureEnabled() || queryInsightsService.isCollectionEnabled(metricType);
}
When search.query.metrics.enabled=false
, top N only returns metrics which are enabled.
Example: 1st query has only latency, 2nd query has latency & cpu
curl -X GET "localhost:9200/_insights/top_queries?pretty"
{
"top_queries" : [
{
"timestamp" : 1724957602437,
"phase_latency_map" : {
"expand" : 0,
"query" : 1,
"fetch" : 0
},
"labels" : { },
"source" : {
"query" : {
"match_all" : {
"boost" : 1.0
}
}
},
"indices" : [ ],
"search_type" : "query_then_fetch",
"node_id" : "DCHfS-bKQHyLsBcqH5j6MQ",
"task_resource_usages" : [
{
"action" : "indices:data/read/search[phase/query]",
"taskId" : 265,
"parentTaskId" : 264,
"nodeId" : "DCHfS-bKQHyLsBcqH5j6MQ",
"taskResourceUsage" : {
"cpu_time_in_nanos" : 811000,
"memory_in_bytes" : 18248
}
},
{
"action" : "indices:data/read/search",
"taskId" : 264,
"parentTaskId" : -1,
"nodeId" : "DCHfS-bKQHyLsBcqH5j6MQ",
"taskResourceUsage" : {
"cpu_time_in_nanos" : 280000,
"memory_in_bytes" : 3272
}
}
],
"total_shards" : 1,
"latency" : 3
},
{
"timestamp" : 1724957554669,
"phase_latency_map" : {
"expand" : 0,
"query" : 2,
"fetch" : 0
},
"labels" : { },
"source" : {
"query" : {
"match_all" : {
"boost" : 1.0
}
}
},
"indices" : [ ],
"search_type" : "query_then_fetch",
"node_id" : "DCHfS-bKQHyLsBcqH5j6MQ",
"task_resource_usages" : [
{
"action" : "indices:data/read/search[phase/query]",
"taskId" : 243,
"parentTaskId" : 242,
"nodeId" : "DCHfS-bKQHyLsBcqH5j6MQ",
"taskResourceUsage" : {
"cpu_time_in_nanos" : 793000,
"memory_in_bytes" : 18248
}
},
{
"action" : "indices:data/read/search",
"taskId" : 242,
"parentTaskId" : -1,
"nodeId" : "DCHfS-bKQHyLsBcqH5j6MQ",
"taskResourceUsage" : {
"cpu_time_in_nanos" : 182000,
"memory_in_bytes" : 3272
}
}
],
"total_shards" : 1,
"cpu" : 975000,
"latency" : 3
}
]
}
This is an expected behavior, we always measure latency, cpu and memory usage unless you turn off search.query.metrics.enabled
as @dzane17 memtioned.
when you do GET /_insights/top_queries?type=latency, it means "get the top queries sorted by latency", but all other metrics will be included, it's just we are not sorting based on those keys.
What is the bug?
Need to filter out memory and cpu when we query top queries using param :
GET /_insights/top_queries?type=latency
However, looks like this is not getting filtered out and might be a regressions.How can one reproduce the bug?
Enabled topN:
Index docs and run a few search queries.
GET
http://{{hostname}}/_insights/top_queries?type=latency
What is the expected behavior?
returns latency, cpu and memory but should only return latency. Same for all the other combinations.
What is your host/environment?
mac localhost
Do you have any screenshots?
If applicable, add screenshots to help explain your problem.
Do you have any additional context?
Add any other context about the problem.