Send AWS CloudWatch logs to Tailcove through Firehose
Send CloudWatch Logs, metrics and EventBridge events from an AWS account to Tailcove through Amazon Data Firehose, with our Terraform module or the console.
Before you start
- A Tailcove account
- An AWS account where you can create IAM roles and a Firehose delivery stream
- Terraform 1.5 or later, if you use the module
Lambda, ECS, RDS and API Gateway all write to CloudWatch log groups. Instead of running a shipper next to each of them, you point one Amazon Data Firehose delivery stream at Tailcove and subscribe the log groups to it. The same stream can carry CloudWatch metrics and EventBridge events too, and Tailcove tells them apart by what each record looks like.
On this page7 sections
This guide sets it up with our Terraform module first, then shows the same settings by hand in the AWS console.
[!NOTE] We haven't run this path against a real AWS account yet. The module is checked against the AWS provider in our CI, but that's not the same as a real delivery. Before you rely on it, check that one real line arrives (step 5).
1. Create a source for the account#
In Tailcove, choose New source and name it after the account and region, such as aws-production. Copy the
ingest token from the last step: it's shown once.
The token does two jobs here. It's the delivery stream's access key, and it's what the S3 forwarder sends. Anyone who has it can send lines to this source, so treat it like a password.
If you manage Tailcove with Terraform, you can skip the app and let the provider create the source. It's in preview and installed from its release archive, so set it up first as that page describes.
2. Create the delivery stream and subscribe your log groups#
Pick a tab. The Terraform module builds the stream, the backup bucket, the IAM roles and the subscription filters in one apply. The console tab lists the same settings, if you'd rather click.
# main.tf: one module per AWS region.
terraform {
required_providers {
tailcove = { source = "tailcove/tailcove" }
aws = { source = "hashicorp/aws" }
}
}
provider "tailcove" {} # reads TAILCOVE_TOKEN (an API token with sources:write)
provider "aws" {
region = "us-east-1"
}
resource "tailcove_source" "aws" {
name = "aws-production"
}
module "tailcove_aws" {
source = "github.com/tailcove/terraform-provider-tailcove//modules/aws"
ingest_token = tailcove_source.aws.ingest_token
# Every log group whose name starts with one of these, as they are at apply time.
log_group_name_prefixes = ["/aws/lambda/", "/aws/ecs/", "/aws/rds/"]
# Or name them one by one.
# log_group_names = ["/aws/apigateway/shop-api"]
}
# The source was made in the Tailcove app: pass its token in, don't commit it.
variable "tailcove_ingest_token" {
type = string
sensitive = true
}
module "tailcove_aws" {
source = "github.com/tailcove/terraform-provider-tailcove//modules/aws"
ingest_token = var.tailcove_ingest_token
log_group_name_prefixes = ["/aws/lambda/", "/aws/ecs/", "/aws/rds/"]
}
Amazon Data Firehose > Create Firehose stream
Source: Direct PUT
Destination: HTTP Endpoint
HTTP endpoint URL: https://ingest.tailcove.dev/api/v1/aws/firehose
Access key: YOUR_INGEST_TOKEN
Content encoding: Disabled (GZIP also works)
Retry duration: 300 seconds
Buffer hints: 1 to 4 MiB, 60 seconds
Backup settings: Failed data only, to an S3 bucket of yours
IAM > Roles > Create role
Trusted by: logs.amazonaws.com
Allows: firehose:PutRecord and firehose:PutRecordBatch on the stream
CloudWatch > Log groups > (your group) > Subscription filters
Create Amazon Data Firehose subscription filter
Destination: the stream above
Role: the role above
Run terraform init and terraform apply. The module's outputs tell you what it made: delivery_stream_name,
backup_bucket and subscribed_log_groups. If you created the stream by hand, repeat the subscription filter for
each log group you want.
[!WARNING] Keep the buffer below 5 MB. Tailcove refuses a request larger than that, and Firehose then retries the same oversized delivery until it gives up. The module only accepts 1 to 4 MB for
firehose_buffer_mbfor that reason.
A few things are worth knowing before you apply:
- The token ends up in the Terraform state. Keep the state in an encrypted remote backend, not in the repository.
- A log group can have two subscription filters in all. If one already has two, subscribing it fails. Remove one you no longer need first.
- Prefixes are read at apply time. A Lambda function created next week isn't subscribed until you apply again.
- The module acts on one region. Use it once per region, with a source per region or one for all of them.
To send only part of each group, set log_filter_pattern to a CloudWatch Logs filter pattern. Empty sends everything.
3. Add metrics and events (optional)#
The same delivery stream can carry CloudWatch metrics and EventBridge events. Turn on what you'll look at.
module "tailcove_aws" {
source = "github.com/tailcove/terraform-provider-tailcove//modules/aws"
ingest_token = tailcove_source.aws.ingest_token
log_group_name_prefixes = ["/aws/lambda/", "/aws/ecs/", "/aws/rds/"]
# A metric stream for the namespaces you chart. Empty means every namespace.
metric_stream_enabled = true
metric_namespaces = ["AWS/EC2", "AWS/Lambda", "AWS/RDS", "AWS/ApplicationELB"]
# GuardDuty findings, ECS and EC2 state changes, Health events and the rest.
eventbridge_enabled = true
# eventbridge_pattern = jsonencode({ source = ["aws.guardduty"] })
}
CloudWatch > Metrics > Streams > Create metric stream
Destination: the Firehose stream from step 2
Output format: JSON
Namespaces: only the ones you chart
EventBridge > Rules > Create rule
Event bus: default
Target: Firehose stream, the one from step 2
Metrics arrive as points named aws.<namespace>.<MetricName>.<statistic>, such as aws.ec2.CPUUtilization.avg. The
dimensions, the region and the account become labels, so InstanceId=i-0abc filters a chart.
[!TIP] Choose namespaces rather than sending all of them. CloudWatch charges per metric update, and each metric with each set of dimensions is a Tailcove series. Your plan caps the number of series.
Events show up as source: detail-type, for example aws.guardduty: GuardDuty Finding, with the whole event in the
context. A GuardDuty severity of 7 or more is stored as an error, and 4 or more as a warning.
Anything else AWS can deliver to Firehose, such as WAF logs, Route 53 resolver query logs, VPC flow logs or Network
Firewall, can use the same stream as its destination. WAF logs come through as lines like WAF BLOCK POST /login (SQLi).
4. Send logs that AWS writes to S3 (optional)#
Load balancers, CloudFront, S3 access logs, VPC flow logs and CloudTrail can only write files to a bucket. Firehose can't read those, so the module adds a small Lambda function that reads each new file and posts it to the same Tailcove endpoint.
module "tailcove_aws" {
source = "github.com/tailcove/terraform-provider-tailcove//modules/aws"
ingest_token = tailcove_source.aws.ingest_token
log_group_name_prefixes = ["/aws/lambda/"]
s3_buckets = [
{ name = "my-alb-logs", prefix = "AWSLogs/" },
{ name = "my-cloudtrail-logs", prefix = "AWSLogs/" },
]
}
The function turns each line into a document before it sends it. A load balancer line becomes the request and its
status, a VPC flow log line reads like REJECT TCP 10.0.0.1:443 -> 10.0.0.2:5000, and a CloudTrail file becomes one
document per record. CloudFront standard logs are read using their #Fields header. Anything it doesn't recognise
is sent line by line. Its source is
forwarder.py
if you want to read it first. The output forwarder_function_name names it.
[!WARNING]
s3_bucketsreplaces the bucket's event notification. A bucket has only one notification configuration and the module sets it, so if the bucket already notifies something else, merge that configuration by hand before you apply.
There's no console tab for this step: the forwarder comes with the module.
5. Check that a line arrives#
Open the source's Live tail in Tailcove, then make something log. Invoking a Lambda function in a subscribed group is the quickest way. The stream buffers for up to 60 seconds by default, so give it a minute.
Each CloudWatch log event becomes one line. The host is the log stream, and the context holds aws.log_group,
aws.log_stream and aws.account.
If a log event is JSON already, like Lambda's JSON logs, it keeps its level and fields. In plain Lambda lines the
ERROR, WARN and DEBUG words set the level. A line that only mentions an error somewhere in its text stays at its
normal level.
Any key and value pairs you set as Firehose parameters on the stream (say environment) are added to every line
under aws.attributes.
How delivery works#
Firehose only counts a 200 as delivered. Anything else is retried for the retry duration (300 seconds in the
module) and then written to the backup bucket, so a delivery Tailcove refused isn't dropped quietly. The module keeps
those files for backup_retention_days, 14 days unless you change it.
Firehose delivers at least once, and a retry carries the same request id. Tailcove remembers what each request id stored for a day, so a retry doesn't store the same lines twice.
The lines count toward your plan's included GB like any other ingest, and the logs endpoint's rate limits apply (quotas). The subscription filters, the metric stream and Firehose itself are billed by AWS.
If nothing arrives#
Start with the delivery stream's Monitoring tab in the AWS console and its backup bucket. The error there tells you which row applies.
| What you see | What it means and what to do |
|---|---|
401 |
The access key isn't this source's ingest token. Copy the token again and update the stream. |
413 |
A delivery was over 5 MB. Lower the buffer size. |
400 about too many events |
A delivery held more than 10,000 events. Lower the buffer size. |
400 on every delivery |
What reached the endpoint isn't a Firehose delivery. Check the stream's destination settings. |
429 |
The source is over its rate or quota. Firehose retries, then backs up; check usage on Billing. |
| A log group fails to subscribe | It already has two subscription filters. Remove one it no longer needs. |
| Metrics stop appearing | The plan's series cap is reached. Choose fewer metric_namespaces, or move to a larger plan. |
| A new Lambda function's logs never show up | Prefixes are read at apply time. Run terraform apply again. |
Every setting and record type is on the AWS docs page. To keep a copy of these logs beyond your plan's retention, see Archive application logs to Amazon S3.
Ready to try it on your own logs?
The Free plan includes a source, live tail, search and alerts. No credit card.