Type to search.

Audit Elasticsearch HTTP request bodies

Serverless Unavailable

Elastic Cloud Serverless projects are autoscaled environments, fully managed by Elastic and available on Elastic Cloud.

Availability

  • Unavailable

    This functionality is not available in Elastic Cloud Serverless.

Stack

The Elastic Stack includes Elastic's core products such as Elasticsearch, Kibana, Logstash, and Beats.

Availability

  • Generally available

    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.

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.

Note The Elastic Stack includes Elastic's core products such as Elasticsearch, Kibana, Logstash, and Beats. Availability Preview since 9.4 This functionality is in technical preview and is ready for evaluation. Use with caution in production; it is not recommended for mission-critical workloads. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features. Specific Support terms apply. 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.

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:

YAML
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.

Important

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.body to the Elastic Common Schema (ECS) field http.request.body.content in indexed documents.
request.raw_body The 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 in request.raw_body_content_type. If the request specifies a content encoding, the audit event records it in request.raw_body_content_encoding.

For complete field descriptions, refer to audit event types.