0
0
Elasticsearchquery~10 mins

Why ELK stack provides observability in Elasticsearch - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create an index in Elasticsearch.

Elasticsearch
PUT /[1]-logs
{
  "mappings": {
    "properties": {
      "timestamp": { "type": "date" },
      "message": { "type": "text" }
    }
  }
}
Drag options to blanks, or click blank then click option'
Auser
Bapp
Csystem
Dnetwork
Attempts:
3 left
💡 Hint
Common Mistakes
Using unrelated index names like 'user' or 'network' for app logs.
2fill in blank
medium

Complete the code to query logs with a specific keyword.

Elasticsearch
GET /app-logs/_search
{
  "query": {
    "match": {
      "message": "[1]"
    }
  }
}
Drag options to blanks, or click blank then click option'
Aerror
Binfo
Cdebug
Dtrace
Attempts:
3 left
💡 Hint
Common Mistakes
Using less severe log levels like 'info' or 'debug' when searching for errors.
3fill in blank
hard

Fix the error in the aggregation to count logs by severity level.

Elasticsearch
GET /app-logs/_search
{
  "size": 0,
  "aggs": {
    "levels": {
      "terms": { "field": "[1]" }
    }
  }
}
Drag options to blanks, or click blank then click option'
Ahost
Bmessage
Cseverity.keyword
Dtimestamp
Attempts:
3 left
💡 Hint
Common Mistakes
Using analyzed text fields like 'message' or 'timestamp' for aggregation.
4fill in blank
hard

Fill both blanks to create a filter for logs between two timestamps.

Elasticsearch
GET /app-logs/_search
{
  "query": {
    "range": {
      "timestamp": {
        "gte": "[1]",
        "lte": "[2]"
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
A2024-01-01T00:00:00Z
B2023-12-31T23:59:59Z
C2024-01-31T23:59:59Z
D2023-01-01T00:00:00Z
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping start and end dates or using invalid date formats.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps log levels to counts for levels above 'warning'.

Elasticsearch
counts = {level: count for level, count in [1].items() if level [2] 'warning' and count [3] 0}
Drag options to blanks, or click blank then click option'
Alog_counts
B>
Dlog_data
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong variable names or incorrect comparison operators.