Bird
Raised Fist0

You need to create an API key that permits monitoring cluster health and read access to indices starting with "metrics-". Which JSON request body correctly implements this?

hard🚀 Application Q8 of Q15
Elasticsearch - Security
You need to create an API key that permits monitoring cluster health and read access to indices starting with "metrics-". Which JSON request body correctly implements this?
A{ "name": "metrics-monitor-key", "role_descriptors": { "monitor_role": { "cluster": ["monitor"], "index": [{ "names": ["metrics-*"], "privileges": ["read"] }] } } }
B{ "name": "metrics-monitor-key", "role_descriptors": { "monitor_role": { "cluster": "monitor", "index": { "names": "metrics-*", "privileges": "read" } } } }
C{ "name": "metrics-monitor-key", "role_descriptors": { "monitor_role": { "cluster": ["all"], "index": [{ "names": ["metrics-*"], "privileges": ["write"] }] } } }
D{ "name": "metrics-monitor-key", "role_descriptors": { "monitor_role": { "cluster": ["monitor"], "index": [{ "names": ["metrics"], "privileges": ["read"] }] } } }
Step-by-Step Solution
Solution:
  1. Step 1: Identify required privileges

    The API key must have cluster privilege "monitor" and index privilege "read" on indices matching "metrics-*".
  2. Step 2: Validate JSON structure

    { "name": "metrics-monitor-key", "role_descriptors": { "monitor_role": { "cluster": ["monitor"], "index": [{ "names": ["metrics-*"], "privileges": ["read"] }] } } } correctly uses arrays for cluster and index privileges and wildcard pattern "metrics-*" for index names.
  3. Step 3: Eliminate incorrect options

    { "name": "metrics-monitor-key", "role_descriptors": { "monitor_role": { "cluster": "monitor", "index": { "names": "metrics-*", "privileges": "read" } } } } uses strings instead of arrays, which is invalid. { "name": "metrics-monitor-key", "role_descriptors": { "monitor_role": { "cluster": ["all"], "index": [{ "names": ["metrics-*"], "privileges": ["write"] }] } } } grants cluster "all" and index "write" privileges, which is excessive. { "name": "metrics-monitor-key", "role_descriptors": { "monitor_role": { "cluster": ["monitor"], "index": [{ "names": ["metrics"], "privileges": ["read"] }] } } } uses "metrics" instead of "metrics-*" so it won't match all relevant indices.
  4. Final Answer:

    Option A -> Option A
  5. Quick Check:

    Use arrays and wildcards for index privileges [OK]
Quick Trick: Cluster privileges are arrays; use wildcards for index names [OK]
Common Mistakes:
MISTAKES
  • Using strings instead of arrays for privileges
  • Granting excessive cluster privileges
  • Not using wildcard patterns for index names

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Elasticsearch Quizzes