Oracle Enterprise Manager Ops Center expression query language is an advanced feature that enables you to build query object constraints and create customized expression monitoring rules. See Adding Monitoring Rules for more information about monitoring rules. See the Oracle® Enterprise Manager Ops Center Tuning Monitoring Rules and Policies Guide for examples of how to tune the default rules that are provided with the software and how to add new rules.
The expression query language is mainly used to define monitoring rules and to check if an asset attribute verifies a given condition. The query language is closely modeled on the WHERE
clause of SQL SELECT
statements.
This section contains the following information:
Asset monitoring attributes vary by asset type. The asset types and corresponding attributes are available in the API Javadocs that are part of the SDK package. The package installs the Javadocs in the /opt/sun/xvm/sdk/xvm_oc/doc/javadoc/
directory. Open the Javadoc file to view all attributes and classes.
The classes corresponding to the asset types are located in the com.sun.hss.type
package and subpackages. The following are a few of the classes representing the asset types that you can use to create expression monitoring rules and some of the attributes available for monitoring:
com.sun.hss.type.os.OperatingSystem
com.sun.hss.type.server.Server
com.sun.hss.type.servercontainer.ServerContainer
com.sun.hss.type.virtserver.VirtServer
com.sun.hss.type.virtserver.VirtServerContainer
For each class, you can deduce the attributes that the software can monitor by looking for the getter methods defined by the class. Those are the methods whose names start with get or is and which take no parameters. The name of the attribute corresponding to a method is built by removing the get or is prefix from the method name. For example, the OperatingSystem
class defines a method named getCpuUsage
, as follows:
@Description(value="CPU Usage information")
CpuUsage getCpuUsage()
The name of corresponding attribute name is CpuUsage
.
The return type of the method describes the attribute type. To find the subfields of the attributes that the software can monitor, navigate to the definition of the corresponding class. The name of the subfields are also deduced from the getter methods defined on the attribute type class. Given the name of a getter method, you can deduce the subfield name by removing the get or is prefix and by setting the next letter to lower case. Following the previous example, when you navigate to the javadoc of the CpuUsage class, you will find the following getter method:
@ValueInfo(metricType="gauge",
thresholdRising=true,
units="%",
minValue="0",
maxValue="100")
public float getUsagePercentage()
This means the subfield is named usagePercentage. The complete attribute / subfield name that you can use in a monitoring rule is CpuUsage.usagePercentage
.
The following are some lexical elements:
Attribute names are case sensitive.
Keywords, such as and
, like
, and between
, are not case sensitive.
Use double quotes to access an attribute whose name, ignoring case, is the same as one of these keywords: not
, instanceof
, like
, true
, or false
. For example, "not"
. You can use double quotes to include non-identifier characters in the name of an attribute. For example, "attribute-name-with-hyphens". To include the double quote character in the attribute name, write it twice. "foo""bar""baz"
represents the attribute called foo"bar"baz
.
String constants are written with single quotes, for example 'this'
. A single quote within a string constant must be doubled, for example 'can''t'
.
Integer constants are written as a sequence of decimal digits, optionally preceded by a plus or minus sign. An integer constant must be a valid input to Long.valueOf(String)
.
Floating-point constants are written using the Java syntax. A floating-point constant must be a valid input to Double.valueOf(String)
.
A boolean constant is either true or false, ignoring case.
Spaces cannot appear inside identifiers (unless written with double quotes), keywords, or multi-character tokens, such as <=
. Spaces can appear anywhere else, but are not required except to separate tokens. For example, you can write the query a < b and 5 =c as a<b and 5=c
, but you cannot remove any other spaces.
andquery [OR query]
predicate [AND andquery]
( query ) |
NOT predicate |
INSTANCEOF stringvalue |
LIKE objectnamepattern |
value predrhs
compare value |
[NOT] BETWEEN value AND value |
[NOT] IN ( value commavalues ) |
[NOT] LIKE stringvalue
[ , value commavalues ]
= | < | > | <= | >= | <> | !=
factor [plusorminus value]
+ | -
term [timesordivide factor]
* | /
attr | literal | ( value )
name [# name]
name:
identifier [.name]
Java-identifier | double-quoted-identifier
booleanlit | longlit | doublelit | stringlit
FALSE | TRUE
stringlit
stringlit
Table G-1 describes the grammar semantics and defines a function q that maps a string to a Java object, such as a QueryExp
or a ValueExp
.
String s | q(s) |
---|---|
query1 OR query2 |
Query.or(q(query1), q(query2)) |
query1 AND query2 |
Query.and(q(query1), q(query2)) |
( queryOrValue ) |
q(queryOrValue) |
NOT query |
Query.not(q(query)) |
INSTANCEOF stringLiteral |
Query.isInstanceOf(Query.value(q(stringLiteral))) |
LIKE stringLiteral |
new ObjectName(q(stringLiteral)) |
value1 = value2 |
Query.eq(q(value1), q(value2)) |
value1 < value2 |
Query.lt(q(value1), q(value2)) |
value1 > value2 |
Query.gt(q(value1), q(value2)) |
value1 <= value2 |
Query.leq(q(value1), q(value2)) |
value1 >= value2 |
Query.geq(q(value1), q(value2)) |
value1 <> value2 |
Query.not(Query.eq(q(value1), q(value2))) |
value1 != value2 |
Query.not(Query.eq(q(value1), q(value2))) |
value1 BETWEEN value2 AND value3 |
Query.between(q(value1), q(value2), q(value3)) |
value1 IN ( value2, value3) |
Query.in(q(value1), new ValueExp[] { q(value2), q(value3)}) |
value1 NOT IN ( value2, value3 ) |
Query.not(Query.in(q(value1), new ValueExp[] { q(value2), q(value3)})) |
value LIKE stringLiteral |
Query.match(q(value), translateWildcards(q(stringLiteral))) |
value NOT LIKE stringLiteral |
Query.not(Query.match(q(value), translateWildcards(q(stringLiteral)))) |
value1 + value2 |
Query.plus(q(value1), q(value2)) |
value1 - value2 |
Query.minus(q(value1), q(value2)) |
value1 * value2 |
Query.times(q(value1), q(value2)) |
value1 / value2 |
Query.div(q(value1), q(value2)) |
name |
Query.attr(q(name)) |
name1#name2 |
Query.attr(q(name1), q(name2)) |
FALSE |
Query.value(false) |
TRUE |
Query.value(true) |
decimalLiteral |
Query.value(Long.valueOf(decimalLiteral)) |
floatingPointLiteral |
Query.value(Double.valueOf(floatingPointLiteral)) |
The translateWildcards
function translates from the SQL notation for wildcards, using %
and _
, to the API notation using *
and ?
. If the LIKE
string already contains a *
or ?
, these characters have their literal meanings, and are quoted in the call to Query.match
.
The formal specification of the language is described in Lexical Elements. The attributes are located in the javadocs.
This section provides some informal examples.
Message = 'OK'
Message = 'OK'
is verified if the Message
attribute is the string 'OK'
.
Message like 'OK: %'
Message
attribute whose value is a string beginning with "OK: "
. The wildcard characters are the same as in SQL. In the query language, percent character means any sequence of characters and the underscore character means any single character.
FreeSpacePercent < 10
TheFreeSpacePercent
attribute whose value is a number less than 10.
FreeSpacePercent < 10 and WarningSent = false
Uses the same attribute as the previous example, but includes a boolean attribute WarningSent
whose value is false.
SpaceUsed > TotalSpace * (2.0 / 3.0)
SpaceUsed
and TotalSpace
attributes where the first is more than two-thirds the second.
not (FreeSpacePercent between 10 and 90)
FreeSpacePercent
attribute whose value is not between 10 and 90, inclusive.
FreeSpacePercent not between 10 and 90
Another way of writing the previous query.
Status in ('STOPPED', 'STARTING', 'STARTED')
Status attribute whose value is one of those three strings.
Example G-1 Root Disk and CPU Usage
Example G-1 is an expression that will raise an alert when the root disk is above 80% and the CPU usage is above 10.
FileSystemUsages.name="/".usedSpacePercentage >= 80) AND (CpuUsage.usagePercentage >= 10
Example G-2 Root Disk and System Load
Example G-2 is an expression that will raise an alert when the root disk is above 80% and the system load is above 15.
FileSystemUsages.name="/".usedSpacePercentage >= 70) AND (SystemLoad.average1Minute >= 15