AWS

One setup sends an AWS account's logs, metrics and events to Tailcove: CloudWatch Logs (Lambda, API Gateway, ECS, EKS, RDS and anything else that writes a log group), CloudWatch metrics, EventBridge events (GuardDuty, ECS and EC2 state changes, Health, Config, Security Hub, CodePipeline and every other service that publishes events) and the logs AWS services write to S3 (load balancers, CloudFront, VPC flow logs, S3 access logs, CloudTrail, WAF).

6 min read

On this page6 sections

Everything goes through Amazon Data Firehose to one Tailcove URL, which tells logs, metrics and events apart by what each document looks like. There is nothing to run yourself except, for S3-delivered logs, a small Lambda function the Terraform module creates.

With Terraform#

The modules/aws module of the Tailcove Terraform provider creates the delivery stream, the permissions and the wiring:

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 Lambda function, ECS service and RDS instance that writes a log group.
  log_group_name_prefixes = ["/aws/lambda/", "/aws/ecs/", "/aws/rds/"]

  # CloudWatch metrics for the services that matter.
  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

  # Logs AWS services write to S3.
  s3_buckets = [{ name = "my-alb-logs", prefix = "AWSLogs/" }]
}

Use the module once per region. Before you apply it:

  • The token is a secret in the Terraform state. It is the delivery stream's access key and the forwarder's token, so keep the state private (an encrypted remote backend, not a file 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.
  • s3_buckets replaces the bucket's event notification. A bucket has only one notification configuration and the module sets it, so a bucket that already notifies something else needs that merged by hand.
  • Metric streams cost money and fill series. CloudWatch charges per metric update, and every metric and dimension set is a Tailcove series (each plan caps them). List only the metric_namespaces you look at.

Without Terraform#

Make a Firehose delivery stream with an HTTP endpoint destination:

  • Endpoint URL: https://ingest.tailcove.dev/api/v1/aws/firehose
  • Access key: your source's ingest token
  • Content encoding: none (gzip also works)
  • Buffer: 1 to 4 MB and 60 seconds. Tailcove takes a request of up to 5 MB, so the buffer must stay below that.
  • Retry duration: 300 seconds, and a backup bucket for failed deliveries only.

Then send to it:

  • CloudWatch Logs: add a subscription filter on the log group with the delivery stream as destination (and a role CloudWatch Logs may assume, allowed firehose:PutRecord and firehose:PutRecordBatch).
  • CloudWatch metrics: create a metric stream with the same delivery stream and the JSON output format, for the namespaces you want.
  • EventBridge: add a rule on the default bus with the delivery stream as target.
  • Anything else that can deliver to Firehose (WAF logs, Route 53 resolver query logs, VPC flow logs, Network Firewall): choose the delivery stream as its destination.

What arrives in Tailcove#

  • CloudWatch Logs: one line per log event. The host is the log stream, and the context holds aws.log_group, aws.log_stream and aws.account. A log event that is itself JSON (Lambda's JSON logs, CloudTrail in a log group) keeps its level and its fields. Lambda's ERROR, WARN and DEBUG words set the level of plain lines; a line that only mentions an error is not one.
  • Metrics: points named aws.<namespace>.<MetricName>.<statistic>, such as aws.ec2.CPUUtilization.avg, with sum, min, max, avg and any percentiles the stream carries. The dimensions, the region and the account are labels, so InstanceId=i-0abc and region=us-east-1 filter a chart. A plan caps the number of series, and each metric with each set of dimensions is a series, so choose namespaces rather than sending everything.
  • EventBridge events: source: detail-type as the message, such as aws.guardduty: GuardDuty Finding, with the event in the context. A GuardDuty severity of 7 or more is an error, 4 or more a warning.
  • CloudTrail records: s3.amazonaws.com GetObject failed: AccessDenied, a warning when the call failed, with the record in the context.
  • WAF logs: WAF BLOCK POST /login (SQLi), a warning for a block.
  • Other JSON is stored with a message, level and time found by the usual field names; plain text (VPC flow logs through Firehose, say) is one line per line.

The stream's own key and value pairs (the Firehose "parameters" you set, such as environment) are added to every line as aws.attributes.

Logs written to S3#

Load balancers, CloudFront, VPC flow logs, S3 access logs, CloudTrail and WAF can only write files to a bucket. With s3_buckets the module adds a Lambda function that reads each new file and sends it, turning each line into a document first: Application and Network Load Balancer logs (the request and status as the message), CloudFront standard logs (from their #Fields header), S3 server access logs, VPC flow logs (REJECT TCP 10.0.0.1:443 -> 10.0.0.2:5000) and CloudTrail files (one document per record). Anything else is sent line by line. The function's source is forwarder.py.

Delivery, limits and retries#

  • Only a 200 is a delivery. A wrong key is a 401, something that is not a Firehose delivery a 400, a delivery over 5 MB or 10,000 events a 413 or 400 (lower the buffer), and a source over its rate or quota a 429. Firehose retries for the retry duration and then writes the delivery to the backup bucket, so nothing is lost silently.
  • A delivery is stored once. Firehose delivers at least once, and a retry carries the same request id: Tailcove remembers what a request stored for a day, so a retry stores nothing twice.
  • Quota and rate limits are the logs endpoint's. The bytes count toward your plan's included GB like any other line.
  • A CloudWatch Logs subscription, a metric stream and Firehose are billed by AWS; Tailcove's side is the ingest you already pay for.

Troubleshooting#

  • Nothing arrives: open the delivery stream's monitoring and its backup bucket. A 401 means the access key is not the source's ingest token; a 413 means the buffer is too large.
  • A log group fails to subscribe: a log group can have two subscription filters in all.
  • Metrics stop appearing: the plan's series cap is reached. Choose fewer namespaces, or raise the plan.

Still stuck?

Email us and we will help you get it working.

Contact support