cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problems from Multiple enviroments

RPbiaggio
Helper

Guys, how are you? I need to consolidate the problems of the 12 tenants we have into a single dashboard. I am using the code below, however, the list of problems in the table is not returning as expected. I need the return to be direct all problems and not the records, type and metadata fields. Does anyone have any idea what could be done to achieve this result?

import { credentialVaultClient } from "@dynatrace-sdk/client-classic-environment-v2";

// 1 authentication against SSO
async function authenticateToDynatrace(clientId = '', clientSecret = '' ) {
  const scopes = [
        "environment-api",
        "storage:buckets:read",
        "storage:bizevents:read",
        "storage:logs:read",
        "storage:metrics:read",
        "storage:entities:read",
        "cloudautomation:events:read",
        "cloudautomation:logs:read",
        "storage:events:read"
      ].join(" ")

  const { access_token } = await fetch("https://{environmentid}.apps.dynatrace.com/platform/storage/query/v1/query:execute?enrich:metric-metadata",
    "https://{environmentid}.apps.dynatrace.com/platform/storage/query/v1/query:execute?enrich:metric-metadata",

  ];
  const query = `
fetch events, from:now()-48h 
| filter event.kind == "DAVIS_PROBLEM"
| fieldsAdd entity_tags
| expand entity_tags
| parse entity_tags, """ "Jornada:" DATA:Jornada """
| parse entity_tags, """ "Serviço Negócio:" DATA:ServicoNegocio """
| parse entity_tags, """ "Canal:" DATA:Canal """
| parse entity_tags, """ "Etapa:" DATA:Etapa """
| parse entity_tags, """ "Fluxo:" DATA:Fluxo """
| fieldsAdd affected_entity_types
| filter dt.davis.is_duplicate == false
| sort timestamp desc
  | summarize {problem = takeFirst( record(timestamp, event.id, event.start, event.status, entity_tags) )}, by:{ display_id} 
  | fieldsFlatten problem 
| fieldsAdd currentTime = toTimestamp(now())
| fieldsAdd status = if((problem.event.status == "ACTIVE"),"OPEN", 
                else:if((problem.event.status == "CLOSED"), "CLOSED"))
| filter status == "OPEN"`;
  const combinedResult = await fetchMultipleURLs(credentialId, urls, query);
  return combinedResult;
}


Retorno da query:

RPbiaggio_1-1717158782643.png

 

Expected result:

RPbiaggio_2-1717158818893.png

Thank you

 



1 REPLY 1

Hi @RPbiaggio ,

 

It seems that function "fetchMultipleURLs" concatenates your query results in that unwanted format. 

Can you show source code of that function?

 

Bests

Michal

Featured Posts