Audit Elasticsearch HTTP request bodies
Elastic Cloud Serverless projects are autoscaled environments, fully managed by Elastic and available on Elastic Cloud. Availability This functionality is not available in Elastic Cloud Serverless. The Elastic Stack includes Elastic's core products such as Elasticsearch, Kibana, Logstash, and Beats. Availability This functionality is generally available and ready for production usage. Unless stated otherwise on the page, this functionality is available when your Elastic Stack is deployed on Elastic Cloud Hosted, Elastic Cloud Enterprise, Elastic Cloud on Kubernetes, and self-managed environments. This documentation corresponds to the latest patch available for each minor version. If you're not using the latest patch, check the release notes for changes.
Serverless
Unavailable
Unavailable
Stack
Generally available
Elasticsearch can include the body of an authenticated REST request in its authentication_success audit event. Request bodies can contain search queries, indexing operations, security configuration changes, or payloads sent to other REST APIs.
To trace and analyze queries, use query logging. Request body auditing can capture query payloads, but it associates the HTTP body with a security audit event and doesn't provide query-specific fields such as duration, outcome, or targeted indices. If query logging isn't available, request body auditing can help identify submitted queries.
To include request bodies, configure the following setting in Elasticsearch:
xpack.security.audit.logfile.events.emit_request_body: true
You can apply this setting through cluster update settings API, as described in Configure audit logging. Alternatively, you can modify elasticsearch.yml in all nodes and restart for the changes to take effect.
The request body is available only on the authentication_success event generated by the REST layer on the coordinating node. This event isn't included by default. Add authentication_success to the existing xpack.security.audit.logfile.events.include list to capture request bodies while preserving the other event types that you audit.
Request bodies can contain sensitive data. Although Elasticsearch filters credentials from audited security APIs, other sensitive data might be recorded in plain text. A request body can also contain malicious content that breaks a parser consuming the audit logs.
How Elasticsearch records the request body depends on its content type:
request.body- For request bodies that Elasticsearch can represent as JSON, contains the full body as an escaped JSON string. Elasticsearch converts supported structured formats, such as YAML, to JSON. If you collect audit logs with the Elasticsearch integration or the Filebeat Elasticsearch module, the ingest pipeline maps
request.bodyto the Elastic Common Schema (ECS) fieldhttp.request.body.contentin indexed documents. request.raw_bodyThe Elastic Stack includes Elastic's core products such as Elasticsearch, Kibana, Logstash, and Beats. Availability Generally available since 9.4 This functionality is generally available and ready for production usage. Unless stated otherwise on the page, this functionality is available when your Elastic Stack is deployed on Elastic Cloud Hosted, Elastic Cloud Enterprise, Elastic Cloud on Kubernetes, and self-managed environments. This documentation corresponds to the latest patch available for each minor version. If you're not using the latest patch, check the release notes for changes.- Contains the request body as a Base64-encoded string when Elasticsearch can't represent it as JSON, such as for Protobuf telemetry payloads. Elasticsearch emits this field instead of
request.body. The audit event records the content type inrequest.raw_body_content_type. If the request specifies a content encoding, the audit event records it inrequest.raw_body_content_encoding.
For complete field descriptions, refer to audit event types.