zhendongcmss edited a comment on issue #5146:
URL: https://github.com/apache/apisix/issues/5146#issuecomment-927637505


   > Maybe we can add:
   > 
   > ```
   > diff --git apisix/plugins/prometheus/exporter.lua 
apisix/plugins/prometheus/exporter.lua
   > index ea1c4843..4a8ec64e 100644
   > --- apisix/plugins/prometheus/exporter.lua
   > +++ apisix/plugins/prometheus/exporter.lua
   > @@ -153,6 +153,10 @@ function _M.log(conf, ctx)
   >          metrics.latency:observe(upstream_latency,
   >              gen_arr("upstream", route_id, service_id, consumer_name, 
balancer_ip))
   >          apisix_latency =  apisix_latency - upstream_latency
   > +        if apisix_latency < 0 then
   > +            ngx.log(ngx.EMERG, "latency now ", ngx.now(), ", start_time: 
", ngx.req.start_time(), ", upstream: ",
   > +                    ctx.var.upstream_response_time)
   > +        end
   >      end
   >      metrics.latency:observe(apisix_latency,
   >          gen_arr("apisix", route_id, service_id, consumer_name, 
balancer_ip))
   > ```
   > 
   > to see each value of the items.
   
   **Got the error.log**
   
   
   **tailf /var/log/balancer/error.log | grep start_time**
   ```
   [root@ZJNB-ICLOUD-SPOD2-PM-DC01-ACCESSER-01 ~]# tailf 
/var/log/balancer/error.log | grep start_time
   2021/09/27 08:10:31 [emerg] 57#57: *46261 [lua] exporter.lua:161: 
phase_func(): latency now 1632730231.246, start_time: 1632730231.203, upstream: 
0.043 while logging request, client: 10.195.158.10, server: _, request: "GET / 
HTTP/1.0", upstream: "http://10.195.152.61:8085/";, host: "10.9080"
   2021/09/27 08:10:31 [emerg] 50#50: *35769 [lua] exporter.lua:161: 
phase_func(): latency now 1632730231.622, start_time: 1632730231.288, upstream: 
0.334 while logging request, client: 10.195.158.13, server: _, request: "PUT 
/tb3/file_tttsMM42626 HTTP/1.1", upstream: 
"http://10.195.152.61:8081/tb3/file_tttsMM42626";, host: "10.195.156.10"
   2021/09/27 08:10:31 [emerg] 50#50: *46882 [lua] exporter.lua:161: 
phase_func(): latency now 1632730231.906, start_time: 1632730231.863, upstream: 
0.043 while logging request, client: 10.195.158.20, server: _, request: "GET / 
HTTP/1.0", upstream: "http://10.195.152.61:8078/";, host: "10.1:9080"
   2021/09/27 08:10:31 [emerg] 76#76: *46898 [lua] exporter.lua:161: 
phase_func(): latency now 1632730231.932, start_time: 1632730231.89, upstream: 
0.042 while logging request, client: 10.195.158.10, server: _, request: "GET / 
HTTP/1.0", upstream: "http://101:8079/";, host: "onest-pgy.cmecloud.cn"
   2021/09/27 08:10:31 [emerg] 67#67: *46897 [lua] exporter.lua:161: 
phase_func(): latency now 1632730231.934, start_time: 1632730231.89, upstream: 
0.044 while logging request, client: 10.195.158.10, server: _, request: "GET / 
HTTP/1.0", upstream: "http://11:8079/";, host: "onest-pgy.cmecloud.cn"
   2021/09/27 08:10:32 [emerg] 59#59: *47115 [lua] exporter.lua:161: 
phase_func(): latency now 1632730232.227, start_time: 1632730232.184, upstream: 
0.043 while logging request, client: 10.195.158.10, server: _, request: "GET / 
HTTP/1.0", upstream: "http://11:8084/";, host: "onest-pgy.cmecloud.cn"
   2021/09/27 08:10:32 [emerg] 59#59: *47138 [lua] exporter.lua:161: 
phase_func(): latency now 1632730232.276, start_time: 1632730232.233, upstream: 
0.044 while logging request, client: 10.195.158.10, server: _, request: "GET / 
HTTP/1.0", upstream: "http://101:8080/";, host: "10.19:9080"
   2021/09/27 08:10:32 [emerg] 67#67: *47321 [lua] exporter.lua:161: 
phase_func(): latency now 1632730232.449, start_time: 1632730232.405, upstream: 
0.044 while logging request, client: 10.195.158.20, server: _, request: "GET / 
HTTP/1.0", upstream: "http://101:8084/";, host: "10.61:9080"
   
   
   ```


-- 
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