Create and assign feature roles to APM Server users
editCreate and assign feature roles to APM Server users
editManage access on a feature-by-feature basis by creating several custom feature-related roles and assigning one or more of these roles to each user or group based on which features they need to access.
A role identifies a set of permissions that translates to privileges on resources. You can associate a user or group with an arbitrary number of roles. The total set of permissions that a user has is defined by the union of the permissions in all its roles.
In general, there are three types of privileges you’ll work with when creating roles:
- Elasticsearch cluster privileges: Manage the actions a user can perform against your cluster.
- Elasticsearch index privileges: Control access to the data in specific indices of your cluster.
- Kibana space privileges: Grant users write or read access to features and apps within Kibana.
The following are common roles that APM Server users might need:
- Writer role: Allows a user to publish events collected by APM Server, which is required to write to Elasticsearch.
- Central configuration management role: Allows a user to view APM Agent central configurations, which is required when central configuration management is enabled (it is enabled by default).
- Monitoring role: Allows a user to publish monitoring data, view monitoring data, or both.
- RUM source mapping role: Allows a user to read RUM source maps.
APM users that publish events to Elasticsearch must have privileges to write to APM data streams.
This is not needed when APM Server doesn’t write to Elasticsearch directly.
For example, in some cases you may configure APM Server to write to another
output like Logstash, Kafka, or any other output supported by libbeat.
In these cases, different authentication credentials will need to be passed to
apm-server.agent.config.elasticsearch
.
To grant an APM Server user the required privileges for writing events to Elasticsearch:
-
Create a general writer role, called something like
apm_writer
, that has the following privileges:Type Privilege Purpose Index
auto_configure
ontraces-apm*
,logs-apm*
, andmetrics-apm*
indicesPermits auto-creation of indices and data streams
Index
create_doc
ontraces-apm*
,logs-apm*
, andmetrics-apm*
indicesWrite events into Elasticsearch
Cluster
monitor
- Allows cluster UUID checks, which are performed as part of APM server startup preconditions if Elasticsearch security is enabled (it is enabled by default).
- Allows a license check, which is required if tail-based sampling is enabled.
If you have explicitly disabled Elastic security and you are not using tail-based sampling, this privilege may not be necessary.
- Assign the general writer role to APM Server users who need to publish APM data.
Assign additional APM feature roles to users as needed including the Central configuration management role, which is required in most cases.
The privileges included in this role are required for all users when central configuration management is enabled (it is enabled by default). You need this role unless central configuration management has been explicitly disabled in the Applications UI.
APM Server acts as a proxy between your APM agents and the Applications UI. The Applications UI communicates any changed settings to APM Server so that your agents only need to poll the Server to determine which central configuration settings have changed.
To create a role with the required privileges for managing central configuration in Elasticsearch without Kibana, you must use the Roles API (the required privileges can’t be assigned to a role in Kibana):
POST /_security/role/apm_agentcfg { "description": "Allow APM Server to manage central configurations in Elasticsearch.", "indices": [ { "names": [".apm-agent-configuration"], "privileges": ["read"], "allow_restricted_indices": true } ] }
The previous privileges should be sufficient for APM agent central configuration to work properly as long as APM Server communicates with Elasticsearch successfully. If it fails, it may fallback to read agent central configuration through Kibana if configured, which requires the following privileges:
Type | Privilege | Purpose |
---|---|---|
Spaces |
|
Allow APM Server to manage central configurations via the Applications UI |
Assign additional APM feature roles to users as needed including the Writer role, which is required in most cases.
Looking for privileges and roles needed to use central configuration from the Applications UI or APM UI API? See Applications UI central configuration user.
Elasticsearch security features provides built-in users and roles for publishing and viewing monitoring data. The privileges and roles needed to publish monitoring data depend on the method used to collect that data.
Elastic Cloud users: This section does not apply to our hosted Elasticsearch Service. Monitoring on Elastic Cloud is enabled by clicking the Enable button in the Monitoring panel.
If you’re using internal collection to collect metrics about APM Server, either:
-
Use the built-in
apm_system
user or role - Create a custom role
Use a built-in user or role
Elasticsearch security features provides the apm_system
built-in user and
apm_system
built-in role to send
monitoring information. You can use the built-in user, if it’s available in your
environment, create a user who has the built-in role assigned,
or create a user and manually assign the privileges needed to send monitoring
information.
If you use the built-in apm_system
user,
make sure you set the password before using it.
Create a custom role
If you don’t use the apm_system
user, you can create a custom role:
-
Create a monitoring role, called something like
apm_monitoring_writer
, that has the following privileges:Type Privilege Purpose Index
create_index
on.monitoring-beats-*
indicesCreate monitoring indices in Elasticsearch
Index
create_doc
on.monitoring-beats-*
indicesWrite monitoring events into Elasticsearch
- Assign the monitoring role to APM Server users who need to write monitoring data to Elasticsearch.
Assign additional APM feature roles to users as needed including the Writer role and Central configuration management role, both of which are required in most cases.
When using Metricbeat to collect metrics, no roles or users need to be created with APM Server. See Use Metricbeat collection for complete details on setting up Metricbeat collection.
If you’re using Metricbeat to collect metrics about APM Server, you can either:
-
Use the built-in
remote_monitoring_user
user or role - Create a custom user
Use a built-in user or role
Elasticsearch security features provides the remote_monitoring_user
built-in user, and the remote_monitoring_collector
and remote_monitoring_agent
built-in roles for
collecting and sending monitoring information. You can use the built-in user, if
it’s available in your environment, or create a user who has the privileges
needed to collect and send monitoring information.
If you use the built-in remote_monitoring_user
user,
make sure you set the password before using it.
Create a custom user
If you don’t use the remote_monitoring_user
user, you can create a custom user:
-
Create a monitoring user on the production cluster who will collect and send monitoring information. Assign the following roles to the monitoring user:
Role Purpose remote_monitoring_collector
Collect monitoring metrics from APM Server
remote_monitoring_agent
Send monitoring data to the monitoring cluster
Assign additional APM feature roles to users as needed including the Writer role and Central configuration management role, both of which are required in most cases.
To grant users the required privileges for viewing monitoring data:
-
Create a monitoring role, called something like
apm_monitoring_viewer
, that has the following privileges:Type Privilege Purpose Spaces
Read
on Stack monitoringRead-only access to the Stack Monitoring feature in Kibana.
Spaces
Read
on DashboardsRead-only access to the Dashboards feature in Kibana.
-
Assign the monitoring role, along with the following built-in roles, to users who need to view monitoring data for APM Server:
Role Purpose monitoring_user
Grants access to monitoring indices for APM Server
Assign additional APM feature roles to users as needed including the Writer role and Central configuration management role, both of which are required in most cases.
If real user monitoring is enabled, additional privileges are required to read source maps.
To grant an APM Server user with the required privileges for reading RUM source maps from Elasticsearch directly without Kibana, assign the user the following privileges:
Type | Privilege | Purpose |
---|---|---|
Index |
|
Allow APM Server to read RUM source maps from Elasticsearch |
Assign additional APM feature roles to users as needed including the Writer role and Central configuration management role, both of which are required in most cases.
The previous privileges should be sufficient for RUM source mapping to work properly as long as APM Server communicates with Elasticsearch successfully. If it fails, it may fallback to read source maps through Kibana if configured, which requires additional Kibana privileges. See RUM source map API for more details.