Create an APM agent key
Create a new agent key for APM.
The user creating an APM agent API key must have at least the manage_own_api_key
cluster privilege and the APM application-level privileges that it wishes to grant.
After it is created, you can copy the API key (Base64 encoded) and use it to to authorize requests from APM agents to the APM Server.
Headers
-
elastic-api-version
string Required The version of the API to use
Value is
2023-10-31
. Default value is2023-10-31
. -
kbn-xsrf
string Required A required header to protect against CSRF attacks
Body
Required
-
name
string Required The name of the APM agent key.
-
privileges
array[string] Required The APM agent key privileges. It can take one or more of the following values:
event:write
, which is required for ingesting APM agent events. *config_agent:read
, which is required for APM agents to read agent configuration remotely.
Values are
event:write
orconfig_agent:read
.
POST
/api/apm/agent_keys
curl \
--request POST 'https://localhost:5601/api/apm/agent_keys' \
--header "Authorization: $API_KEY" \
--header "Content-Type: application/json" \
--header "elastic-api-version: 2023-10-31" \
--header "kbn-xsrf: true" \
--data '"{\n \"name\": \"apm-key\",\n \"privileges\": [\"event:write\", \"config_agent:read\"]\n}\n"'
Request example
Run `POST /api/apm/agent_keys` to create an APM agent API key with the specified privileges.
{
"name": "apm-key",
"privileges": ["event:write", "config_agent:read"]
}
Response examples (200)
An example of a successful response from `POST /api/apm/agent_keys`, which creates an APM agent API key.
{
"agentKey": {
"id": "3DCLmn0B3ZMhLUa7WBG9",
"name": "apm-key",
"api_key": "PjGloCGOTzaZr8ilUPvkjA",
"encoded": "M0RDTG1uMEIzWk1oTFVhN1dCRzk6UGpHbG9DR09UemFacjhpbFVQdmtqQQ=="
}
}
Response examples (400)
{
"error": "Not Found",
"message": "Not Found",
"statusCode": 400
}
Response examples (401)
{
"error": "Unauthorized",
"message": "string",
"statusCode": 401
}
Response examples (403)
{
"error": "Forbidden",
"message": "string",
"statusCode": 403
}
Response examples (500)
{
"error": "Internal Server Error",
"message": "string",
"statusCode": 500
}