The invention provides a microservice
request response viewing method and
system based on nginx. The microservice
request response viewing method comprises the steps that the format of an nginx log is self-defined through log_format of the nginx, lua is embedded into the nginx through lua-nginx-module, and configuration for obtaining response data returned by a back-end
server is written in a
coroutine of the lua; receiving the request data and the response data by the nginx, outputting the request data and the response data by utilizing the access_log of the nginx to generate the nginx log, and outputting the nginx log to a back-end
server; the configuration supporting the
syslog being written in nginx.conf of the nginx, and then outputting the nginx log to a
syslog server; and storing the nginx log in the
syslog server in the ElasticSearch, and checking the nginx log in the ElasticSearch. The method does not affect normal operation of online micro-service applications, facilitates
data query, is high in applicability, is highly decoupled from back-end applications, and is easy for later maintenance and expansion. Developers can be helped to quickly analyze and diagnose the performance
bottleneck under the distributed application architecture, and the development and diagnosis efficiency under the micro-service age is improved.