What Is Role-Based Access Control (RBAC) in Elasticsearch?

What Is Role-Based Access Control (RBAC) in Elasticsearch?

The system that decides who can see what, write what, and manage what inside a cluster — built from three simple ideas: users, roles, and privileges. Learn how it actually works, piece by piece, in plain language.

Imagine an office building with hundreds of employees. The receptionist can access the lobby and the mailroom, but not the server room. A finance analyst can open the accounting floor, but not the executive suite. The building does not hand every employee a master key and hope for the best. Instead, it issues badges, and each badge is tied to a role that unlocks exactly the doors that role needs, nothing more.

Elasticsearch runs on the same idea, applied to data instead of doors. A cluster might hold customer records, financial transactions, application logs, and security events, all at once, all searched by different teams for different reasons. Without a system to control who can touch what, any person or application with a connection to the cluster could read, change, or delete anything in it. Role-Based Access Control, usually shortened to RBAC, is the badge system that prevents that.

This guide explains RBAC in Elasticsearch from the ground up. No prior security or Elasticsearch background is assumed. Every new term is explained the moment it appears, and every abstract idea is paired with something familiar from everyday life.

1What Is RBAC in Elasticsearch?

RBAC is a way of granting permission indirectly, through roles, instead of handing permissions to individual people one by one.

The one-sentence answer

Elasticsearch is a search and analytics engine that stores data across servers called nodes. Role-based access control is Elasticsearch’s primary authorization method: it works by assigning privileges to named roles, and then assigning those roles to users or groups, so that what a person can do is determined entirely by which roles they carry.

Two words matter enormously here, and they are easy to confuse. Authentication answers “who are you?” — it is the login step, checking a username and password, a certificate, or a token. Authorization answers “what are you allowed to do, now that we know who you are?” RBAC lives entirely on the authorization side. It never decides whether a login attempt is genuine; it only decides what a successfully logged-in identity is permitted to touch.

Everyday analogy

A hotel key card system authenticates you at check-in, when the front desk confirms your reservation and identity. It authorizes you every time you tap the card against a door, deciding whether that specific door opens for that specific card. RBAC is the second part: the logic that decides which doors any given card is allowed to open, based on what kind of guest, staff member, or manager holds it.

3
core building blocks: users, roles, and privileges
4+
privilege categories: cluster, index, application, and run_as
30+
built-in roles shipped with Elasticsearch out of the box

Why indirection is the whole point

It would technically be possible to grant permissions directly to each individual person: “Priya can read the orders index,” “Sam can write to the logs index,” and so on, one line per person. This approach collapses almost immediately in any organization bigger than a handful of people. When fifty analysts all need the same access, you would have to write and maintain fifty nearly identical permission entries. When that access needs to change, you would have to edit all fifty, and inevitably a few get missed.

RBAC solves this by inserting one layer of indirection. You define a role once — say, analyst_read_only — describing exactly what that role can do. Then you assign that one role to as many users as need it. Changing what analysts are allowed to do means editing the role definition a single time, and every user holding that role is updated automatically and consistently.

What RBAC is not

  • It is not encryption. RBAC controls who can ask for data through the API; encryption protects data at rest on disk and in transit over the network. Elasticsearch uses both, but they solve different problems.
  • It is not the same as a network firewall. A firewall decides which machines can even reach the cluster over the network. RBAC decides, once a connection and a login have already succeeded, what that authenticated identity may do.
  • It is not audit logging, although the two work well together. RBAC prevents actions; audit logging records what actually happened, including attempts that RBAC blocked.
i
Good to know

RBAC is part of the Elasticsearch security features, which also include authentication realms (native, file, LDAP, Active Directory, SAML, and others), API keys, transport and HTTP layer encryption, and audit logging. RBAC is specifically the authorization piece — the part answering “what can this identity do?” once every other security check has already passed.

2Why Elasticsearch Needs RBAC

Without access control, every person and application with a valid connection could read, change, or delete anything stored in the cluster.

The problem: one cluster, many audiences

A modern Elasticsearch deployment rarely serves just one purpose. The same cluster might store application logs that developers need to debug an outage, security events that only the security team should see, customer records that must stay restricted under privacy regulations, and business dashboards that executives check every morning. These audiences overlap in the systems they use but not in what they should be allowed to see or change.

Without RBAC, a single set of credentials that can search would, by default, be able to search everything, and depending on the surrounding setup, potentially write or delete data too. A support engineer looking up a single customer’s order history could, in principle, also see every other customer’s private data, or accidentally trigger a bulk delete meant for a completely different index.

The cost of getting this wrong

Overly broad access is not a theoretical risk. A single set of overshared credentials, if leaked through a misconfigured application, a committed configuration file, or a compromised laptop, can expose or destroy far more than the credentials were ever meant to touch. Many real-world data exposure incidents trace back not to a sophisticated attack, but to a database or search cluster that granted broad access “to keep things simple,” and later paid for that simplicity all at once.

flowchart LR
  A["Single shared superuser credential"] --> B["Used by many applications and people"]
  B --> C["One credential leaks or is misused"]
  C --> D["Attacker or mistake can read every index"]
  D --> E["Attacker or mistake can write or delete every index"]
  E --> F["Full data breach or full data loss"]
Fig 1 · What happens without RBAC: one shared, overly broad credential becomes a single point of total failure

RBAC breaks this chain early. A support engineer’s credentials, scoped to a narrow role, simply cannot read the security index even if those credentials are compromised, because the role attached to them never granted that permission in the first place. The damage from any single leaked credential is limited to exactly what that credential’s roles allowed, which is the entire purpose of the design.

Everyday analogy

Think about the principle of least privilege the way a bank vault works. A teller can open the cash drawer at their own station. A branch manager can open the vault. Neither one carries a master key to every vault in every branch across the country, even though both work for the same bank. If a teller’s badge is ever stolen, the thief gets one cash drawer, not the entire bank’s reserves.

The principle of least privilege

This idea — giving every identity the smallest set of permissions it genuinely needs to do its job, and nothing more — is called the principle of least privilege. RBAC is the mechanism Elasticsearch provides to actually implement that principle in practice, rather than it staying a nice idea nobody enforces. Roles are how “the smallest set of permissions needed” gets written down, stored, and applied consistently, forever, without depending on every administrator remembering to be careful by hand.

3Core Concepts You Need First

Eight simple ideas unlock the entire system. Learn these and every later chapter reads easily.

Concept 01

User

An identity that authenticates to Elasticsearch — a real person, or an application connecting with its own credentials. A user by itself has no permissions at all.

Concept 02

Role

A named, reusable collection of permissions. A role describes what actions are allowed on which resources, but is not tied to any specific person until assigned.

Concept 03

Privilege

A named group of one or more specific actions that can be performed against a secured resource — for example, the read privilege covers searching and retrieving documents.

Concept 04

Permission

A privilege combined with the specific resource it applies to, such as read access to one particular index, or manage access to the whole cluster.

Concept 05

Secured resource

Anything RBAC can protect: indices, aliases, individual documents, individual fields, other users, and the cluster itself.

Concept 06

Realm

The system that performs authentication — checking who someone is. Elasticsearch supports several realm types, including native, file, LDAP, Active Directory, and SAML.

Concept 07

Role mapping

The rule set that connects an external identity (a group in Active Directory, for instance) to one or more Elasticsearch roles, used whenever roles are not assigned directly.

Concept 08

Union of permissions

When a user holds more than one role, their effective, total permissions are the combination of every permission across every one of those roles — never a restriction to just the overlap.

Putting the pieces together

A useful way to hold all of this in your head at once: a user is who someone is. A role is a named bundle of permission. A privilege is one specific kind of allowed action. A permission is that action tied to a specific resource. Roles are built out of permissions, and users are given roles. Nothing is ever granted to a user directly in a well-designed setup; everything flows through the role in between.

Why “union,” not “intersection,” matters

This point trips people up constantly, so it deserves its own callout. If a user holds Role A, which grants read access to the orders index, and Role B, which grants read access to the shipping index, that user can read both indices — the combination of everything each role allows, not merely whatever the two roles happen to share in common. This has a direct and important consequence for security design: adding a role to a user can only ever expand what they can do, never shrink it. There is no equivalent of a role that “takes away” a permission another role granted.

!
Important limit

Because permissions always combine additively, the safest default is to assign the narrowest role that satisfies a need, and add more roles only when a genuinely new need appears. Assigning a broad role “just in case” and expecting a narrower role to rein it back in later does not work, because Elasticsearch has no mechanism for one role to override or restrict what another role already granted.

4Architecture: How the Pieces Fit Together

RBAC is not one component. It is several cooperating parts: realms that authenticate, roles that define permission, and a mapping layer that connects the two.

The big picture

Every request that reaches Elasticsearch’s security layer passes through authentication first, and only afterward through authorization. The diagram below shows the full path, from a raw request arriving at the cluster to a final decision on whether it is allowed to proceed.

flowchart TD
  A["Incoming request with credentials"] --> B["Authentication: which realm verifies this identity?"]
  B --> C["Identity confirmed: a user object exists"]
  C --> D["Role resolution: which roles apply to this user?"]
  D --> E["Native or file realm: roles assigned directly"]
  D --> F["External realm: role mapping rules translate groups to roles"]
  E --> G["Combine all resolved roles into one effective permission set"]
  F --> G
  G --> H["Authorization check against the requested action and resource"]
  H --> I["Allowed: request proceeds"]
  H --> J["Denied: request rejected"]
Fig 2 · The full path from an incoming request to an allow or deny decision

Notice the branch in the middle. Depending on which realm authenticated the user, roles arrive differently. Some realms attach roles to the user directly. Others rely entirely on role mapping to translate an external group membership into Elasticsearch roles. Both paths converge at the same place: one combined, effective set of permissions that the authorization check then measures the incoming request against.

Realms: where identity comes from

The native realm stores users and their role assignments directly inside Elasticsearch itself, managed through the Security API or the Kibana user management screens. The file realm reads users and their role assignments from a file on disk, which is common in simpler, self-managed, or containerized deployments where roles are set as part of basic authentication secrets. External realms — Active Directory, LDAP, SAML, OpenID Connect, Kerberos, and PKI among them — authenticate against systems the organization already runs, and use role mapping rules rather than direct assignment to decide which Elasticsearch roles an authenticated identity receives.

Roles: where permission lives

A role is defined once, independent of any specific realm, as a set of cluster privileges, index privileges (each tied to a pattern of index names), and optionally application privileges and a run_as list. The same role definition can be assigned to a native-realm user, referenced by a file-realm entry, or targeted by a role mapping rule for an external realm — the role itself does not care where the identity holding it came from.

Role mapping: the translation layer

Role mapping matters most for external realms, where Elasticsearch has no native concept of “this LDAP group” or “this SAML attribute.” A role mapping rule says, in effect, “anyone who authenticates through this realm and belongs to this external group should receive these Elasticsearch roles.” This is what lets an organization manage group membership in its existing identity system — Active Directory, for example — while Elasticsearch permissions stay automatically synchronized to it, with no need to create or update individual Elasticsearch users by hand every time someone joins or leaves a team.

i
Also worth knowing

API keys are a related but distinct mechanism, commonly used for machine-to-machine and application access rather than human logins. An API key can be created with its own role descriptors attached directly, and those descriptors are intersected with the creating user’s own permissions, meaning an API key can never grant more access than the person or service that created it already had.

5Internal Working: How an Authorization Decision Is Made

Every single request Elasticsearch receives goes through the same sequence of checks before it is allowed to do anything at all.

Step by step

1

Identity is established

Authentication confirms who is making the request, producing a verified user identity that the rest of the process can rely on.

2

All applicable roles are gathered

Every role assigned to that user — whether directly, through a role mapping rule, or through an API key’s own descriptors — is collected into one list.

3

Roles are merged into one effective permission set

Because permissions combine as a union, this step produces the single, complete answer to “everything this identity is currently allowed to do,” across every one of its roles at once.

4

The requested action is identified

Elasticsearch determines exactly what the incoming request is trying to do — search, index a document, delete an index, update a cluster setting — and which privilege category that action falls under.

5

The target resource is identified

For index-level actions, Elasticsearch resolves which specific indices, aliases, or data streams the request touches, since index privileges are always scoped to a name pattern.

6

The action and resource are checked against the effective permission set

If any permission in the combined set covers this exact action on this exact resource, the request is authorized to proceed.

7

Field and document restrictions are applied, if present

Even after an index-level check passes, field-level security and document-level security, if defined on the matching role, further narrow exactly what the request can see or affect within that index.

8

The request proceeds, or is rejected

A request that clears every check runs normally. One that fails any step is rejected with an authorization error, and the attempt can be recorded through audit logging.

Why the order of these steps matters

Authentication always happens before authorization, without exception, because authorization has no meaning without a confirmed identity to check permissions against. Similarly, index-level authorization always happens before field-level or document-level restrictions are even considered, because there is no point calculating which fields or documents someone can see inside an index they were never allowed to access in the first place. This ordering is what makes the whole system predictable: broader checks always gate narrower ones.

Everyday analogy

Getting into a restricted archive works the same way. A security guard checks your identification first (authentication). Then a second check confirms your badge is cleared for this particular archive room at all (index-level authorization). Only once you are standing inside does anyone check whether specific drawers are locked to you, or whether certain pages within a folder have been redacted before you’re handed the file (field-level and document-level security). Each check only matters once the one before it has already passed.

6Data Flow: Following One Search Request Through RBAC

Tracing one concrete request end to end shows exactly where each RBAC check happens in practice.

The journey of a search request

Imagine an analyst named Priya, who authenticates through her company’s Active Directory and searches an index called customer-orders, filtered to just her assigned region.

sequenceDiagram
  participant Priya as Priya (Client)
  participant Auth as Authentication (LDAP realm)
  participant Map as Role Mapping
  participant AuthZ as Authorization Engine
  participant Idx as customer-orders Index

  Priya->>Auth: Log in with Active Directory credentials
  Auth-->>Priya: Identity confirmed
  Auth->>Map: Look up Priya's AD group membership
  Map-->>AuthZ: Assign role "regional_analyst"
  Priya->>AuthZ: Search request on customer-orders
  AuthZ->>AuthZ: Check index privilege: read on customer-orders granted
  AuthZ->>AuthZ: Apply document-level security query: region = "APAC"
  AuthZ->>AuthZ: Apply field-level security: hide "internal_margin" field
  AuthZ->>Idx: Execute restricted search
  Idx-->>Priya: Only APAC documents, without internal_margin field
Fig 3 · One search request passes through authentication, role mapping, and three layers of authorization before any data comes back

Priya never sees an error and never even realizes most of these checks happened. From her point of view, she searched an index and got sensible results back. Underneath, the effective role she was assigned filtered the results down to her region automatically through document-level security, and hid a sensitive field through field-level security, entirely transparently.

What happens when a check fails

If Priya’s role had never granted read access to customer-orders at all, the request would be rejected at the index-privilege step, well before document-level or field-level security ever entered the picture, and she would receive an authorization error rather than an empty or filtered result. This distinction matters: a role that grants access but restricts it heavily behaves very differently from a role that grants no access at all, even though both can end up limiting what a user actually sees.

The write path looks similar, with higher stakes

A write request — indexing a new document, updating an existing one, or deleting one — follows the same authentication and index-privilege steps, but checks a different privilege (such as write, create, or delete rather than read). Field-level and document-level security interact with writes more carefully: a role restricted with field-level security cannot use the update API or bulk update actions at all, since partially updating a document a user cannot fully see creates ambiguous, unsafe semantics that Elasticsearch deliberately avoids rather than trying to guess the right behavior.

7Cluster Privileges Explained

Cluster privileges govern actions that affect the cluster as a whole, rather than any single index.

PrivilegeWhat it allows
allComplete cluster administration, including snapshots, node management, settings, and user or role control.
manageBuilds on monitor; adds operations that modify cluster state, such as snapshots, settings updates, and shard rerouting.
monitorRead-only cluster operations, such as health checks, statistics, and node information — looking, never changing.
manage_securityAll security-related operations, including creating, updating, and deleting users and roles, and clearing security caches.
manage_api_keyCreating, retrieving, updating, and invalidating REST API keys.
manage_tokenOperations on tokens generated by the Elasticsearch token service, used for OAuth2-style authentication flows.
manage_ilmManaging index lifecycle policies, which automate how indices age from hot storage through to eventual deletion.
manage_mlMachine learning operations, covering datafeeds, jobs, and model snapshots.
create_snapshotCreating snapshots against existing repositories, and viewing details of existing repositories and snapshots.

Reading these privileges the right way

Notice the pattern across almost every category here: a narrow, read-only monitor-style privilege, and a broader manage-style privilege that includes everything the narrower one does, plus the ability to actually change things. This pattern repeats throughout Elasticsearch’s privilege system deliberately, because it lets an administrator grant visibility into cluster health to a much wider group of people — dashboards, on-call engineers, automated monitoring tools — without also handing every one of them the power to change cluster settings or delete data.

A practical example

A team building an internal status dashboard that shows cluster health, node counts, and index sizes needs only the monitor cluster privilege. Granting that team the full manage or all privilege instead — simply because it was the first option that worked during initial testing — leaves the dashboard’s credentials capable of reconfiguring the entire cluster, a far larger blast radius than the dashboard was ever designed to need.

8Index Privileges Explained

Index privileges govern what can be done to the actual data stored in specific indices, aliases, or data streams.

PrivilegeWhat it allows
allAny action on the matching indices or data streams — the index-level equivalent of the cluster’s all privilege.
readRead-only operations: searching, counting, explaining relevance scores, and retrieving individual documents.
writeDocument write operations, including indexing new documents, updating existing ones, and deleting them.
createIndexing new documents specifically through the index API, without necessarily allowing updates to existing ones.
deleteDeleting individual documents from the matching indices.
manageEverything monitor allows, plus administrative tasks such as managing aliases, mappings, and settings, and triggering refresh or flush operations.
create_indexCreating new indices or data streams that match the role’s configured name pattern.
delete_indexRemoving entire indices or data streams — a far larger action than deleting individual documents within one.
view_index_metadataRead-only access to index metadata, commonly needed by Kibana users who need to see what indices exist without reading their contents.

Index privileges are always scoped to a pattern

Unlike cluster privileges, which apply cluster-wide, every index privilege in a role is tied to a pattern of index names, such as logs-* or customer-orders. This is what allows one role to grant broad read access to an entire family of log indices while granting a completely different, much narrower set of privileges to a single sensitive index, all within the same role definition, simply by listing multiple index-privilege blocks with different patterns.

Everyday analogy

A single employee badge can be programmed to open every door on the second floor, but only one specific door on the fourth floor. The badge is one object, but its authorization is expressed as multiple separate rules, each scoped to a different set of doors. An Elasticsearch role works the same way, with index name patterns standing in for floors and doors.

run_as: acting on behalf of someone else

The run_as privilege is different from the others in this chapter because it does not grant access to data directly. Instead, it allows an authenticated user to submit requests on behalf of a different, specified user, with the request then authorized using that second user’s own permissions rather than the original caller’s. This is primarily useful for trusted backend services that need to act on behalf of many different end users without storing or managing separate credentials for every single one of them.

9Built-in Roles You Should Know

Elasticsearch ships with a substantial library of ready-made roles, covering the most common needs so that not every deployment has to design permissions entirely from scratch.

Built-in

superuser

Full access to cluster management and every data index. Reserved for genuine administrators, and never assigned to applications or day-to-day accounts.

Built-in

kibana_admin

Grants access to all Kibana features across all spaces, intended for people administering Kibana itself rather than raw Elasticsearch data.

Built-in

kibana_system

A system-level role used by Kibana’s own backend connection to Elasticsearch, covering the reads, writes, and token management Kibana needs internally to function.

Built-in

viewer

Read-only access to all Kibana features, including Solutions, and to data indices — a safe default for people who only need to look, never change.

Built-in

editor

Full access to all Kibana features, including Solutions, but only read-only access to the underlying data indices themselves.

Built-in

monitoring_user

The minimum privileges required to use Elastic Stack monitoring features, without any broader administrative capability.

Built-in

machine_learning_admin

Full administrative access to machine learning APIs, jobs, and model management.

Built-in

machine_learning_user

The minimum privileges needed to view machine learning configuration and results, without administrative power over jobs.

Built-in

transform_admin / transform_user

Administrative versus read-only access to transforms, which convert existing indices into new, summarized ones.

Built-in

watcher_admin / watcher_user

Administrative versus read-only access to Watcher, the alerting feature that triggers actions based on conditions detected in the data.

Built-in

snapshot_user

Enough access to create snapshots and view their metadata, without the ability to restore data or manage repositories directly.

Built-in

remote_monitoring_agent

Used by monitoring agents to write monitoring data and create the indices that data lives in, without broader cluster access.

Why built-in roles exist, and when to use them

Built-in roles cover the common, well-understood cases that almost every deployment eventually needs: a way for Kibana itself to talk to Elasticsearch, a way for monitoring agents to report health data, a way for an administrator to have full control. Using a built-in role where one genuinely fits saves time and reduces the chance of a hand-written role accidentally missing a permission some internal feature quietly depends on. Built-in roles are also maintained and updated by Elastic itself as new versions add features, which a hand-rolled equivalent role would not automatically receive.

!
Important limit

Built-in roles are intentionally broad, because they are designed to cover an entire well-known use case such as “everything Kibana’s backend needs” rather than one specific team’s narrow slice of that use case. They should not be treated as a shortcut for custom application or team-specific access; those situations call for a purpose-built custom role, covered next.

10Designing Custom Roles

Most real deployments eventually need roles tailored to their own teams, applications, and data sensitivity, beyond what any built-in role covers.

Start from the job, not from the person

The most durable approach to designing custom roles is to name and define them around a job function or responsibility, rather than around any specific individual. A role called billing_read_only or log_ingest_writer describes a function that will outlive any one employee holding it, whereas a role built around one particular person’s exact current needs has to be rebuilt every time that person’s job changes, or when someone new needs equivalent access.

A worked example: a support team role

Consider a customer support team that needs to look up individual customer orders to answer questions, but should never see internal profit margins, should never be able to modify any order data, and should never touch any index outside the orders system entirely. A well-designed role for this team would grant the read index privilege scoped only to an orders-* index pattern, combined with field-level security excluding the internal_margin field, and no cluster privileges beyond perhaps monitor for basic health visibility if their tooling needs it.

flowchart TD
  R["Role: support_read_only"]
  R --> C1["Cluster privilege: monitor (optional, for tooling)"]
  R --> I1["Index privilege: read on pattern orders-*"]
  I1 --> F1["Field-level security: exclude internal_margin"]
  I1 --> D1["Document-level security: none needed, full order visibility within pattern"]
Fig 4 · A custom role built entirely around one team’s actual job, with nothing extra attached

Naming conventions that scale

As the number of custom roles grows, a consistent naming pattern prevents confusion later. Many organizations settle on a scheme like {team-or-system}_{index-scope}_{access-level}, producing names such as support_orders_read or billing_invoices_write. A name that states its scope and access level up front lets anyone reviewing the role list understand, at a glance, roughly what each role is for, without opening every single one to check.

Reviewing roles over time

Roles are not “set once and forget forever.” Job responsibilities shift, new indices appear, old indices get retired, and a role written two years ago may grant access to data patterns that no longer make sense, or fail to cover a new index that logically belongs within its original intent. Periodically reviewing custom roles against what they are actually used for in practice — rather than what someone guessed they might need years earlier — keeps the whole system honest and prevents silent permission creep.

A worked walkthrough: designing a role from a real request

Concepts land better with a concrete story attached. Imagine a data science team asks for “access to the analytics cluster” to build a new churn-prediction model. Taken literally, that request could mean anything from full superuser access to a narrow read-only slice of one index, so the first step is never to write a role, but to ask clarifying questions: which specific indices does the model actually need to read from, does the team need to write any new indices back, does the team need visibility into cluster health, and does any of the underlying data contain fields that should stay hidden from this particular team.

Suppose the answers turn out to be: read access to customer-events-* and customer-profile-*, write access to a new index the team will create themselves called churn-predictions, no need for cluster-wide visibility beyond basic health, and the customer-profile-* indices contain a field called payment_method_token that should never leave the payments team’s own systems.

Translating those answers into a role produces something like this, in plain language rather than raw syntax: a cluster privilege of monitor only; an index privilege of read on the pattern customer-events-* with no field restrictions, since that data was already considered non-sensitive; an index privilege of read on the pattern customer-profile-* with field-level security excluding payment_method_token; and an index privilege of create_index combined with write scoped specifically to the pattern churn-predictions, so the team can create and populate their own output index without touching anyone else’s. Every single privilege in that list traces back directly to something the team actually said they needed, which is exactly the discipline that keeps a role from quietly growing broader than its job requires.

11Field-Level and Document-Level Security

Beyond deciding which indices someone can touch, Elasticsearch can restrict access down to individual fields and individual documents within an index that a role otherwise permits.

Document-level security (DLS)

Document-level security restricts which specific documents inside an otherwise-accessible index a user’s search results are allowed to include. It works by attaching a query to the index permission within a role — the same kind of query you would write in an ordinary search request — and Elasticsearch silently applies that query as a filter on every request the role makes against that index. A role restricted to documents where region equals APAC, for instance, will simply never return documents from any other region, regardless of what the underlying search itself asked for.

This filtering can even reference details about the currently authenticated user through templating, so a single role definition can dynamically restrict each user to their own department, region, or account, rather than requiring one hand-written role per department.

!
Important limit

When a user holds multiple roles covering the same index, their document-level security queries combine with OR logic, and critically, if even one of those roles has no document-level security defined for that index at all, that role grants access to every document in it — which effectively cancels out the restriction the other, more careful role was trying to enforce. Mixing a broad, unrestricted role with a narrow, DLS-restricted role on the same index silently defeats the restriction.

Field-level security (FLS)

Field-level security restricts which specific fields within a document a role can see, using grant and except lists, with wildcard patterns supported for both. A role might grant access to an entire customer.* field group while separately excluding the specific customer.tax_id field from within that same group, hiding one sensitive piece of an otherwise visible record.

Field-level security also combines across multiple roles, but unlike document-level security’s OR-based filtering of rows, field visibility combines as a union of allowed fields — a user with two roles sees every field either role individually grants, and again, if any single role has no field restriction configured for an index at all, every field in that index becomes visible through that role, overriding any narrower restriction another role tried to apply.

Everyday analogy

Document-level security is like being handed only the case files that belong to your assigned clients, out of an entire filing cabinet full of everyone’s cases. Field-level security is like being handed your assigned client’s full case file, but with the social security number field physically redacted with a black marker before it reaches your desk. One controls which files you get; the other controls what you can read once you have a file in hand.

Interactions with write operations

A role that applies field-level security cannot be used to perform update operations, including the update API and bulk updates, because partially modifying a document containing fields the role cannot even see would create ambiguous, unsafe behavior — Elasticsearch has no sensible way to decide what should happen to fields a role cannot view but a write operation might otherwise touch. Certain other index-management actions, including cloning, shrinking, splitting, and working with certain alias operations, are similarly restricted or disallowed for roles using field-level or document-level security, since these operations reshape or copy an index in ways that do not interact cleanly with per-field or per-document restrictions.

Fields that stay visible no matter what

A small set of internal metadata fields, such as the document identifier and the routing value, remain accessible regardless of any field-level security configuration on a role. This is intentional rather than an oversight: these fields carry structural information Elasticsearch itself needs to locate and manage a document correctly, rather than business data that could be considered sensitive on its own, so restricting them would break normal operation without adding any meaningful protection.

Performance considerations for DLS and FLS

Document-level security is implemented as an additional filter applied to every query against the restricted index, which means it does carry a small, generally modest performance cost compared to an unrestricted query, since Elasticsearch has to evaluate the filter alongside whatever the request itself asked for. Certain advanced search features are deliberately disabled when document-level security is active on a request, including search profiling and suggesters, along with some caching optimizations for particularly complex or templated queries, because these features do not combine safely or efficiently with a per-user filtering layer sitting underneath them.

12Advantages, Disadvantages, and Trade-offs

RBAC is powerful, but it is a design discipline, not a switch you flip once and forget.

Advantages

  • Limits the damage any single compromised credential can cause, by design rather than by luck.
  • Scales cleanly as an organization grows — updating one role updates every user who holds it, instantly.
  • Lets an organization’s existing group structure, through role mapping, drive Elasticsearch permissions automatically.
  • Provides field- and document-level granularity for genuinely sensitive data, beyond simple index-level access.
  • Comes with a substantial library of built-in roles that cover common needs without custom work.

Trade-offs

  • Designing good custom roles requires real thought; a lazily broad role undermines the entire system’s purpose.
  • Permissions only ever combine additively, so a mistakenly over-broad role cannot be quietly narrowed by another, more careful role.
  • Field-level and document-level security add meaningful complexity, and interact with write operations in ways that are easy to overlook at first.
  • Role mapping for external realms requires the external identity system’s group structure to actually reflect real organizational boundaries, or the mapping inherits whatever mess already existed there.
  • Ongoing review is necessary — roles drift out of sync with actual job responsibilities if nobody revisits them.
“A role is a promise about what someone can do. Like any promise, it needs to be kept up to date, or it stops meaning anything.”

13Security Considerations Beyond RBAC

RBAC is one layer of a larger security posture. Understanding where it ends, and what picks up from there, prevents a false sense of complete protection.

RBAC assumes authentication already succeeded

Every guarantee RBAC provides rests on the assumption that the identity it is authorizing is genuine. If authentication itself is weak — passwords that never expire, no multi-factor authentication, or overly trusting external identity provider configuration — then RBAC is authorizing an identity that may not actually belong to the person it claims to. A carefully designed set of roles cannot compensate for a front door that was never properly locked.

Credentials and API keys still need their own hygiene

A role that follows the principle of least privilege perfectly still needs the credentials carrying it to be handled responsibly: rotated periodically, never committed into source control, and scoped through API keys with as short a lifetime and as narrow a role attachment as the situation allows. An API key created with an extremely broad role attached defeats much of the purpose of using a scoped API key at all, even though the key mechanism itself is sound.

Auditing closes the loop

RBAC prevents unauthorized actions; audit logging records what was attempted, whether it succeeded or was blocked, and by whom. The two work together: RBAC is the lock, and audit logging is the record of every attempt to turn the handle. A mature security posture treats denied-by-RBAC events in the audit log as worth periodically reviewing, since a pattern of repeated denials against the same sensitive index can be an early signal of either a misconfigured application or a genuine attempted intrusion.

i
What an interviewer may ask

“If RBAC is correctly configured, does that mean the cluster is secure?” A strong answer distinguishes authorization from the full security picture: RBAC controls what an authenticated identity can do, but overall security also depends on strong authentication, encrypted transport, careful credential handling, network-level restrictions, and audit visibility — RBAC is a necessary layer, not a complete security program on its own.

14Real-World Examples

Seeing RBAC applied to genuine, common situations makes the concept concrete rather than abstract.

Multi-team observability platforms

Organizations running a shared Elasticsearch cluster as the backbone of centralized logging often have dozens of teams, each owning a different application’s logs, all searching the same underlying cluster. RBAC, combined with index naming patterns like logs-team-a-* and logs-team-b-*, lets each team’s role grant access only to its own application’s data, while a separate platform team holds a broader role covering every log index for genuine cross-team troubleshooting.

Regulated industries and customer data

Financial services and healthcare organizations frequently face regulatory requirements that specific categories of customer data, such as tax identifiers or medical record numbers, be visible only to a narrow, named set of roles. Field-level security lets these organizations store all customer data together in one coherent index for operational simplicity, while still enforcing that only specifically authorized roles can ever see the regulated fields, satisfying compliance requirements without fragmenting the data model.

Software-as-a-service platforms with tenant isolation

Vendors running a single Elasticsearch cluster underneath many customer accounts often use document-level security, keyed to a tenant identifier stored on every document, to guarantee that one customer’s search requests can never return another customer’s data, even though all tenants’ data physically lives in the same underlying indices for operational efficiency.

Kibana access for mixed audiences

A single Kibana instance often serves both engineers who need to build and edit dashboards and executives who only need to view finished ones. Assigning engineers the editor built-in role and executives the viewer built-in role achieves exactly this split with zero custom role work, using Elastic’s own maintained built-in roles rather than building the equivalent distinction from scratch.

Security operations and threat-hunting teams

Security teams running detection and response workloads on Elasticsearch typically need very broad read access across every index containing event data, since a genuine investigation can require correlating signals from sources nobody predicted in advance. RBAC still applies here, just shaped differently: rather than narrow index scoping, these roles are usually broad on the read side but tightly restricted on write and administrative privileges, so investigators can search everything relevant to a case without being able to alter the underlying evidence they are examining.

CI/CD pipelines and automated ingestion services

Automated systems that continuously ingest logs, metrics, or build artifacts into Elasticsearch are a common source of overly broad access, simply because a working superuser credential is the fastest thing to reach for when a pipeline needs to get data in quickly. A properly scoped role for this kind of service typically needs only create_index and write on the specific index pattern it populates, with no read access to unrelated data and no cluster-level administrative privileges at all, since an ingestion pipeline has no legitimate reason to ever query or reconfigure indices outside its own narrow responsibility.

15Best Practices, Design Patterns, and Common Mistakes

Practical guidance for building an RBAC setup that stays trustworthy as an organization and its data grow.

Best practice

Design roles around jobs, not people

Name and scope roles by function, so a role outlives any single person currently holding it and applies cleanly to the next person too.

Best practice

Start narrow, expand deliberately

Grant the smallest set of privileges a role’s job genuinely requires, and add more only when a specific, real need appears — never “just in case.”

Best practice

Reserve superuser for genuine administrators

Never assign the built-in superuser role to applications, automated processes, or day-to-day human accounts that do not need full cluster control.

Best practice

Use role mapping to leverage existing groups

Let an organization’s existing directory service drive Elasticsearch role assignment automatically, rather than manually managing native-realm users in parallel.

Best practice

Scope API keys as tightly as the task allows

Attach the narrowest possible role descriptors to every API key, and set an expiration where the use case allows one.

Best practice

Review roles periodically

Revisit custom roles against how they are actually used in practice, retiring or tightening ones that have drifted from their original purpose.

Common mistakes to avoid

ANTI-PATTERN · Mixing a broad role with a DLS-restricted oneAvoid
The mistake

Assigning a user both a carefully document-level-restricted role and a second, broader role that has no document-level security defined at all for the same index.

Why it backfires

Because document-level security queries combine with OR logic, and a role with no restriction defined grants access to every document, the broader role silently cancels out the careful restriction the narrower role was meant to enforce — often without anyone noticing until an audit turns it up.

What to do instead

Keep DLS-restricted roles and unrestricted roles on the same index mutually exclusive for any given user, and explicitly document which roles are meant to combine with which.

ANTI-PATTERN · Treating a role as permanent once writtenAvoid
The mistake

Writing a role once during initial setup and never revisiting it again, even as the team’s responsibilities, the indices in the cluster, and the sensitivity of the data all change over the following years.

Why it backfires

Roles drift silently. A pattern like logs-* written when only application logs existed can, years later, unintentionally also cover a newly created, far more sensitive index that happens to match the same naming pattern.

What to do instead

Schedule periodic reviews of role definitions against the current index landscape and current team responsibilities, treating roles as living configuration rather than a one-time setup task.

16Frequently Asked Questions

Q1Is RBAC the same thing as authentication in Elasticsearch?
No. Authentication confirms who someone is, through a realm such as native, file, LDAP, or SAML. RBAC is the authorization layer that comes afterward, deciding what that already-confirmed identity is allowed to do. Both are part of Elasticsearch’s overall security features, but they answer different questions.
Q2Can I take away a permission by assigning a more restrictive role afterward?
No. Permissions across all of a user’s roles always combine as a union, so adding any role can only expand what a user can do, never narrow it. If a user should have less access, the fix is to remove or edit the role that granted the unwanted permission in the first place, not to add a supposedly “more restrictive” role on top.
Q3What happens if two roles define conflicting document-level security for the same index?
Their queries combine with OR logic, meaning a user sees the union of documents either role’s query would return on its own. If either role has no document-level security defined for that index at all, that role effectively grants access to every document, overriding the more restrictive role’s intent for that index.
Q4Do I need a custom role for every single team, or can built-in roles usually cover it?
It depends on how closely a team’s actual needs match an existing built-in role’s intended purpose. Built-in roles cover broad, common cases well, such as Kibana administration or read-only dashboard viewing. Anything scoped to specific application data, specific index patterns, or specific sensitive fields almost always needs a purpose-built custom role.
Q5Can an API key have more access than the user who created it?
No. An API key’s effective permissions are the intersection of the role descriptors attached to the key itself and the permissions the creating user already held at the moment of creation. An API key can only narrow access relative to its creator, never expand beyond it.
Q6Why can’t a role with field-level security be used for update operations?
Because updating a document, particularly through partial update or bulk update operations, can require reading and rewriting fields the role’s field-level security might not even permit it to see. Rather than guessing at ambiguous behavior, Elasticsearch disallows these operations for roles carrying field-level security restrictions on the relevant index.
Q7Is document-level security the same as filtering results in the application layer instead?
No, and the difference matters for security, not just convenience. Application-layer filtering only works if every single application correctly implements the filter every single time, with no exceptions. Document-level security is enforced inside Elasticsearch itself, at the authorization layer, so it applies consistently regardless of which application, script, or direct API call is making the request.
Q8How does role mapping know which Elasticsearch roles to assign to an Active Directory or LDAP user?
Role mapping rules match on attributes of the authenticated identity supplied by the external realm, most commonly group membership, and translate a match into one or more specific Elasticsearch role names. The external system’s own group structure effectively drives Elasticsearch access, provided the mapping rules are configured to reflect it accurately.
Q9If I remove a role from a user, does that take effect immediately?
Generally yes for future requests, since authorization is recalculated on each request against the user’s currently assigned roles, though Elasticsearch does cache some security information briefly for performance. If an immediate, guaranteed effect is required after a sensitive change, clearing the relevant security caches confirms the update is in effect everywhere right away rather than waiting for a cache to naturally expire.
Q10Can a role restrict access to specific aliases rather than raw index names?
Yes, index privileges can be scoped to alias names just as they can to concrete index names or wildcard patterns, since aliases are themselves a kind of named reference to one or more underlying indices. This is a common pattern for giving a role stable access to “the current version” of a dataset without needing to update the role every time the underlying index is rotated or reindexed.
Q11Does RBAC apply the same way to requests made through Kibana as it does to raw API calls?
The same underlying Elasticsearch roles and privileges apply either way, since Kibana ultimately issues requests to Elasticsearch using the logged-in user’s own credentials for most actions. Kibana also layers its own separate concept of feature and space privileges on top, controlling which Kibana screens and features a user sees, which is a related but distinct authorization system built specifically for Kibana rather than for Elasticsearch’s own data APIs.
Q12Is it possible to see exactly why a specific request was denied?
Yes. Elasticsearch returns an authorization error indicating the request was denied, and audit logging, when enabled, records denied access attempts in detail, including which user, which action, and which resource were involved. Reviewing these records is the standard way to diagnose whether a denial reflects a genuinely missing permission or a role that needs to be corrected.

17Summary and Key Takeaways

The essentials, distilled

  • RBAC is Elasticsearch’s authorization system. It works by granting privileges to named roles, and then assigning those roles to users, so that what any identity can do is determined entirely by the roles it carries.
  • Authentication and authorization are different questions. Realms answer “who are you?”; RBAC answers “what are you allowed to do, now that we know?” RBAC only ever operates on an identity that has already been confirmed.
  • Permissions across roles always combine as a union. Holding more roles can only ever expand what a user can do, never narrow it — there is no mechanism for one role to restrict what another already granted.
  • Privileges come in categories: cluster, index, application, and run_as. Cluster privileges govern the cluster as a whole; index privileges are always scoped to a name pattern; run_as allows acting on behalf of another user.
  • Built-in roles cover common needs out of the box — superuser, kibana_admin, viewer, editor, and dozens more — while custom roles handle anything scoped to a specific team, application, or sensitive dataset.
  • Field-level and document-level security add fine-grained control within an otherwise-accessible index, but require care: an unrestricted role on the same index can silently cancel out a carefully restricted one.
  • RBAC is one layer of a larger security posture. It depends on strong authentication underneath it and works best alongside careful credential handling and genuine audit logging above it.