Functions

Overview

Functions are predefined procedures that calculate a value or perform a task. Functions are called by name with arguments passed in brackets and separated by comma. Function names are case-sensitive.

/* Returns true if the create_ms date is a working day. */
to_datetime(create_ms, 'US/Pacific').is_workday()

When invoked in expressions and placeholders, function definitions are replaced with the value returned by the function.

Functions can be referenced in a filter expression, user-defined variables, condition statements and placeholders.

  • Filter Expression:

    lower(tags.location) = 'nur'
    

    Filter expression cannot include statistical functions which require access to the window object.

  • Condition:

    avg() > 80
    
  • Placeholder:

    ${lookup('assets', entity)}
    

Arguments

The parameters passed to the function in brackets are called arguments.

Functions can accept arguments and return values in one of the following data types:

Notation Name Example
double double number percentile(99.5)
long long number elapsedTime(1515758392702)
integer integer number round(value, 1)
boolean boolean scriptOut('dsk.sh', [true])
string string startsWith(entity, 'NUR')
[] collection randomItem([1, 2, 3])
[string] collection of strings coalesce([tags.location, 'SVL'])
[k: v] key-value map randomKey(['john.doe': 0.8, 'mary.jones': 0.2])
object object rule_window('disk_check').status

Collection

Collection functions and operators check if the collection contains the specified element.

Database Message

Message functions retrieve message counts or specific messages from the database.

Database Series

Series functions retrieve series values from the database whereas the series can be different from the series in the current window.

Alert History

Database SQL

SQL functions return the results of user-defined SQL queries.

Date

Date functions perform various operations on dates, timestamps and intervals.

Distribution

Forecast

Forecast functions retrieve forecast values and variance from the database.

Formatting

These functions format dates and numbers to strings according to the specified pattern.

Lookup

Lookup functions retrieve records from replacement tables, collections, and other entities.

Mathematical

Math functions perform basic numeric operations on the input number and return a number as the result.

Portal

Portal functions allow attaching custom portals to email and outgoing webhooks.

Property

Property functions retrieve and compare property keys and tags.

Rule

The rule functions check the status of windows created by other rules.

Script

Execute the predefined script and return its output.

Security

Statistical

Univariate statistical functions listed below perform a calculation on the array of numeric values stored in the window.

Table

Text

Text functions transform and compare strings.

Utility

Value

Value functions retrieve values for other metrics contained in the same command.

Web Query

Web Query functions allow to perform requests to external web services.