Programmatic setup for Java agent not reading server URL setting

I am setting up APM for a Springboot Java application on maven. The APM server is running on ECE. I followed the guide on the Elastic documentation:
Programmatic API setup
Configuration

I put the APM settings inside src/main/resources/elasticapm.properties

elastic.apm.service_name=my_app
elastic.apm.server_url=https://27e366e292694865adf03548593877db.apm.ece-playground.dev.org:9243
elastic.apm.application_packages=org.dev.prototype
elastic.apm.secret_token=Token123

When the application starts up, I noticed that the agent is trying to connect to the default localhost:8200 instead of the actual APM server.

WARN co.elastic.apm.agent.report.ApmServerHealthChecker - Elastic APM Server http://localhost:8200/ is not available (Connection refused: connect)

I also tried putting all the APM settings in the default Springboot application.properties but the outcome is still the same.

Is there any missing step in the above?

Kibana version: 8.2,3

Elasticsearch version: 8.2.3

APM Server version: 8.2.3

APM Agent language and version: Java, 1.34.0

Browser version: Chrome 107.0.5304.89

Fresh install or upgraded from other version? Fresh setup

If you look at your agent log, you would see that during startup it prints at INFO level the configuration options that it found in your setup (value and source). That would help you verify that what you configured is actually being picked up.
In this case, it seems that you used the wrong config option names- as you can see in the docs (for example, the server_url one), when setting through a property file, you don't need the elastic.apm prefix, only the actual config option name (for example: server_url). This prefix is required if you configure through system properties.

1 Like

Thank you. I have removed the elastic.apm prefix and the app is able to read the values correctly.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.