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

Using API get CPU and Memory of a host and all the host under an application

shailandra
Newcomer

hi,

 

i am trying to capture CPU and Memory of a host and all the host under an application for given time period, is this possible in DT

1 REPLY 1

trevor_masseng1
Dynatrace Pro
Dynatrace Pro

Hi Shailandra,

 

Yes, this is possible.

 

Pulling metrics out of Dynatrace can be done with the Metrics API:
https://www.dynatrace.com/support/help/dynatrace-api/environment-api/metric-v2/get-data-points/

Depending on the type of host, there may be a different metric that is used for CPU or Memory, but all Host/Infrastructure metrics are listed here:
https://www.dynatrace.com/support/help/shortlink/api-metrics2-available-saas#host

 

Now as for grabbing all host metrics that serve a particular RUM Application, that requires a bit of configuration. You'll either want to tag each host with the name of the application it serves, or create a management zone for them. After that, you can include the tag/management zone as a filter in your request to just pull those hosts.

 

The below requests should give you the results you want after you set up your tag or management zone (replace X with your tag/management zone name or change the metricSelector metric ID if you want to pull a different metric):

/api/v2/metrics/query?metricSelector=builtin:host.mem.usage&entitySelector=type(HOST),tag(X)

/api/v2/metrics/query?metricSelector=builtin:host.mem.usage&entitySelector=type(HOST),mzName(X)