# I can not get the API to collect the %CPU of a monitor host

**URL:** <https://community.dynatrace.com/t/i-can-not-get-the-api-to-collect-the-cpu-of-a-monitor-host/23049>\
**Category:** Extensions\
**Tags:** hosts-classic, extensions\
**Created:** [February 18, 2020, 2:54pm UTC](https://community.dynatrace.com/t/i-can-not-get-the-api-to-collect-the-cpu-of-a-monitor-host/23049 "2020-02-18T14:54:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![olivier\_ebaach1](https://avatars.discourse-cdn.com/v4/letter/o/9dc877/32.png) [@olivier\_ebaach1](https://community.dynatrace.com/u/olivier_ebaach1)\
**Post date:** [February 18, 2020, 2:54pm UTC](https://community.dynatrace.com/t/i-can-not-get-the-api-to-collect-the-cpu-of-a-monitor-host/23049/1 "2020-02-18T14:54:44Z")

</div>

Hi

I need to collect Memory, CPU of a Host.

I also need to collect Response time of a service.

I read the API Document but didn’t understand what to do.

Can you give me an exemple then i will learn from it

Can you help me?

Regards

---

<div class="post-metadata">

**Author:** ![MaciejNeumann](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@MaciejNeumann](https://community.dynatrace.com/u/MaciejNeumann)\
**Post date:** [February 18, 2020, 3:22pm UTC](https://community.dynatrace.com/t/i-can-not-get-the-api-to-collect-the-cpu-of-a-monitor-host/23049/2 "2020-02-18T15:22:48Z")

</div>

Hello [@EBA’A CHI O.](https://answers.dynatrace.com/users/31501/view.html),

Remember to never provide the Dynatrace environment ID in your question. Here are a couple of tips on how to ask the best question on our forum and increase your chances of getting a quick and precise answer:

 ![23655-23358-ask-questions-1-04.png](https://global.discourse-cdn.com/dynatrace/original/2X/0/01767538d2dc3b68165ebec496c1857ff70e4cdf.png)

---

<div class="post-metadata">

**Author:** ![Dallas](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/dallas/32/31233_2.png) [@Dallas](https://community.dynatrace.com/u/Dallas)\
**Post date:** [February 18, 2020, 4:25pm UTC](https://community.dynatrace.com/t/i-can-not-get-the-api-to-collect-the-cpu-of-a-monitor-host/23049/3 "2020-02-18T16:25:13Z")

</div>

Hello [@EBA’A CHI O.](https://answers.dynatrace.com/users/31501/view.html),

Here is an example request to capture host CPU idle for every hour in the last day:

```auto
https://xxxx.live.dynatrace.com/api/v2/metrics/query?metricSelector=builtin%3Ahost.cpu.idle&resolution=h&from=now-1d%2Fh&entitySelector=type%28HOST%29%2CentityId%28HOST-C98F015DFD9D8A95%29

```

Keep in mind you will also need your token for this.

Here are some good resources for creating these requests:

> **[Integrate Dynatrace more easily using the new Metrics REST API](https://www.dynatrace.com/news/blog/integrate-dynatrace-more-easily-using-the-new-metrics-rest-api/)**
>
> One of the most important aspects of the newly introduced metrics API endpoint is the logical structure for all Dynatrace metrics.

> **[Metrics API - GET metric data points](https://docs.dynatrace.com/docs/dynatrace-api/environment-api/metric-v2/get-data-points)**
>
> Read data points of one or multiple metrics via Metrics v2 API.

Also, if you haven’t tried. Go to your tenant and click the user icon. Under “dynatrace API” select “Environment API”. This gives you a pretty great interface for creating a simple query.

Let me know if you need more help.

Thanks

-Dallas
