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

help request: How to filter HEAD requests when using file-logger? #9596

Closed
kamly opened this issue Jun 4, 2023 · 11 comments · Fixed by #9712
Closed

help request: How to filter HEAD requests when using file-logger? #9596

kamly opened this issue Jun 4, 2023 · 11 comments · Fixed by #9712

Comments

@kamly
Copy link
Contributor

kamly commented Jun 4, 2023

Description

many head request , i want to filter it

Environment

  • APISIX version (run apisix version): 3.3.0
  • Operating system (run uname -a):
  • OpenResty / Nginx version (run openresty -V or nginx -V):
  • etcd version, if relevant (run curl http://127.0.0.1:9090/v1/server_info):
  • APISIX Dashboard version, if relevant:
  • Plugin runner version, for issues related to plugin runners:
  • LuaRocks version, for installation issues (run luarocks --version):
@An-DJ
Copy link
Contributor

An-DJ commented Jun 5, 2023

https://apisix.apache.org/docs/apisix/plugins/file-logger/

You may need include_resp_body_expr?

@kamly
Copy link
Contributor Author

kamly commented Jun 5, 2023

https://apisix.apache.org/docs/apisix/plugins/file-logger/

You may need include_resp_body_expr?

i think include_resp_body_expr records the conditions of the body

"include_resp_body": true,
"include_resp_body_expr": [
    [
      "arg_foo",
      "==",
      "bar"
    ]
]

is arg foo is bar , can log the response body

but what I want is that if the method is a head request, the log is not recorded

@An-DJ
Copy link
Contributor

An-DJ commented Jun 5, 2023

but what I want is that if the method is a head request, the log is not recorded

FYI it is not supported in APISIX yet.

IMHO, filtering, aggregation, count and other analysis operation can be further done based on the raw log data. If we do more restriction conditions on logging, it may lose the control of observability.

Recommend you filter and aggregate logs with other tools and OLAP system. : )

@kamly
Copy link
Contributor Author

kamly commented Jun 5, 2023

in nginx, we can

map $request_method $ignore_head_request {
    HEAD 0;
    default 1;
}
access_log /data/logs/nginx/nginx_access.log json if=$ignore_head_request;

@shreemaan-abhishek
Copy link
Contributor

I think you will have to patch apisix for this use case.

@kamly
Copy link
Contributor Author

kamly commented Jun 5, 2023

I want to push mr to apisix, but where should I start to solve this problem? Can you provide some ideas?

@kamly
Copy link
Contributor Author

kamly commented Jun 9, 2023

@shreemaan-abhishek want help~

@kamly
Copy link
Contributor Author

kamly commented Jun 10, 2023

@spacewander hi , can file-logger support filter_expr

example:

{
    "file-logger": {
        "filter_expr": [
            [
                "http_method",
                "!=",
                "HEAD"
            ]
        ]
    }
}

only filter_expr is true , can log

@tao12345666333
Copy link
Member

@monkeyDluffy6017 PTAL, thanks

@kamly
Copy link
Contributor Author

kamly commented Jun 14, 2023

@monkeyDluffy6017 hi, please look look, thanks~

@monkeyDluffy6017
Copy link
Contributor

LGTM

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

Successfully merging a pull request may close this issue.

6 participants