# Elastic-apm-agent.jar on PCF

**URL:** <https://discuss.elastic.co/t/elastic-apm-agent-jar-on-pcf/166137>\
**Category:** APM\
**Created:** [January 29, 2019, 10:09am UTC](https://discuss.elastic.co/t/elastic-apm-agent-jar-on-pcf/166137 "2019-01-29T10:09:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Datta\_Diware](https://avatars.discourse-cdn.com/v4/letter/d/46a35a/32.png) [@Datta\_Diware](https://discuss.elastic.co/u/Datta_Diware)\
**Post date:** [January 29, 2019, 10:09am UTC](https://discuss.elastic.co/t/elastic-apm-agent-jar-on-pcf/166137/1 "2019-01-29T10:09:12Z")

</div>

How to add elastic-apm-agent.jar on PCF environment ?

---

<div class="post-metadata">

**Author:** ![felixbarny](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felixbarny/32/27341_2.png) [@felixbarny](https://discuss.elastic.co/u/felixbarny)\
**Post date:** [February 1, 2019, 10:01am UTC](https://discuss.elastic.co/t/elastic-apm-agent-jar-on-pcf/166137/2 "2019-02-01T10:01:16Z")

</div>

Hi and sorry for the late answer. You can try out an upcoming experimental installation method: [https://www.elastic.co/guide/en/apm/agent/java/master/setup-attach-api.html](https://www.elastic.co/guide/en/apm/agent/java/master/setup-attach-api.html). You'll have to use version `1.3.1-SNAPSHOT` add add the sonatype snapshot repository:

```auto
    <repositories>
       <repository>
         <id>snapshots-repo</id>
         <url>https://oss.sonatype.org/content/repositories/snapshots</url>
         <releases><enabled>false</enabled></releases>
         <snapshots><enabled>true</enabled></snapshots>
       </repository>
     </repositories>

```

I'm not sure it it actually works on pivotal cloud foundry but it's worth a try 🙂

I hope that helps.

Cheers,  
Felix

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [February 12, 2019, 10:56pm UTC](https://discuss.elastic.co/t/elastic-apm-agent-jar-on-pcf/166137/3 "2019-02-12T22:56:03Z")

</div>

Hi,

Thanks for using the Java Agent and deploying on PCF.

You can insert the java APM agent into your deployable jar and then configure in the manifest.

Here is an example using the spring-petclinic project.

```
git clone https://github.com/spring-projects/spring-petclinic.git

cd spring-petclinic/

./mvnw package -Dmaven.test.skip=true

```

Now this is a little brute force but demonstrates the principle. You insert the `elastic-apm-agent-1.3.0.jar` into the app deployable jar.

```
curl -O https://search.maven.org/remotecontent?filepath=co/elastic/apm/elastic-apm-agent/1.3.0/elastic-apm-agent-1.3.0.jar

jar -uf target/spring-petclinic-2.1.0.BUILD-SNAPSHOT.jar elastic-apm-agent-1.3.0.jar

```

Check to make sure the agent made it into the jar

```
jar -tvf target/spring-petclinic-2.1.0.BUILD-SNAPSHOT.jar | grep apm

```

Create a manifest file `spring-petclinic-monolith-manifest-apm.yml`.

The `apm-server` server must be resolvable outside Cloud Foundry or use an IP address. In this case I also turned on the `trace_methods` capability, this will show all the methods in the `petclinic` package. This can create some overhead but I am just showing so you can see the level of detail if needed.

```
---
applications:
- name: spring-petclinic-monolith
  memory: 1G
  path: ./target/spring-petclinic-2.1.0.BUILD-SNAPSHOT.jar
  env:
    JAVA_OPTS: -javaagent:./elastic-apm-agent-1.3.0.jar -Delastic.apm.server_urls=https://apm.yourapmserver.net:8200 -Delastic.apm.service_name="spring-petclinic-monolith" -Delastic.apm.application_packages="org.springframework.samples" -Delastic.apm.trace_methods="org.springframework.samples.petclinic.*#*"

```

Then deploy the app

`cf push spring-petclinic-monolith -f spring-petclinic-monolith-manifest-apm.yml`

Now navigate to the application and click around and you should see the transaction begin to show up in in the APM Dashboard / App. Make sure your time frame is set etc.

Cheers,  
Stephen

---

<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:** [March 5, 2019, 6:56pm UTC](https://discuss.elastic.co/t/elastic-apm-agent-jar-on-pcf/166137/4 "2019-03-05T18:56:23Z")

</div>

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