# How to configure apm-agent properties on yaml file for a spring-boot application?

**URL:** <https://discuss.elastic.co/t/how-to-configure-apm-agent-properties-on-yaml-file-for-a-spring-boot-application/370995>\
**Category:** APM\
**Tags:** java\
**Created:** [November 24, 2024, 2:34pm UTC](https://discuss.elastic.co/t/how-to-configure-apm-agent-properties-on-yaml-file-for-a-spring-boot-application/370995 "2024-11-24T14:34:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aldosilva6](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aldosilva6/32/68843_2.png) [@aldosilva6](https://discuss.elastic.co/u/aldosilva6)\
**Post date:** [November 24, 2024, 2:34pm UTC](https://discuss.elastic.co/t/how-to-configure-apm-agent-properties-on-yaml-file-for-a-spring-boot-application/370995/1 "2024-11-24T14:34:26Z")

</div>

Is it possible to configure the apm properties on a yaml file? I'm trying to configure on a spring-boot application but I think it is getting the default configuration :(.

SpringBootApplication.java

```auto
public static void main(String[] args) {
	ElasticApmAttacher.attach();
	SpringApplication.run(CpoEventsKafkaApplication.class, args);
}

```

pom.xml

```auto
<dependency>
    <groupId>co.elastic.apm</groupId>
    <artifactId>apm-agent-attach</artifactId>
    <version>1.50.0</version>
</dependency>

```

application.yml

```auto
elastic:
  apm:
    enabled: true
    application_packages: com.####.cpoeventskafka
    capture_body: true
    server_url: http://10.###.##.5:8200
    environment: dev
    service_name: cpo-event

```

Spring-boot log showing trying to connect to ip 127.0.0.1 no 10.###.##.5

```auto
10:41:44.654 [http-nio-7056-exec-1] INFO o.s.web.servlet.DispatcherServlet - Completed initialization in 2 ms
2024-11-24 10:41:44,744 [elastic-apm-server-reporter] ERROR co.elastic.apm.agent.report.AbstractIntakeApiHandler - Error trying to connect to APM Server at http://127.0.0.1:8200/intake/v2/events. Although not necessarily related to SSL, some related SSL configurations corresponding the current connection are logged at INFO level.
2024-11-24 10:41:44,746 [elastic-apm-server-reporter] ERROR co.elastic.apm.agent.report.IntakeV2ReportingEventHandler - Failed to handle event of type TRANSACTION with this error: Connection refused

```

I didn't find in any documentation using a yaml file.

Kibana: 7.17.24  
Elasticsearch: 7.17.24  
APM: 7.17.0  
Spring-boot: 2.4.2

---

<div class="post-metadata">

**Author:** ![Jack\_Shirazi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jack_shirazi/32/91641_2.png) [@Jack\_Shirazi](https://discuss.elastic.co/u/Jack_Shirazi)\
**Post date:** [November 26, 2024, 2:08pm UTC](https://discuss.elastic.co/t/how-to-configure-apm-agent-properties-on-yaml-file-for-a-spring-boot-application/370995/2 "2024-11-26T14:08:42Z")

</div>

[ElasticApmAttacher](https://github.com/elastic/apm-agent-java/blob/main/apm-agent-attach/src/main/java/co/elastic/apm/attach/ElasticApmAttacher.java) has several `attach` methods that may be what you want. yaml is not supported but a simple properties file or directly setting properties are both supported

---

<div class="post-metadata">

**Author:** ![aldosilva6](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aldosilva6/32/68843_2.png) [@aldosilva6](https://discuss.elastic.co/u/aldosilva6)\
**Post date:** [November 28, 2024, 1:24pm UTC](https://discuss.elastic.co/t/how-to-configure-apm-agent-properties-on-yaml-file-for-a-spring-boot-application/370995/3 "2024-11-28T13:24:05Z")

</div>

I solved using environment variable on docker-compose:

```auto
cpo-event:
    container_name: cpo-event
    image: lserillo/cpo-event:$IMAGE_VERSION_CPO_EVENT
    ports:
      - 7056:7056
    volumes:
      - /etc/timezone:/etc/timezone:ro
      - ......
    environment:
      - ELASTIC_APM_SERVICE_NAME=cpo-event
      - ELASTIC_APM_SERVER_URL=http://10.###.##.5:8200
      - ELASTIC_APM_ENVIRONMENT=dev
    networks:
      - cup-network

```
