0
0
Elasticsearchquery~20 mins

API key management in Elasticsearch - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
API Key Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this API key creation response?
You run this Elasticsearch API call to create an API key. What is the output?
Elasticsearch
POST /_security/api_key
{
  "name": "my-api-key",
  "role_descriptors": {
    "my-role": {
      "cluster": ["all"],
      "index": [
        {
          "names": ["my-index"],
          "privileges": ["read"]
        }
      ]
    }
  }
}
A{"name":"my-api-key","api_key":"ZXhhbXBsZWFwaWtleQ=="}
B{"id":"abc123","name":"my-api-key"}
C{"error":"missing api_key field"}
D{"id":"abc123","name":"my-api-key","api_key":"ZXhhbXBsZWFwaWtleQ=="}
Attempts:
2 left
💡 Hint
The API key creation response includes the key ID, name, and the encoded key string.
Predict Output
intermediate
2:00remaining
What error does this API key deletion request produce?
You try to delete an API key with this request but get an error. What is the error?
Elasticsearch
DELETE /_security/api_key
{
  "id": "nonexistent-id"
}
A{"found":false}
B{"deleted":false}
C{"status":404,"error":"Not Found"}
D{"error":"api key not found"}
Attempts:
2 left
💡 Hint
Elasticsearch returns a simple found flag for deletion attempts.
🧠 Conceptual
advanced
2:00remaining
Which option correctly describes API key privileges in Elasticsearch?
Choose the correct statement about API key privileges in Elasticsearch.
AAPI keys can have both cluster and index privileges defined in role descriptors.
BAPI keys can only have cluster-wide privileges, not index privileges.
CAPI keys automatically inherit all privileges of the user who created them.
DAPI keys cannot be restricted and always have full access.
Attempts:
2 left
💡 Hint
Think about how roles define access in Elasticsearch.
Predict Output
advanced
2:00remaining
What is the output of this API key authentication attempt?
You use this API key in the Authorization header to authenticate. What is the expected response?
Elasticsearch
GET /_security/_authenticate
Headers: {"Authorization": "ApiKey ZXhhbXBsZWFwaWtleQ=="}
A{"error":"invalid api key"}
B{"username":"elastic","roles":["superuser"],"api_key":{"id":"abc123","name":"my-api-key"}}
C{"username":"elastic","roles":[],"api_key":null}
D{"status":401,"error":"Unauthorized"}
Attempts:
2 left
💡 Hint
Successful API key authentication returns user info and key details.
Predict Output
expert
2:00remaining
How many API keys are returned by this query?
You run this request to list API keys created by user 'alice'. How many keys are returned?
Elasticsearch
GET /_security/api_key?owner=true
AThe response is empty because 'owner' is not a valid parameter.
BThe response contains all API keys in the cluster regardless of owner, count is total keys.
CThe response contains only API keys created by the authenticated user, count depends on keys owned.
DThe response contains only API keys created by other users, excluding the authenticated user.
Attempts:
2 left
💡 Hint
The 'owner' parameter filters keys by the authenticated user.