Reading Data Collector Results

To read the results that a data collector has written into the metric database, you can use the javascript funtion 'GetMetricResults'.

Prerequisites:

  • An existing Data Collector
  • The Data Collector has collected some valid data.

If there is no Data Collector, you have to create one.

Instructions

1. Create a Report with a Stages Data Source and a Data Set

2. Add the Result Set Columns which you want to retrieve from your data collector.

Notice: The data collector automatically adds a column with the name 'CreationTime'. This column shows the data and time of the data collection.

3. Copy the Data Set Script from below into your Data Set.

4. Change the CollectorName variable to match with your collector name.

5. Add your column names in the array AllColumns.

Notice: The column CreationTime is always available.

function GetMetricResults(myMetric, myAllColumns, myCollectorName) {
 var metrics_collectors =
 myMetric.getEntities("containsCollector@SYSTEM");
 for (var j = 0; j <metrics_collectors.length; j++) {
 if (metrics_collectors[j].getProperty("Name")==myCollectorName) {
 var metrics_results =
 metrics_collectors[j].getEntities("containsResult@SYSTEM");
 for (var i = 0; i <metrics_results.length; i++) {
 for (var k = 0; k <AllColumns.length; k++) {
 dataset.setColumnValue(AllColumns[k],
 metrics_results[i].getProperty(AllColumns[k]));
 }
 dataset.storeResultRow();
 }
 }
 }
}
var CollectorName = "My First Collector";
var AllColumns = new Array("CreationTime","State", "DocumentName");
GetMetricResults(currentMetric, AllColumns, CollectorName);