Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Suggestion] Make access log format compatible with NGINX/Apache format #465

Open
Tragio opened this issue Dec 16, 2024 · 0 comments
Open

Comments

@Tragio
Copy link

Tragio commented Dec 16, 2024

Hi there 👋,

I was setting up Netdata on my side and noticed that it's compatible with Apache and NGINX log formats.

While configuring, I set the log format as follows:
--access-log-fmt '%(addr)s - - [%(time)s] "%(method)s %(path)s %(protocol)s" %(status)d 0 "-" "-"'

This outputs:
127.0.0.1 - - [2024-12-16 14:34:34 +0000] "GET /api/users/me HTTP/1.1" 200 0 "-" "-"

It's almost perfect, but the Nginx log format uses a slightly different date format:
127.0.0.1 - - [16/Dec/2024:14:41:54 +0000] "GET /api/users/me HTTP/1.1" 200 0 "-" "-"

I've created a custom formatter on my side:

class GranianFormatter(Formatter):
    def format(self, record, datefmt=None):
        dt = datetime.fromtimestamp(record.created, tz=timezone.utc)
        time_str = dt.strftime("%d/%b/%Y:%H:%M:%S %z")

        return f"{record.args['addr']} - - [{time_str}] \"{record.args['method']} {record.args['path']} {record.args['protocol']}\" {record.args['status']} 0 \"-\" \"-\""

However, I was wondering if we could align the format with NGINX/Apache by default, as it can enhance compatibility across the ecosystem without much trouble! 🤔

Just a suggestion, feel free to close it 😋

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant