You can enhance your super metrics by using clauses and resource entry aliasing.

Where Clause

The where clause verifies whether a particular metric value can be used in the super metric. Use this clause to point to a different metric of the same object, such as where=(${metric=metric_group|my_metric} > 0).

For example: count(${objecttype = ExampleAdapter, adaptertype = ExampleObject, metric = ExampleGroup|Rating, depth=2, where =($value==1})

IsFresh Function

Use the isFresh function in the where clause to check if the last value of the metrics is fresh or not.

For every metric published in VMware Aria Operations, the point with the latest publishing time is called as the last point of that metric. The value of that metric’s last point is called the last value of that metric. A metric’s last point is considered fresh when the time elapsed after the metric’s last point is lesser than the estimated publishing interval of that metric.

The isFresh function returns true if the last value of the metrics is fresh. For example, in the following scenarios, the function:
  • ${this, metric=a|b, where=($value.isFresh())}, returns the last value of the metric a|b if the last value is fresh.
  • ${this, metric=a|b, where=($value == 7 && $value.isFresh())}, returns the last value of the metric a|b if it is equal to seven and is fresh.
  • ${this, metric=a|b, where=(${metric=c|d} == 7 && ${metric=c|d}.isFresh())}, returns the last value of the metric a|b only if the last value of the metric c|d is equal to seven and is fresh.

Resource Entry Aliasing

Resource entries are used to retrieve metric data from VMware Aria Operations for computing super metrics. A resource entry is the part of an expression which begins with $ followed by a {..} block. When computing a super metric, you might have to use the same resource entry multiple times. If you have to change your computation, you must change every resource entry, which might lead to errors. You can use resource entry aliasing to rewrite the expression.

The following example, shows a resource entry that has been used twice.

(min(${adaptertype=VMWARE, objecttype=HostSystem, attribute= cpu|demand|active_longterm_load, depth=5, where=($value>=0)}) + 0.0001)/(max(${adaptertype=VMWARE, objecttype=HostSystem, attribute=cpu|demand|active_longterm_load, depth=5, where=($value>=0)}) + 0.0001)"

The following example shows how to write the expressing using resource entry aliasing. The output of both expressions is the same.

(min(${adaptertype=VMWARE, objecttype=HostSystem, attribute= cpu|demand|active_longterm_load, depth=5, where=($value>=0)} as cpuload) + 0.0001)/(max(cpuload) + 0.0001)"
Follow these guidelines when you use resource entry aliasing:
  • When you create an alias, make sure that after the resource entry you write as and then alias:name. For example: ${…} as alias_name.
  • The alias cannot contain the ()[]+-*/%|&!=<>,.?:$ special characters, and cannot begin with a digit.
  • An alias name, like all names in super metric expressions, is case-insensitive.
  • Use of an alias name is optional. You can define the alias, and not use it in an expression.
  • Each alias name can be used only once. For example: ${resource1,…} as r1 + ${resource2,…} as R1.
  • You can specify multiple aliases for the same resource entry. For example: ${…} as a1 as a2.

Conditional Expression ?: Ternary Operators

You can use a ternary operator in an expression to run conditional expressions.

For example: expression_condition ? expression_if_true : expression_if_false.

The result of the conditional expression is converted to a number. If the value is not 0, then the condition is assumed as true.

For example: -0.7 ? 10 : 20 equals 10. 2 + 2 / 2 - 3 ? 4 + 5 / 6 : 7 + 8 equals 15 (7 + 8).

Depending on the condition, either expression_if_true or expression_if_false is run, but not both of them. In this way, you can write expressions such as, ${this, metric=cpu|demandmhz} as a != 0 ? 1/a : -1. A ternary operator can contain other operators in all its expressions, including other ternary operators.

For example: !1 ? 2 ? 3 : 4 : 5 equals 5.