Can we create custom metrics using java melody

605 views
Skip to first unread message

Pathik Mehta

unread,
Jul 6, 2016, 8:42:03 AM7/6/16
to javamelody

I am already using Java Melody and it is giving me a good monitoring data.
I am thinking of creating some custom metrics using Java Melody. I want to add new counter in Java Melody which monitors my custom metrics same way as it is doing for all other metrics and counters.

Is there any way in Java Melody that i can pass the data to Java Melody and it starts monitoring of that custom counter and also starts displaying that counter details (Table like Statistics of sql) and graphs (Like % of sql error, sql hit rates per minute) in monitoring page.

Thanks,
Pathik

evernat

unread,
Jul 7, 2016, 6:04:15 AM7/7/16
to javamelody
Hi Pathik,

If I understand your question well and if what you want to monitor is execution of methods, then yes.

For that, if you have Spring, EJB or Guice see the user's guide. For example, for Spring:
https://github.com/javamelody/javamelody/wiki/UserGuide#9-business-facades-if-spring

Or without Spring, EJB or Guice, see:
https://github.com/javamelody/javamelody/wiki/UserGuideAdvanced#business-facades-without-ejb3-and-without-spring-and-without-guice

You may need to create an interface to be able to monitor execution of methods.
For example,
public interface MyInterface {
   void myMethod();
}

MyInterface service = new MyInterface() {
   public void myMethod() {
      myObject.myMethodToMonitor();
   }
};

and without Spring/EJB/Guice:
   service = net.bull.javamelody.MonitoringProxy.createProxy(service, "MyObject.
myMethodToMonitor");

then you can execute the method being monitored:
  service.myMethod();

bye,
Emeric



Pathik Mehta

unread,
Jul 8, 2016, 2:54:45 AM7/8/16
to javamelody
Hi Emeric,

Thanks for the reply.

I don't want to monitor the execution of methods.
I wanted something like a custom counter similar to sql counter and http counter which will monitor the data i provides and It prepares the table presentation similar to the Statistics of Sql and statics of Http on monitoring page.
And also it produce that 3 global graphs of that counter similar to these graphs for http counter : 
1) % of http error (% of myCounter error)
2) http hits per minute (myCounter hits per minute)
3) http mean times (myCounter mean times)

Thanks,
Pathik

Reply all
Reply to author
Forward
0 new messages