Name
sn_app_insights.AnnotationsDataUtils
Description
No description available
Script
var AnnotationsDataUtils = Class.create();
AnnotationsDataUtils.prototype = {
initialize: function() {
this.INFO_SYMBOL = "info";
this.WARNING_SYMBOL = "exclamation";
this.ERROR_SYMBOL = "x";
},
/**
* @private
*
* @returns an object that contains configurations for the annotated events to be displayed
*/
_getAnnotationsConfig: function() {
var data = {};
data[this.INFO_SYMBOL] = this._createAnnotationConfig(this.INFO_SYMBOL, "#0E78C4");
data[this.WARNING_SYMBOL] = this._createAnnotationConfig(this.WARNING_SYMBOL, "#958B11");
data[this.ERROR_SYMBOL] = this._createAnnotationConfig(this.ERROR_SYMBOL, "#C83C36");
return data;
},
/**
* @private
* @param start start of the time window to retrieve diagnostic events
*
* @returns an array that contains the individual data points for the annotated events to display
*/
_getAnnotationsData: function(start) {
var data = [];
var counts = {};
counts[this.WARNING_SYMBOL] = 0;
counts[this.INFO_SYMBOL] = 0;
counts[this.ERROR_SYMBOL] = 0;
var diagnosticEvents = new GlideRecord("diagnostic_event");
diagnosticEvents.addQuery("reported_on", ">=", start);
diagnosticEvents.query();
while (diagnosticEvents.next()) {
var event = {};
var localTimeStamp = new GlideDateTime(diagnosticEvents.getDisplayValue('reported_on'));
event["x"] = localTimeStamp.getNumericValue();
event["header"] = diagnosticEvents.getValue("name") + ": " + diagnosticEvents.getValue("detail");
var systemId = diagnosticEvents.getValue('system_id') ? diagnosticEvents.getValue('system_id') : 'the instance';
event["message"] = "<p>" + gs.getMessage("Performed on {0} at {1}", [systemId, localTimeStamp.getValue()]) + "</p>";
var type;
switch (String(diagnosticEvents.severity)) {
case "Warning":
type = this.WARNING_SYMBOL;
++counts[this.WARNING_SYMBOL];
break;
case "Error":
type = this.ERROR_SYMBOL;
++counts[this.ERROR_SYMBOL];
break;
default:
type = this.INFO_SYMBOL;
++counts[this.INFO_SYMBOL];
}
event["type"] = type;
data.push(event);
}
return {
data: data,
counts: counts
};
},
/**
* @private
* @param symbol the symbol to use for the annotation
* @param color the color of the annotation symbol
*
* @returns an object that contains configuration for the annotation of the specified symbol and color
*/
_createAnnotationConfig: function(symbol, color) {
var data = {};
data["axis"] = "x";
data["symbol"] = symbol;
data["symbolColor"] = color;
return data;
},
type: 'AnnotationsDataUtils'
};
Sys ID
bf4f318e531130107ea5ddeeff7b1266