Skip to content

Instantly share code, notes, and snippets.

@beneshed
Last active September 26, 2017 12:44
Show Gist options
  • Select an option

  • Save beneshed/dae911d817aa6805f6a11195c9345c05 to your computer and use it in GitHub Desktop.

Select an option

Save beneshed/dae911d817aa6805f6a11195c9345c05 to your computer and use it in GitHub Desktop.
Python Named Regex for ALB
regex = r"(?P<PROTOCOL>http|https|h2) (?P<TIMESTAMP>[^ ]*) (?P<PATH>[^ ]*) (?P<SOURCE_IP>[^ ]*):(?P<SOURCE_PORT>[0-9]*) ((?P<DESTINATION_IP>[^ ]*):(?P<DESTINATION_PORT>[0-9]*)|-) (?P<REQUEST_PROCESS_TIME>[-.0-9]*) (?P<TARGET_PROCESSING_TIME>[-.0-9]*) (?P<RESPONSE_PROCESSING_TIME>[-.0-9]*) (?P<ELB_STATUS_CODE>-|[0-9]*) (?P<TARGET_STATUS_CODE>-|[0-9]*) (?P<RECEIVED_BYTES>[-0-9]*) (?P<SENT_BYTES>[-0-9]*) \"(?P<REQUEST_TYPE>[^ ]*) (?P<URL>[^ ]*) (?P<HTTP_VERSION>- |[^ ]*) (?P<USER_AGENT>\".*\") (?P<SSL_CIPHER>[-A-Za-z0-9]+) (?P<SSL_VERSION>[-A-Za-z0-9.]+) (?P<RESOURCE>[\/A-Za-z0-9:-]+) \"(?P<END_PATH>[A-Za-z0-9-=;]+)\""
@beneshed
Copy link
Copy Markdown
Author

Not the most effective, but groups well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment