You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/10/30 06:18:33 UTC

[GitHub] [apisix] qq54903099 opened a new issue #5376: request help: http-log内容中如何区分是上游返回的错误码,还是apisix返回的错误码

qq54903099 opened a new issue #5376:
URL: https://github.com/apache/apisix/issues/5376


   ### Issue description
   
   http-log内容中如何区分是上游返回的错误码,还是apisix返回的错误码。
   
   我测试了两种情况,这一种是调用路由未传递授权信息,返回的状态码为401
   > "response":
           {
               "status": 401,
               "headers":
               {
                   "x-request-id": "8942b7d6-a0a5-4cab-8dde-d09f80d144ec",
                   "transfer-encoding": "chunked",
                   "server": "APISIX",
                   "content-type": "text/plain; charset=utf-8",
                   "connection": "close"
               },
               "size": 280
           },
   
   这个是上游返回的401
   > "response":
           {
               "status": 401,
               "headers":
               {
                   "report-to": "{\"endpoints\":
                   [{\"url\":\"https:\\/\\/a.nel.cloudflare.com\\/report\\/v3?s=m3zBHUeAq%2FCMTZmPTMVJcjuWvV3WTvEhTfdy54CRtdhX11Y9UPjf9xjfSThBue%2FHsUjwgiccigR86FEeNOb7ciAhG9oZvANirZmWhESF3MxYQXprg8XslhBTmN9C7Q%3D%3D\"}],\"group\":\"cf-nel\",\"max_age\":604800}",
                   "nel": "{\"success_fraction\":0,\"report_to\":\"cf-nel\",\"max_age\":604800}",
                   "cf-ray": "6a6283167c160d58-LAX",
                   "server": "APISIX",
                   "alt-svc": "h3=\":443\"; ma=86400, h3-29=\":443\"; ma=86400, h3-28=\":443\"; ma=86400, h3-27=\":443\"; ma=86400",
                   "content-length": "0",
                   "x-request-id": "3d59e960-82e3-4bf0-8eca-f87130875986",
                   "date": "Sat, 30 Oct 2021 06:15:57 GMT",
                   "via": "1.1 vegur",
                   "cf-cache-status": "DYNAMIC",
                   "etag": "W/\"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk\"",
                   "connection": "close"
               },
               "size": 708
           },
   
   
   有没有什么办法能够区分?
   
   ### Environment
   
   - apisix version (cmd: `apisix version`): 2.10.0
   - OS (cmd: `uname -a`):
   - OpenResty / Nginx version (cmd: `nginx -V` or `openresty -V`):
   - etcd version, if have (cmd: run `curl http://127.0.0.1:9090/v1/server_info` to get the info from server-info API):
   - apisix-dashboard version, if have:
   - the plugin runner version, if the issue is about a plugin runner (cmd: depended on the kind of runner):
   - luarocks version, if the issue is about installation (cmd: `luarocks --version`):
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] tzssangglass edited a comment on issue #5376: request help: how to distinguish in the http-logger plugin whether the response is returned by upstream or apisix

Posted by GitBox <gi...@apache.org>.
tzssangglass edited a comment on issue #5376:
URL: https://github.com/apache/apisix/issues/5376#issuecomment-955197499


   ~~If the 401 status code is returned by APISIX, then the request will not go through the `log_by_lua*` phase, and therefore not through the http-logger plugin.~~


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] qq54903099 commented on issue #5376: request help: how to distinguish in the http-logger plugin whether the response is returned by upstream or apisix

Posted by GitBox <gi...@apache.org>.
qq54903099 commented on issue #5376:
URL: https://github.com/apache/apisix/issues/5376#issuecomment-955836255


   > No, the request will still go through the log phase. Maybe we need to extend "X-APISIX-Upstream-Status" header, see #3963
   
   yes! 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] tzssangglass commented on issue #5376: request help: how to distinguish in the http-logger plugin whether the response is returned by upstream or apisix

Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #5376:
URL: https://github.com/apache/apisix/issues/5376#issuecomment-959514325


   I think this should be changed in the log function of `http-logger`. add `X-APISIX-Upstream-Status` to indicate the status of the upstream response. just like the `set_resp_upstream_status` function.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] qq54903099 closed issue #5376: request help: how to distinguish in the http-logger plugin whether the response is returned by upstream or apisix

Posted by GitBox <gi...@apache.org>.
qq54903099 closed issue #5376:
URL: https://github.com/apache/apisix/issues/5376


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] spacewander commented on issue #5376: request help: how to distinguish in the http-logger plugin whether the response is returned by upstream or apisix

Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #5376:
URL: https://github.com/apache/apisix/issues/5376#issuecomment-955690509


   No, the request will still go through the log phase.
   Maybe we need to extend "X-APISIX-Upstream-Status" header, see https://github.com/apache/apisix/issues/3963


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] qq54903099 commented on issue #5376: request help: how to distinguish in the http-logger plugin whether the response is returned by upstream or apisix

Posted by GitBox <gi...@apache.org>.
qq54903099 commented on issue #5376:
URL: https://github.com/apache/apisix/issues/5376#issuecomment-958789743


   I thought I found another method
   like this
    "plugins": {
       "proxy-rewrite": {
         "host": "httpbin.org",
         "uri": "/ip"
       },
       "response-rewrite": {
         "disable": false,
         "headers": {
           "x-upstream-status": "$upstream_status"
         }
       }
     },


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] qq54903099 commented on issue #5376: request help: how to distinguish in the http-logger plugin whether the response is returned by upstream or apisix

Posted by GitBox <gi...@apache.org>.
qq54903099 commented on issue #5376:
URL: https://github.com/apache/apisix/issues/5376#issuecomment-958777333






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] qq54903099 commented on issue #5376: request help: how to distinguish in the http-logger plugin whether the response is returned by upstream or apisix

Posted by GitBox <gi...@apache.org>.
qq54903099 commented on issue #5376:
URL: https://github.com/apache/apisix/issues/5376#issuecomment-958777333


   I thought code in  init.lua modify like this? 
   
   ![image](https://user-images.githubusercontent.com/3895272/140036266-6b45b942-10ed-414c-83e5-2d1b5dbc4d47.png)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] qq54903099 commented on issue #5376: request help: how to distinguish in the http-logger plugin whether the response is returned by upstream or apisix

Posted by GitBox <gi...@apache.org>.
qq54903099 commented on issue #5376:
URL: https://github.com/apache/apisix/issues/5376#issuecomment-958777333






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] tzssangglass commented on issue #5376: request help: how to distinguish in the http-log plugin whether the error code is returned upstream or by apisix

Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #5376:
URL: https://github.com/apache/apisix/issues/5376#issuecomment-955197499


   If the 401 status code is returned by APISIX, then the request will not go through the `log_by_lua*` phase, and therefore not through the http-logger plugin.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] qq54903099 commented on issue #5376: request help: how to distinguish in the http-logger plugin whether the response is returned by upstream or apisix

Posted by GitBox <gi...@apache.org>.
qq54903099 commented on issue #5376:
URL: https://github.com/apache/apisix/issues/5376#issuecomment-958777333






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] tzssangglass commented on issue #5376: request help: how to distinguish in the http-logger plugin whether the response is returned by upstream or apisix

Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #5376:
URL: https://github.com/apache/apisix/issues/5376#issuecomment-959514325


   I think this should be changed in the log function of `http-logger`. add `X-APISIX-Upstream-Status` to indicate the status of the upstream response. just like the `set_resp_upstream_status` function.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] tzssangglass commented on issue #5376: request help: how to distinguish in the http-logger plugin whether the response is returned by upstream or apisix

Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #5376:
URL: https://github.com/apache/apisix/issues/5376#issuecomment-959514325


   I think this should be changed in the log function of `http-logger`. add `X-APISIX-Upstream-Status` to indicate the status of the upstream response. just like the `set_resp_upstream_status` function.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] tzssangglass commented on issue #5376: request help: how to distinguish in the http-logger plugin whether the response is returned by upstream or apisix

Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #5376:
URL: https://github.com/apache/apisix/issues/5376#issuecomment-959514325


   I think this should be changed in the log function of `http-logger`. add `X-APISIX-Upstream-Status` to indicate the status of the upstream response. just like the `set_resp_upstream_status` function.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org