A MetricsElement object represents an element on the Operations Center server under the Experience Manager_adapter represents the Experience Manager adapter name.
branch whereString[] elementKeys: (Required) The elementKeys array holds the element’s hierarchy relative to
.String condition: The condition (OK, MAJOR, CRITICAL, and so on) to assign to this element. If set, the value must one of the constants described in metrics.constants Severities.
String message: The title bar message for this element (aka description).
SeriesData[] seriesData: Array of time points to record with this element.
java.util.Map properties: Values to be exposed on the element’s
.Boolean isPropertySetComplete: This indicator impacts how properties are applied to a preexisting element.
String toString(): Returns a String representation of this object.
Boolean isValid(): Returns True if object contains all required data and all provided data is valid. If False is return, the logs include details of the error.
A MetricsElement object represents an element on the Operations Center server under the elementKeys ['Page Stats', 'Home Page'], then the MetricsElement object creates or updates .
branch. When a MetricsElement object is received by the Experience Manager adapter on the Operations Center server, the MetricsElement data is used to create or update the Operations Center Element. The elementKeys property specifies the relative path from . So, if you specifyIt is not necessary to create “Page Stats” prior to creating “Home Page”; if a nonexistent element is referenced in the element hierarchy, it is created automatically. The condition and message properties are used to update the corresponding fields on the Operations Center element.
The seriesData property is used to capture metric data that you wish to record over time. When you select the
tab for the element you have created, any series data types you have populated should show in the panel of the display.The properties property is used to populate the metrics properties page (right-click 'elem.properties.put('somePropertyName', null);'). Alternatively, if you set isPropertySetComplete to True, then any properties not included in the MetricsElement object is removed.
> ) for the element. After a metrics property has been added to an element, it remains there until the element has been removed, or the property is deleted. To delete a property, you can set its value to null (for example,var collector = metrics.createSummaryCollector('Page Stats', 60000, processPageStats); collector.groupingFieldNames=[metrics.constants.FN_PAGE_TITLE]; var targetRange = metrics.createResponseTimeRange('target', 0, 1500); var acceptRange = metrics.createResponseTimeRange('accept', 1500, 4000); var problemRange = metrics.createResponseTimeRange('problem', 4000, 60000); collector.ranges=[targetRange,acceptRange,problemRange]; // ... add other collector props and deploy /* * Process reports generated by the Page Stats collector */ function processPageStats(reports) { for(var i=0; i < reports.length;i++) { var report = reports[i]; // create element and automatically map stats into series data. var elem = metrics.createMetricsElement() elem.elementKeys=[report.key.collectorName, report.key.groupValues[0]]; assignConditonAndMessage(elem, report); elem.seriesData = createSeriesEntries(report); elem.properties.put('Reference URL', report.lastEvent.URL); elem.properties.put('Page Title', report.lastEvent.title); elem.properties.put('Hit Count', report.overall.count); // mine other properties .. metrics.sendMetricsElement(elem); } } /* * calculate element condition based on relative hit count */ function assignConditonAndMessage(elem,report) { var targetHits = getRangeHitCount(report,'target'); var acceptHits = getRangeHitCount(report,'accept'); var problemHits = getRangeHitCount(report,'problem'); if(targetHits > acceptHits + problemHits) { elem.condition=metrics.constants.SEV_OK; elem.message = 'Performance target achieved'; } else if (targetHits > problemHits || acceptHits > problemHits) { elem.condition = metrics.constants.SEV_MINOR; elem.message = 'Performance acceptable'; } else if (targetHits + acceptHits > problemHits) { elem.condition = metrics.constants.SEV_MAJOR; elem.message = 'Performance degraded'; } else { elem.condition = metrics.constants.SEV_CRITICAL; elem.message = 'Performance violation'; } elem.message += ': T=' + targetHits + ' A='+ acceptHits + ' P=' + problemHits; } /* * Return hit count if range has data, or 0 if it does not */ function getRangeHitCount(report, rangeName) { var hitCount = 0; var rangeStats = report.rangeStats.get(rangeName); if(rangeStats != null) { hitCount = rangeStats.count; } return hitCount; } /* * Create Series entries for this report */ function createSeriesEntries(report) { var seriesData = new Array(); var avg=metrics.createSeriesData(); avg.name = 'Overall:Avg'; avg.timestamp = report.stopTime; avg.value = report.overall.average; seriesData.push(avg); seriesData.push(metrics.createSeriesData('Overall:Max', report.stopTime,report.overall.high)); seriesData.push(metrics.createSeriesData('Overall:Min', report.stopTime,report.overall.low)); seriesData.push(metrics.createSeriesData('Overall:Count', report.stopTime,report.overall.count)); var iterator = report.rangeStats.entrySet().iterator(); while(iterator.hasNext()) { var mapEntry = iterator.next(); var rangeName = mapEntry.getKey(); var rangeStats = mapEntry.getValue(); seriesData.push(metrics.createSeriesData(rangeName +':Avg', report.stopTime,rangeStats.average)); seriesData.push(metrics.createSeriesData(rangeName +':Max', report.stopTime,rangeStats.high)); seriesData.push(metrics.createSeriesData(rangeName +':Min', report.stopTime,rangeStats.low)); seriesData.push(metrics.createSeriesData(rangeName +':Count', report.stopTime,rangeStats.count)); } return seriesData; }