We would like to monitor HTTP error codes (e.g. per minute) for later graphing.
How can we expose HTTP return (error) codes with JMX?
Are there code samples or have you done something like that? Is this contained in Tomcat per default?
About the implementation: Should the code increase a JMX counter and set it to 0 every minute? Thanks for ideas.
If you’re looking to derive rates of errors and graph those, you’re better off having the server return a total count of errors. That way the client can then derive a rate independent of the server (e.g. per minute/per hour/per day).
More importantly, you won’t miss any temporary surges in the data. If the server is deriving a rate and your client process doesn’t pick it up (if it’s not monitoring at that particular time, say), then it’s lost forever. Whereas maintaining a count will record the total number of errors.
SNMP agents (and similar) take this approach, allowing clients to monitor and derive values as they see fit.