Back to Checks
Amazon OpenSearch Service domain publishes search and index slow logs to CloudWatch Logs
opensearch_service_domains_cloudwatch_logging_enabled
Service: opensearchSeverity: low
OfficialBuilt-inVerified
Categories:logging
Resource Type:AwsOpenSearchServiceDomain
Amazon OpenSearch Service domains have slow log publishing enabled for both search and indexing operations to CloudWatch Logs (SEARCH_SLOW_LOGS and INDEX_SLOW_LOGS).
Risk
Without these logs, visibility into expensive searches and slow indexing is lost, masking hotspots and abuse.
- Availability: timeouts, throttling, node pressure
- Integrity: missed or delayed indexing
- Operations: slower incident response and capacity planning
Run this check with Prowler
Run in Prowler CloudRun
prowler aws --checks opensearch_service_domains_cloudwatch_logging_enabledRecommendation
Enable both SEARCH_SLOW_LOGS and INDEX_SLOW_LOGS for all domains and publish to CloudWatch. Set meaningful thresholds and retention, separate log groups, and alert on anomalies. Apply least privilege to log access and use defense in depth with complementary error and audit logs.
Remediation
CLI
aws opensearch update-domain-config --domain-name <DOMAIN_NAME> --log-publishing-options "SEARCH_SLOW_LOGS={CloudWatchLogsLogGroupArn=<LOG_GROUP_ARN>,Enabled=true},INDEX_SLOW_LOGS={CloudWatchLogsLogGroupArn=<LOG_GROUP_ARN>,Enabled=true}"Terraform
# Enable OpenSearch search and index slow logs to CloudWatch
resource "aws_opensearch_domain" "<example_resource_name>" {
domain_name = "<example_resource_name>"
# Critical: enables SEARCH_SLOW_LOGS publishing
log_publishing_options {
log_type = "SEARCH_SLOW_LOGS"
cloudwatch_log_group_arn = "<LOG_GROUP_ARN>"
enabled = true
}
# Critical: enables INDEX_SLOW_LOGS publishing
log_publishing_options {
log_type = "INDEX_SLOW_LOGS"
cloudwatch_log_group_arn = "<LOG_GROUP_ARN>"
enabled = true
}
}NativeIaC
# CloudFormation: enable OpenSearch search and index slow logs to CloudWatch
Resources:
<example_resource_name>:
Type: AWS::OpenSearchService::Domain
Properties:
DomainName: <example_resource_name>
LogPublishingOptions:
SEARCH_SLOW_LOGS:
CloudWatchLogsLogGroupArn: <LOG_GROUP_ARN>
Enabled: true # Critical: enables SEARCH_SLOW_LOGS publishing
INDEX_SLOW_LOGS:
CloudWatchLogsLogGroupArn: <LOG_GROUP_ARN>
Enabled: true # Critical: enables INDEX_SLOW_LOGS publishingOther
1In the AWS Console, open Amazon OpenSearch Service and select your domain
2Go to the Logs tab
3For Search slow logs, click Enable, choose or create a CloudWatch log group, accept/attach the suggested resource policy, then Save
4For Index slow logs, click Enable, choose or create a CloudWatch log group, accept/attach the suggested resource policy, then Save
5Wait for domain status to return to Active
Check Code
from prowler.lib.check.models import Check, Check_Report_AWS
from prowler.providers.aws.services.opensearch.opensearch_client import (
opensearch_client,
)
class opensearch_service_domains_cloudwatch_logging_enabled(Check):
def execute(self):
findings = []
for domain in opensearch_client.opensearch_domains.values():
report = Check_Report_AWS(metadata=self.metadata(), resource=domain)
report.status = "FAIL"
report.status_extended = f"Opensearch domain {domain.name} SEARCH_SLOW_LOGS and INDEX_SLOW_LOGS disabled."
has_SEARCH_SLOW_LOGS = False
has_INDEX_SLOW_LOGS = False
for logging_item in domain.logging:
if logging_item.name == "SEARCH_SLOW_LOGS" and logging_item.enabled:
has_SEARCH_SLOW_LOGS = True
if logging_item.name == "INDEX_SLOW_LOGS" and logging_item.enabled:
has_INDEX_SLOW_LOGS = True
if has_SEARCH_SLOW_LOGS and has_INDEX_SLOW_LOGS:
report.status = "PASS"
report.status_extended = f"Opensearch domain {domain.name} SEARCH_SLOW_LOGS and INDEX_SLOW_LOGS enabled."
elif not has_SEARCH_SLOW_LOGS and has_INDEX_SLOW_LOGS:
report.status = "FAIL"
report.status_extended = f"Opensearch domain {domain.name} INDEX_SLOW_LOGS enabled but SEARCH_SLOW_LOGS disabled."
elif not has_INDEX_SLOW_LOGS and has_SEARCH_SLOW_LOGS:
report.status = "FAIL"
report.status_extended = f"Opensearch domain {domain.name} SEARCH_SLOW_LOGS enabled but INDEX_SLOW_LOGS disabled."
findings.append(report)
return findingsReferences
- https://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/es-createdomain-configure-slow-logs.html
- https://support.icompaas.com/support/solutions/articles/62000129471-ensure-amazon-elasticsearch-service-es-domains-have-logging-enabled
- https://bigdataboutique.com/blog/inspecting-search-slow-logs-on-elasticsearch-and-opensearch-b05d87
- https://repost.aws/knowledge-center/opensearch-troubleshoot-slow-logs
- https://www.trendmicro.com/trendaivisiononecloudriskmanagement/knowledge-base/aws/Elasticsearch/slow-logs.html
- https://medium.com/heyjobs-tech/how-to-create-an-opensearch-cluster-using-terraform-926b4a62b489
- https://docs.aws.amazon.com/opensearch-service/latest/developerguide/createdomain-configure-slow-logs.html