# Setting APM for elasticsearch 7.17.4

**URL:** <https://discuss.elastic.co/t/setting-apm-for-elasticsearch-7-17-4/320644>\
**Category:** APM\
**Tags:** java, server\
**Created:** [December 7, 2022, 6:13am UTC](https://discuss.elastic.co/t/setting-apm-for-elasticsearch-7-17-4/320644 "2022-12-07T06:13:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Atul\_Chadha](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/atul_chadha/32/75469_2.png) [@Atul\_Chadha](https://discuss.elastic.co/u/Atul_Chadha)\
**Post date:** [December 7, 2022, 6:13am UTC](https://discuss.elastic.co/t/setting-apm-for-elasticsearch-7-17-4/320644/1 "2022-12-07T06:13:15Z")

</div>

I am trying to setup APM on elasticsearch 7.17.4 stack, i have successfully setup apm server and trying to use the [Automatic setup with `apm-agent-attach-cli.jar`](https://www.elastic.co/guide/en/apm/agent/java/current/setup-attach-cli.html) method with below flags  
`java -jar apm-agent-attach-cli-1.34.1.jar --include-all --include-vmarg elastic.apm.attach=true --continuous --config service_name=apm-test --config server_url=https://x.x.x.x:8200 --log-level debug --log-file /tmp/log`

I see the "OK" at the end of the command execution and logs suggesting the apm is attaching to JVM however i dont see any connections. I am missing something ?

---

<div class="post-metadata">

**Author:** ![Atul\_Chadha](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/atul_chadha/32/75469_2.png) [@Atul\_Chadha](https://discuss.elastic.co/u/Atul_Chadha)\
**Post date:** [December 8, 2022, 1:54am UTC](https://discuss.elastic.co/t/setting-apm-for-elasticsearch-7-17-4/320644/2 "2022-12-08T01:54:46Z")

</div>

Checking if anyone has any thoughts ?

---

<div class="post-metadata">

**Author:** ![Jonas\_Kunz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jonas_kunz/32/110740_2.png) [@Jonas\_Kunz](https://discuss.elastic.co/u/Jonas_Kunz)\
**Post date:** [December 8, 2022, 11:59am UTC](https://discuss.elastic.co/t/setting-apm-for-elasticsearch-7-17-4/320644/3 "2022-12-08T11:59:41Z")

</div>

Hi @Atul_Chadha ,

What do you mean with "I don't see any connections"?

On attachment the log of the JVM you want to attach to should contain log statements from our agent. Could you please verify that this is the case?

In addition please provide the logs from the `apm-agent-attach-cli` execution.

---

<div class="post-metadata">

**Author:** ![Atul\_Chadha](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/atul_chadha/32/75469_2.png) [@Atul\_Chadha](https://discuss.elastic.co/u/Atul_Chadha)\
**Post date:** [December 9, 2022, 2:08am UTC](https://discuss.elastic.co/t/setting-apm-for-elasticsearch-7-17-4/320644/4 "2022-12-09T02:08:00Z")

</div>

@Jonas_Kunz Thank you for the response, here is what i have done so far.  
Setup the APM server (Seems to be done correctly)

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/e/9/e9f26269272f075899c5b90808fcae1e725bab38.png)  
Downloaded the jar file and ran it using below command  
`java -jar apm-agent-attach-cli-1.35.0.jar --include-all --include-vmarg elastic.apm.attach=true --continuous --config service_name=apm-test --config server_url=http://XXXX:8200 --log-level trace --log-file /tmp/log`

Above results in the below log

```auto
{"@timestamp":"2022-12-09T02:00:52.240Z","log.level":"DEBUG","message":"attach process started with: user = 'root', current directory = /tmp", "ecs.version": "1.2.0","service.name":"java-attacher","event.dataset":"java-attacher.log","process.thread.name":"main","log.logger":"co.elastic.apm.attach.AgentAttacher"}
{"@timestamp":"2022-12-09T02:00:52.242Z","log.level":"DEBUG","message":"attacher arguments : Arguments{rules=DiscoveryRules{discoveryRules=[include(all), include(vmArgs(elastic.apm.attach=true))]}, config={service_name=apm-test, server_url=http://XXXX:8200}, argsProvider='null', help=false, list=false, continuous=true, logLevel=TRACE, logFile='/tmp/log', listVmArgs=false, agentJar=/tmp/elastic-apm-agent-4813494d137e1631bba301d5acab6e7b-27dac082444cc125d3c066c2b0742288.jar}", "ecs.version": "1.2.0","service.name":"java-attacher","event.dataset":"java-attacher.log","process.thread.name":"main","log.logger":"co.elastic.apm.attach.AgentAttacher"}
{"@timestamp":"2022-12-09T02:00:52.983Z","log.level":"DEBUG","message":"Looking in the following folders for hsperfdata_<user>/<pid> files: [/tmp/hsperfdata_root, /tmp/hsperfdata_spc]", "ecs.version": "1.2.0","service.name":"java-attacher","event.dataset":"java-attacher.log","process.thread.name":"main","log.logger":"co.elastic.apm.attach.JvmDiscoverer.ForHotSpotVm"}
{"@timestamp":"2022-12-09T02:00:56.975Z","log.level": "INFO","message":"Include rule include(all) matches for JVM 23153 org.elasticsearch.bootstrap.Elasticsearch", "ecs.version": "1.2.0","service.name":"java-attacher","event.dataset":"java-attacher.log","process.thread.name":"main","log.logger":"co.elastic.apm.attach.AgentAttacher"}
{"@timestamp":"2022-12-09T02:00:56.976Z","log.level": "INFO","message":"Attaching the Elastic APM agent to 23153 org.elasticsearch.bootstrap.Elasticsearch with arguments {service_name=apm-test, server_url=http://XXXX:8200}", "ecs.version": "1.2.0","service.name":"java-attacher","event.dataset":"java-attacher.log","process.thread.name":"main","log.logger":"co.elastic.apm.at

```

However i am not seeing any connection on the apm server when checked using netstat. I am sure the port is open, telnet works fine on port 8200.

This leads to failure of the agent check on UI

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/d/1/d11bda66029ba23ae3699708f043bea081b0de22.png)

Let me know if any other info can help debug this.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 6, 2023, 2:08am UTC](https://discuss.elastic.co/t/setting-apm-for-elasticsearch-7-17-4/320644/5 "2023-01-06T02:08:46Z")

</div>

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