Create athena table in logging_alb (#92)
This commit is contained in:
1 parent
333b53caf5
commit
379e51d0dc
1 file changed
+175
@@ -255,3 +255,178 @@ resource "aws_athena_workgroup" "logs" {
|
||||
|
||||
force_destroy = true
|
||||
}
|
||||
|
||||
resource "aws_glue_catalog_table" "partitioned_alb_logs" {
|
||||
count = var.enable_athena == true ? 1 : 0
|
||||
name = "partitioned_alb_logs"
|
||||
database_name = aws_athena_database.logs[0].name
|
||||
table_type = "EXTERNAL_TABLE"
|
||||
|
||||
storage_descriptor {
|
||||
location = "s3://${module.s3_bucket_for_logs.s3_bucket_id}/${var.prefix}/AWSLogs/${data.aws_caller_identity.current.account_id}/elasticloadbalancing/${data.aws_region.current.region}/"
|
||||
input_format = "org.apache.hadoop.mapred.TextInputFormat"
|
||||
output_format = "org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat"
|
||||
|
||||
ser_de_info {
|
||||
name = "regex-serde"
|
||||
serialization_library = "org.apache.hadoop.hive.serde2.RegexSerDe"
|
||||
parameters = {
|
||||
"serialization.format" = "1"
|
||||
"input.regex" = "([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*):([0-9]*) ([^ ]*)[:-]([0-9]*) ([-.0-9]*) ([-.0-9]*) ([-.0-9]*) (|[-0-9]*) (-|[-0-9]*) ([-0-9]*) ([-0-9]*) \\\"([^ ]*) (.*) (- |[^ ]*)\\\" \\\"([^\\\"]*)\\\" ([A-Z0-9-_]+) ([A-Za-z0-9.-]*) ([^ ]*) \\\"([^\\\"]*)\\\" \\\"([^\\\"]*)\\\" \\\"([^\\\"]*)\\\" ([-.0-9]*) ([^ ]*) \\\"([^\\\"]*)\\\" \\\"([^\\\"]*)\\\" \\\"([^ ]*)\\\" \\\"([^\\\\s]+?)\\\" \\\"([^\\\\s]+)\\\" \\\"([^ ]*)\\\" \\\"([^ ]*)\\\" ?([^ ]*)?"
|
||||
}
|
||||
}
|
||||
|
||||
columns {
|
||||
name = "type"
|
||||
type = "string"
|
||||
}
|
||||
columns {
|
||||
name = "time"
|
||||
type = "string"
|
||||
}
|
||||
columns {
|
||||
name = "elb"
|
||||
type = "string"
|
||||
}
|
||||
columns {
|
||||
name = "client_ip"
|
||||
type = "string"
|
||||
}
|
||||
columns {
|
||||
name = "client_port"
|
||||
type = "int"
|
||||
}
|
||||
columns {
|
||||
name = "target_ip"
|
||||
type = "string"
|
||||
}
|
||||
columns {
|
||||
name = "target_port"
|
||||
type = "int"
|
||||
}
|
||||
columns {
|
||||
name = "request_processing_time"
|
||||
type = "double"
|
||||
}
|
||||
columns {
|
||||
name = "target_processing_time"
|
||||
type = "double"
|
||||
}
|
||||
columns {
|
||||
name = "response_processing_time"
|
||||
type = "double"
|
||||
}
|
||||
columns {
|
||||
name = "elb_status_code"
|
||||
type = "int"
|
||||
}
|
||||
columns {
|
||||
name = "target_status_code"
|
||||
type = "string"
|
||||
}
|
||||
columns {
|
||||
name = "received_bytes"
|
||||
type = "bigint"
|
||||
}
|
||||
columns {
|
||||
name = "sent_bytes"
|
||||
type = "bigint"
|
||||
}
|
||||
columns {
|
||||
name = "request_verb"
|
||||
type = "string"
|
||||
}
|
||||
columns {
|
||||
name = "request_url"
|
||||
type = "string"
|
||||
}
|
||||
columns {
|
||||
name = "request_proto"
|
||||
type = "string"
|
||||
}
|
||||
columns {
|
||||
name = "user_agent"
|
||||
type = "string"
|
||||
}
|
||||
columns {
|
||||
name = "ssl_cipher"
|
||||
type = "string"
|
||||
}
|
||||
columns {
|
||||
name = "ssl_protocol"
|
||||
type = "string"
|
||||
}
|
||||
columns {
|
||||
name = "target_group_arn"
|
||||
type = "string"
|
||||
}
|
||||
columns {
|
||||
name = "trace_id"
|
||||
type = "string"
|
||||
}
|
||||
columns {
|
||||
name = "domain_name"
|
||||
type = "string"
|
||||
}
|
||||
columns {
|
||||
name = "chosen_cert_arn"
|
||||
type = "string"
|
||||
}
|
||||
columns {
|
||||
name = "matched_rule_priority"
|
||||
type = "string"
|
||||
}
|
||||
columns {
|
||||
name = "request_creation_time"
|
||||
type = "string"
|
||||
}
|
||||
columns {
|
||||
name = "actions_executed"
|
||||
type = "string"
|
||||
}
|
||||
columns {
|
||||
name = "redirect_url"
|
||||
type = "string"
|
||||
}
|
||||
columns {
|
||||
name = "lambda_error_reason"
|
||||
type = "string"
|
||||
}
|
||||
columns {
|
||||
name = "target_port_list"
|
||||
type = "string"
|
||||
}
|
||||
columns {
|
||||
name = "target_status_code_list"
|
||||
type = "string"
|
||||
}
|
||||
columns {
|
||||
name = "classification"
|
||||
type = "string"
|
||||
}
|
||||
columns {
|
||||
name = "classification_reason"
|
||||
type = "string"
|
||||
}
|
||||
columns {
|
||||
name = "conn_trace_id"
|
||||
type = "string"
|
||||
}
|
||||
}
|
||||
|
||||
partition_keys {
|
||||
name = "day"
|
||||
type = "string"
|
||||
}
|
||||
|
||||
parameters = {
|
||||
"EXTERNAL" = "TRUE"
|
||||
"projection.enabled" = "true"
|
||||
"projection.day.type" = "date"
|
||||
"projection.day.range" = "2022/01/01,NOW"
|
||||
"projection.day.format" = "yyyy/MM/dd"
|
||||
"projection.day.interval" = "1"
|
||||
"projection.day.interval.unit" = "DAYS"
|
||||
"storage.location.template" = "s3://${module.s3_bucket_for_logs.s3_bucket_id}/${var.prefix}/AWSLogs/${data.aws_caller_identity.current.account_id}/elasticloadbalancing/${data.aws_region.current.region}/${"$"}{day}"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user