Bird
Raised Fist0

Which of the following is the correct syntax to query Elasticsearch for CPU usage metrics in the last 5 minutes?

easy📝 Syntax Q3 of Q15
Elasticsearch - ELK Stack Integration
Which of the following is the correct syntax to query Elasticsearch for CPU usage metrics in the last 5 minutes?
APOST /metrics/_search { "filter": { "time": "last 5 minutes" } }
BGET /metrics/_search { "query": { "range": { "@timestamp": { "gte": "now-5m" } } } }
CGET /metrics/_search { "query": { "match_all": {} } }
DGET /metrics/_search { "query": { "term": { "cpu": "usage" } } }
Step-by-Step Solution
Solution:
  1. Step 1: Understand Elasticsearch query syntax for time range

    The range query with @timestamp and gte (greater than or equal) is used to filter documents by time.
  2. Step 2: Identify the correct JSON structure

    GET /metrics/_search { "query": { "range": { "@timestamp": { "gte": "now-5m" } } } } uses the correct GET method and range query for last 5 minutes.
  3. Final Answer:

    GET /metrics/_search { "query": { "range": { "@timestamp": { "gte": "now-5m" } } } } -> Option B
  4. Quick Check:

    Time range query = GET /metrics/_search { "query": { "range": { "@timestamp": { "gte": "now-5m" } } } } [OK]
Quick Trick: Use range query with @timestamp for time filtering [OK]
Common Mistakes:
MISTAKES
  • Using POST instead of GET for search
  • Incorrect JSON structure for time filter
  • Using match_all without time filter

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Elasticsearch Quizzes