- Newest
- Most votes
- Most comments
Hello.
It seems that around August 19th, a field that is not listed in the AWS documentation was added to the ALB access log.
This added field is likely causing the query results to be null.
The following blog introduces a Japanese blog that creates a table with the following query, which makes it possible to query logs whose field names are temporarily unknown.
https://dev.classmethod.jp/articles/alb-log-additional-column-athena-table/
CREATE EXTERNAL TABLE IF NOT EXISTS alb_access_logs (
type string,
time string,
elb string,
client_ip string,
client_port int,
target_ip string,
target_port int,
request_processing_time double,
target_processing_time double,
response_processing_time double,
elb_status_code int,
target_status_code string,
received_bytes bigint,
sent_bytes bigint,
request_verb string,
request_url string,
request_proto string,
user_agent string,
ssl_cipher string,
ssl_protocol string,
target_group_arn string,
trace_id string,
domain_name string,
chosen_cert_arn string,
matched_rule_priority string,
request_creation_time string,
actions_executed string,
redirect_url string,
lambda_error_reason string,
target_port_list string,
target_status_code_list string,
classification string,
classification_reason string,
conn_trace_id string,
additional_column string
)
PARTITIONED BY
(
day STRING
)
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.RegexSerDe'
WITH SERDEPROPERTIES (
'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]+)\" \"([^ ]*)\" \"([^ ]*)\" ?([^ ]*)? ?(.*)?'
)
LOCATION 's3://amzn-s3-demo-bucket/AWSLogs/<ACCOUNT-NUMBER>/elasticloadbalancing/<REGION>/'
TBLPROPERTIES
(
"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://amzn-s3-demo-bucket/AWSLogs/<ACCOUNT-NUMBER>/elasticloadbalancing/<REGION>/${day}"
)
This issue appears to be related to a potential change in the ALB access log format that's causing your Athena queries to return NULL values for non-partitioned fields. Based on the data you've provided, there seems to be a gradual transition starting on 2025/08/19, with the issue becoming complete by 2025/08/22.
This type of problem typically occurs when there's a mismatch between the log format and the table schema/SerDe configuration. The RegexSerDe used for ALB access logs is particularly sensitive to format changes.
Here are some potential causes and solutions:
-
Log Format Change: AWS may have updated the ALB access log format. This has happened in the past when new fields were added to the logs.
-
Table Schema Update Needed: You might need to update your table schema to match the new log format. The CREATE TABLE statement for ALB access logs includes a regex pattern that needs to match the exact format of your logs.
-
Inconsistent Behavior: The transition period (2025/08/19-2025/08/21) where some records work and others don't suggests a rolling update to the ALB logging system.
To resolve this issue:
-
Check a few raw log files from before and after the issue started to see if there are format differences.
-
Update your table definition with the latest CREATE TABLE statement from AWS documentation, which should include any new fields and the correct regex pattern.
-
If you're using partition projection, ensure your partition configuration is still correct.
-
As a temporary workaround, you could query specific date ranges separately (before and after the change) using different table definitions.
This appears to be similar to issues that have occurred after previous Athena or ALB updates, where queries that previously worked start failing or returning unexpected results.
Sources
ATHENA INTERNAL_ERROR_QUERY_ENGINE | AWS re:Post
Query fails (inconsistency) after last athena update | AWS re:Post
Create the table for ALB access logs - Amazon Athena
answered a year ago
Relevant content
asked 3 years ago
asked 2 years ago
