Review Elasticsearch log publishing

Configure required log types and their generation settings for operational and security investigations.

Description

Elasticsearch and OpenSearch domains have separate log types for slow searches, slow indexing, engine errors and audit events.

Potential impact

A missing log type can leave you without the records needed to investigate a delay or identify who performed an operation.

Remediation

In logPublishingOptions, choose each required type and destination group ARN, then set enabled to true. Allow the service to write to the group and set retention. For slow logs, set per-index thresholds. For audit logs, enable fine-grained access control and auditing for the required categories. Verify an event of the selected type reaches its group.

Examples

The excerpts show parts of the same exampleDomain. Add the second excerpt’s publishing option to the existing engine and cluster settings, and supply the referenced log group.

Before

yaml
resources:
  exampleDomain:
    type: aws:elasticsearch:Domain
    properties:
      elasticsearchVersion: "7.10"
      clusterConfig:
        instanceType: t2.small.elasticsearch
        instanceCount: 1

After

yaml
resources:
  exampleDomain:
    type: aws:elasticsearch:Domain
    properties:
      logPublishingOptions:
        - cloudwatchLogGroupArn: ${exampleLogGroup.arn}
          logType: INDEX_SLOW_LOGS
          enabled: true

INDEX_SLOW_LOGS publishes only indexing operations that exceed a configured threshold.

References