Elastic APM cloud allowing request from a dev env localhost

I'm using elastic cloud.
I am requesting assistance enabling Cross-Origin Resource Sharing (CORS) for http://localhost:8080 on our APM server.
how can I configure the APM server to allow requests from a test localhost instance?

We are currently developing and testing applications locally, and our frontend running on http://localhost:8080 needs to send data to the APM server. However, we are encountering CORS-related issues, as the APM server does not currently allow requests from this origin.

apm-server:
  cors:
    enabled: true
    allow_origins: ['http://localhost:8080']
    allow_headers: ['Authorization', 'Content-Type', 'Content-Encoding']

Here are the relevant details:

  • APM Server URL: https://pamp-dc8943.kb.us-east-1.aws.elastic.cloud
  • Origin to Allow: http://localhost:8080

Kind regards

Hi @Andre_Pereira1 Welcome to the community!

what is the "de server"?

Apologies it is not clear what you are trying to accomplish.

What version are you on?

What architecture are you trying to support?

Are you trying to have a local APM server connect to Elastic Cloud?

What can not connect another APM server or an APM Language Agent?

Hi @stephenb ,
Thank you for your feedback, I’ve reformulated the question to explain the issue better. Please let me know if it’s clear or if you need any additional details.

Regards,

To allow requests from a localhost dev environment in Elastic APM Cloud, configure the server_url to point to your APM server and ensure CORS is enabled for localhost in the APM settings.

Thank you for your response. However, I am using Elastic Cloud, and I cannot find the option to configure CORS settings for the APM server. It seems that Elastic Cloud does not provide direct access to the apm-server.yml file or a UI to modify advanced configurations like CORS.

Could you please advise on how to enable CORS for http://localhost:8080 in an Elastic Cloud environment? Is there an alternative approach or workaround to allow requests from a localhost development environment?

Here are the details of my setup:

  • APM Server URL: https://pamp-dc8943.kb.us-east-1.aws.elastic.cloud
  • Origin to Allow: http://localhost:8080

Kind regards,

Hi @Andre_Pereira1

I would like to help .. and I can... but I need your help.

Exactly what version of Elastic Cloud are you on?

And what APM Schema are you on?

Kibana -> APM -> Settings > Schema

I need these two answers

Next

That is not the APM URL .. that is the Kibana URL

The APM URL would be

https://pamp-dc8943.apm.us-east-1.aws.elastic.cloud

Note the apm vs kb perhaps you Are trying to send davida to the wrong endpoint.

I suspect your issues is that you have the RUM agent pointing to Kibana not the APM Endpoint

Per the docs

A list of permitted origins can be supplied to the apm-server.rum.allow_origins configuration option. By default, APM Server allows all origins.

FInally if you are using the new Elastic Integration

Go to
Fleet -> Agent Policies -> Elastic Cloud Agent => Edit Elastic APM

And you will see the cors setting which is already set to all origins
I suspect your issues is that you have the RUM agent pointing to Kibana not the APM Endpoint