gaoxingliang opened a new issue, #8828:
URL: https://github.com/apache/apisix/issues/8828

   ### Current Behavior
   
    the response is not recorded in clickhouse logger.
   and the apisix log shows:
   ```
    2023/02/10 07:55:26 [error] 51#51: *196137 [lua] batch-processor.lua:95: 
Batch Processor[clickhouse-logger] failed to process entries: server returned 
status code[400] host[clickhouse-clickhous] port[8123] body[Code: 117. 
DB::Exception: Cannot parse object: (while reading the value of key response): 
(at row 1)
   
    : While executing JSONEachRowRowInputFormat. (INCORRECT_DATA) (version 
22.10.7.13 (official build))
   
    ], context: ngx.timer, client:
   ```
   It shows the `response` field is null?
   I guess maybe some 404 or 500 requests may cause this error.
   My clickhouse logger table:
   ```
   create table api_log2 on cluster "all-nodes" (
     upstream String,
     start_time DateTime64(3, 'Asia/Shanghai'),
     client_ip String,
     service_id String,
     route_id String,
     request JSON,
     response JSON,
     server JSON,
     latency Float64,
     upstream_latency Float64,
     apisix_latency Float64
   )
   ENGINE = 
ReplicatedMergeTree('/clickhouse/tables/{shard}/{database}/{table}', 
'{replica}')
   PARTITION BY toYYYYMM(start_time)
   ORDER BY (start_time, route_id);
   ```
   
   A normal response log: **NOTE the status is in the response part**
   ```
                   {
                           "upstream": "",
                           "start_time": "2023-02-01 15:56:15.394",
                           "client_ip": "xxxx",
                           "service_id": "xxxxcn",
                           "route_id": "",
                           "request": 
{"headers":{"accept":"*\/*","accept-encoding":"gzip, deflate, 
br","accept-language":"","api-token":"","cache-control":"no-cache","connection":"","content-length":"","content-type":"","host":"api.xxx.cn:8888","postman-token":"3d9ef9fb-127e-4749-9211-b7b7fb048550","user-agent":"PostmanRuntime\/7.30.1"},"method":"GET","querystring":1"},"size":325,"uri":"cccc","url":"bbbb"},
                           "response": 
{"headers":{"connection":"close","content-length":"","content-type":"text\/plain;
 
charset=utf-8","date":"","grpc-message":"","grpc-metadata-content-type":"","grpc-metadata-trailer":[],"grpc-status":"","location":"","server":"APISIX\/3.1.0","trailer":[],"transfer-encoding":"chunked","x-request-id":"f2b15f9f-fb08-4843-8efd-978b100a503f"},"size":277,"status":404},
                           "server": 
{"hostname":"apisix-66f66cb69b-vvtf5","version":"3.1.0"},
                           "latency": 0,
                           "upstream_latency": 0,
                           "apisix_latency": 0
                   }
   ```
   
   
   ### Expected Behavior
   
   It should log all request and response (404, 500 of the upstream)
   
   ### Error Logs
   
   _No response_
   
   ### Steps to Reproduce
   
   1. create a clickhouse log table.
   2. send some requests eg 404 or 500 
   
   ### Environment
   
   - APISIX version (run `apisix version`): 3.1.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`):
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to