Review Elasticsearch and OpenSearch error logging

Deliver the logs needed to investigate domain errors to CloudWatch.

Description

ES_APPLICATION_LOGS publishes domain errors and warnings from operations such as querying, indexing and snapshots. A complete record of individual requests requires separate logging.

Potential impact

Missing error messages can delay diagnosis. The logs themselves can contain sensitive query data.

Remediation

Set retention and reader access on the destination group, then allow service writes in the CloudWatch Logs resource policy. On an engine that supports error logs, set the group ARN and Enabled: true under ES_APPLICATION_LOGS. Check that a qualifying error or warning reaches the group. Configure any required audit logs, slow logs and alarms separately.

Examples

The two AWS::Elasticsearch::Domain excerpts use the same destination and change only error-log publishing.

Before

yaml
Resources:
  ElasticsearchDomain:
    Type: AWS::Elasticsearch::Domain
    Properties:
      DomainName: my-domain
      LogPublishingOptions:
        ES_APPLICATION_LOGS:
          CloudWatchLogsLogGroupArn: arn:aws:logs:us-east-1:123456789012:log-group:/aws/aes/domains/app
          Enabled: false

After

yaml
Resources:
  ElasticsearchDomain:
    Type: AWS::Elasticsearch::Domain
    Properties:
      DomainName: my-domain
      LogPublishingOptions:
        ES_APPLICATION_LOGS:
          CloudWatchLogsLogGroupArn: arn:aws:logs:us-east-1:123456789012:log-group:/aws/aes/domains/app
          Enabled: true

References