31 May 2024 01:34 PM
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:
Expected result:
Thank you
03 Jun 2024 09:25 AM
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