Predicates
A predicate limits the number of streams in the returned series.
A predicate can take one of the following forms:
-
time_series_attribute
operator
value, where
- time_series_attribute is one of the supported attributes.
-
operator is one of = and
rlike
-
value is an attribute value
subject to the following constraints:
- For attributes values that contain spaces or values of
attributes of the form
xxxName
such asdisplayName
, use quoted strings. - The value for the
rlike
operator must be specified in quotes. For example:hostname rlike "host[0-3]+.*"
. - value can be any regular expression as specified in regular expression constructs in the Java Pattern class documentation.
- For attributes values that contain spaces or values of
attributes of the form
-
scalar_producing_function(metric_expression) comparator number
, where-
scalar_producing_function is
any function that takes a time series and produces a scalar. For example,
min
ormax
. -
metric_expression is a valid
metric expression. For example,
total_cpu_user + total_cpu_system
. -
comparator is a comparison
operator:
<
,<=
,=
,!=
,>=
,>
. -
number is any number
expression or a number expression with units. For example,
5
,5mb
,5s
are all valid number expressions. The valid units are:- Time -
ms
(milliseconds),s
(seconds),m
(minutes),h
(hours), andd
(days). - Bytes -
b
(bytes),kb
orkib
(kilobytes),mb
ormib
(megabytes),gb
orgib
(gigabytes),tb
ortib
(terabytes), andpb
orpib
(petabytes) - Bytes per second - Bytes and Time:
bps
,kbps
,kibps
,mbps
,mibps
, and so on. For example, 5 kilobytes per second is5 kbps
. - Bytes time - Bytes and Time combined:
bms
,bs
,bm
,bh
,bd
,kms
,ks
, and so on. For example, 5 kilobytes seconds is5 ks
or5 kis
.
- Time -
-
scalar_producing_function is
any function that takes a time series and produces a scalar. For example,
You use the AND
and OR
operators to compose
compound predicates.
Example Statements with Compound Predicates
- Retrieve all time series for all metrics for DataNodes or TaskTrackers.
select * where roleType=DATANODE or roleType=TASKTRACKER
- Retrieve all time series for all metrics for DataNodes or TaskTrackers that are
running on host named "myhost".
select * where (roleType=DATANODE or roleType=TASKTRACKER) and hostname=myhost
- Retrieve the
total_cpu_user
metric time series for all hosts with names that match the regular expression "host[0-3]+.*"select total_cpu_user where category=role and hostname rlike "host[0-3]+.*"
Example Statements with Predicates with Scalar Producing Functions
- Return the entities where the last count of Java VM garbage collections was
greater than 10:
select jvm_gc_count where last(jvm_gc_count) > 10
- Return the number of open file descriptors where processes have more than 500Mb
of
mem_rss
:select fd_open where min(mem_rss) > 500Mb