# Configuration API for Service naming rules?

**URL:** <https://community.dynatrace.com/t/configuration-api-for-service-naming-rules/20755>\
**Category:** Dynatrace API\
**Tags:** services-classic, settings, dynatrace-api\
**Created:** [November 5, 2020, 9:45pm UTC](https://community.dynatrace.com/t/configuration-api-for-service-naming-rules/20755 "2020-11-05T21:45:57Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![sureshKumarK](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/sureshkumark/32/11469_2.png) [@sureshKumarK](https://community.dynatrace.com/u/sureshKumarK)\
**Post date:** [November 5, 2020, 9:45pm UTC](https://community.dynatrace.com/t/configuration-api-for-service-naming-rules/20755/1 "2020-11-05T21:45:57Z")

</div>

Hi, I am trying to find whether there is an Configuration API available to define or copy the Service naming rules. In one environment I have defined the rules manually and I am trying to use Configuration API to GET, modify and POST the rules to a new Environment. Please let me know if there is an API available for this?

Thanks, Suresh.

---

<div class="post-metadata">

**Author:** ![ChadTurner](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/chadturner/32/161_2.png) [@ChadTurner](https://community.dynatrace.com/u/ChadTurner)\
**Post date:** [November 6, 2020, 2:00am UTC](https://community.dynatrace.com/t/configuration-api-for-service-naming-rules/20755/2 "2020-11-06T02:00:34Z")

</div>

Within the configuration API, you can pull the metrics on each rule and then post that into your new environment as shown here:

 ![27192-1604627720052.png](https://global.discourse-cdn.com/dynatrace/original/2X/0/0fe71aab167395036e1fc68d90da59f99ffe3756.png)

We had Dynatrace Support do the migration for us so it was apples to apples

---

<div class="post-metadata">

**Author:** ![Julius\_Loman](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/julius_loman/32/51_2.png) [@Julius\_Loman](https://community.dynatrace.com/u/Julius_Loman)\
**Post date:** [November 6, 2020, 10:00am UTC](https://community.dynatrace.com/t/configuration-api-for-service-naming-rules/20755/3 "2020-11-06T10:00:43Z")

</div>

At the moment, you cannot transfer service naming rules via API and you have to recreate them manually or maybe ask Dynatrace support to do that for you as [@Chad T.](https://answers.dynatrace.com/users/36422/view.html) mentions.

But it’s likely your situation can be also covered by the Service detection rules. Those are for a different purpose. They can be migrated via API easily.

---

<div class="post-metadata">

**Author:** ![alonso\_decosio](https://avatars.discourse-cdn.com/v4/letter/a/bbe5ce/32.png) [@alonso\_decosio](https://community.dynatrace.com/u/alonso_decosio)\
**Post date:** [November 6, 2020, 2:58pm UTC](https://community.dynatrace.com/t/configuration-api-for-service-naming-rules/20755/4 "2020-11-06T14:58:59Z")

</div>

Hi Suresh,

To migrate the service naming rules, you can use the /conditionalNaming/{Type} endpoint.

 ![27241-screen-shot-2020-11-06-at-95208-am.png](https://global.discourse-cdn.com/dynatrace/original/3X/6/5/65c95b1680ee97171c8806e0bc56b8091e38bb6d.png)

In your case, the type will be “service”, and as you said, first you need to do a GET and then do a POST in the second environment.

Alonso

---

<div class="post-metadata">

**Author:** ![sureshKumarK](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/sureshkumark/32/11469_2.png) [@sureshKumarK](https://community.dynatrace.com/u/sureshKumarK)\
**Post date:** [November 10, 2020, 5:16pm UTC](https://community.dynatrace.com/t/configuration-api-for-service-naming-rules/20755/5 "2020-11-10T17:16:51Z")

</div>

thanks [@Chad T.](https://answers.dynatrace.com/users/36422/view.html) I am not looking for metrics, I am looking for renaming the Services with rules using API

---

<div class="post-metadata">

**Author:** ![sureshKumarK](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/sureshkumark/32/11469_2.png) [@sureshKumarK](https://community.dynatrace.com/u/sureshKumarK)\
**Post date:** [November 10, 2020, 5:22pm UTC](https://community.dynatrace.com/t/configuration-api-for-service-naming-rules/20755/6 "2020-11-10T17:22:38Z")

</div>

Hi Alonso, looks like this API is useful for process groups not for each service

---

<div class="post-metadata">

**Author:** ![sureshKumarK](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/sureshkumark/32/11469_2.png) [@sureshKumarK](https://community.dynatrace.com/u/sureshKumarK)\
**Post date:** [November 10, 2020, 6:08pm UTC](https://community.dynatrace.com/t/configuration-api-for-service-naming-rules/20755/7 "2020-11-10T18:08:03Z")

</div>

Hi [@Alonso de Cosio F.](https://answers.dynatrace.com/users/18250/view.html), [@Július L.](https://answers.dynatrace.com/users/16467/view.html), and [@Chad T.](https://answers.dynatrace.com/users/36422/view.html) i have made some progress to get this done.

As Alonso mentioned, I can do the GET to pull all the services and their IDs using conditionalNaming API { {tenant}}/api/config/v1/conditionalNaming/:type

 ![27259-1605031154410.jpg](https://global.discourse-cdn.com/dynatrace/original/2X/a/a35c55d4734ef121855833fbeef53a65c9effc86.jpeg)

and do another GET on id to pull the properties of that service { {tenant}}/api/config/v1/conditionalNaming/:type/:id

 ![27284-1605034690221.jpg](https://global.discourse-cdn.com/dynatrace/original/2X/c/c31c12e6505b5252711610c6990aaee30d8ff7cd.jpeg)

now the question is, to do POST this in new environment where I want to modify and create as a new rule, I am not able to find how to GET the HOST\_GROUP\_ID values for new environment so that I can modify the Payload and POST to the new environment to create the rule(s)

fyi, this is the payload I am trying to POST in new Environment to get the rule created. Not sure how to get the HOST\_GROUP\_ID values of new Environment. if I get them, then should be easy to create. Please suggest.

 ![27283-1605034529727.jpg](https://global.discourse-cdn.com/dynatrace/original/3X/2/d/2df5c3e44d28ab3964509910e7f39c9a944fc465.jpeg)

---

<div class="post-metadata">

**Author:** ![sureshKumarK](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/sureshkumark/32/11469_2.png) [@sureshKumarK](https://community.dynatrace.com/u/sureshKumarK)\
**Post date:** [November 10, 2020, 6:13pm UTC](https://community.dynatrace.com/t/configuration-api-for-service-naming-rules/20755/8 "2020-11-10T18:13:23Z")

</div>

If I know how to GET the HOST group IDs using API, simply i can replace that in the payload and do POST.

---

<div class="post-metadata">

**Author:** ![sureshKumarK](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/sureshkumark/32/11469_2.png) [@sureshKumarK](https://community.dynatrace.com/u/sureshKumarK)\
**Post date:** [November 10, 2020, 6:49pm UTC](https://community.dynatrace.com/t/configuration-api-for-service-naming-rules/20755/9 "2020-11-10T18:49:37Z")

</div>

Seems using the following API we can find the host group ID

> **[Hosts API - GET all hosts](https://docs.dynatrace.com/docs/dynatrace-api/environment-api/topology-and-smartscape/hosts-api/get-all)**
>
> List all monitored hosts via Dynatrace API.

 ![27285-1605035683929.jpg](https://global.discourse-cdn.com/dynatrace/original/3X/2/5/25f3f34afd258b6977f8c3d54a60d30b3175a978.jpeg)

---

<div class="post-metadata">

**Author:** ![sureshKumarK](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/sureshkumark/32/11469_2.png) [@sureshKumarK](https://community.dynatrace.com/u/sureshKumarK)\
**Post date:** [November 10, 2020, 7:45pm UTC](https://community.dynatrace.com/t/configuration-api-for-service-naming-rules/20755/10 "2020-11-10T19:45:56Z")

</div>

thanks Alonso, conditional naming API gave a good lead for the solution

---

<div class="post-metadata">

**Author:** ![sureshKumarK](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/sureshkumark/32/11469_2.png) [@sureshKumarK](https://community.dynatrace.com/u/sureshKumarK)\
**Post date:** [November 10, 2020, 8:11pm UTC](https://community.dynatrace.com/t/configuration-api-for-service-naming-rules/20755/11 "2020-11-10T20:11:53Z")

</div>

_ **Here is the solution:** _

1. Using ConditionalNaming rule API GET the Services and their IDs’ where all the Service naming rules are created { {tenant}}/api/config/v1/conditionalNaming/:type
2. GET the properties of each Id { {tenant}}/api/config/v1/conditionalNaming/:type/:id
3. GET the host group ID of the host group of the the enviornment where you are planning to create the rule using API { {tenant}}/api/v1/entity/infrastructure/hosts
4. Take the meId from #3, modify the #2 response and POST the payload using { {tenant}}/api/config/v1/conditionalNaming/:type

Hope this helps!

Thanks for your inputs [@Alonso de Cosio F.](https://answers.dynatrace.com/users/18250/view.html) [@Július L.](https://answers.dynatrace.com/users/16467/view.html) and [@Chad T.](https://answers.dynatrace.com/users/36422/view.html)

Thanks, Suresh.
