How to Configure Elasticsearch Service Account
You set up an elasticsearch service account by generating a bearer token for an internal stack tool. This token lets the app log in and run tasks without a user password. Many teams use these tokens for routine background jobs or data pipelines. When teams grant broad permissions to a token, any caller with that token can read or change whole indices. How an elasticsearch service account works in your cluster An elasticsearch service account is a special identity built for official stack apps
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
You set up an elasticsearch service account by generating a bearer token for an internal stack tool. This token lets the app log in and run tasks without a user password. Many teams use these tokens for routine background jobs or data pipelines. When teams grant broad permissions to a token, any caller with that token can read or change whole indices.
How an elasticsearch service account works in your cluster
An elasticsearch service account is a special identity built for official stack apps. You do not create new custom account types from scratch. Instead, the cluster provides built-in namespaces for tools like Kibana, Fleet, and Logstash. Each account holds a fixed set of permissions tied to that tool's daily job.
To use the account, an admin generates a secret token through the cluster API or a local node tool. Node tokens sit in local files on the server. API tokens live inside the cluster security index and replicate across all nodes. The external app sends this token in the HTTP header on every request. The cluster checks the token, matches the built-in permissions, and runs the request.
For custom apps that are not part of the official stack, teams use API keys instead. An API key lets you pick exact index roles for your own scripts. Service accounts stay locked to the exact duties of official stack components.
Choosing between tokens and API keys for apps
Teams often mix up service account tokens and regular API keys during setup. Service accounts only work for official stack components with predefined roles. You cannot edit the permissions attached to a service account token. If a built-in role has broad cluster rights, the token keeps those exact rights.
Custom apps need standard API keys or user roles with tight index rules. When a team reuses a service token for a custom script, that script gets too much power. It can read system states or change settings meant only for stack tools. Keeping official stack tokens separate from custom app keys prevents accidental data leaks.
Service-to-Service Authentication + Service Account Governance: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
What native tokens solve and where gaps remain
Native tokens remove the need to share human passwords across your servers. You can create multiple tokens for one service account and revoke a single token at any time. This makes key rotation simple when you move an app to a new host. The cluster also tracks token usage so you know which component logged in.
Still, native tokens only check who logs in at the start of a request. Once a token passes that check, the cluster trusts every query inside that scope. Native tokens do not pause a risky delete query for human approval. They also do not mask sensitive fields like emails, phone numbers, or card numbers in search results. If an engineer or script uses a valid token, the cluster returns the raw documents right away. Teams that need query-level checks or dynamic data masking must look beyond static token setup.
Add runtime guardrails and masking beside your databases and APIs
Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits inline in the protocol beside the service as an open-source proxy, a sidecar for your database or API. On every production query an agent or human runs, hoop.dev decides whether to pass, mask, block, or escalate it for review.
Before a query runs, hoop.dev guardrails check the statement against your rules, an AI Analyzer you configure can score intent or hold risky calls for human approval, and hoop.dev data masking rewrites sensitive fields in responses in memory. Explore the MIT-licensed project on GitHub.
Frequently asked questions
Can I create a custom elasticsearch service account for my own app?
No, service accounts are reserved for official stack components like Kibana or Fleet. For your own custom apps, you should create an API key with specific index roles.
How do I rotate a leaked service account token?
You generate a new token for that service account and update your app settings. Once the app uses the new token, you delete the old token through the cluster API.
Do service account tokens expire on their own?
No, service account tokens stay active until an admin deletes them. You must track and rotate these tokens on a set schedule to keep your cluster safe.
Related guides
In this post