-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Comments
The recommended way to use the jmx exporter is as a java agent, which avoids this. |
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. |
In such a scenario, how do you plan on handling the application restarting? |
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. |
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. |
Managing thousands of JVMs has to be slightly complicated ;-) |
Have you considered not using JMX ;) |
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). |
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. |
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. |
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.
The text was updated successfully, but these errors were encountered: