-
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
Expose service port as a system property, mainly to support use-case where configured port is zero and picked by OS #686
Conversation
…r the actual port used, in case the configured port is 0 expose configured port number and actual port number as system properties Signed-off-by: Yann ROBERT <[email protected]>
d21a149
to
04db0fc
Compare
Most systems that access the jmx_exporter HTTP endpoint require a known declarative port for configuration. In an ideal deployment / operating environment, CI/CD would be used using declarative configuration for deployment. I don't see an issue with the code, but don't see any benefits. |
Hello Doug, thank you for your reply. Let me tell you more about one possible use-case : Imagine a system composed of many microservices. Maybe also, you do not want to be limited by deployed configuration, and be able to start many more instances than it was predicted (scale up the number of instances, on the same machine). Sure you could maintain a configuration for each environment, That will put a different port number for each instance of a JVM. Now imagine you use So now, clients (like Since service discovery is used in order to find It's would be only required because you cannot find the port number used by Now when Now it's not only possible to address robustness issues, but it's also easy. And almost zero configuration or devops work is needed. Sure there may be a few downsides in using port Finally, since |
@YannRobert Thanks for the detailed explanation.
I feel if we are going to provide insight to the Edit: Not sure I see any value providing the configured port. (Not a maintainer... just my opinions.) |
I'm sorry, I cannot see a link between this PR and authentication.
That is a very good point. The immediate minimal need is to be able to get the port number actually used to bind the HTTP server (including when zero is configured as the port number). Other information are part of the configuration. So we may consider the information is available with minimal effort. But since you ask, I would probably like to have easy access to all java agent parameters as System properties :
So as you can see, there won't ever be a lot of properties to expose.
I proposed a namespace in this PR's code. This can be changed to anything else if contributors/maintainers can think of a better property name.
I am not using it myself, still I find it useful to emphasize the fact that actual port can differ from configured port. I understand this PR may trigger discussion about what else to expose and how. @fstab @tomwilkie Any thoughts ? |
Hello @fstab Could this PR or any alternative solution be considered to be merged ? Many thanks |
@YannRobert If a Options
I feel that we can't allow A and B could lead to frustration for those wanting the functionality. DevOps work will be required to install the core application using the agent, so adding additional configuration as part of that work makes the most sense to me. Additionally, System/Application administrators commonly test the agent HTTP endpoint. If the port is allocated dynamically, there is no easy way for them to know the port in use. (lack of consistency) |
Expose service port as a system property, mainly to support use-case where configured port is zero and picked by OS
When adding jmx_exporter java agent, you typically provide a port number as configuration.
However, you may want to rely on the operating system to pick a port number at startup time, so that you don't need to bother with assigning a different port number for the many JVMs that may be running on the same machine.
In that case, it become very difficult to discover which port what used for this particular process. (you may need to rely on various command lines to get the port for a process, still when the process opens multiple other ports this is becoming quite impossible to do, and platform dependantt)
Exposing the actual port as a system property is an handy solution.
In this case, it become easy to get the value of the system property, from any other code running inside the JVM.
This other (application) code could then advertise this information into any discovery service.