Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Detailed Request Processing time with JAMon?

N.K.
2011-10-20
2013-05-20
  • N.K.
    N.K.
    2011-10-20

    JAMon experts,

    First of all, i have to say that JAMon is one of the greatest monitoring tools I found so far! The fine-granularity of monitoring at different levels is one of the key competitive advantages.

    I went  through the JAMon documentation and I was unable to precisely decide if it can serve my requirements. You'd be able to quickly  help answering this question.

    My application architecture is (Load balancer + JBoss 3.2.3 + MySQL 5.0.19). I use J2sdk1.4.2.19 and my application uses Java servlets.

    I want to log the processing for each request at the JBoss server as well as the the corresponding MySQL processing time of each request. I need to get these times separately. For example:

    If we have 3 requests; search for item, checkout, and login

    I want to log data such as the following:

    Request              JBoss processing time      MySQL processing time
    r1. search for time         85 ms                                      150 ms
    r2. checkout                    50 ms                                       20 ms
    r3. login                          60 ms                                        80 ms      

    I want to log such information for each request received by JBoss (along with request details)

    I was not sure if JAMon does support such feature (not at the page level but request level processing time)?

    It would be appreciated if you can provide some pointers/insights how to do so with JAMon if possible

    I look forward to hearing from you

    N.K

     
  • Steve Souza
    Steve Souza
    2011-10-21

    First of all thank you for publicly stating how useful JAMon has been to you.  It is appreciated.

    As far as trying to track servlet time and mysql query time the easiest solution is to use the servlet filter and the jamon jdbc proxy driver.  Both are pretty simple.  Let me know if you have questions there. 

    As you mention being as the queries are performed inside a page request the page request time will also include the query.  So you will have to do some custom monitoring. 

    The following should work though I am not sure how easy it will be to incorporate it into your code.

    I am guessing from within a monitor like login you want to time how much time within it is take doing the query and how much time is from everything else.  So the 2 added together would give total login time.  Right?

    You should be able to do this using 3 monitors.  Pseudocode follows:

    Monitor totalMon=MonitorFactory.start("login.total");

    Monitor queryMon=MonitorFactory.start("login.query");
       …run query….
    queryMon.stop():
       …do other stuff…
    totalMon.stop():
    MonitorFactory.add("login.jboss", "ms.", totalMon.getLastValue()-queryMon.getLastValue());

    A bit ugly, but that might work.  You could probably encapsulate that in a class.  It might be that the value has changed by the time you called getLastValue().  If this is a possibility you could use temporary monitors by calling MonitorFactory.start(), and adding the values by calling the add function at the end.

    This brings up an interesting future enhancement that would do this in a more natural way (allowing you to roll up login.jboss, and login.query into a total for login) while only creating the login.jboss and login.query monitors.

    As an aside note that the latest version of jamon doesn't support jdk 1.4.  I believe up to jamon 2.71 it was supported under though.

     
  • N.K.
    N.K.
    2011-10-25

    Thanks a lot Steve for such professional explanation. That's bringing it closer to the key points.

    "As far as trying to track servlet time and mysql query time the easiest solution is to use the servlet filter and the jamon jdbc proxy driver.  Both are pretty simple.  Let me know if you have questions there. "

    >>> I tried to install and configure the servlet filter on my Jboss-3.2.3 & J2sdk1.4 as advised here (http://jamonapi.sourceforge.net/http_monitoring.html#configuring) but it seems it didn't work. I tried (Jamon2.7). it could be because of the old versions (Jboss & jdk). I have to stick with these versions as the application is old. The instruction here (http://jamonapi.sourceforge.net/#ServletFilter) seems a bit different though. Any insights?

    "I am guessing from within a monitor like login you want to time how much time within it is take doing the query and how much time is from everything else.  So the 2 added together would give total login time.  Right?"

    >>> Right. The code you've supplied is useful and makes sense. Unfortunately, I can't touch/change the code.

    The servlet filer and JDBC proxy driver seems to fit my monitoring needs; I may use "com.jamonapi.http.JAMonTomcatValve.request.page.value:/myapp/login.jsp, ms.", for ex., to monitor login page. I should later get it corresponding SQL processing time (from the JDBC proxy driver) and get the difference. This also applies to other pages, e.g., home, checkout, etc. Please correct me if this not correct?

    I'm not very much interested in the statistics (display), I'd like to get the raw monitoring data for each page so I do my own analysis on it. I'm guessing this is possible as the monitoring data can be accessed from a log file or so. Right?

    If both of the above points are correct, then I need to resolve the version issues (jboss & Jdk, MySQL as well). If this is solved then JAMon should work perfectly for such old application.

    "This brings up an interesting future enhancement that would do this in a more natural way (allowing you to roll up login.jboss, and login.query into a total for login) while only creating the login.jboss and login.query monitors."

    This in fact would be great feature.

    looking forward for your insights

    Much appreciated
    N.K.

     
  • N.K.
    N.K.
    2011-10-25

    And one more thing I forgot: where Can I find former versions of Jamon (less than 2.7) so hopefully it will work with my jboss 3.2.3 & j2sdk1.4.19

     
  • Steve Souza
    Steve Souza
    2011-10-26

    First try to see if you can get jamon to work with your version of jdk.  I believe up until recently jdk 1.4 was supported by jamon 2.71 or lower. 

    What do you mean is jamon data available from a log file?  You can write the data to a file.  Simply System.out.println(monitor).  There is no way to do this with jdbc, and page monitor devices at this point.  Although that would also be a good improvement.  You can do this with your own monitors easily enough, or you could change the jamon source code pretty easily.  I could help you with that. 

    Here is an example of what it would look like written to a file:  http://jamonapi.sourceforge.net/#SimpleExamples

    Yes, you can get all the data out of a monitor.  There are methods like the following:
    mon.getHits();
    mon.getTotal();
    mon.getMin();
    mon.getMax();

    >>> I tried to install and configure the servlet filter on my Jboss-3.2.3 & J2sdk1.4 as advised here (http://jamonapi.sourceforge.net/http_monitoring.html#configuring) but it seems it didn't work. I tried (Jamon2.7). it could be because of the old versions (Jboss & jdk). I have to stick with these versions as the application is old. The instruction here (http://jamonapi.sourceforge.net/#ServletFilter) seems a bit different though. Any insights? "I am guessing from within a monitor like login you want to time how much time within it is take doing the query and how much time is from everything else. So the 2 added together would give total login time. Right?" >>> Right. The code you've supplied is useful and makes sense. Unfortunately, I can't touch/change the code. The servlet filer and JDBC proxy driver seems to fit my monitoring needs; I may use "com.jamonapi.http.JAMonTomcatValve.request.page.value:/myapp/login.jsp, ms.", for ex., to monitor login page. I should later get it corresponding SQL processing time (from the JDBC proxy driver) and get the difference. This also applies to other pages, e.g., home, checkout, etc. Please correct me if this not correct? I'm not very much interested in the statistics (display), I'd like to get the raw monitoring data for each page so I do my own analysis on it. I'm guessing this is possible as the monitoring data can be accessed from a log file or so. Right? If both of the above points are correct, then I need to resolve the version issues (jboss & Jdk, MySQL as well). If this is solved then JAMon should work perfectly for such old application. "This brings up an interesting future enhancement that would do this in a more natural way (allowing you to roll up login.jboss, and login.query into a total for login) while only creating the login.jboss and login.query monitors." This in fact would be great feature. looking forward for your insights Much appreciated

     
  • N.K.
    N.K.
    2011-10-27

    I'll test Jamon 2.71- you're right this is the last version that supports java 1.4 (as noted soureforge read me file)

    Thank you very much for offering help with code samples and so..at the moment changing my code to add custom monitors would be the last option for my application. I'l let you know if I choose this option and need a help

    "What do you mean is jamon data available from a log file? "

    >>> JAMon API (War) displays monitoring statistics  of certain/all web pages (http://www.youtube.com/watch?v=BfIuoy8mP5c). Instead of displaying monitoring data (aggregated as statistics) I want to get the raw monitoring data, e.g.,  all hits for search page request along with when it has been requested and time taken by JBoss to process this request and return response to client to upstream server, processing time at MySQL server. 

    page                         URL           processing  time on JBoss          processing time on MySQL   
    search page         htt://…                       20 ms                                            30 ms
    search page        htt://…                       25 ms                                            30 ms
    ….
    (note time is not avg or max/min but the raw data- time it took to process each request)

    Can I get such collected data in file with Jamon 2.71? How/where the data is stored?

    Thank you for your great support

     
  • Steve Souza
    Steve Souza
    2011-10-27

    You can easily with a couple lines of code create and register a listener that will write any jamon monitors to a file.  Add a Jamon Listener by implementing the interface.  The interface has a method that will be called for each monitor and it gives you access to the monitor.  Simply write it to a file. 

    Something like this.  You need to register this as a jamon listener too.

    class LogListener implements JAMonListener {
    void processEvent(Monitor mon) {
      System.out.println(mon);
    }
    }

    To see more:
    http://jamonapi.sourceforge.net/jamonlisteners.html