I have a Java application that I'm deploying inside a Cloud Foundry environment. I want to monitor the application's memory usage. Cloud Foundry provides the cf app
command that produces output about each instance of the specified application. Here you can see information about a particular application with two running instances (expurgated):
$ cf app myapp
Showing health and status for app myapp in org myorg / space myspace as admin...
OK
requested state: started
instances: 2/2
usage: 1G x 2 instances
urls: myapp.example.com
last uploaded: Wed Jan 27 09:00:53 UTC 2016
stack: mylinuxstack
buildpack: myjavabuildpack
state since cpu memory disk details
#0 running 2016-01-27 09:01:31 AM 0.4% 689.8M of 1G 0 of 1G
#1 running 2016-02-03 05:35:03 PM 0.0% 624.2M of 1G 0 of 1G
However, the memory metrics appear to just report the amount of memory used by the processes running inside the Cloud Foundry container. If you've dealt with monitoring Java apps, you're aware that JVMs will eventually, potentially, consume as much memory as you've told them they can have, even if the Java application is not using it. (In other words, it does its own memory management.) This means that the actual java
process might be consuming its full 1GB of memory, but that doesn't imply that it's about to run out of memory.
In my experience, useful monitoring of Java app memory utilization depends on getting data from the JVM itself, via something like JMX (such as via jconsole
). However, Cloud Foundry does not seem to provide information about where the app is actually running. (In fact, I've found some people claiming that Cloud Foundry explicitly will not tell you that information.) And that means I have nowhere to connect a JMX client to.
If I want to monitor the memory utilization of my Java apps inside Cloud Foundry, how should I do so? Feel free to rebut any of my claims if you know better.