Hi Max,
There is currently no official api to do that, but I think that it would be good to have one, for the aws use case for example.
For guidance:
As you can see in the collector servlet, the collector server currently expects a http post request with parameters "appName" and "appUrls":
https://github.com/javamelody/javamelody/blob/master/javamelody-core/src/main/java/net/bull/javamelody/CollectorServlet.java#L108appName should contain a name of the app, for example "HelloWorld".
And appUrls should contain the url(s) of webapp(s) monitored by javamelody, for example "
http://server1/helloworld" or "
http://server1/helloworld,http://server2/helloworld" (note the comma for 2 urls).
The response contains a OK message if success.
To remove an application, the collector server expects a http get request with parameters like this "?application=HelloWorld&action=remove_application".
So javamelody-core in the monitored webapp can notify the collector servers that it wants to be monitored, based on some javamelody configuration giving the collector server url.
It should probably be somewhere in the FilterContext class during initialization and shutdown:
https://github.com/javamelody/javamelody/blob/master/javamelody-core/src/main/java/net/bull/javamelody/FilterContext.java#L60(Note: I suppose that we don't want to send an UDP broadcast to notify the collector server.)
bye,
Emeric