Processing Logs in Real Time with Subscription Filters
Some log processing must happen as events arrive: forwarding logs to a central account or third-party tool, indexing them for search, or detecting patterns in real time. Subscription filters stream matching log events from CloudWatch Logs to Kinesis Data Streams, Amazon Data Firehose, AWS Lambda or Amazon OpenSearch Service. This lesson explains subscription filters, their destinations, cross-account log delivery and centralised logging architectures.
Learning outcomes
After completing this lesson, you will be able to:
- Explain how subscription filters deliver log events and the destinations they support.
- Choose between Kinesis Data Streams, Firehose, Lambda and OpenSearch as subscription destinations.
- Explain cross-account log delivery with destinations and account-level subscription filters.
- Design a centralised logging architecture for an organisation.
Subscription Filters
A subscription filter on a log group sends every event that matches its filter pattern (an empty pattern matches everything) to a destination in near real time. Events are delivered base64-encoded and gzip-compressed in batches. Each log group can have up to two subscription filters, so fan-out to more consumers is done downstream, for example through Kinesis Data Streams with several consumers. Account-level subscription filters apply one filter to all, or a selection of, log groups in an account, which simplifies centralisation without configuring each group; a selection criterion can exclude log groups to avoid recursive delivery loops.
Subscription filters require the log group to be in the Standard log class, and CloudWatch Logs needs permission to write to the destination, through an IAM role for Kinesis and Firehose or a resource policy for Lambda.
Destinations
Each destination suits a different purpose.
Amazon Kinesis Data Streams
A durable stream with retention of 24 hours to 365 days and multiple independent consumers, such as Lambda functions, Amazon Managed Service for Apache Flink applications and custom applications. It suits real-time analytics, fan-out to several processors and replay. The team manages shard capacity or uses on-demand mode.
Amazon Data Firehose
A fully managed delivery service that buffers, optionally transforms with Lambda, converts formats and delivers to Amazon S3, Amazon OpenSearch Service, Amazon Redshift, Splunk, Apache Iceberg tables and HTTP endpoints of partner tools. It needs no capacity management and is the simplest way to archive logs to S3 or forward them to a third-party platform. Delivery is near real time, with buffering intervals measured in seconds to minutes.
AWS Lambda
A function processes each batch directly, which suits lightweight real-time reactions, such as sending a notification when a specific error appears, or custom transformations. Very high volumes are better handled through Kinesis.
Amazon OpenSearch Service
The console offers streaming to an OpenSearch domain, implemented with a Lambda function that indexes events. Firehose or OpenSearch Ingestion pipelines are more scalable ways to load logs into OpenSearch for full-text search and dashboards.
Choose the subscription destination
Cross-Account Log Delivery
To deliver logs from many accounts to a central logging account, the central account creates a CloudWatch Logs destination: a resource that wraps a Kinesis data stream or Firehose stream in the central account, with an IAM role that CloudWatch Logs uses to write to it and an access policy that lists the source accounts, or the organisation through aws:PrincipalOrgID, allowed to subscribe. Each source account creates subscription filters, or an account-level subscription filter, that point to the destination's ARN. Logs then flow into the central stream, from which Firehose delivers them to S3 or OpenSearch.
Destinations are Regional, so organisations operating in several Regions create a destination in each Region or forward to one Region downstream. Deploying the source-side subscription filters with StackSets ensures every account, including new ones, is covered.
# In the central logging account: create a destination wrapping a Kinesis stream
aws logs put-destination --destination-name org-logs \
--target-arn arn:aws:kinesis:eu-west-1:999999999999:stream/org-logs \
--role-arn arn:aws:iam::999999999999:role/CWLtoKinesisRole
aws logs put-destination-policy --destination-name org-logs --access-policy '{
"Version": "2012-10-17",
"Statement": [{"Effect": "Allow", "Principal": "*", "Action": "logs:PutSubscriptionFilter",
"Resource": "arn:aws:logs:eu-west-1:999999999999:destination:org-logs",
"Condition": {"StringEquals": {"aws:PrincipalOrgID": "o-a1b2c3d4e5"}}}]}'Central log delivery
A Centralised Logging Architecture
A common organisation design combines the elements of this module, as listed below.
- Each workload account keeps its logs in CloudWatch Logs with short retention for local troubleshooting.
- Account-level subscription filters, deployed by StackSets, send logs to a cross-account destination in the log archive account.
- In the log archive account, Firehose delivers logs to an S3 bucket with encryption, Object Lock for security logs and lifecycle rules, and optionally to OpenSearch for search.
- CloudTrail organisation trails, VPC Flow Logs and load balancer logs deliver to the same archive bucket directly.
- Security tooling and analysts query the archive with Athena and OpenSearch, and the security account uses cross-account observability for live queries.
The following diagram shows the elements of the design across accounts.

Forwarding Logs to a SIEM
A security team requires all application and VPC Flow Logs from 50 accounts to reach the company's Splunk deployment within five minutes, with a copy retained in S3 for a year, and no per-team configuration.
-
Central delivery
In the log archive account, create a Firehose stream with Splunk as the destination and S3 backup of all records, and a CloudWatch Logs destination that wraps it, with an organisation access policy.
-
Sources
Deploy an account-level subscription filter with StackSets to every account and Region in use, pointing to the destination.
-
Retention
Apply an S3 lifecycle rule to the backup bucket that expires objects after one year.
A log group already has two subscription filters, and a third team needs the same logs. What should be done?
Show answer
A log group supports at most two subscription filters. Send the logs to a Kinesis data stream and let each team consume from the stream, or reuse an existing downstream delivery.
Exam Tips
Remember for the exam
- Subscription filters stream matching events to Kinesis Data Streams, Data Firehose, Lambda or OpenSearch; up to two per log group; account-level filters cover many log groups.
- Firehose is the simplest path to S3 or third-party tools; Kinesis Data Streams adds replay and multiple consumers.
- Cross-account delivery uses a CloudWatch Logs destination in the central account with an access policy (for example aws:PrincipalOrgID) and subscription filters in source accounts.
- Destinations are Regional; deploy source subscriptions with StackSets.