Bird
Raised Fist0

Given this query:

medium📝 Command Output Q5 of Q15
Elasticsearch - ELK Stack Integration
Given this query:
GET /metrics/_search
{
  "query": {
    "bool": {
      "must": [
        { "match": { "host": "server1" } },
        { "range": { "@timestamp": { "gte": "now-1h" } } }
      ]
    }
  }
}

What does this query return?
AAll metrics from 'server1' in the last hour
BAll metrics from all hosts older than 1 hour
COnly documents with missing host field
DAn error due to invalid query syntax
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the bool query with must clauses

    Both conditions must be true: host equals 'server1' and timestamp within last hour.
  2. Step 2: Understand the range filter on @timestamp

    Range with gte 'now-1h' filters documents from the last hour.
  3. Final Answer:

    All metrics from 'server1' in the last hour -> Option A
  4. Quick Check:

    Bool must with host and time = All metrics from 'server1' in the last hour [OK]
Quick Trick: Bool must means all conditions must match [OK]
Common Mistakes:
MISTAKES
  • Misreading range as older than 1 hour
  • Ignoring the host match condition
  • Assuming syntax error without checking structure

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Elasticsearch Quizzes