Regular Expressions 101

Community Patterns

elb log filename parser

0

Regular Expression
Python

r"
^(?P<bucket>[^\/]+)\/(?:(?P<prefix>.+)\/)?AWSLogs\/(?P<aws_account_id>[\d]{12})\/elasticloadbalancing\/(?P<region>[\w\d\-]+)\/(?P<year>\d{4})\/(?P<month>\d{2})\/(?P<day>\d{2})\/(?P=aws_account_id)_elasticloadbalancing_(?P=region)_(?P<load_balancer_id>[\w\.\-\d]+)_(?P<end_time>\d{8}T\d{4}Z)_(?P<ip_address>(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))_(?P<random_string>.+)\.log\.gz$
"
gm

Description

This is the pattern for a ALB log files exported to s3.

Submitted by anonymous - 4 years ago