# API to pull the exception and it's count

**URL:** <https://community.dynatrace.com/t/api-to-pull-the-exception-and-its-count/43062>\
**Category:** Dynatrace API\
**Tags:** dynatrace-api\
**Created:** [December 7, 2023, 6:30am UTC](https://community.dynatrace.com/t/api-to-pull-the-exception-and-its-count/43062 "2023-12-07T06:30:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shruts](https://avatars.discourse-cdn.com/v4/letter/s/839c29/32.png) [@Shruts](https://community.dynatrace.com/u/Shruts)\
**Post date:** [December 7, 2023, 6:30am UTC](https://community.dynatrace.com/t/api-to-pull-the-exception-and-its-count/43062/1 "2023-12-07T06:30:41Z")

</div>

Hi,

I wanted to pull all the exception that occurred with it’s counts using API. Can I fetch the result by using provided API and if yes then let me know the API details.

---

<div class="post-metadata">

**Author:** ![radek\_jasinski](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/radek_jasinski/32/10432_2.png) [@radek\_jasinski](https://community.dynatrace.com/u/radek_jasinski)\
**Post date:** [December 7, 2023, 7:47am UTC](https://community.dynatrace.com/t/api-to-pull-the-exception-and-its-count/43062/2 "2023-12-07T07:47:10Z")

</div>

Hi&nbsp;[@Shruts](https://community.dynatrace.com/user/68893)

To retrieve exceptions and their counts using the Dynatrace API, you can utilize the Dynatrace Problem and Event Feed API or the Logs API, depending on the exact nature of the data you’re interested in.

- **Problem and Event Feed API:** This API provides detailed information about problems detected in your monitored environment. It might include exception data if these exceptions are part of broader problems detected by Dynatrace.
- **Logs API:** If you’re specifically interested in exceptions as they are logged, the Logs API would be the right choice. This API allows you to query log data, which can include exception details.

Example:

GET https://{your-environment-id}.live.dynatrace.com/api/v2/logs/query  
Authorization: Api-Token {your-api-token}  
Content-Type: application/json

{  
“query”: “log level ERROR | count”,  
“from”: “now-2d”,  
“to”: “now”  
}

Radek

---

<div class="post-metadata">

**Author:** ![Shruts](https://avatars.discourse-cdn.com/v4/letter/s/839c29/32.png) [@Shruts](https://community.dynatrace.com/u/Shruts)\
**Post date:** [December 7, 2023, 10:07am UTC](https://community.dynatrace.com/t/api-to-pull-the-exception-and-its-count/43062/3 "2023-12-07T10:07:52Z")

</div>

Hi,

Can you send API documentation link or swagger document link for Logs API? Because couldn’t able to find this API in given swagger doc.

Thanks & Regards,  
Shruti

---

<div class="post-metadata">

**Author:** ![radek\_jasinski](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/radek_jasinski/32/10432_2.png) [@radek\_jasinski](https://community.dynatrace.com/u/radek_jasinski)\
**Post date:** [December 7, 2023, 11:55am UTC](https://community.dynatrace.com/t/api-to-pull-the-exception-and-its-count/43062/4 "2023-12-07T11:55:24Z")

</div>

Hi,

You can find swagger in Managed \>\> Access tokens

 ![Zrzut ekranu 2023-12-7 o 12.53.59.png](https://global.discourse-cdn.com/dynatrace/original/2X/4/4ff84383d4fc689af8d2975bf4c0b72f09789d9c.png)

> **[Events API v2](https://docs.dynatrace.com/docs/dynatrace-api/environment-api/events-v2)**
>
> Find out what you can do with the Dynatrace Events API v2.

Radek

---

<div class="post-metadata">

**Author:** ![mark\_bley](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/mark_bley/32/20954_2.png) [@mark\_bley](https://community.dynatrace.com/u/mark_bley)\
**Post date:** [December 8, 2023, 8:51am UTC](https://community.dynatrace.com/t/api-to-pull-the-exception-and-its-count/43062/5 "2023-12-08T08:51:03Z")

</div>

You may be looking for this information displayed in the multidimensional analysis tool

 ![mark_bley_0-1702025289234.png](https://global.discourse-cdn.com/dynatrace/original/2X/8/83f5d964fd8217b898aa395c58f0f0336ab32e28.png)

There you can create a Metric based on the Exceptions and the count.

Once you have the metric you can easily pull the information from&nbsp;/api/v2/metrics

You may need to filter down the search using a specific service or request otherwise it may not work if you have too much data in your environment.

---

<div class="post-metadata">

**Author:** ![radek\_jasinski](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/radek_jasinski/32/10432_2.png) [@radek\_jasinski](https://community.dynatrace.com/u/radek_jasinski)\
**Post date:** [December 8, 2023, 9:14am UTC](https://community.dynatrace.com/t/api-to-pull-the-exception-and-its-count/43062/6 "2023-12-08T09:14:55Z")

</div>

Please note that creating additional metrics consumes the DDU licence.
