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

The dynamic configuration items of Java apm agent cannot take effect dynamically #3923

Open
arTG0D opened this issue Dec 24, 2024 · 5 comments
Labels
agent-java community Issues and PRs created by the community

Comments

@arTG0D
Copy link

arTG0D commented Dec 24, 2024

We kindly ask to post all questions and issues on the Discuss forum first. In addition to awesome, knowledgeable community contributors, core APM developers are on the forums every single day to help you out as well, so your questions will reach a wider audience there.

Version

Elastic Stack 8.13.3
Java apm agent : apm-agent-attach-cli-1.52.0.jar

BUG

I noticed in the official documentation that server_url, server_urls, and log_level are dynamic, when I comment out the server_url, when I enable server_urls, it doesn't take effect, the apm data is still sent to the old apm-server, and when I use log_level=DEBUG to view the logs, it doesn't take effect.
Until then, APM is working fine

Config

recording=true
service_name=xxxxx
environment=prod
#server_url=http://xxxxxx:8200
server_urls=http://xxxxxx:8200,http://xxxxxx:8200
service_node_name=xxxxx
log_level=INFO
log_file=/opt/apm/apm-agent.log
log_ecs_reformatting=SHADE
log_ecs_reformatting_dir=/opt/apm
capture_body=off
agent_reporter_health_metrics=true
agent_background_overhead_metrics=true
transaction_max_spans=500
circuit_breaker_enabled=true

Image

@github-actions github-actions bot added agent-java community Issues and PRs created by the community triage labels Dec 24, 2024
@jackshirazi
Copy link
Contributor

It's not clear what you are doing because you listed the attach-cli as your agent. If you are using the attach cli to attach the agent with one config, then using a different config and using the attach-cli again against the same JVM, that won't work. If you look at the output from the attach-cli, only the first attach works, the subsequent attaches don't, because you can only attach the agent once.

The dynamic capability works for the options that the agent can see, so you would need to change those in something it has visibility on. for example with using the attach-cli it would still see central config

@arTG0D
Copy link
Author

arTG0D commented Dec 24, 2024

It's not clear what you are doing because you listed the attach-cli as your agent. If you are using the attach cli to attach the agent with one config, then using a different config and using the attach-cli again against the same JVM, that won't work. If you look at the output from the attach-cli, only the first attach works, the subsequent attaches don't, because you can only attach the agent once.

The dynamic capability works for the options that the agent can see, so you would need to change those in something it has visibility on. for example with using the attach-cli it would still see central config

I started a spring application on a virtual machine using java-jar and attached it to the spring application using attach-cli for monitoring. When I changed the server_url in the apm.properties file, it did not take effect dynamically. I tried setting recording=false again, but it still didn't take effect dynamically.

@jackshirazi
Copy link
Contributor

So the config file /opt/apm/elasticapm.properties is on the host/VM/container that the target JVM is running on, and that's the file that you changed properties in?

@arTG0D
Copy link
Author

arTG0D commented Dec 24, 2024

So the config file /opt/apm/elasticapm.properties is on the host/VM/container that the target JVM is running on, and that's the file that you changed properties in?

Yes. I'm sorry that I didn't describe it clearly before.

@jackshirazi
Copy link
Contributor

log_level is changed dynamically all the time with our agents, so this suggests to me this is a configuration error somewhere. My suggestion is to start with log_level=DEBUG in the properties so you can then look at the agent log output and confirm it is using the config file you expect, and seeing the values you set. You should also see it attempting to reload the config every 30 seconds, eg

2024-12-24 11:41:53,664 [elastic-apm-configuration-reloader] DEBUG co.elastic.apm.agent.impl.ElasticApmTracerBuilder - Beginning scheduled configuration reload (interval is 30 sec)...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agent-java community Issues and PRs created by the community
Projects
None yet
Development

No branches or pull requests

2 participants