Amazon Data Firehose logs & metrics
Send logs and CloudWatch metrics to Better Stack through Amazon Data Firehose, formerly Kinesis Data Firehose.
Bring your own Firehose streams when the Better Stack CloudFormation stack isn't an option for you, for example because of your account's IAM policy.
Already running the CloudFormation stack?
You already have both streams described here, better-stack-logs and better-stack-metrics. There is nothing to create.
Create a source
Create a new AWS source in Better Stack. One source can receive both logs and metrics.
Create a Firehose stream
Logs and metrics use different Better Stack endpoints, and a Firehose stream has one destination. Create a stream for logs, a stream for metrics, or just the one you need.
In AWS Console → Amazon Data Firehose → Firehose streams, click Create Firehose stream and use these settings:
Keep the remaining settings at their defaults:
- Retry duration: 300 seconds.
- Buffer hints: 5 MiB and 60 seconds. Better Stack accepts requests up to 10 MB.
- Backup settings: Failed data only with an S3 bucket of your choice. Firehose keeps the batches Better Stack couldn't accept there.
- Service access: Create or update IAM role.
Stream creation failed with "unable to assume role"?
The IAM role the console just created hasn't propagated yet. Wait a few seconds and press Create Firehose stream again.
For the logs stream, run Test with demo data on the stream's detail page to check the connection. The demo records show up in Live tail within a few minutes. Skip it for the metrics stream. The demo records are not CloudWatch metrics and are discarded.
Send logs
From CloudWatch Logs
Forward a log group to your logs stream with a subscription filter:
- Go to CloudWatch → Log groups and open the log group.
- Switch to the Subscription filters tab and choose Create → Create Amazon Data Firehose subscription filter.
- Select your logs Firehose stream as the destination.
- Select an IAM role that CloudWatch Logs can assume to write to the stream. If you don't have one, create a role trusted by
logs.amazonaws.comwith the policy below, replacing the region and account ID. - Optionally enter a filter pattern to forward only matching events, then press Start streaming.
Each log event arrives in Better Stack as a separate log with the log group and log stream names as context. Repeat the steps for every log group you want to forward. They can all share one Firehose stream.
To give log groups different retention periods, send them to separate sources through separate streams. If you use the CloudFormation stack, follow Custom log group routing.
From other producers
Anything that writes JSON records to a Firehose stream works the same way, such as Fluent Bit's kinesis_firehose output on AWS Fargate or AWS WAF logs.
Stream CloudWatch metrics
A CloudWatch metric stream delivers every metric update in a region to your metrics Firehose stream within a few minutes.
- Create a metric stream in CloudWatch.
- Under Destination, choose Custom setup with Firehose and select your metrics Firehose stream.
- Expand Change output format and choose JSON.
- Under Metrics to be streamed, keep All metrics, or choose Select metrics to include or exclude namespaces.
- Name the stream and press Create metric stream.
Why JSON and not OpenTelemetry?
The console preselects the OpenTelemetry 1.0 format for custom Firehose setups. Better Stack ingests the JSON format only and rejects metrics in an OpenTelemetry format, so the Firehose stream's Destination error logs show Metric stream output format must be JSON. Switch an existing metric stream to JSON from its Edit page at any time.
Your metrics appear in Dashboards within a few minutes. To watch the Firehose stream itself, create a dashboard from the AWS Firehose template.
Metrics in Better Stack
Metrics are converted to Better Stack naming. For example, AWS/EC2/CPUUtilization becomes aws.ec2.cpu_utilization, with its dimensions as tags such as instance_id. The CloudWatch statistics are available as aws.ec2.cpu_utilization_min, _max, _sum and _count.
Costs and limits
- CloudWatch bills metric streams per metric update, and Firehose per gigabyte. Use Select metrics to limit the stream to the namespaces you need.
- AWS publishes metrics for global services such as Amazon CloudFront and Route 53 only in
us-east-1. Create the metric stream there to collect them. - A metric stream delivers to a single Firehose stream. To send the same metrics to Better Stack and to another destination, create a second metric stream.
- Metric streams are a per-region resource. Repeat the setup in every region you want to collect metrics from.
To trade latency for a lower bill, the CloudFormation stack can poll your metrics through the CloudWatch API instead.
Deploy with CloudFormation
Prefer infrastructure as code? Each template creates the Firehose stream, its backup bucket and IAM roles, plus the producer - a subscription filter for one log group, or a metric stream with the output format set to JSON. Deploy them in each region you want to collect from.
Deploy with the AWS CLI:
Troubleshooting
Not seeing any data?
Open the stream's Monitoring tab for the HTTP endpoint delivery success rate and the Destination error logs tab for rejected deliveries. Batches that failed for longer than the retry duration end up in the backup bucket under the error output prefix. If the destination error logs say Metric stream output format must be JSON, set the metric stream's output format to JSON.
Seeing 401 Unauthorized in the destination error logs?
The access key doesn't match your source token. Update it under Configuration → Destination settings and Firehose retries the pending batches on its own.
Pause or remove the integration
Firehose streams can't be paused. Stop the metric stream in CloudWatch → Metrics → Streams, or delete the subscription filter on a log group. Delivery resumes when you start it again.
To remove the integration, delete the metric stream and the subscription filters first, then the Firehose streams, the IAM roles, and the backup bucket after emptying it.
Need help?
Please let us know at hello@betterstack.com.
We're happy to help! 🙏