javaspring-bootapmobservability

How to configure apm-agent properties on yaml file?


I'm trying to configure the apm-agent properties on a yaml file for a spring-boot applicaiton but I'm getting the following error:

Error trying to connect to APM Server at http://127.0.0.1:8200

The application is trying to connect to the default ip and port.

2024-11-24 12:00:07,298 [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 12:00:07,300 [elastic-apm-server-reporter] ERROR co.elastic.apm.agent.report.IntakeV2ReportingEventHandler - 
Failed to handle event of type TRANSACTION with this error: Connection refused

I've configured the properties on yaml file:

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

pom.xml

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

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


Solution

  • I solved using environment variable on docker-compose:

    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