我想將“x-kong-proxy-latency”和“x-kong-upstream-latency”標頭的值記錄到 Kong 日志中。我怎樣才能訪問 log_format 中的那些值?
KONG_PROXY_ACCESS_LOG: /dev/stdout custom_formatter
KONG_NGINX_HTTP_LOG_FORMAT: custom_formatter 'xkpl $$x_kong_proxy_latency'
這讓我出錯:
2022-11-20 00:13:18 Run with --v (verbose) or --vv (debug) for more details
2022-11-20 00:14:20 Error: could not prepare Kong prefix at /usr/local/kong: nginx configuration is invalid (exit code 1):
2022-11-20 00:14:20 nginx: [emerg] unknown "x_kong_proxy_latency" variable
2022-11-20 00:14:20 nginx: configuration file /usr/local/kong/nginx.conf test failed
現在,在變數中獲取這些資料的正確方法是什么?
uj5u.com熱心網友回復:
正如錯誤所暗示的那樣,x_kong_proxy_latency默認情況下不是 nginx 知道的變數。是發送到客戶端的 HTTP 標頭,分別指示 kong 延遲和上游
x-kong-proxy-latency延遲x-kong-upstream-latency
由于這些header是Kong創建的發送t個客戶端,我們可以使用$sent_http_nginx的前綴將header注入access_log,例如:
KONG_PROXY_ACCESS_LOG:/dev/stdout latency
KONG_NGINX_HTTP_LOG_FORMAT:latency '$$sent_http_x_kong_proxy_latency $$sent_http_x_kong_upstream_latency'
將注入您要查找的兩個標頭的值。
如果您正在尋找更多配置,可以在此處查看 nginx 檔案
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/537051.html
標籤:nginx孔
上一篇:從字串中決議長格式日期
