FieldFilter

A FieldFilter object is used to include or exclude an HVEvent based on the value of one of its fields.

Properties

  • String name: (Required) Name of the filter.

  • String fieldName: (Required) Name of the field the filter operates on.

Methods

  • isValid(): Returns True if all fields are populated and the regex field contains a valid regular expression.

    If False is returned, the scripting log contains a description of the failure.

  • toString(): Returns a string representation of this object.

Description

A FieldFilter object is used to include or exclude an HVEvent based on the value of one of its fields. All fields in this object are required. In addition, the regex field must contain a valid regular expression as described here:

http://java.sun.com/javase/6/docs/api/java/util/regex/Pattern.html.

The fieldName value is normally one of standard field names described in metrics.constants Field Names. However, custom field names created with a FieldXform can be used. HVEvents not containing a value in the field specified by fieldName never match the filter.

Example

var appsCollector = metrics.createSummaryCollector();

var testFilter = metrics.createFieldFilter();
testFilter.name = 'testFilter';
testFilter.fieldName = metrics.constants.FN_APPLICATION_NAME;
testFilter.regex = 'TEST.*';
if(testFilter.isValid())
{
   appsCollector.exclusionFilters=[testFilter]; //exclude test events
}
else
{
  bem.logWarning('Test filter not valid:' + testFilter.toString());
}