Expression Basics


CloudMonix determines when alerts and actions need to execute by evaluating expression formulas that comprise the core of alert or action logic.  Expressions are comparison statements that evaluate conditions of captured metrics and result in a boolean value.  When evaluated value is TRUE alert or action is marked as ON.  When evaluated value is FALSE, alert or action is marked as OFF.  When an error occurs evaluating the expression, alert or action is generally ignored and expression's previous value remains active.

Expressions are also used when filtering data within Aggregated metrics.  Concept is the same.  Aggregate filters throw away metrics that do not match the filter's boolean condition.


Expressions allow for comparisons of metrics, can use combinations of multiple conditions, and generally behave like comprehensive boolean statements from C#.  In fact, expression evaluation engine is powered by Dynamic Espresso, a .NET library that is capeable of evaluating sophisticated expressions. 


Metrics are used as variables in expressions and can be used directly.  Certain variables, such as dates (ie: CheckTimeUtc) can be accessed by addressing their properties, ie: CheckTimeUtc.Month or CheckTimeUtc.Minute




Expressions Examples


  • Cpu > 70   -- (evaluates to true when metric Cpu is grater than 70)
  • (Queue1Length + Queue2Length) > 100 && CheckTimeUtc.Hour > 9 && CheckTimeUtc.Hour < 17  -- (evaluates to true between 9am and 5pm UTC, if depth of both queues Q1 and Q2 exceed 100 messages combined)
  • 1 == 1   -- (always is evaluated to true)
  • Status == "Ready"  -- (evaluates to true when Status metric is "Ready")
  • Contains(SomeTextMetric, "Error")   -- (evaluates to true if SomeTextMetric contains inside itself string "Error".  Contains is case-insensetive)



Evaluating data in sets\arrays (advanced)


CloudMonix is capable of evaluating data in arrays/sets of collected metric data against custom critera.  This is useful when trying to alert on data found in Event Logs, running Processes, subscriptions of Azure Service Bus Topic, etc.

Metrics that are displayed in grids when highlighted on dashboard are considered to be array-based metrics.  Set of CloudMonix-specific functions exist that can aggregate data in these metrics and present an expression with a single result.  

Functions are: Any, All, None, and Count

Syntax is as follows FunctionName(metric, "subcondition expression").  


Example 1

A metric that is capturing application event logs is called AppLogs.  By observing columns in the ApplicationEventLogs grid it can be seen that a Message property contains description of the event. Alerting on an expression that parses thru Message and looking for a substring "Exception" will yield a proper alert:

   

Any(ApplicationEventLogs, "Contains(Message,\"Exception\")")

   

Notice that subcondition expression supports Contains function but needs to have string constants be specified with escaped quotes.


Example 2

A metric that is capturing service bus topic details is called Topic1Details.  This metric contains 1 record per each subsrciption within the topic. By observing columns in the Topic1Details metric, it can be seen that Subscription property contains the name of the subscription and DeadLetters property contains number of dead letters within a particular subscription. Alerting on an expression that evaluates all subscriptions with Deadletters over 5 and that contain the word PROD in subscription name can be done as follows

  

Any(Topic1Details, "Contains(Subscription, \"PROD\") && DeadLetters > 5")

  



Supported Operators & Functions


Category Operators
Primary x.y a[x]
Unary + - !
Multiplicative * / %
Additive + -
Relational and type testing < > <= >=
Equality == !=
Conditional AND &&
Conditional OR ||
Conditional ?:
Assignment =
Aggregate Functions bool Any(array_variable,"sub-expression")
bool All(array_variable,"sub-expression")
int Count(array_variable,"sub-expression")
Text Comparison bool Contains(a,b)