Dynatrace API
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Is it possible create/update/delete host groups via Rest API?

gschramm
Helper

Hello,

I'm currently build a script that allows us to quickly setup a new application we want to onboard. The goal is to build a sceleton configuration with all important pieces including permissions.

Application, URL mapping, storage buckets, management zone ect.. all find. One important piece is the host group and there doesn't seem to be a REST endpunkt for managing host groups.

Can you confirm that or am I simply overlooking something?

 

regards,

Günter

7 REPLIES 7

Julius_Loman
DynaMight Legend
DynaMight Legend

That's correct, there is no API for managing hostgroups.  Host groups get automatically created when you set them in the OneAgent installer arguments, in the OneAgent configuration using oneagentctl, by changing them in Deployment status or by using OneAgent configuration API. 

Dynatrace Ambassador | Alanata a.s., Slovakia, Dynatrace Master Partner

gschramm
Helper

That's major disappointment. Host groups are useful config items that are reused in other parts of a configuration, eg. Management Zones, Mainteance Windows, Logs Ingest Rules, Bucket assignment.. also in Policies for boundaries definitions ect.

In our case I simply cannot build a proper starting configuration without a new host group. Connecting / changing an agent to create a new group seems like a very silly workaround to me.

I'll create a product idea for this.

@gschramm I'm curious about what you are trying to accomplish. You can still create rules such as tagging rules, or management zones referring to a host group name even when such a host group does not exist yet. 

Dynatrace Ambassador | Alanata a.s., Slovakia, Dynatrace Master Partner

apasoquen1
Helper

One use case could be maintenance windows.  For example, I have a few agents that I need to deploy however, they will not be in production until a certain time.  If I was able to create an 'empty host group', I could configure my maintenance window based on that host group.  Then when those agents are deployed, they should automatically be in maintenance mode.

Didier
Frequent Guest

My use case : create a new host-group with specifics settings before to install OneAgent. I need to desactivate some monitoring features to the new host group only.
How can i do that ? 
I do not understand how this page can help : The solution https://docs.dynatrace.com/managed/shortlink/api-v2-remote-configuration-oneagents-post-job
I do not have entities ID because OneAgent is not installed yet on the new hosts.
I'am interested if you have un curl example

Didier
Frequent Guest

I'm answering my own question (with Jean-Louis's help). And in case it's helpful to others :

To list Host_Groups, you can use the entities API with the following entitySelector configuration: type(HOST_GROUP)

/api/v2/entities?entitySelector=type%28HOST_GROUP%29

Example :

curl -s "${DT_TENANT_URL}api/v2/entities?entitySelector=type%28HOST_GROUP%29" -X GET -H 'Accept: application/json; charset=utf-8' -H
 'Content-Type: application/json; charset=utf-8' -H "Authorization: Api-Token ${DT_TENANT_TOKEN}"


and then, you can modify a specific host group with it's ID ("scope":"HOST_GROUP-ID") in api/v2/settings/objects

curl "${DT_TENANT_URL}api/v2/settings/objects" \
-X POST \
-H "Accept: application/json; charset=utf-8" \
-H "Content-Type: application/json; charset=utf-8" \
-H "Authorization: Api-Token ${DT_TENANT_TOKEN}" \
-d $'[{"schemaId":"builtin:process.process-monitoring","schemaVersion":"0.2","scope":"HOST_GROUP-ID","value":{"autoMonitoring":false}}]'

 

However, you cannot create a host group without a host; it must be associated with at least one host.

Featured Posts