Slide 4 of 10

AWS logs - Lambda

How it works

AWS logs Lambda architecture: S3-based logs trigger Lambda to forward to Grafana Cloud Loki

Complexity: Simple | Infrastructure: Serverless | Latency: Event-driven

S3-based logs collected with Lambda

Log typeFormatKey insights
ALB Access LogsSpace-delimitedRequest latency, targets, status codes
CloudFront LogsTab-separatedEdge locations, cache hits
S3 Access LogsSpace-delimitedBucket access patterns
CloudTrailJSONAPI activity, audit

Trade-offs

ProsCons
Event-driven, automaticLambda execution costs
Serverless (no infrastructure)Format parsing required
Custom transformation possibleCold start latency

Documentation

View the full documentation. Learning path coming soon!

AWS Lambda logs

Script

The Lambda agent, also known as lambda-promtail, is your go-to for collecting logs that AWS services write to S3.

Several important services write directly to S3 instead of CloudWatch. ALB access logs give you HTTP request details: latency, status codes, which backend handled the request. CloudFront logs show CDN performance: edge locations, cache hit rates. CloudTrail logs every AWS API call: who did what, when, from where.

Here’s how it works: you deploy a Lambda function that triggers on S3 events. When logs arrive in the bucket, Lambda processes them, parsing the format and adding labels, then forwards them to Loki in Grafana Cloud.

The beauty is serverless simplicity. No EC2 instances to patch, no containers to manage. Lambda scales automatically with your log volume. You can customize the processing logic to fit your needs.

Trade-offs? Lambda has execution costs. You’re paying per invocation and duration. And you’ll need to configure parsing for each log format since ALB logs are space-delimited, CloudFront is tab-separated, and CloudTrail is JSON.