Skip to content

Commit bca23de

Browse files
committed
added new workflow logs function
1 parent f3db9a9 commit bca23de

File tree

4 files changed

+1430
-18
lines changed

4 files changed

+1430
-18
lines changed

experimental.js

Lines changed: 133 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ var nextUrl,formUrl;
3333
var finalCall;
3434
var loginStageCounter = 0;
3535
var vbid;
36+
var format;
3637
var flowuid;
3738
var payloaduid;
3839
var projectuid;
@@ -172,6 +173,16 @@ function workflowResubmit(instartOrResume, inStartDate,inEndDate, inProjectId,in
172173
loginPhase1();
173174
}
174175

176+
177+
function vbidAnalysis(inVbid, inFormat)
178+
{
179+
vbid = inVbid
180+
format = inFormat;
181+
finalCall = getVbidAnalysis;
182+
loginPhase1();
183+
}
184+
185+
175186
function debugMonitorInfo()
176187
{
177188
debug("Monitor Project: [" + projectName + "]");
@@ -229,6 +240,18 @@ function setHeaders()
229240
return headers;
230241
}
231242

243+
244+
function getVbidAnalysis()
245+
{
246+
247+
dbg.message("<EXPERIMENTAL>Getting VBID analysis [" + vbid + "]");
248+
var endPoint = "https://" + domainName + "/enterprise/v1/tenant/logs/" + vbid + "?field=created_at&direction=asc";
249+
debug("Next URL [" + endPoint + "]");
250+
var headers = setHeaders();
251+
rest.custom(endPoint,undefined,undefined,timeout,undefined,undefined,"GET",processVbidResponse,undefined,headers,true,false);
252+
253+
}
254+
232255
function checkResubmissions()
233256
{
234257
debug("Check Resubmissions")
@@ -357,6 +380,107 @@ function processFinalSingleResubmissionResponse(url,err,body,res){
357380
}
358381
}
359382

383+
384+
385+
function logsToCSV(logsJson){
386+
387+
var csv="ActivityId,ActivityLabel,ActivityType,Message,ActionDate,ElapsedMilliSeconds\n";
388+
var activityId, activityLabel,activityType, message, actype, actionDate, prevDate;
389+
var sep = ",";
390+
391+
for(var i=0;i<logsJson.output.objects.length;i++){
392+
dbg.message("<EXPERIMENTAL>"+"CSV Conversion [" + i + "]",4);
393+
activityId = logsJson.output.objects[i].activity_id;
394+
activityLabel = logsJson.output.objects[i].activity_label;
395+
activityType = logsJson.output.objects[i].type;
396+
message = logsJson.output.objects[i].message;
397+
actype = logsJson.output.objects[i].type;
398+
actionDate = logsJson.output.objects[i].updated_at;
399+
400+
if(activityType=="input")message="##DATA##";
401+
if(activityType=="output")message="##DATA##";
402+
if(activityType=="bill"){
403+
message="##DATA##";
404+
activityId = "bill";
405+
}
406+
if(activityLabel=="Logger")message="##DATA##";
407+
if(activityLabel===undefined)activityLabel=actype;
408+
activityLabel = "\"" + activityLabel + "\"";
409+
410+
activitId = "\"" + activityId + "\"";
411+
412+
413+
csv += activityId + sep + activityLabel + sep + activityType + sep + message + sep + actionDate + sep;
414+
if(i>0)
415+
{
416+
dbg.message("<EXPERIMENTAL>"+"CSV Conversion Calculating delta",4);
417+
var dateObjPrev = new Date(prevDate);
418+
var dateObjCurr = new Date(actionDate);
419+
var res = dateObjCurr.getTime() - dateObjPrev.getTime();
420+
csv += res;
421+
422+
}
423+
else
424+
{
425+
csv += 0;
426+
}
427+
csv += "\n";
428+
429+
prevDate = actionDate;
430+
}
431+
return csv;
432+
433+
}
434+
435+
function processVbidResponse(url,err,body,res){
436+
if(res.statusCode==200)
437+
{
438+
if(body.output.objects)
439+
{
440+
dbg.message("<EXPERIMENTAL>"+"Found Logs for - VBID",4);
441+
442+
var outputFormat = format.toUpperCase();
443+
444+
switch(outputFormat)
445+
{
446+
447+
case "JSON":
448+
dbg.message("<EXPERIMENTAL>"+"Outputting in JSON Format",4);
449+
if(prettyprint==true){
450+
dbg.message(JSON.stringify(body,null,4),-1);
451+
}
452+
else{
453+
dbg.message((JSON.stringify(body)),-1);
454+
}
455+
break;
456+
case "CSV":
457+
dbg.message("<EXPERIMENTAL>"+"Outputting in CSV Format",4);
458+
var csv = logsToCSV(body);
459+
dbg.message(csv,-1);
460+
break;
461+
462+
default:
463+
dbg.message("<EXPERIMENTAL>" + "Please provide a valid format - either JSON or CSV");
464+
break;
465+
}
466+
467+
468+
469+
}
470+
else{
471+
472+
dbg.message("<EXPERIMENTAL>"+ "Unable to find logs for VBID",1);
473+
}
474+
}
475+
else
476+
{
477+
dbg.message("<EXPERIMENTAL>"+"Failed to get logs for VBID",1)
478+
dbg.message(JSON.stringify(body),1);
479+
process.exit(99);
480+
}
481+
}
482+
483+
360484
function processSingleResubmissionResponse(url,err,body,res){
361485
if(res.statusCode==200)
362486
{
@@ -872,6 +996,12 @@ function loginResponse(url,err,body,res){
872996

873997
}
874998

875-
module.exports = {init,user,stages,projectWorkflows,projectFlowservices,connectorAccounts,
876-
getProjectAccountConfig,searchProject,getMonitorInfo,workflowResubmit,
877-
projectDeployments,messagingCreate,messagingStats,messagingDelete};
999+
module.exports = {init,
1000+
user,stages,
1001+
searchProject,
1002+
projectDeployments,
1003+
projectWorkflows,projectFlowservices,
1004+
connectorAccounts,getProjectAccountConfig,
1005+
getMonitorInfo,workflowResubmit,
1006+
messagingCreate,messagingStats,messagingDelete,
1007+
vbidAnalysis};

output.csv

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
ActivityId,ActivityLabel,ActivityType,Message,ActionDate,ElapsedMilliSeconds
2+
start,"Start",system,action started,2022-11-28T17:18:54.880Z,0
3+
start,"Start",system,action completed,2022-11-28T17:18:54.881Z,1
4+
c0,"condition",system,action started,2022-11-28T17:18:54.884Z,3
5+
c0,"condition",system,action completed,2022-11-28T17:18:54.886Z,2
6+
a2,"List Files/Folders",system,action started,2022-11-28T17:18:54.891Z,5
7+
a2,"List Files/Folders",input,##DATA##,2022-11-28T17:18:54.894Z,3
8+
a2,"List Files/Folders",output,##DATA##,2022-11-28T17:18:55.997Z,1103
9+
a2,"List Files/Folders",system,action completed,2022-11-28T17:18:55.997Z,0
10+
c1,"condition",system,action started,2022-11-28T17:18:55.998Z,1
11+
c1,"condition",system,action completed,2022-11-28T17:18:56.000Z,2
12+
a3,"Query JSON",system,action started,2022-11-28T17:18:56.002Z,2
13+
a3,"Query JSON",input,##DATA##,2022-11-28T17:18:56.004Z,2
14+
a3,"Query JSON",system,action completed,2022-11-28T17:18:56.027Z,23
15+
a3,"Query JSON",output,##DATA##,2022-11-28T17:18:56.027Z,0
16+
c8,"condition",system,action started,2022-11-28T17:18:56.029Z,2
17+
c8,"condition",system,action completed,2022-11-28T17:18:56.030Z,1
18+
a7,"Logger",system,##DATA##,2022-11-28T17:18:56.039Z,9
19+
t1,"null",output,##DATA##,2022-11-28T17:18:56.039Z,0
20+
a7,"Logger",activity,##DATA##,2022-11-28T17:18:56.041Z,2
21+
a7,"Logger",system,##DATA##,2022-11-28T17:18:56.043Z,2
22+
c9,"condition",system,action started,2022-11-28T17:18:56.045Z,2
23+
c9,"condition",system,action completed,2022-11-28T17:18:56.048Z,3
24+
a6,"Download FIle",system,action started,2022-11-28T17:18:56.050Z,2
25+
a6,"Download FIle",input,##DATA##,2022-11-28T17:18:56.052Z,2
26+
a6,"Download FIle",output,##DATA##,2022-11-28T17:18:56.778Z,726
27+
a6,"Download FIle",system,action completed,2022-11-28T17:18:56.778Z,0
28+
c10,"condition",system,action started,2022-11-28T17:18:56.779Z,1
29+
c10,"condition",system,action completed,2022-11-28T17:18:56.781Z,2
30+
a8,"Read File",system,action started,2022-11-28T17:18:56.782Z,1
31+
a8,"Read File",input,##DATA##,2022-11-28T17:18:56.784Z,2
32+
a8,"Read File",system,action completed,2022-11-28T17:18:56.787Z,3
33+
a8,"Read File",output,##DATA##,2022-11-28T17:18:56.788Z,1
34+
c18,"condition",system,action started,2022-11-28T17:18:56.793Z,5
35+
c18,"condition",system,action completed,2022-11-28T17:18:56.795Z,2
36+
a11,"publish",system,action started,2022-11-28T17:18:56.796Z,1
37+
a11,"publish",input,##DATA##,2022-11-28T17:18:56.799Z,3
38+
a11,"publish",system,action completed,2022-11-28T17:18:57.040Z,241
39+
a11,"publish",output,##DATA##,2022-11-28T17:18:57.041Z,1
40+
c17,"condition",system,action started,2022-11-28T17:18:57.044Z,3
41+
c17,"condition",system,action completed,2022-11-28T17:18:57.046Z,2
42+
a10,"Return Data on Sync Webhook",system,action started,2022-11-28T17:18:57.048Z,2
43+
a10,"Return Data on Sync Webhook",input,##DATA##,2022-11-28T17:18:57.050Z,2
44+
a10,"Return Data on Sync Webhook",system,action completed,2022-11-28T17:18:57.052Z,2
45+
a10,"Return Data on Sync Webhook",output,##DATA##,2022-11-28T17:18:57.052Z,0
46+
c14,"condition",system,action started,2022-11-28T17:18:57.053Z,1
47+
c14,"condition",system,action completed,2022-11-28T17:18:57.055Z,2
48+
stop,"Stop",system,action started,2022-11-28T17:18:57.056Z,1
49+
stop,"Stop",system,action completed,2022-11-28T17:18:57.057Z,1
50+
bill,"bill",bill,##DATA##,2022-11-28T17:18:57.136Z,79
51+

0 commit comments

Comments
 (0)