# SDK problems fetched using @dynatrace-sdk/client-classic-environment-v2

**URL:** <https://community.dynatrace.com/t/sdk-problems-fetched-using-dynatrace-sdk-client-classic-environment-v2/42089>\
**Category:** Developer Q&A Forum\
**Created:** [October 13, 2023, 11:26pm UTC](https://community.dynatrace.com/t/sdk-problems-fetched-using-dynatrace-sdk-client-classic-environment-v2/42089 "2023-10-13T23:26:01Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![derija](https://avatars.discourse-cdn.com/v4/letter/d/a87d85/32.png) [@derija](https://community.dynatrace.com/u/derija)\
**Post date:** [October 13, 2023, 11:26pm UTC](https://community.dynatrace.com/t/sdk-problems-fetched-using-dynatrace-sdk-client-classic-environment-v2/42089/1 "2023-10-13T23:26:01Z")

</div>

**code:**

import { problemsClient} from ‘@dynatrace-sdk/client-classic-environment-v2’  
export default async function () {

const config: Object = {  
“problemSelector”: “displayId(P-23097463)”,  
“from”: “-60d”,  
“to”: “now”  
}

let problems = (await problemsClient.getProblems(config)).problems  
for (var sv of problems) {  
console.log(Date(sv.startTime), Date(sv.endTime))  
}  
console.log(problems)

}

The startTime and EndTime are for the **query** and NOT for the actual Problem:

![derija_1-1697239190603.png](https://global.discourse-cdn.com/dynatrace/original/2X/7/77e485d7e0fb1d3b9ff8485643a272bd10f1d159.png)

UI shows correct values:

 ![derija_0-1697239118537.png](https://global.discourse-cdn.com/dynatrace/original/3X/3/8/382093f3c1850e3c5e98583453808303383e0b31.png)

How is this supposed to work? If I ask for a problem in the past?? Things like reports of problems in the last X days, to calculate total disruption based on entities and problems? like above?

---

<div class="post-metadata">

**Author:** ![sinisa\_zubic](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/sinisa_zubic/32/32498_2.png) [@sinisa\_zubic](https://community.dynatrace.com/u/sinisa_zubic)\
**Post date:** [October 14, 2023, 4:47pm UTC](https://community.dynatrace.com/t/sdk-problems-fetched-using-dynatrace-sdk-client-classic-environment-v2/42089/2 "2023-10-14T16:47:34Z")

</div>

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

I can’t reproduce your problem with problemsClient.getProblems

Also I am not sure why you are quering problems via the problemsClient and not using DQL? Davis events and problems are also being stored in Grail.

here you have my code snippet

```markup
import React, { useEffect } from "react";
import { DataTable, Flex, convertToColumns } from "@dynatrace/strato-components-preview";
import { problemsClient } from "@dynatrace-sdk/client-classic-environment-v2";
import { useDqlQuery } from "@dynatrace-sdk/react-hooks";

export const Home = () => {
  const query = `fetch events, from:now()-60d
  | filter event.kind == "DAVIS_PROBLEM"
  | filter display_id == "P-2309107"
  | summarize {problem=takeMax(record(timestamp,resolved_problem_duration,event.end,event.start,dt.davis.is_duplicate,event.status,maintenance.is_under_maintenance,dt.davis.is_frequent_event)) }, by:{display_id}
  | fieldsFlatten problem
  | filter problem.event.status == "CLOSED"
  | filter problem.dt.davis.is_frequent_event == false and problem.dt.davis.is_duplicate == false and problem.maintenance.is_under_maintenance == false
  | fields display_id, problem.event.start, problem.event.end`;

  const resp = useDqlQuery({
    body: {
      query: query,
    },
  });

  useEffect(() => {
    if (resp.data !== undefined) {
      console.log(resp.data.records);
    }
  }, [resp]);

  useEffect(() => {
    const config: Object = {
      "problemSelector": "displayId(P-2309107)",
      "from": "-60d",
      "to": "now"
    };

    problemsClient.getProblems(config).then((problems) => {

      for (var sv of problems.problems) {
        console.log(new Date(sv.startTime), new Date(sv.endTime));
      }
    });
  }, []);

  return (
    <Flex flexDirection="column" >
      {resp.data && resp.data.records && <DataTable columns={convertToColumns(resp.data.types)} data={resp.data.records} fullWidth />}
    </Flex>
  );
};

```

You can use that snippet if you connect to&nbsp;[https://wkf10640.apps.dynatrace.com/](https://wkf10640.apps.dynatrace.com/) - that is the Discover Dynatrace environment and every user has access to that.

 ![sinisa_zubic_0-1697302027136.png](https://global.discourse-cdn.com/dynatrace/original/3X/f/f/ff87cf9240da2d1ace8b5a34210bfd5c6fafeea7.png)

Please let me know if&nbsp; you still have problems after checking out my snippet.

Best,  
Sini

---

<div class="post-metadata">

**Author:** ![derija](https://avatars.discourse-cdn.com/v4/letter/d/a87d85/32.png) [@derija](https://community.dynatrace.com/u/derija)\
**Post date:** [October 19, 2023, 9:45pm UTC](https://community.dynatrace.com/t/sdk-problems-fetched-using-dynatrace-sdk-client-classic-environment-v2/42089/3 "2023-10-19T21:45:38Z")

</div>

Thank for response. I used the example as a tuned down example I received as an example for problem inquiry.

I used your code as is in a new notebook and received the following:

 ![derija_0-1697751880257.png](https://global.discourse-cdn.com/dynatrace/original/3X/9/2/92f540e0c6807c5054aae99a5d490abea0eccd34.png)

Note sure why.. thanks in advance.

---

<div class="post-metadata">

**Author:** ![derija](https://avatars.discourse-cdn.com/v4/letter/d/a87d85/32.png) [@derija](https://community.dynatrace.com/u/derija)\
**Post date:** [October 20, 2023, 3:30pm UTC](https://community.dynatrace.com/t/sdk-problems-fetched-using-dynatrace-sdk-client-classic-environment-v2/42089/4 "2023-10-20T15:30:53Z")

</div>

Went to the playground created new notebook and pasted your code in and ran code with same error

 ![derija_0-1697815817496.png](https://global.discourse-cdn.com/dynatrace/original/2X/f/fddb34c10cbf96d5718559baf7692d548cfe99c6.png)

 ![derija_1-1697815838236.png](https://global.discourse-cdn.com/dynatrace/original/3X/4/5/45e61a6c0488e345fd9b8d5a1f07166170ac274e.png)

---

<div class="post-metadata">

**Author:** ![sinisa\_zubic](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/sinisa_zubic/32/32498_2.png) [@sinisa\_zubic](https://community.dynatrace.com/u/sinisa_zubic)\
**Post date:** [November 2, 2023, 1:33pm UTC](https://community.dynatrace.com/t/sdk-problems-fetched-using-dynatrace-sdk-client-classic-environment-v2/42089/5 "2023-11-02T13:33:50Z")

</div>

I did not know that you want to do this in notebooks. The code snippet I have shared with you works within a [Dynatrace custom app](https://developer.dynatrace.com/introduction/).

If you want to see the duration of a problem, you can use this [dql query](https://wkf10640.apps.dynatrace.com/ui/intent/dynatrace.notebooks/view-query#%7B%22dt.query%22%3A%22fetch%20events%2C%20from%3Anow()-90d%5Cn%20%20%7C%20filter%20event.kind%20%3D%3D%20%5C%22DAVIS_PROBLEM%5C%22%5Cn%20%20%7C%20filter%20display_id%20%3D%3D%20%5C%22P-2309241%5C%22%5Cn%20%20%7C%20summarize%20%7Bproblem%3DtakeMax(record(timestamp%2Cresolved_problem_duration%2Cevent.end%2Cevent.start%2Cdt.davis.is_duplicate%2Cevent.status%2Cmaintenance.is_under_maintenance%2Cdt.davis.is_frequent_event))%20%7D%2C%20by%3A%7Bdisplay_id%7D%5Cn%20%20%7C%20fieldsFlatten%20problem%5Cn%20%20%7C%20filter%20problem.event.status%20%3D%3D%20%5C%22CLOSED%5C%22%5Cn%20%20%7C%20filter%20problem.dt.davis.is_frequent_event%20%3D%3D%20false%20and%20problem.dt.davis.is_duplicate%20%3D%3D%20false%20and%20problem.maintenance.is_under_maintenance%20%3D%3D%20false%5Cn%20%20%7C%20fields%20display_id%2C%20problem.event.start%2C%20problem.event.end%2C%20duration%3Dproblem.event.end%20-%20problem.event.start%22%2C%22hideInput%22%3Afalse%2C%22visualization%22%3A%22recordView%22%2C%22visualizationSettings%22%3A%7B%22thresholds%22%3A%5B%5D%2C%22chartSettings%22%3A%7B%22gapPolicy%22%3A%22connect%22%2C%22circleChartSettings%22%3A%7B%22groupingThresholdType%22%3A%22absolute%22%7D%2C%22categoryOverrides%22%3A%7B%7D%7D%2C%22singleValue%22%3A%7B%22label%22%3A%22%22%2C%22prefixIcon%22%3A%22%22%2C%22autoscale%22%3Atrue%2C%22alignment%22%3A%22center%22%7D%2C%22table%22%3A%7B%22rowDensity%22%3A%22condensed%22%2C%22enableSparklines%22%3Afalse%2C%22hiddenColumns%22%3A%5B%5D%2C%22lineWrapIds%22%3A%5B%5D%2C%22firstVisibleRowIndex%22%3A0%2C%22columnWidths%22%3A%7B%7D%2C%22enableLineWrap%22%3Atrue%7D%7D%7D):

```markup
fetch events, from:now()-90d
  | filter event.kind == "DAVIS_PROBLEM"
  | filter display_id == "P-2309241"
  | summarize {problem=takeMax(record(timestamp,resolved_problem_duration,event.end,event.start,dt.davis.is_duplicate,event.status,maintenance.is_under_maintenance,dt.davis.is_frequent_event)) }, by:{display_id}
  | fieldsFlatten problem
  | filter problem.event.status == "CLOSED"
  | filter problem.dt.davis.is_frequent_event == false and problem.dt.davis.is_duplicate == false and problem.maintenance.is_under_maintenance == false
  | fields display_id, problem.event.start, problem.event.end, duration=problem.event.end - problem.event.start

```

[Here](https://wkf10640.apps.dynatrace.com/ui/apps/dynatrace.classic.problems/#problems/problemdetails;gtf=-90d%20to%20now;gf=all;pid=-7848720326958616911_1695923880000V2) you see the example problem.

 ![sinisa_zubic_0-1698931834143.png](https://global.discourse-cdn.com/dynatrace/original/3X/0/3/03705d7ac7075e2bc4c80c573483131e19f25daf.png)

 ![sinisa_zubic_1-1698931862198.png](https://global.discourse-cdn.com/dynatrace/original/3X/2/4/24b797804819c5cbe8f5c58a252fcc63d39ebbb1.png)

for more examples on how to use DQL and Davis problems, please check out following help page:&nbsp;[Dynatrace Intelligence DQL examples — Dynatrace Docs](https://docs.dynatrace.com/docs/platform/davis-ai/davis-dql-examples)

Best,  
Sini

---

<div class="post-metadata">

**Author:** ![tarjei\_statkraf](https://avatars.discourse-cdn.com/v4/letter/t/f475e1/32.png) [@tarjei\_statkraf](https://community.dynatrace.com/u/tarjei_statkraf)\
**Post date:** [January 14, 2026, 9:29am UTC](https://community.dynatrace.com/t/sdk-problems-fetched-using-dynatrace-sdk-client-classic-environment-v2/42089/6 "2026-01-14T09:29:47Z")

</div>

Hi!

I am also trying to get the

problemsClient.getProblems to work as I have not been able to use DQL to get the davis problems with corresponding Management Zones.&nbsp;  
With the getProblems it is quite easy to do this.
