Tomcat request count only considers requests handeled by the default Servlet#878
Tomcat request count only considers requests handeled by the default Servlet#878toKrause wants to merge 1 commit intoCheckmk:masterfrom
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
|
I have read the CLA Document and I hereby sign the CLA or my organization already has a signed CLA. |
422cb92 to
8e43ceb
Compare
8e43ceb to
db5ffec
Compare
db5ffec to
66fc7e5
Compare
|
Dear Torsten, Thank you again for submitting this pull request and for the work you’ve put into it — we really appreciate your contribution. We’ve reviewed the proposed changes internally, and overall we are satisfied with the direction. That said, from a development and maintenance perspective, the changes introduce a certain level of risk, as they may have broader implications for other users and use cases. Because of this, we would like to propose the following next step: before merging, we’d like to submit these changes to the wider community to gather feedback. The goal would be to better understand the potential impact, identify any risks we may have missed, and see how other users feel about the changes and their effect on existing setups. Given that you’ve previously contributed on this topic, we wanted to ask you directly whether this approach would be acceptable to you. Of course, we would clearly reference your work and involve you in the discussion as much as you’d like. Thanks again for your contribution, and we’re looking forward to your thoughts. Best regards, |
General information
CheckMK provides out-of-the-box-support for monitoring a Tomcat Application Server. This includes a metric for a request count.
Bug report
What is the expected behavior?
For each web application, the request count monitored by CheckMK should equal the total number of incoming HTTP requests, regardless of which Servlet responded to them.
What is the observed behavior?
For each web application, the request count monitored by CheckMK considers only HTTP request responded to by the "default" servlet, i.e. requests for static content such as images of CSS files.
The request count monitored by CheckMK is always significantly smaller than the actual request count for any given web application.
An extreme example would be a web application that only provides a REST-API and has no static content. In such a case, the request count would currently always be zero.
Proposed changes
Using Jolokia, query not just the request count of the "default" Servlet (which is a named Servlet with name
default). Query the request counts of all Servlets and aggregate the returned values.The agent plugin
mk_jolokia.pycontains two selectors for the request count of Servlets.The first one is currently active and queries only the named Servlet
default. If this selector is used, the response from Jolokia contains (per web application) only a single entry for a value namedrequestCount. This is the reqest count for the "default" Servlet. This causes the issue described above.The second one is currently commented out and queries all Servlets. If this selector is used, the response from Jolokia contains (per web application) multiple entries for values named
requestCount- one for each Servlet of the corresponding web application.When the response from Jolokia is processed, each of these entries is processes separately. For each entry, the
requestCountis extracted, but overwrites any previously extracted value. Therefore, only the last value would be seen by CheckMK. This would not be okay.It is therefore necessary to aggregate all entries containing a
requestCountinto a single such entry, before entries are further processed.This can be done in
fetch_metric.The approach described here and the change proposed in this PR are certainly not the most elegant solution to the problem, as they introduce hard-coded behavior for specific selectors. However, the method
fetch_metricalready includes hard-coded behavior for another specific selector (threadStatus,threadParam), so this should be acceptable.