Skip to content

Custom log format - using port as protocol #2891

@ds-cbo

Description

@ds-cbo

My nginx log format is this:

log_format logger-json escape=json '{'
     '"remote_addr": "$remote_addr", "remote_user": "$remote_user"'
     ', "time_iso8601": "$time_iso8601", "msec": $msec'
     ', "host": "$http_host", "method": "$request_method", "uri": "$request_uri"'
     ', "status": "$status", "body_bytes_sent": "$body_bytes_sent"'
     ', "referer": "$http_referer", "user_agent": "$http_user_agent", "server_name": "$server_name"'
     ', "port": "$server_port", "ut": "$upstream_response_time", "rl": "$request_length"'
     ', "ssl_client_s_dn": "$ssl_client_s_dn"'
     ', "ssl_cipher": "$ssl_cipher", "ssl_protocol": "$ssl_protocol"'
     ', "rt": "$request_time", "uct": "$upstream_connect_time"'
     '}';

Which I have converted to goaccess configuration as

time-format %H:%M:%S
date-format %Y-%m-%d

log-format {"remote_addr": "%h", "remote_user": "%e", "time_iso8601": "%dT%t+%^", "msec": %^, "host": "%^", "method": "%m", "uri": "%U", "status": "%s", "body_bytes_sent": "%b", "referer": "%R", "user_agent": "%u", "server_name": "%v", "port": "%H", "ut": "%^", "rl": "%^", "ssl_client_s_dn": "%^", "ssl_cipher": "%k", "ssl_protocol": "%K", "rt": "%T", "uct": "%^"}

However, this is not fully accepted:

Token '80' doesn't match specifier '%H'

Would it be possible to allow %H to accept 80 for HTTP and 443 for HTTPS ?

--

And semi-related, I'm surprised there seems to be no specifier for request_length, but that might warrant its own ticket

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions