# Can we have different apm service name for subset of microservices

**URL:** <https://discuss.elastic.co/t/can-we-have-different-apm-service-name-for-subset-of-microservices/261095>\
**Category:** APM\
**Tags:** python\
**Created:** [January 14, 2021, 8:51am UTC](https://discuss.elastic.co/t/can-we-have-different-apm-service-name-for-subset-of-microservices/261095 "2021-01-14T08:51:30Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![NikeshN](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nikeshn/32/82216_2.png) [@NikeshN](https://discuss.elastic.co/u/NikeshN)\
**Post date:** [January 14, 2021, 8:51am UTC](https://discuss.elastic.co/t/can-we-have-different-apm-service-name-for-subset-of-microservices/261095/1 "2021-01-14T08:51:31Z")

</div>

Hey hi,

Can we create a new APM service from a subset of APIs which represent a common business logic, as check logs in one big APM service doesn't make sense

Service 1 has multiple child services. Services 5 to 10 are a subset of service\_1 which service\_1 uses anytime. Can we have separate APM service\_name for Service 1 and Services 5 to 10.? So a team can view only their own transactions and not get lost in distributed tracings spans.

---

<div class="post-metadata">

**Author:** ![basepi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/basepi/32/53056_2.png) [@basepi](https://discuss.elastic.co/u/basepi)\
**Post date:** [January 15, 2021, 12:01am UTC](https://discuss.elastic.co/t/can-we-have-different-apm-service-name-for-subset-of-microservices/261095/2 "2021-01-15T00:01:16Z")

</div>

Welcome, @NikeshN!

I think your best bet may be to set labels for different parts of your app using [`elasticapm.label()`](https://www.elastic.co/guide/en/apm/agent/python/current/api.html#api-label) -- then, you can filter by them in the UI. But they still won't show up as separate services, unfortunately.

---

<div class="post-metadata">

**Author:** ![NikeshN](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nikeshn/32/82216_2.png) [@NikeshN](https://discuss.elastic.co/u/NikeshN)\
**Post date:** [January 15, 2021, 4:59pm UTC](https://discuss.elastic.co/t/can-we-have-different-apm-service-name-for-subset-of-microservices/261095/3 "2021-01-15T16:59:27Z")

</div>

how about using custom instrumentation code in python decorator. I tried but errors are not getting captured in APM dashboard by capture\_exception, requests are shown as transactions but errors are not captured. I followed this blog [https://www.elastic.co/blog/creating-custom-framework-integrations-with-the-elastic-apm-python-agent](https://www.elastic.co/blog/creating-custom-framework-integrations-with-the-elastic-apm-python-agent), tweaked a bit little for flask.

---

<div class="post-metadata">

**Author:** ![basepi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/basepi/32/53056_2.png) [@basepi](https://discuss.elastic.co/u/basepi)\
**Post date:** [January 19, 2021, 3:17pm UTC](https://discuss.elastic.co/t/can-we-have-different-apm-service-name-for-subset-of-microservices/261095/4 "2021-01-19T15:17:18Z")

</div>

In [v5.10.0](https://github.com/elastic/apm-agent-python/releases/tag/v5.10.0) we introduced the ability to replace the global excepthook with an Elastic handler. If you set `USE_ELASTIC_EXCEPTHOOK=True` you can enable this feature and that should help plug some of the holes in your exception reporting.

Note that if a framework catches uncaught exceptions automatically, this feature may not solve your problem. In that case you need to hook into the framework's exception handling and `capture_exception` there.

---

<div class="post-metadata">

**Author:** ![NikeshN](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nikeshn/32/82216_2.png) [@NikeshN](https://discuss.elastic.co/u/NikeshN)\
**Post date:** [January 21, 2021, 6:04am UTC](https://discuss.elastic.co/t/can-we-have-different-apm-service-name-for-subset-of-microservices/261095/5 "2021-01-21T06:04:06Z")

</div>

okay, I think I have a newer problem on my side, so we have log handlers and use filebeat to send logs, which works perfectly fine. Now, after adding elastic APM agent, all requests which have 200 stat are shown as errors.

we are using [pythonjsonlogger](https://github.com/madzak/python-json-logger) package.

---

<div class="post-metadata">

**Author:** ![basepi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/basepi/32/53056_2.png) [@basepi](https://discuss.elastic.co/u/basepi)\
**Post date:** [January 21, 2021, 3:48pm UTC](https://discuss.elastic.co/t/can-we-have-different-apm-service-name-for-subset-of-microservices/261095/6 "2021-01-21T15:48:16Z")

</div>

That sounds very odd. Anything in the application/agent logs?

You might also consider checking out [ecs-logging-python](https://github.com/elastic/ecs-logging-python) which provides ECS-compliant formatters for easy ingestion via Filebeat, including log correlation with APM traces.

---

<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:** [February 11, 2021, 11:48am UTC](https://discuss.elastic.co/t/can-we-have-different-apm-service-name-for-subset-of-microservices/261095/7 "2021-02-11T11:48:19Z")

</div>

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