Skip to content

Instantly share code, notes, and snippets.

@jonesy1234
Created December 8, 2022 11:14
Show Gist options
  • Save jonesy1234/5cb7cfa145e6e01e01e6db960e2eed8e to your computer and use it in GitHub Desktop.
Save jonesy1234/5cb7cfa145e6e01e01e6db960e2eed8e to your computer and use it in GitHub Desktop.
Transit Gateway Flow Logs
CREATE EXTERNAL TABLE IF NOT EXISTS `twgflowlogs`.`awslogs` (
version int,
resource_type string,
account_id string,
tgw_id string,
tgw_attachment_id string,
tgw_src_vpc_account_id string,
tgw_dst_vpc_account_id string,
tgw_src_vpc_id string,
tgw_dst_vpc_id string,
tgw_src_subnet_id string,
tgw_dst_subnet_id string,
tgw_src_eni string,
tgw_dst_eni string,
tgw_src_az_id string,
tgw_dst_az_id string,
tgw_pair_attachment_id string,
srcaddr string,
dstaddr string,
srcpor int,
dstport int,
protocol bigint,
packet bigint,
bytes bigint,
start bigint,
`end` bigint,
log_status string,
type string,
packets_lost_no_route bigint,
packets_lost_blackhole bigint,
packets_lost_mtu_exceeded bigint,
packets_lost_ttl_expired bigint,
tcp_flags int,
region string,
flow_direction string,
pkt_src_aws_service string,
pkt_dst_aws_service string)
PARTITIONED BY (
`aws-account-id` string,
`aws-service` string,
`aws-region` string,
year string,
month string,
day string,
hour string)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ' '
LOCATION
's3://BUCKET_NAME_REPLACE_ME/AWSLogs/'
TBLPROPERTIES (
'skip.header.line.count'='1',
'write.compression'='GZIP')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment