# WLOC Administration Console Online Help

# Define custom metrics

Before you begin

Review Define and assign policies.

To define a custom metric:

1. Access the Constraints page in one of the following ways:
   - Click the Policies tab in the WLOC navigation bar, click the Definitions tab, and click the Rules tab.
   - Click the Home tab in the WLOC navigation bar and click Rule Definitions under Manage Policies.

   The list of currently defined constraints is displayed in the Rules table.

2. Click Add Policy Definition.
3. Set the fields for the constraint, as required:

   Field | Description
   --- | ---
   Name | Name of the constraint.
   Type | Select Based on the value of an attribute or function.

4. Click Next.
5. Set the additional fields for the constraint, as described in Define constraints, but leave the Instance Name, Instance Type, and Attribute fields blank.
6. Click Define Custom.
7. Set the fields for the custom constraint.

   Field | Description
   --- | ---
   Function | Function used for the custom constraint (described below).
   Metric | MBean attribute or scalar values required by the specified function. The number of fields displayed depends on the function selected. Use the following format when entering MBean attributes: `[instance-type|instance-name|attribute-name]` Where: `instance-type`: MBean type. For example, `weblogic.management.runtime.ServerRuntimeMBean`. `instance-name`: Name of the MBean. For example: `com.bea:Name=ManagedServer1,Type=ServerRuntime`. For a collection, you might specify the name using a wildcard (*): `com.bea:Name=*,Type=ServerRuntime` `attribute-name`: Name of the MBean attribute. For example: `State`. If you want the metric to appy to multiple instances, you can specify `.*` for `instance-name`. For more information about the MBean attributes, see WebLogic Server MBean Reference. For example: `[weblogic.management.runtime.ServerRuntimeMBean|.*|RestartsTotalCount]` Click Browse to browse the list of MBeans and select the attribute. Note: Attributes with complex types are not valid for selection.

   The following table summarizes the available functions for custom constraints.

   Property | Description
   --- | ---
   Abs(x) | Absolute value of the specified attribute.
   Difference(x, y) | Difference between two attributes (x-y).
   DifferenceWithScalar(x, s) | Difference between the specified attribute and a scalar value (x-s).
   HighModeOfCollection(c) | Highest value that occurs most frequently in the collection of attributes. For example, if the returned values are 1 2 3 3 4 5 5 6 7, the function returns 5.
   Inverse(x) | Inverse value of an attribute (1/x).
   LowModeOfCollection(c) | Lowest value that occurs most frequently in the collection of attributes. For example, if the returned values are 1 2 3 3 4 5 5 6 7, the function returns 3.
   Max(x) | Maximum observed value for the attribute.
   MaxOfCollection(c) | Maximum observed value for the collection.
   MeanOfCollection(c) | Statistical average observed value for the collection.
   MedianOfCollection(c) | Statistical median observed value for the collection.
   MinOfCollection(c) | Minimum observed value for the collection.
   Negative(x) | Negative value of the attribute.
   Over(x,s) | Upper threshold value (s) for specified attribute. If the value of x is greater than s, then the function returns 1. Otherwise, the function returns 0.
   OverMetric(x,y) | Upper threshold attribute value (y) for specified attribute. If the value of x is greater than s, then the function returns 1. Otherwise, the function returns 0.
   Product(x,y) | Product of the specified attributes (x*y).
   ProductWithScalar(x,s) | Product of the specified attribute and scalar values (x*s).
   Ratio(x,y) | Ratio of the specified attributes (x/y).
   RatioWithScalar(x,s) | Ratio of the specifed attribute and scalar values (x/s).
   Size(c) | Number of values in the collection.
   StandardDeviationOfCollection(c) | Standard deviation of attributes in the collection.
   Sum(x,y) | Sum of the specified attributes (x+y).
   SummationOfCollection(c) | Sum of the collection of attributes.
   SumWithScalar(x,s) | Sum of the specified attribute and scalar values (x+s).
   Under(x,s) | Lower threshold value (s) for specified attribute. If the value of x is greater than s, then the function returns 1. Otherwise, tjhe function returns 0.
   UnderMetric(x,y) | Lower threshold value (y) for specified attribute. If the value of x is greater than s, then the function returns 1. Otherwise, the function returns 0.

8. Click Finish.

   The constraint type is added and the following confirmation message is displayed:

       New policy created successfully

After you finish

- Modify constraints.
- Create actions and set up action pipelines to run when policy rules are violated, as described in Define actions and Define action pipelines.