# Metrics v2: How to pull out data from specific Key Request or use filters

**URL:** <https://community.dynatrace.com/t/metrics-v2-how-to-pull-out-data-from-specific-key-request-or-use-filters/19909>\
**Category:** Dynatrace API\
**Tags:** dynatrace-managed, key-requests, dynatrace-api\
**Created:** [July 29, 2020, 12:51pm UTC](https://community.dynatrace.com/t/metrics-v2-how-to-pull-out-data-from-specific-key-request-or-use-filters/19909 "2020-07-29T12:51:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![janne\_olkoniemi](https://avatars.discourse-cdn.com/v4/letter/j/8e8cbc/32.png) [@janne\_olkoniemi](https://community.dynatrace.com/u/janne_olkoniemi)\
**Post date:** [July 29, 2020, 12:51pm UTC](https://community.dynatrace.com/t/metrics-v2-how-to-pull-out-data-from-specific-key-request-or-use-filters/19909/1 "2020-07-29T12:51:13Z")

</div>

How to pull out data from metrics api v2 which would contain data from one certain key request?  
Should I use and obtain the entityID for my KeyRequest somehow and would there be possibility to filter the requests based on request parameters?

I can filter out some certain service but this call returns data from all the Key Requests and I would need to filter my data to one specific use case but can’t get my head around how to do it.

_[https://xxxxxxxxx.live.dynatrace.com/api/v2/metrics/query?resolution=Inf&from=1595851920000&to=1595852100000&api-token=XXXXXXXXXX&metricSelector=builtin:service.keyRequest.dbChildCallCount&entitySelector=type(SERVICE\_METHOD),entityId](https://xxxxxxxxx.live.dynatrace.com/api/v2/metrics/query?resolution=Inf&from=1595851920000&to=1595852100000&api-token=XXXXXXXXXX&metricSelector=builtin:service.keyRequest.dbChildCallCount&entitySelector=type(SERVICE%5C_METHOD),entityId)(SERVICE\_METHOD-18444A1107CDD08C&nbsp;)_

I have tried go trough the documentation but I would appreciate if someone could offer some help how we could filter out data.

---

<div class="post-metadata">

**Author:** ![Radu](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/radu/32/23351_2.png) [@Radu](https://community.dynatrace.com/u/Radu)\
**Post date:** [July 29, 2020, 3:16pm UTC](https://community.dynatrace.com/t/metrics-v2-how-to-pull-out-data-from-specific-key-request-or-use-filters/19909/2 "2020-07-29T15:16:35Z")

</div>

Hi Janne,

You are absolutely spot on! Your API call seems correct to me.

The key parts are:

- metricSelector - must be for a ‘.keyRequest.’ type metric
- entitySelector - must have:

```auto
type("SERVICE_METHOD"),entityId("SERVICE_METHOD-xxxxxxxx")

```

Also, make sure your metric actually exists at the keyRequest level. On my environment for example, I have dbChildCall only at the service level:

```auto
builtin:service.dbChildCallCount

```

Try using a generic one (for testing purposes) to ensure your call returns something. Maybe something like:

```auto
builtin:service.keyRequest.count.total

```

I hope this helps.

Best regards,

Radu
