Skip to content

log request_header when key set#9726

Closed
ning1875 wants to merge 1 commit into
apache:masterfrom
ning1875:master
Closed

log request_header when key set#9726
ning1875 wants to merge 1 commit into
apache:masterfrom
ning1875:master

Conversation

@ning1875

Copy link
Copy Markdown

Description

When the log format is configured, it is also expected to print some important request headers such as the release that identifies the lane to help troubleshoot the request problem, so the user needs to configure the header list to be printed

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

eg

  • config like this
"request_header_keys": [
    "release",
    "env",
  ]
  • log like
"release"="dev",
"env"="stage"

@juststillthinking

juststillthinking commented Jun 27, 2023

Copy link
Copy Markdown
Contributor

Hi @ning1875, I don't think you need to create this pr to implement this function.
You could record the request header like this, we suppose the nginx and apisix variable

curl http://127.0.0.1:9180/apisix/admin/plugin_metadata/file-logger -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
  "log_format": {
    "release": "$http_release",
  }
}'

@ning1875

Copy link
Copy Markdown
Author

Hi @ning1875, I don't think you need to create this pr to implement this function. You could record the request header like this, we suppose the nginx and apisix variable

curl http://127.0.0.1:9180/apisix/admin/plugin_metadata/file-logger -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
  "log_format": {
    "release": "$http_release",
  }
}'

test ok ,it works 。so does it support by openresty ?

@juststillthinking

Copy link
Copy Markdown
Contributor

It's an nginx variable, and you could refer to this: https://github.com/openresty/lua-nginx-module#ngxvarvariable

@juststillthinking

Copy link
Copy Markdown
Contributor

I will close this pr, feel free to reopen it

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants