Home » Java » java – How to get last access time of application in WebSphere Liberty Server

java – How to get last access time of application in WebSphere Liberty Server

Posted by: admin February 25, 2020 Leave a comment


Am developing application in Java 8, JSF, Maven. Build application as war and deploying it in WebSphere Liberty Server I got requirement to get application last access time.? Is there any way to get this detail.?

How to&Answers:

One way you could do that is by watching the vendor_servlet_request_total metric (provided by the mpMetrics-2.x feature). There is a separately labeled time series for each servlet (a time series is a sequence of metric values in chronological order) — by periodically polling the /metrics endpoint, and totalling the values across all servlets you would be able to tell when traffic has stopped.


vendor_servlet_request_total{servlet=MyServletA} 100
vendor_servlet_request_total{servlet=MyServletB} 205


vendor_servlet_request_total{servlet=MyServletA} 102
vendor_servlet_request_total{servlet=MyServletB} 209


vendor_servlet_request_total{servlet=MyServletA} 102
vendor_servlet_request_total{servlet=MyServletB} 209

In the example above, since the servlet request counts didn’t change between 10:18am and 10:19am you can conclude that the last access was before 10:18am.

see https://openliberty.io/docs/ref/general/#metrics-catalog.html for more detail on the available metrics from mpMetrics-2.x.


You could probably write a filter that would intercept all requests to the app and update variable that would hold last access , or return that variable value if you would query for that.