请教agentzh一个关于$body_bytes_sent的问题
我的openresty配置如下
http {
include mime.types;
default_type application/octet-stream;
log_format json '{"@timestamp":"$time_local",'
'"@fields":{'
'"ip":"$remote_addr",'
'"cache":"$upstream_cache_status",'
#'"req":"$request_body",'
'"req":"$request",'
'"key":"$arg_key",'
'"status":$status,'
'"resbytes":$body_bytes_sent,'
'"reqtime":$request_time}}';
access_log logs/access.log json;
server {
listen 8081;
server_name 127.0.0.1;
location / {
access_log off;
content_by_lua_file '/usr/local/openresty/luaframework/luasrc/mch/localcache.lua';
}
location /@cacheredis {
log_subrequest on;
echo 'this is my test string - dsddddddddddddddddddddddddddddddd';
#proxy_cache my_cache;
#proxy_cache_revalidate on;
#proxy_cache_key $arg_key;
#proxy_cache_valid 200 304 302 10m;
#proxy_cache_methods GET HEAD POST;
#proxy_cache_min_uses 3;
#proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
#proxy_cache_lock on;
#proxy_pass http://127.0.0.1:8082;
}
/usr/local/openresty/luaframework/luasrc/mch/localcache.lua的代码如下:
local res = ngx.location.capture("/@cacheredis", { method = ngx.HTTP_POST, body = ngx.var.request_body})
ngx.say(res.body)
我用curl -X POST --data "data="" http://127.0.0.1:8081请求能正常返回this is my test string - dsddddddddddddddddddddddddddddddd
我的access.log记录如下
{"@timestamp":"02/Jun/2016:15:26:47 +0800","@fields":{"ip":"127.0.0.1","cache":"-","req":"POST / HTTP/1.1","key":"-","status":200,"resbytes":0,"reqtime":0.000}}
我的问题是,为什么resbytes即$body_bytes_sent一直是0呢?