Automations
All questions related to Workflow Automation, AutomationEngine, and EdgeConnect, as well as integrations with various tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Workflow

tmehta3
Visitor

Hello Community,

I am working on creating a Dynatrace workflow where I start with sample JSON data and need to convert that JSON into the BizEvents format so it can be ingested into Grail.

Could you please help me with the correct JavaScript structure for this conversion? Here’s the sample JSON I am working with and the code I have so far:

javascriptBecause  when i am ingesting and fetching bizevents through DQL  I am getting No records found in the dashboards
The approach I have used is - Trigger->Javascript->Ingest Business events
 
function main() {
  // Sample JSON data
  const data = {
    requestId: "12345",
    dateTime: "2024-04-22T14:30:00.000Z",
    totalProxies: 100,
    proxyList: [
      {
        proxyName: "ddd",
        environment: "hhh",
        revision: 1,
        created: "2024-04-22T14:30:00.000Z",
        lastModified: "2024-04-22T14:30:00.000Z",
        basePath: "/basePath",
        deployState: true,
        TargetServer: ["Server1", "Server2"],
        targetEndpoint: ["/Service1", "/Service2"],
        sharedFlows: ["sgg", "sgg"]
      }
    ]
  };

  // Convert each proxy into a BizEvent
  return data.proxyList.map(proxy => ({
    "event.provider": "apigee",
    "event.type": "apigee.proxy.metadata",
    "event.category": "inventory",
    attributes: {
      bucket: "test-poc",   // custom marker
      requestId: data.requestId,
      dateTime: data.dateTime,
      totalProxies: data.totalProxies,
      proxyName: proxy.proxyName,
      environment: proxy.environment,
      revision: proxy.revision,
      created: proxy.created,
      lastModified: proxy.lastModified,
      basePath: proxy.basePath,
      deployState: proxy.deployState,
      targetServers: proxy.TargetServer,
      targetEndpoints: proxy.targetEndpoint,
      sharedFlows: proxy.sharedFlows
    }
  }));}
 

🔹 My Questions

  1. Is this the correct way to structure BizEvents JSON in a workflow JavaScript step?

  2. Do I need to add or change any mandatory fields for Grail ingestion?

  3. Are there best practices for handling multiple proxies in the array (e.g., batching vs individual events)?

Thanks in advance for your guidance!

7 REPLIES 7

AntonPineiro
DynaMight Guru
DynaMight Guru

Hi,

Since you are in Managed... Are workflows available in your environment?

Best regards

❤️ Emacs ❤️ Vim ❤️ Bash ❤️ Perl

Yes workflows are available in my environment . I am working on staging now 

Hi,

I was not aware workflows were available in Managed environment... Are you in SaaS?

Best regards

❤️ Emacs ❤️ Vim ❤️ Bash ❤️ Perl

It is definitely SaaS. Workflows are SaaS only feature.

Dynatrace Ambassador | Alanata a.s., Slovakia, Dynatrace Master Partner

Hi,

I have just moved this thread to "Automations" thread instead of Managed.

Best regards

❤️ Emacs ❤️ Vim ❤️ Bash ❤️ Perl

Julius_Loman
DynaMight Legend
DynaMight Legend

@tmehta3 I'm not sure what issue you are trying to solve. Maybe a different option of raising business events - (in OpenPipeline) may fit your case better. Be aware that workflows have some execution limitations and you may run in throttling issues if your workflow is executed too often.

For an example to raise a bizevent from JavaScript in the platform, see https://developer.dynatrace.com/develop/sdks/client-classic-environment-v2/#businesseventsclient (example included).
As then it comes to the data:

Dynatrace Ambassador | Alanata a.s., Slovakia, Dynatrace Master Partner

michiel_otten
Champion

Hi there,

I've checked this on my own demo environment, I am able to ingest this event via:



/*
* This function will run in the DYNATRACE JavaScript runtime.
* For information visit https://dt-url.net/functions-help
*/
import { businessEventsClient } from '@dynatrace-sdk/client-classic-environment-v2';

export default async function () {

  // Sample JSON data
  const data = {
    requestId: "12345",
    dateTime: "2024-04-22T14:30:00.000Z",
    totalProxies: 100,
    proxyList: [
      {
        proxyName: "ddd",
        environment: "hhh",
        revision: 1,
        created: "2024-04-22T14:30:00.000Z",
        lastModified: "2024-04-22T14:30:00.000Z",
        basePath: "/basePath",
        deployState: true,
        TargetServer: ["Server1", "Server2"],
        targetEndpoint: ["/Service1", "/Service2"],
        sharedFlows: ["sgg", "sgg"]
      }
    ]}

  console.log(data);


  // Convert each proxy into a BizEvent
  const mapEvent =  data.proxyList.map(proxy => ({
    "event.provider": "apigee",
    "event.type": "apigee.proxy.metadata",
    "event.category": "inventory",
    "attributes": {
      bucket: "test-poc",   // custom marker
      requestId: data.requestId,
      dateTime: data.dateTime,
      totalProxies: data.totalProxies,
      proxyName: proxy.proxyName,
      environment: proxy.environment,
      revision: proxy.revision,
      created: proxy.created,
      lastModified: proxy.lastModified,
      basePath: proxy.basePath,
      deployState: proxy.deployState,
      targetServers: proxy.TargetServer,
      targetEndpoints: proxy.targetEndpoint,
      sharedFlows: proxy.sharedFlows
    }
  }));
  console.log(mapEvent)

businessEventsClient
  .ingest({
    body: mapEvent,
    type: 'application/json',
  })
  .then(() => console.log('Event ingested'))
  .catch((e) => console.error('Failed to ingest event: ' + e));
  
}


The event pops up in my environment, could you verify whether you are doing the same steps?

michiel_otten_0-1778659090419.png

 

#Performance matter!

Featured Posts