Complete the code to query all documents from the 'metrics' index.
{
"index": "metrics",
"body": {
"query": {
"match_all": [1]
}
}
}The match_all query requires an empty JSON object {} to match all documents.
Complete the code to filter documents where the 'status' field is 'active'.
{
"query": {
"term": {
"status": [1]
}
}
}The term query expects the exact value as a string, so use "active".
Fix the error in the aggregation to calculate average CPU usage.
{
"aggs": {
"avg_cpu": {
"avg": {
"field": [1]
}
}
}
}The field name must be a string with quotes, like "cpu_usage".
Fill both blanks to create a range query filtering memory usage between 4GB and 16GB.
{
"query": {
"range": {
"memory": {
"gte": [1],
"lte": [2]
}
}
}
}Use the correct string format for sizes: "4gb" and "16gb" to specify the range.
Fill all three blanks to create a terms aggregation on 'host' filtering buckets with doc_count greater than 10.
{
"aggs": {
"hosts": {
"terms": {
"field": [1]
},
"aggs": {
"filtered_hosts": {
"bucket_selector": {
"buckets_path": {
"count": [2]
},
"script": "params.count [3] 10"
}
}
}
}
}
}Use "host.keyword" for exact terms aggregation, "_count" for bucket doc count, and ">" in the script to filter counts greater than 10.