collectd-fast-jmx
collectd-fast-jmx copied to clipboard
InstancePrefix in <Value> not being used
The InstancePrefix configuration directive within the <Value> block doesn't seem to be used. Below is my example config and so I expected to see metrics like:
*.cass-test-1.jvm.heap.
and what I got was
*.cass-test-1.jvm.memory-
A quick test of changing the Type shows that the 'memory-' is coming from the type. Maybe the type is mistakenly being added to the metric name instead of the prefix?
LoadPlugin java
<Plugin java>
JVMARG "-Djava.class.path=/usr/share/collectd/java/collectd-api.jar:/usr/share/collectd/java/collectd-fast-jmx-1.0.0.jar"
LoadPlugin "com.e_gineering.collectd.FastJMX"
<Plugin FastJMX>
LogLevel "FINE"
MaxThreads 256
<MBean "memory">
ObjectName "java.lang:type=Memory"
<Value>
Attribute "HeapMemoryUsage"
Type "memory"
Composite true
InstancePrefix "heap"
PluginName "jvm"
</Value>
<Value>
Attribute "NonHeapMemoryUsage"
Type "memory"
Composite true
InstancePrefx "non-heap"
PluginName "jvm"
</Value>
</MBean>
<Connection "cass-test-1">
ServiceURL "service:jmx:rmi:///jndi/rmi://localhost:7199/jmxrmi"
Collect "memory"
</Connection>
</Plugin>
</Plugin>
I'm a bit rusty on this (project and code at this point) so bear with me...
But, I believe what you're seeing is the correct behavior.
The InstancePrefix of a <Value>
is a prefix applied to the type instance portion of the naming schema for collectd.
https://collectd.org/wiki/index.php/Naming_schema#Serialization
Looking through the code it looks like it should be applied properly, and I'm almost positive I've used this feature in the past.
From your configured I'd expect the following metrics reported to collectd...
localhost/java-FastJMX/memory-heap-'metric'
Personally, I tend to prefer instrumenting the memory-pools which gives a bit more visibility to the JVM internals. I typically do that with this block.
# Memory usage by memory pool.
<MBean "memory_pool">
ObjectName "java.lang:type=MemoryPool,*"
InstancePrefix "memory_pool-"
InstanceFrom "name"
<Value "Usage">
Type "memory"
Composite true
</Value>
</MBean>
Documentation for my future self (I'll probably be using this plugin this week or next!)...
in situations where we're working with prefixing names, rather than checking a iterator count (i > 0)
before prefixing hyphens into a name, check the existing length of the name buffer (beanInstance.length() > 0)
. one such example AttributePermutation.java:85