How to find the total number of requests processed by tomcat server?

I want to host a tomcat server that will host 3 web applications. I want to get the total number of requests processed by my server (for any of the three web applications). Is there any log where I can check the total number of requests processed by my server (including HTTP 404 requests)

Note. I can calculate the general requests processed by each individual application and get the total number of requests processed by my server, but the applications deployed in tomcat are third-party, and I can not make any changes to it.

Basically, I am creating a monitoring application for the tomcat server, and I have to provide the general requests filed in the application,

In addition, my first thought was to override the HTTPServletRequest class constructor in servlet-api.jar and set a static counter. since every request is mapped to an HTTPServletRequest object, I assume that it will do the job. But is it worth overloading the HTTPServletRequest or is there an existing solution for this?

+4
source share
2 answers

If you decide to override the HTTPServletRequest class, do not just add a static counter, this will cause your counter to reset itself each time the / jvm server reboots.

I think this may be the best option to either increase it from the database, or save the value in a file every time. This way you won’t lose your account, even if something happens to the server, and you must restart it.

All this assumes that there is no longer an Apache extension that already doses this, and you want to work with the HTTPServletRequest class.

+1
source

For this purpose, you can use a special filter called the Dumper Filter for queries .

According to official Tomcat documentation:

The following entries in a web application web.xml would enable the Request Dumper filter for all requests for that web application. If the entries were added to CATALINA_BASE/conf/web.xml, the Request Dumper Filter would be enabled for all web applications. 
+1
source

Source: https://habr.com/ru/post/1391453/


All Articles