# Generating Problem  with  workflow action "Analyze with Davis"

**URL:** <https://community.dynatrace.com/t/generating-problem-with-workflow-action-analyze-with-davis/52431>\
**Category:** Automations\
**Tags:** workflows, automation\
**Created:** [July 9, 2025, 7:41pm UTC](https://community.dynatrace.com/t/generating-problem-with-workflow-action-analyze-with-davis/52431 "2025-07-09T19:41:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Akhil-Jayendran](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/akhil-jayendran/32/153_2.png) [@Akhil-Jayendran](https://community.dynatrace.com/u/Akhil-Jayendran)\
**Post date:** [July 9, 2025, 7:41pm UTC](https://community.dynatrace.com/t/generating-problem-with-workflow-action-analyze-with-davis/52431/1 "2025-07-09T19:41:46Z")

</div>

Hello Community,

I am currently exploring the workflow capabilities for Analyze with Davis. I’ve created a simple workflow that runs every day at 05:00 AM to check for specific errors in a particular log. If the error count is 1, it should create a problem. I added an action ‘Analyze with Davis’ included my dql and set the static threshould, workflow runs successfully not getting any problem/events out of this ? Does the ‘Analyze with Davis’ action in a workflow automatically create a problem like the Anomaly Detection app, or do we need to use JavaScript to create the problem ?

---

<div class="post-metadata">

**Author:** ![Emm4nuel](https://avatars.discourse-cdn.com/v4/letter/e/e9bcb4/32.png) [@Emm4nuel](https://community.dynatrace.com/u/Emm4nuel)\
**Post date:** [July 9, 2025, 11:16pm UTC](https://community.dynatrace.com/t/generating-problem-with-workflow-action-analyze-with-davis/52431/2 "2025-07-09T23:16:54Z")

</div>

**Hi Akhil,**

Yes, you need to push the problem using a separate task. For instance, I have two executions—one without anomalies and another where the static threshold condition was exceeded.

Use values from the result JSON to define a condition in the next task. Based on that, I either send an alert to Slack or push a problem to the Problems API.

You’ll notice that the execution with an issue includes additional fields like&nbsp;raisedAlerts,&nbsp;numberOfViolations, etc., which help identify and handle the problem.

 ![Screenshot 2025-07-09 170845.png](https://global.discourse-cdn.com/dynatrace/original/2X/a/a67d2458c63992f8511c0b7994dd52d43f4ba277.png)  
 ![Screenshot 2025-07-09 170811.png](https://global.discourse-cdn.com/dynatrace/original/3X/c/2/c2b36f1c996cf3b1a5d22bba939d101460364348.png)

---

<div class="post-metadata">

**Author:** ![Akhil-Jayendran](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/akhil-jayendran/32/153_2.png) [@Akhil-Jayendran](https://community.dynatrace.com/u/Akhil-Jayendran)\
**Post date:** [July 10, 2025, 4:26am UTC](https://community.dynatrace.com/t/generating-problem-with-workflow-action-analyze-with-davis/52431/3 "2025-07-10T04:26:17Z")

</div>

Thanks&nbsp;[@Emm4nuel](https://community.dynatrace.com/user/85008)&nbsp; ,

I’ve added a JavaScript action, but unfortunately it’s not working. My JavaScript knowledge is a bit limited. I’ve attached the workflow JSON ,any chance to have look?  
[wf\_check\_logs\_3dc31eb5-261a-4d7c-b014-6e7918698f7c.json](https://community.dynatrace.com/uploads/short-url/kY83n7Ov2tGpf0HmUvH4Of7d6EX.json) (4.46 KB)

---

<div class="post-metadata">

**Author:** ![Emm4nuel](https://avatars.discourse-cdn.com/v4/letter/e/e9bcb4/32.png) [@Emm4nuel](https://community.dynatrace.com/u/Emm4nuel)\
**Post date:** [July 10, 2025, 3:16pm UTC](https://community.dynatrace.com/t/generating-problem-with-workflow-action-analyze-with-davis/52431/4 "2025-07-10T15:16:17Z")

</div>

You have a structure mistake in your output variable, I fixed it: Try with this code:

Please, let me know if it works for you.

```javascript
import { eventsClient, EventIngestEventType } from "@dynatrace-sdk/client-classic-environment-v2";
import { execution } from "@dynatrace-sdk/automation-utils";

export default async function ({ executionId }) {
  // Step 1: Get workflow execution result
  const exe = await execution(executionId);
  const checkResult = await exe.result("check_logs");

  // Step 2: Inspect output structure
  // I made the change here!
  const output = checkResult?.result?.output[0];
  const dimensions = output?.dimensions || [];

  console.log("Full dimensions:", JSON.stringify(dimensions, null, 2));

  // Step 3: Extract potentialAlerts from dimensions
  const potentialAlertDim = dimensions.find(dim => dim.key === "potentialAlerts");
  console.log("Raw potentialAlertDim:", potentialAlertDim);

  const potentialAlerts = parseInt((potentialAlertDim?.value || "0").trim(), 10);
  console.log("Parsed potentialAlerts:", potentialAlerts);

  // Step 4: If alert count > 0, send a custom event
  if (potentialAlerts > 0) {
    const hostDimension = dimensions.find(dim => dim.key === "dt.entity.host");
    const hostId = hostDimension?.value;

    if (hostId) {
      console.log(`Raising event on host: ${hostId}`);

      await eventsClient.createEvent({
        body: {
          eventType: EventIngestEventType.CustomAnnotation,
          title: "⚠️ Predicted Disk Capacity Alert",
          description: "Disk issue detected based on timeseries analysis",
          entitySelector: `type(HOST),entityId("${hostId}")`,
          properties: {
            "dt.entity.host": hostId,
            severity: "warning"
          },
          source: "workflow-automation"
        }
      });
    } else {
      console.log("Host ID not found in dimensions.");
    }
  } else {
    console.log("No potential alerts found.");
  }
};

```

 ![Screenshot 2025-07-10 090012.png](https://global.discourse-cdn.com/dynatrace/original/2X/4/48bef20d946787aef5ada97ac334adfbd56690a3.png)

---

<div class="post-metadata">

**Author:** ![Akhil-Jayendran](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/akhil-jayendran/32/153_2.png) [@Akhil-Jayendran](https://community.dynatrace.com/u/Akhil-Jayendran)\
**Post date:** [July 10, 2025, 6:18pm UTC](https://community.dynatrace.com/t/generating-problem-with-workflow-action-analyze-with-davis/52431/5 "2025-07-10T18:18:55Z")

</div>

Thank you so much &nbsp;[@Emm4nuel](https://community.dynatrace.com/user/85008)&nbsp; , it worked like a charm.
