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

$http_x_forwarded_for field missing from nginx parser plugin format #1907

Closed
yaron-idan opened this issue Mar 22, 2018 · 2 comments
Closed
Labels
enhancement Feature request or improve operations

Comments

@yaron-idan
Copy link
Contributor

  • fluentd or td-agent version.
    fluentd v1.1.2
  • Environment information, e.g. OS.
    Linux / Docker
  • Your configuration
<source>
  @type tail
  path "/logs/*.log"
  format nginx
  tag "nginx.*"
</source>
  • Your problem explanation. If you have an error logs, write it together.
    When receiving a log from nginx, I get the following message -
    fluentd_1 | 2018-03-22 18:07:49 +0000 [warn]: #0 pattern not match: "172.18.0.1 - - [22/Mar/2018:18:07:49 +0000] \"GET / HTTP/1.1\" 200 612 \"-\" \"curl/7.54.0\" \"-\""
    If I swap the format configuration to the one listed in the plugin docs and add the last field like so the log level goes through -
format /^(?<remote>[^ ]*) (?<host>[^ ]*) (?<user>[^ ]*) \[(?<time>[^\]]*)\] "(?<method>\S+)(?: +(?<path>[^\"]*) +\S*)?" (?<code>[^ ]*) (?<size>[^ ]*)(?: "(?<referer>[^\"]*)" "(?<agent>[^\"]*)" "(?<agent2>[^\"]*)")?$/
  time_format %d/%b/%Y:%H:%M:%S %z

I find this a bit strange since the last field ($http_x_forwarded_for) has been part of the default nginx logging for a long time. Is there a real reason for omitting this line from the plugins format?

If the field needs adding, I'm cool with opening the PR for it. Just wanted to check up before starting to work on it.

@repeatedly
Copy link
Member

Maybe, nginx's regexp comes from https://github.com/nginx/nginx/blob/764737256521de5c34f7ce1cc1b27bf440b6cced/src/http/modules/ngx_http_log_module.c#L227
I checked the configuration and $http_x_forwarded_for is included in the example.
https://github.com/nginx/nginx/blob/9207cc84b21e94283478cee7a953b1859c4434cb/conf/nginx.conf#L21
So support $http_x_forwarded_for seems good for many users.

@repeatedly
Copy link
Member

v1.2.0.pre1 includes this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature request or improve operations
Projects
None yet
Development

No branches or pull requests

2 participants