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

Unable to use JmxMonitorRegistry for registering metrics #155

Closed
arora-ajay-11 opened this issue May 6, 2013 · 9 comments · Fixed by #250
Closed

Unable to use JmxMonitorRegistry for registering metrics #155

arora-ajay-11 opened this issue May 6, 2013 · 9 comments · Fixed by #250

Comments

@arora-ajay-11
Copy link

To Use JmxMonitorRegistry/ DefaultMonitorRegistry, I have to pass them a Monitor<?> types argument. But I just have a POJO class in which some properties have been annotated with @monitor annotation. Now I want to publish these properties to JMX server for monitoring purpose. But, when I follow your example,

Server s1 = new Server("s1");
DefaultMonitorRegistry.getInstance().registerObject(s1);

This is not working for me as DefaultMonitorRegistry's registerObject method requires a Monitor<?> object and not a simple Java Object.

Can you please explain how can I use DefaultMonitorRegistry/JmxMonitorRegistry to register properties of my simple java class ?

Thanks,
Ajay Arora

@dmuino
Copy link
Contributor

dmuino commented May 7, 2013

You can use Monitors.registerObject(s1)

Daniel
Sent from my phone

On May 6, 2013, at 2:55 PM, arora-ajay-11 notifications@github.com wrote:

To Use JmxMonitorRegistry/ DefaultMonitorRegistry, I have to pass them a Monitor<?> types argument. But I just have a POJO class in which some properties have been annotated with @monitor annotation. Now I want to publish these properties to JMX server for monitoring purpose. But, when I follow your example,

Server s1 = new Server("s1");
DefaultMonitorRegistry.getInstance().registerObject(s1);

This is not working for me as DefaultMonitorRegistry's registerObject method requires a Monitor<?> object and not a simple Java Object.

Can you please explain how can I use DefaultMonitorRegistry/JmxMonitorRegistry to register properties of my simple java class ?

Thanks,
Ajay Arora


Reply to this email directly or view it on GitHub.

@arora-ajay-11
Copy link
Author

Hi Daniel,
I have tried it but the object structure it is creating is too long and not
the one we get while using MBeans. Can you pkz suggest how should I
register my metrics using @monitor annotation so that I can get the object
structure as we get using MBeans.

I am attaching an image of the structure I am getting in VisualVM for your reference.

jconsole

Thanks,
Ajay Arora

On May 6, 2013 9:19 PM, "Daniel Muino" notifications@github.com wrote:

You can use Monitors.registerObject(s1)

Daniel
Sent from my phone

On May 6, 2013, at 2:55 PM, arora-ajay-11 notifications@github.com
wrote:

To Use JmxMonitorRegistry/ DefaultMonitorRegistry, I have to pass them a
Monitor<?> types argument. But I just have a POJO class in which some
properties have been annotated with @monitor annotation. Now I want to
publish these properties to JMX server for monitoring purpose. But, when I
follow your example,

Server s1 = new Server("s1");
DefaultMonitorRegistry.getInstance().registerObject(s1);

This is not working for me as DefaultMonitorRegistry's registerObject
method requires a Monitor<?> object and not a simple Java Object.

Can you please explain how can I use
DefaultMonitorRegistry/JmxMonitorRegistry to register properties of my
simple java class ?

Thanks,
Ajay Arora


Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHubhttps://github.com//issues/155#issuecomment-17522649
.

@brharrington
Copy link
Contributor

Servo maps the tags specified for a monitor to properties on the JMX object name. In general we don't know how to map arbitrary tags on monitors into an object name so we just map the tags one-to-one to object name properties. This also gives the most flexibility for querying them using patterns:

http://docs.oracle.com/javaee/1.4/api/javax/management/ObjectName.html

For the jmx view I use there object name query matches a set of mbeans which then get flattened to a table letting me slice and dice across mbeans. The order of properties is not significant on the object name, but some tools allow you to specify the order. This can let you change the way they are grouped when expanding the tree to something that is more convenient. For example in visual vm:

Preferences > MBeans > Ordered key property list

The other difference is you seem to have tags like the server name and ip in your list. We typically apply common tags globally to metrics using a custom observer when they are reported to the backends. So things like ip won't show up in the jmx view. In general stuff like ip isn't useful for jmx on a single instance, but is useful for aggregation backends.

We can consider adding a hook that would let the user specify how they want to map a servo MonitorConfig to an ObjectName.

@arora-ajay-11
Copy link
Author

Hi,
I tried to run the example given at following link :

http://techblog.netflix.com/2012/02/announcing-servo.html

But I couldn't find the @monitorid annotation. Can you please provide me the details of the library which has it ?
Also, after removing @monitorid tag, I tried to register my Server class with JMX Server in the way mentioned in the example, but got a compilation error.

Server s1 = new Server("s1");
DefaultMonitorRegistry.getInstance().registerObject(s1);

There is no such method like registerObject(s1) in DefaultMonitorRegistry class. Can you please provide me some info on that too ?

Actually, I am getting the following object tree in JConsole after using @monitor annotations :

See IncorrectFormat.jpg attached.

While I want it to be looked like ( See attached CorrectFormat.jpg). Below is my java class :

This is CorrectFormat.jpg

correctformat

This is IncorrectFormat.jpg

incorrectformat

public class Server {

    @Monitor(name="Status", type=DataSourceType.INFORMATIONAL)
    private final AtomicReference<String> status = new AtomicReference<String>("UP");

    @Monitor(name="CurrentConnections", type=DataSourceType.GAUGE)
    private final AtomicInteger currentConnections = new AtomicInteger(0);

    @Monitor(name="TotalConnections", type=DataSourceType.COUNTER)
    private final AtomicInteger totalConnections = new AtomicInteger(0);

    @Monitor(name="BytesIn", type=DataSourceType.COUNTER)
    private final AtomicLong bytesIn = new AtomicLong(0L);

    @Monitor(name="BytesOut", type=DataSourceType.COUNTER)
    private final AtomicLong bytesOut = new AtomicLong(0L);

}

Can you please guide me how can I get the desired output in JConsole or VisualVM ?

@dmuino
Copy link
Contributor

dmuino commented May 10, 2013

@monitorid was replaced by @MonitorTags which is more generic and allows
you to have an 'id' tag.

DefaultMonitorRegistry.getInstance().registerObject(s1);

should be:

Monitors.registerObject(s1);

Please see https://github.com/Netflix/servo/wiki for current documentation.

Regarding how metrics get represented in JMX I don't think that's
configurable right now.

On Fri, May 10, 2013 at 11:12 AM, arora-ajay-11 notifications@github.comwrote:

Hi,
I tried to run the example given at following link :

http://techblog.netflix.com/2012/02/announcing-servo.html

But I couldn't find the @monitorid annotation. Can you please provide me
the details of the library which has it ?
Also, after removing @monitorid tag, I tried to register my Server class
with JMX Server in the way mentioned in the example, but got a compilation
error.

Server s1 = new Server("s1");
DefaultMonitorRegistry.getInstance().registerObject(s1);

There is no such method like registerObject(s1) in DefaultMonitorRegistry
class. Can you please provide me some info on that too ?

Actually, I am getting the following object tree in JConsole after using
@monitor https://github.com/Monitor annotations :

See IncorrectFormat.jpg attached.

While I want it to be looked like ( See attached CorrectFormat.jpg). Below
is my java class [image: 👍]

public class Server {

@Monitor(name="Status", type=DataSourceType.INFORMATIONAL)
private final AtomicReference<String> status = new AtomicReference<String>("UP");

@Monitor(name="CurrentConnections", type=DataSourceType.GAUGE)
private final AtomicInteger currentConnections = new AtomicInteger(0);

@Monitor(name="TotalConnections", type=DataSourceType.COUNTER)
private final AtomicInteger totalConnections = new AtomicInteger(0);

@Monitor(name="BytesIn", type=DataSourceType.COUNTER)
private final AtomicLong bytesIn = new AtomicLong(0L);

@Monitor(name="BytesOut", type=DataSourceType.COUNTER)
private final AtomicLong bytesOut = new AtomicLong(0L);

}

Can you please guide me how can I get the desired output in JConsole or
VisualVM ?


Reply to this email directly or view it on GitHubhttps://github.com//issues/155#issuecomment-17735738
.

@danfin
Copy link

danfin commented May 23, 2013

What strikes me as odd is that the servo home page wiki, https://github.com/Netflix/servo/wiki, has an image, as referenced above by Ajay, which shows a nice jconsole screen display. Perhaps feature might have been removed when the project was being released to open source? As a small shop, we frequently use jconsole -- without this method of displaying all the keys and values together on one page, it would mean clicking endlessly to go from value to value. :(

@robertjchristian
Copy link

I believe you are referring to visualvm, a product that ships with the java
jdk (http://visualvm.java.net/), and is not part of netflix?

On Wed, May 22, 2013 at 5:19 PM, danfin notifications@github.com wrote:

What strikes me as odd is that the servo home page wiki,
https://github.com/Netflix/servo/wiki, has an image, as referenced above
by Ajay, which shows a nice jconsole screen display. Perhaps feature might
have been removed when the project was being released to open source? As a
small shop, we frequently use jconsole -- without this method of displaying
all the keys and values together on one page, it would mean clicking
endlessly to go from value to value. :(


Reply to this email directly or view it on GitHubhttps://github.com//issues/155#issuecomment-18316505
.

@brharrington
Copy link
Contributor

There are a number of areas where we need to update and improve the documention, that image is one of them. The change that you are seeing has to do with the increased use of tags for describing the metrics. Internally we increasingly use tags on the metrics so we can slice and dice on arbitrary dimensions and these get reported to an internal monitoring system that handles it well. We usually look at graphs aggregated across clusters and only drill down to individual machines as needed so the local JMX view isn't really used much.

The problem with tags has been that not all backends support them. JMX does support them in the sense that the object name can take an arbitrary set of properties and if you query using the object name wildcards you can slice and dice the metrics to get better views. However, most JMX clients don't support this very well.

My proposal, would be to introduce an option for allowing a you to customize the way the MonitorConfig gets mapped to an ObjectName. We can provide an implementation that uses the current approach and another that attempts to make the names work with most JMX viewers, though we'll have to either exclude or fold tags into a big string or use composite data support which is also painful to view unless only simple known tags are used. Thoughts?

@brharrington
Copy link
Contributor

To make this a bit more concrete, if you consider built in garbage collector data in jmx, visual vm forces you to look at old and young gen separately, for example:

visualvm screentshot

With the simple servlet view I typically use for JMX I can get the same view for an individual "mbean":

servlet jmx

But simply by tweaking the object name wildcard I can view information for both the young and old gen collector together:

screen shot 2013-05-22 at 7 35 23 pm

With the way we model the mbeans right now you can do powerful queries using the object name wildcards to control how the data is viewed. It also allows us to keep the value type as simple, even with arbitrary tag lists, rather than the "CompositeDataSupport" type like you see with the LastGcInfo attribute of the garbage collector stats.

In my opinion the best option is for JMX viewers to become less rigid and allow users to take advantage of the query support in JMX. However, right now for servo I think the right approach is to provide some user control over how the mapping to JMX ObjectName takes place. So you can make the choice map it in such a way it is more convenient for tools like jconsole of visualvm.

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

Successfully merging a pull request may close this issue.

5 participants