Elasticsearch Audit Logging: Who Accessed What, for DORA and ISO 27001

How to turn on Elasticsearch and Kibana audit logging, keep the volume manageable, link searches to real users, and store the logs so auditors trust them. Includes OpenSearch.

Sooner or later an auditor asks a simple question: who looked at this customer's data, and when? If your transactions, customer records or screening results live in Elasticsearch, the answer has to come from Elasticsearch too. Under DORA, ISO 27001 or an ISAE 3402 report, "we think only the app can read it" is not an answer.

This is how to set up audit logging that actually answers the question.

Turn on audit logging

In Elasticsearch, audit logging is part of the security features. On self-managed clusters it needs a paid subscription (Enterprise for new customers; Platinum is only offered to existing ones) or a trial; on Elastic Cloud it is available on the matching tiers. Check Elastic's subscription page for the current list. Add this to elasticsearch.yml on every node:

xpack.security.audit.enabled: true
xpack.security.audit.logfile.events.include:
  - access_denied
  - access_granted
  - authentication_failed
  - connection_denied
  - security_config_change
  - run_as_granted
  - run_as_denied

Each node writes JSON events to <cluster_name>_audit.json in its log directory. Kibana has its own audit log for who opened which dashboard, saved search or case:

# kibana.yml
xpack.security.audit.enabled: true

Keep the volume under control

access_granted logs every authorised request, including the cluster's own internal traffic and your monitoring agents. That can be more data than the business data itself. Filter out what nobody will ever ask about:

xpack.security.audit.logfile.events.ignore_filters:
  system_users:
    users: ["_xpack_security", "_async_search", "elastic/fleet-server"]
  metrics:
    indices: [".monitoring-*", "metrics-*"]

Keep emit_request_body off unless you really need it. Request bodies can contain the very data you are protecting, such as names, IBANs and search terms, and then your audit log becomes another copy of it.

This is the part most setups miss. If your application connects with one service account, every audit event says the same user did everything. Two ways to fix it:

  • X-Opaque-Id header: have the application send the end user's ID (or a session reference) on every request. It appears as opaque_id in the audit event.
  • run_as: the service account runs each request as the end user, who must exist in Elasticsearch or your identity provider. The event then shows both the service account and the real user, and the user's own roles apply.

run_as is stronger, because permissions are enforced per user, not just recorded. X-Opaque-Id is quicker to add to an existing application.

Store audit logs where they cannot be changed

An audit log that the cluster's admins can edit is weak evidence. A setup auditors accept:

  1. Ship the logs off the cluster with Elastic Agent or Filebeat (both have an audit log integration) to a separate monitoring cluster.
  2. Restrict that cluster: application admins can read it, nobody can delete from it, and only a few people can change its settings.
  3. Keep it for the required period with an index lifecycle policy: hot for a few weeks, then cold or frozen, deleted only after the retention period.
  4. Snapshot to write-once storage, such as S3 with Object Lock, for an extra copy that cannot be altered.

Questions the setup should answer in minutes

Test it with the questions an auditor or incident responder will ask:

  • Who read documents in the customers index for account 12345 last month?
  • Which users had failed logins over the weekend, and from which addresses?
  • Who changed a role, user or API key, and what changed?
  • Which service accounts accessed data outside office hours?

Save each one as a Kibana search or dashboard. If one takes more than a few minutes to answer, fix that before the audit.

OpenSearch

OpenSearch includes audit logging in its free security plugin. It is set in opensearch.yml with plugins.security.audit.type, for example internal_opensearch or external_opensearch to send events to another cluster, and fine-tuned in the security plugin's audit configuration. The same principles apply: filter the noise, pass the end user, and store the logs outside the reach of cluster admins. For the wider comparison, see Elasticsearch vs OpenSearch for banks.

Where compliance stops and Elasticsearch starts

Elasticsearch gives you evidence: access logs, configuration changes, failed logins and timelines for incidents. Compliance with DORA or ISO 27001 is still a matter of your processes and controls. We set up audit logging, access control and retention for banks and fintechs, and document every change for your audit trail; see Elasticsearch for fintech and Elasticsearch security best practices.

Talk to an Elasticsearch expert

We reply within one business day. Your details are used only to answer you.