lj-lua-ngx-status-code can be used to capture lua backtrace of HTTP requests that call ngx.exit(code) with code greater or equal than 400.

This analyzer has three filter conditions: HTTP status code, request URI, and hostname. You can use it to narrow the target requests that you are interested in.

By default, the analyzer captures all the request which has a status code greater or equal than 400 that triggered by ngx.exit(). At most, 1000 requests will be captured.

For example: You can find the root cause of the status code through the lua backtrace flame graph.