Intranet solution Java agent send metric to cloud apm server via proxy server

Hello,

Is it possible to configure the java agent to send the metrics through a proxy server?

My service is deployed in an intranet server, it connect to apm server (deployed in cloud) though a proxy server.

ELK version: 7.2.0
Java Agent: 1.7.0

After I read the documentation I am not able find any settings related to proxy server.

elasticapm.properties
proxy_server?
proxy_port?

Hi,

there are no dedicated APM agent settings for using a proxy but as the agent is using HttpUrlConnection, you can just use the Java system properties http.proxyHost and http.proxyPort.

See also https://docs.oracle.com/javase/8/docs/technotes/guides/net/proxies.html for more information.

However, that sets the proxy JVM-wide. Is that what you want?

Cheers,
Felix

You mean a reverse proxy like HAProxy?

That's how my set up is, and is necessary if you want to load balance multiple APM Servers. But even a single backend to the proxy works as I have that simplke config for quick testing

APM Agent --> HAProxy --> APM Server --> Elasticsearch

I think the kind of proxy @Wayne_Shen is talking about is one which proxies requests from a DMZ to the outside world and used to restrict access to the internet.

Note that you can configure multiple URLs in server_urls which allows load balancing without a dedicated load balancer like HAProxy (aka client-side load balancing)

2 Likes

Thanks for you reply. @felixbarny

I have tried your solution, it works perfectly.

Thanks for sharing.

Actually my solution is behind corporate proxy, the proxy is used to sent traffic from Java agent to apm server.

@felixbarny's answer solved my problem.

1 Like

Thanks for the clarification @felixbarny

(Without intending to hijack this thread) Just a note on why we we used a client-side proxy: it was easier for us to abstract the resultant APM Servers this way. As the server_urls config is not dynamically reloaded, by putting the APM Servers behind HAProxy or BigIP, we can easily scale the APM Servers as well as move the target APM Servers whenever we want without having to reload the instrumented services. I could not find any other way to do this in such a scenario. We're definitely open to suggestions :slight_smile:

Thanks!

1 Like

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