# Elastic APM service discovery not working with public API

**URL:** <https://discuss.elastic.co/t/elastic-apm-service-discovery-not-working-with-public-api/305448>\
**Category:** APM\
**Tags:** java\
**Created:** [May 24, 2022, 5:08am UTC](https://discuss.elastic.co/t/elastic-apm-service-discovery-not-working-with-public-api/305448 "2022-05-24T05:08:10Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![avinashupadhyaya](https://avatars.discourse-cdn.com/v4/letter/a/e47774/32.png) [@avinashupadhyaya](https://discuss.elastic.co/u/avinashupadhyaya)\
**Post date:** [May 24, 2022, 5:08am UTC](https://discuss.elastic.co/t/elastic-apm-service-discovery-not-working-with-public-api/305448/1 "2022-05-24T05:08:10Z")

</div>

If you are asking about a problem you are experiencing, please use the following template, as it will help us help you. If you have a different problem, please delete all of this text 🙂

TIP 1: select at least one tag that further categorizes your topic. For example `server` for APM Server related questions, `java` for questions regarding the Elastic APM Java agent, or `ui` for questions about the APM App within Kibana.

TIP 2: Check out the [troubleshooting guide](https://www.elastic.co/guide/en/apm/get-started/current/troubleshooting.html) first. Not only will it help you to resolve common problems faster but it also explains in more detail which information we need before we can properly help you.

**Kibana version** : v8.2.0 (Elastic Cloud)

**Elasticsearch version** :

**APM Server version** : v8.2.0 (Elastic Cloud)

**APM Agent language and version** : Java 1.31.0

**Browser version** :

**Original install method (e.g. download page, yum, deb, from source, etc.) and version**: Elastic Cloud

**Fresh install or upgraded from other versions?** : Fresh

**Is there anything special in your setup?** No, services communicate through Public APIs

**Description of the problem including expected versus actual behavior. Please include screenshots (if relevant)**:

The inter service communication between services in a microservice based application is not accurate for the services communicating with each other through public APIs. Elastic APM considers the public endpoints as a different service and does not actually connect with the service that is instrumented with Elastic APM. The services are hosted on the same cluster of Azure Spring Cloud and all services use Java Spring with the same elastic agent version.

The actual flow of transaction -

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/9/c/9c78e9d4c92576a600486abc9fef0f628878378f.png)

Elastic APM Service Map-  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/5/d/5d486669e1a6a86332499d4af133f70bf8d2b061.png)

As you can see, there are no links to produce service but there are new services for the public endpoints called

**Steps to reproduce** :

1. Deploy a simple microservice based application that communicates with each other through publically exposed REST APIs.
2. Instrument one service with APM and perform a transaction that hits all services in the application.
3. Instrument the rest of the application for all services.
4. View the service map in the kibana dashboard and the service links are not accurate

**Errors in browser console (if relevant)**: N/A

**Provide logs and/or server output (if relevant)**:

---

<div class="post-metadata">

**Author:** ![nugusbayevkk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nugusbayevkk/32/126683_2.png) [@nugusbayevkk](https://discuss.elastic.co/u/nugusbayevkk)\
**Post date:** [May 24, 2022, 8:41am UTC](https://discuss.elastic.co/t/elastic-apm-service-discovery-not-working-with-public-api/305448/2 "2022-05-24T08:41:21Z")

</div>

Hi @avinashupadhyaya

Do you see any transactions in `produce-service`?  
What http client do you use to communicate between `Order Service` and `Produce service` services?

---

<div class="post-metadata">

**Author:** ![avinashupadhyaya](https://avatars.discourse-cdn.com/v4/letter/a/e47774/32.png) [@avinashupadhyaya](https://discuss.elastic.co/u/avinashupadhyaya)\
**Post date:** [May 24, 2022, 9:39am UTC](https://discuss.elastic.co/t/elastic-apm-service-discovery-not-working-with-public-api/305448/3 "2022-05-24T09:39:19Z")

</div>

Hi @nugusbayevkk  
There are no transactions in the produce service.  
I am using the rest template in Java for the HTTP calls. Code here - [order-service/ProduceService.java at f2dd2657a150fd60d39587587bf1f1146f90cf21 · avinashupadhya99/order-service · GitHub](https://github.com/avinashupadhya99/order-service/blob/f2dd2657a150fd60d39587587bf1f1146f90cf21/src/main/java/com/commission/order/service/ProduceService.java#L20)

---

<div class="post-metadata">

**Author:** ![nugusbayevkk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nugusbayevkk/32/126683_2.png) [@nugusbayevkk](https://discuss.elastic.co/u/nugusbayevkk)\
**Post date:** [May 24, 2022, 12:37pm UTC](https://discuss.elastic.co/t/elastic-apm-service-discovery-not-working-with-public-api/305448/4 "2022-05-24T12:37:26Z")

</div>

> [@avinashupadhyaya](#):
>
> Hi @nugusbayevkk  
> There are no transactions in the produce service.  
> I am using the rest template in Java for the HTTP calls. Code here - [order-service/ProduceService.java at f2dd2657a150fd60d39587587bf1f1146f90cf21 · avinashupadhya99/order-service · GitHub](https://github.com/avinashupadhya99/order-service/blob/f2dd2657a150fd60d39587587bf1f1146f90cf21/src/main/java/com/commission/order/service/ProduceService.java#L20)

I analyzed your services, all services are supported by agent.  
Can you provide information how do you run elastic-java-agent with your `Order-Service` and `Produce Service`?

---

<div class="post-metadata">

**Author:** ![avinashupadhyaya](https://avatars.discourse-cdn.com/v4/letter/a/e47774/32.png) [@avinashupadhyaya](https://discuss.elastic.co/u/avinashupadhyaya)\
**Post date:** [May 24, 2022, 12:58pm UTC](https://discuss.elastic.co/t/elastic-apm-service-discovery-not-working-with-public-api/305448/5 "2022-05-24T12:58:59Z")

</div>

Thank you for validating the services. The services are instrumented using the `-javaagent` flag while deploying the services to Azure Spring Cloud. I have followed [How to monitor Spring Boot apps with Elastic APM Java Agent | Microsoft Docs](https://docs.microsoft.com/en-us/azure/spring-cloud/how-to-elastic-apm-java-agent-monitor)

---

<div class="post-metadata">

**Author:** ![nugusbayevkk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nugusbayevkk/32/126683_2.png) [@nugusbayevkk](https://discuss.elastic.co/u/nugusbayevkk)\
**Post date:** [May 24, 2022, 1:10pm UTC](https://discuss.elastic.co/t/elastic-apm-service-discovery-not-working-with-public-api/305448/6 "2022-05-24T13:10:02Z")

</div>

@avinashupadhyaya

If possible, set `log_level=debug` ([Logging configuration options | APM Java Agent Reference [master] | Elastic](https://www.elastic.co/guide/en/apm/agent/java/master/config-logging.html#config-log-level)) in `Produce Service` and share the entire log from startup through [https://gist.github.com/](https://gist.github.com/).

In addition can you provide detailed information how do you deploy your applications on azure for `Produce Service` and `Order Service`?

```auto
az spring app deploy \
    --name <your-app-name> \
    --artifact-path <unique-path-to-your-app-jar-on-custom-storage> \
    --jvm-options='-javaagent:<agent-location>' \
    --env ELASTIC_APM_SERVICE_NAME=<your-app-name> \
          ELASTIC_APM_APPLICATION_PACKAGES='<your-app-package-name>' \
          ELASTIC_APM_SERVER_URL='<your-Elastic-APM-server-URL>' \
          ELASTIC_APM_SECRET_TOKEN='hide value'

```

---

<div class="post-metadata">

**Author:** ![avinashupadhyaya](https://avatars.discourse-cdn.com/v4/letter/a/e47774/32.png) [@avinashupadhyaya](https://discuss.elastic.co/u/avinashupadhyaya)\
**Post date:** [May 29, 2022, 9:02am UTC](https://discuss.elastic.co/t/elastic-apm-service-discovery-not-working-with-public-api/305448/7 "2022-05-29T09:02:02Z")

</div>

I have documented the deployment steps on [azure-spring-cloud-apm.md · GitHub](https://gist.github.com/avinashupadhya99/37ba40a9641efe96343583d40327d4c1)

When I turn on the debug logs, the following were captured for produce-service - [elastic-apm-debug-logs.log · GitHub](https://gist.github.com/avinashupadhya99/4bbd8c25a80c611e4558cd87ce490d4f)

---

<div class="post-metadata">

**Author:** ![nugusbayevkk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nugusbayevkk/32/126683_2.png) [@nugusbayevkk](https://discuss.elastic.co/u/nugusbayevkk)\
**Post date:** [June 6, 2022, 11:00am UTC](https://discuss.elastic.co/t/elastic-apm-service-discovery-not-working-with-public-api/305448/8 "2022-06-06T11:00:34Z")

</div>

Hi @avinashupadhyaya ,  
can you provide debug logs from application startup?

---

<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:** [June 27, 2022, 7:01am UTC](https://discuss.elastic.co/t/elastic-apm-service-discovery-not-working-with-public-api/305448/9 "2022-06-27T07:01:08Z")

</div>

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