Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of patterns in mbean parameter name doesn't work #3

Open
ghost opened this issue Jun 6, 2013 · 6 comments
Open

Use of patterns in mbean parameter name doesn't work #3

ghost opened this issue Jun 6, 2013 · 6 comments

Comments

@ghost
Copy link

ghost commented Jun 6, 2013

Hello according to http://docs.oracle.com/javase/7/docs/api/javax/management/ObjectName.html
it is possible to use patterns in the objectName.
If I use a pattern in the mbean parameter. f.i.
name="org.eclipse.jetty.server:type=connectorstatistics,*"
Then Jmxetric doesn't collect the counters

@dpocock
Copy link
Member

dpocock commented Mar 17, 2014

Confirmed

a) the code needs to be patched to detect when a pattern has been supplied

b) it also needs to detect when attributes come and go dynamically at runtime

@ngzhian
Copy link
Contributor

ngzhian commented May 20, 2014

When a pattern is specified in the configuration file, for example
<mbean name="*:type=Memory" pname="Memory">, which should match any domains, e.g. java.lang, or org.apache.karaf, how should we interpret this?
This seems to be logical: only the specified attributes of this mbean, which can be of ANY domain with type=Memory, for example:

<mbean name="*:type=Memory" pname="Memory">
  <attribute name="HeapMemoryUsage">
  <composite name="init" pname="Heap_init" type="int32" units="bytes"/>
  <composite name="committed" pname="Heap_committed" type="int32" units="bytes"/>
  <composite name="used" pname="Heap_used" type="int32" units="bytes" />
  <composite name="max" pname="Heap_max" type="int32" units="bytes" />
</attribute>
</mbean>

will match the attribute HeapMemoryUsage of ANY domain with type=Memory.

@ngzhian
Copy link
Contributor

ngzhian commented Jun 3, 2014

Object o = mbs.getAttribute(new ObjectName("*:type=Threading"), "ThreadCount"); just results in a InstanceNotFoundException being thrown. The way that JMXetric currently retrieves the values of MBeans is the same way,

Object o = mbs.getAttribute(objectName, attributeName);

This means that we cannot naively use the pattern ObjectName.

One way to do this is to list all MBeans using queryMBeans passing in null arguments, as described here, and doing a check if the names matches using the apply method

@dpocock
Copy link
Member

dpocock commented Jun 4, 2014

There is one further aspect to this - we probably need to support regex "groups" in the pattern and then extract the string in the group and use it to create the metric names sent to Ganglia.

@ngzhian
Copy link
Contributor

ngzhian commented Jun 7, 2014

One way of doing so is (in pseudo code)

if ObjectName contains pattern
  loop through all available mbeans
    if mbean matches this ObjectName
      add to the MBeanSampler with specific MBean name (no patterns)
else
  add to MBeanSampler

@ngzhian
Copy link
Contributor

ngzhian commented Jun 9, 2014

There are two possible places we can translate the patterns to actual object names, when reading in the XML configuration (1), or just before publishing (2).

(1) will mean that the reading of XML depends on a MBeanServer. If we do this, we can make use of this dependency to discard bad configurations, e.g. MBeans that we cannot access, or do not exist

(2) will require us to do the checking of pattern names and testing the patterns again all available MBeans in the publish method, which seems to be beyond the responsibility of MBeanAttribute.

I will make a new branch to pursue (1) and see how it fares.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants