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

Add option to connect with the Attach API #86

Closed
elecnix opened this issue Oct 20, 2016 · 10 comments
Closed

Add option to connect with the Attach API #86

elecnix opened this issue Oct 20, 2016 · 10 comments

Comments

@elecnix
Copy link
Contributor

elecnix commented Oct 20, 2016

com.sun.tools.attach.VirtualMachine.attach allows one to load an agent into a target JVM to expose a JMX port, knowing the PID of the JVM.

There should be an option to provide a PID instead of host & port.

@brian-brazil
Copy link
Contributor

The recommended way to use the jmx exporter is as a java agent, which avoids this.

@elecnix
Copy link
Contributor Author

elecnix commented Oct 20, 2016

Thanks for the suggestion. The java agent is indeed easier and more lightweight to deploy. However, some applications already expose interesting metrics through MBeans, but may not be listening on a port. It is a bit invasive to require a restart of such applications only to have Prometheus scrape them, when they are already providing a mechanism to be scraped, through the Attach API.

@brian-brazil
Copy link
Contributor

In such a scenario, how do you plan on handling the application restarting?

@elecnix
Copy link
Contributor Author

elecnix commented Oct 20, 2016

If the application restarts for some reason, and jmx_exporter was connected through the Attach API, jmx_exporter would exit if it notices that the PID no longer exists. An external agent would re-launch it once the PID is known.

@brian-brazil
Copy link
Contributor

That seems a bit on the complicated side to me, and you'd likely be better off accepting the one restart required for the java agent.

@elecnix
Copy link
Contributor Author

elecnix commented Oct 20, 2016

Managing thousands of JVMs has to be slightly complicated ;-)

@brian-brazil
Copy link
Contributor

Have you considered not using JMX ;)

@elecnix
Copy link
Contributor Author

elecnix commented Oct 20, 2016

To elaborate, in a large system that consists of small services, some of them written a decade ago, and actively used by people, some are not designed to be restarted without causing some amount of disruption. Deploying a monitoring agent that spawns a jmx_exporter child to monitor these JVMs is a reasonable use-case.

It would be a small addition to the project that other people could find useful for other reasons (perhaps just to try it out on a running JVM prior to deciding to go for an agent).

@elecnix
Copy link
Contributor Author

elecnix commented Oct 26, 2016

Instead of adding an external agent to restart jmx_exporter, I'm thinking of giving the path to a PID file to jmx_exporter, and watching changes to that file through the same mechanism as the configuration reload.

@brian-brazil
Copy link
Contributor

I'm not sure this feature is worth the complexity it'd add, considering the objection to one of the supported ways we already have for this is that it causes a single application restart.

I'm already not a big fan of the webserver way of doing things.

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