I have a Java application running as a container in an ECS cluster. I want to be able to get JMX metrics and send them to AWS CloudWatch. Initially, I was using this article as a reference:
However, I noticed that it runs everything on a single EC2 instance. I have read that ECS integrates with CloudWatch Insights but I can't get it to work. I also tried using CollectD only, but I'm only getting logs saying that plugins have been initialised.
I run the application with the following flags:
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=9999
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
I also have the following config for CollectD(sidecar):
LoadPlugin network
<Plugin network>
<Server "127.0.0.1" "25826">
</Server>
</Plugin>
LoadPlugin java
<Plugin java>
JVMArg "-Djava.class.path=/usr/share/collectd/java/collectd-api.jar:/usr/share/collectd/java/generic-jmx.jar"
LoadPlugin "org.collectd.java.GenericJMX"
<Plugin "GenericJMX">
<MBean "Memory">
ObjectName "java.lang:type=Memory"
InstancePrefix "java"
<Value>
Type "gauge"
InstancePrefix "java_lang_memory_heapmemoryusage_"
Table true
Attribute "HeapMemoryUsage"
</Value>
</MBean>
<MBean "OperatingSystem">
ObjectName "java.lang:type=OperatingSystem"
InstancePrefix "java"
<Value>
Type "gauge"
InstancePrefix "java_lang_operatingsystem_freephysicalmemorysize"
Attribute "FreePhysicalMemorySize"
</Value>
<Value>
Type "gauge"
InstancePrefix "java_lang_operatingsystem_freeswapsizespace"
Attribute "FreeSwapSpaceSize"
</Value>
<Value>
Type "gauge"
InstancePrefix "java_lang_operatingsystem_committedvirtualmemorysize"
Attribute "CommittedVirtualMemorySize"
</Value>
</MBean>
<MBean "Threading">
ObjectName "java.lang:type=Threading"
InstancePrefix "java"
<Value>
Type "gauge"
InstancePrefix "java_lang_threading_threadcount"
Attribute "ThreadCount"
</Value>
<Value>
Type "gauge"
InstancePrefix "java_lang_threading_daemonthreadcount"
Attribute "DaemonThreadCount"
</Value>
</MBean>
<MBean "ClassLoading">
ObjectName "java.lang:type=ClassLoading"
InstancePrefix "java"
<Value>
Type "gauge"
InstancePrefix "java_lang_classloading_loadedclasscount"
Attribute "LoadedClassCount"
</Value>
</MBean>
<Connection>
Host "127.0.0.1"
ServiceURL "service:jmx:rmi:///jndi/rmi://127.0.0.1:9999/jmxrmi"
Collect "Memory"
Collect "OperatingSystem"
Collect "Threading"
Collect "ClassLoading"
</Connection>
</Plugin>
</Plugin>
Any idea how I can get this to work?I need to get the metrics configured in CollectD config file.