Skip to content

Instantly share code, notes, and snippets.

@emmanuelnk
Created February 23, 2023 15:20
Show Gist options
  • Save emmanuelnk/a914371238cc5ce3127ed8a86810b211 to your computer and use it in GitHub Desktop.
Save emmanuelnk/a914371238cc5ce3127ed8a86810b211 to your computer and use it in GitHub Desktop.
AWS Application Load Balancer Access Logs Typescript Interface
export interface AlbAccessLogFormat {
/**
* The type of request or connection. The possible values are as follows (ignore any other values):
*
* * http — HTTP
* * https — HTTP over TLS
* * h2 — HTTP/2 over TLS
* * grpcs— gRPC over TLS
* * ws — WebSockets
* * wss — WebSockets over TLS
*/
type: string
/**
* The time when the load balancer generated a response to the client, in ISO 8601 format.
*
* For WebSockets, this is the time when the connection is closed.
*/
time: string
/**
* The resource ID of the load balancer.
*
* If you are parsing access log entries, note that resources IDs can contain forward slashes (/).
*/
elb: string
/**
* The IP address of the requesting client.
*
* If there is a proxy in front of the load balancer, this field contains the IP address of the proxy.
*/
client_ip: string
/**
* The port of the requesting client.
*/
client_port: number
/**
* The IP address of the target that processed this request.
*
* If the client didn't send a full request, the load balancer can't dispatch the request to a target, and this value is set to `-`.
*
* If the target is a Lambda function, this value is set to `-`.
*
* If the request is blocked by AWS WAF, this value is set to `-` and the value of elb_status_code is set to 403.
*/
target_ip: string
/**
* The port of the target that processed this request.
*/
target_port: number
/**
* The total time elapsed (in seconds, with millisecond precision) from the time the load balancer received the request until the time it sent the request to a target.
*
* This value is set to `-1` if the load balancer can't dispatch the request to a target. This can happen if the target closes the connection before the idle timeout or if the client sends a malformed request.
*
* This value can also be set to `-1` if the registered target does not respond before the idle timeout.
*
* If AWS WAF is enabled for your Application Load Balancer, the time it takes for the client to send the required data for POST requests is counted towards request_processing_time.
*/
request_processing_time: number
/**
* The total time elapsed (in seconds, with millisecond precision) from the time the load balancer sent the request to a target until the target started to send the response headers.
*
* This value is set to `-1` if the load balancer can't dispatch the request to a target. This can happen if the target closes the connection before the idle timeout or if the client sends a malformed request.
*
* This value can also be set to `-1` if the registered target does not respond before the idle timeout.
*
* If AWS WAF is not enabled for your Application Load Balancer, the time it takes for the client to send the required data for POST requests is counted towards target_processing_time.
*/
target_processing_time: number
/**
* The total time elapsed (in seconds, with millisecond precision) from the time the load balancer received the response header from the target until it started to send the response to the client.
*
* This includes both the queuing time at the load balancer and the connection acquisition time from the load balancer to the client.
*
* This value is set to `-1` if the load balancer can't send the request to a target.
*
* This can happen if the target closes the connection before the idle timeout or if the client sends a malformed request.
*/
response_processing_time: number
/**
* The status code of the response from the load balancer.
*
*/
elb_status_code: string
/**
* The status code of the response from the target.
*
* This value is recorded only if a connection was established to the target and the target sent a response.
* Otherwise, it is set to `-`.
*/
target_status_code: string
/**
* The size of the request, in bytes, received from the client (requester).
*
* For HTTP requests, this includes the headers.
*
* For WebSockets, this is the total number of bytes received from the client on the connection.
*/
received_bytes: number
/**
* The size of the response, in bytes, sent to the client (requester).
*
* For HTTP requests, this includes the headers.
*
* For WebSockets, this is the total number of bytes sent to the client on the connection.
*/
sent_bytes: number
/**
* The request http verb e.g. GET, POST, PUT, PATCH, OPTIONS
*/
request_verb: string
/**
* The request url in the format `PROTOCOL://DOMAIN:PORT/URI`
* @example
* `https://example.com:443/api/some/endpoint`
*/
request_url: string
/**
* The request protocol e.g. HTTP/1.1, HTTP/2, HTTP/3
*/
request_proto: string
/**
* A User-Agent string that identifies the client that originated the request, enclosed in double quotes.
*
* The string consists of one or more product identifiers, product[/version].
*
* If the string is longer than 8 KB, it is truncated.
* @example
* `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36`
*/
user_agent: string
/**
* [HTTPS listener]
*
* The SSL cipher.
*
* This value is set to `-` if the listener is not an HTTPS listener.
* @example
* `ECDHE-RSA-AES128-GCM-SHA256`
*/
ssl_cipher: string
/**
* [HTTPS listener]
*
* The SSL protocol.
*
* This value is set to `-` if the listener is not an HTTPS listener.
* @example
* `TLSv1.2`
*/
ssl_protocol: string
/**
* The Amazon Resource Name (ARN) of the target group.
* @example
* `arn:aws:elasticloadbalancing:us-east-1:123456789012:targetgroup/my-targets/73e2d6bc24d8a067`
*/
target_group_arn: string
/**
* The contents of the X-Amzn-Trace-Id header, enclosed in double quotes.
* @example
* `Root=1-5a7c6a9e-7e9f1624342b851934be8fa`
*/
trace_id: string
/**
* [HTTPS listener]
*
* The SNI domain provided by the client during the TLS handshake, enclosed in double quotes.
*
* This value is set to `-` if the client doesn't support SNI or the domain doesn't match a certificate and the default certificate is presented to the client.
* @example
* `example.com`
*/
domain_name: string
/**
* [HTTPS listener]
*
* The ARN of the certificate presented to the client, enclosed in double quotes.
*
* This value is set to `session-reused` if the session is reused.
*
* This value is set to `-` if the listener is not an HTTPS listener.
* @example
* `arn:aws:acm:us-east-1:123456789012:certificate/12345678-1234-1234-1234-123456789012`
* `session-reused`
*/
chosen_cert_arn: string
/**
* The priority value of the rule that matched the request.
*
* If a rule matched, this is a value from `1` to `50 000`.
*
* If no rule matched and the default action was taken, this value is set to `0`.
*
* If an error occurs during rules evaluation, it is set to `-1`.
*
* For any other error, it is set to `-`.
* @example
* `1`
*/
matched_rule_priority: string
/**
* The time when the load balancer received the request from the client, in ISO 8601 format.
* @example
* `2019-07-01T00:00:00.000Z`
*/
request_creation_time: string
/**
* The actions taken when processing the request, enclosed in double quotes.
*
* This value is a comma-separated list that can include the values described in [Actions taken](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-access-logs.html#actions-taken).
*
* If no action was taken, such as for a malformed request, this value is set to `-`.
* @example
* `waf,forward`
*/
actions_executed: string
/**
* The URL of the redirect target for the location header of the HTTP response, enclosed in double quotes.
*
* If no redirect actions were taken, this value is set to `-`.
*/
redirect_url: string
/**
* The error reason code, enclosed in double quotes.
*
* If the request failed, this is one of the error codes described in [Error reason codes](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-access-logs.html#error-reason-codes).
*
* If the actions taken do not include an authenticate action or the target is not a Lambda function, this value is set to `-`.
*/
lambda_error_reason: string
/**
* A space-delimited list of IP addresses and ports for the targets that processed this request, enclosed in double quotes.
*
* Currently, this list can contain one item and it matches the target:port field.
*
* If the client didn't send a full request, the load balancer can't dispatch the request to a target, and this value is set to `-`.
*
* If the target is a Lambda function, this value is set to `-`.
*
* If the request is blocked by AWS WAF, this value is set to `-` and the value of elb_status_code is set to `403`.
* @example
* `172.31.10.71:443`
*/
target_port_list: string
/**
* A space-delimited list of status codes from the responses of the targets, enclosed in double quotes.
*
* Currently, this list can contain one item and it matches the `target_status_code` field.
*
* This value is recorded only if a connection was established to the target and the target sent a response. Otherwise, it is set to `-`.
*/
target_status_code_list: string
/**
* The classification for desync mitigation, enclosed in double quotes.
*
* If the request does not comply with RFC 7230, the possible values are Acceptable, Ambiguous, and Severe.
*
* If the request complies with RFC 7230, this value is set to `-`.
*/
classification: string
/**
* The classification reason code, enclosed in double quotes.
*
* If the request does not comply with RFC 7230, this is one of the classification codes described in [Classification reasons](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-access-logs.html#classification-reasons).
*
* If the request complies with RFC 7230, this value is set to `-`.
*/
classification_reason: string
/** The year partition in which the log was recorded */
year: number
/** The month partition in which the log was recorded */
month: number
/** The day partition in which the log was recorded */
day: number
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment