Slide 4 of 10

AWS logs - Lambda

How it works

AWS logs Lambda architecture: Specific log types trigger Lambda to forward to Grafana Cloud Loki

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

Specific log types 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, automaticHigher cost for high volumes
Serverless (no infrastructure)Format parsing required
Custom transformation possible~3x more expensive than Firehose

Documentation

View the full documentation. Learning path coming soon!

AWS Lambda logs

Script

The Lambda agent, also known as lambda-promtail, handles specific log types that Firehose doesn’t support yet.

Several AWS services write logs that need Lambda collection. 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, and from where.

Here’s how it works: you deploy a Lambda function that triggers on events. When these logs are available, Lambda processes them, parsing the format and adding labels, and 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. For high log volumes, Firehose is about three times cheaper. 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.