- About LogicMonitor
- Cloud Monitoring
- Dashboards and Widgets
- Getting Started
- LM Service Insight
- Rest API Developers Guide
- RPC API Developers Guide - Deprecated
- Servicenow CMDB Integration
- Terminology and Syntax
- Using Glob throughout your account
- Scripting Support
AppliesTo scripting is a method for selecting a set of LogicMonitor resources based on their properties. As discussed in Resource and Instance Properties, these properties may be assigned automatically via basic system information discovery or PropertySource execution, or they may be assigned manually.
As a proprietary LogicMonitor scripting language, AppliesTo scripting queries the resources that you have added into monitoring and returns those resources for which the expression evaluates to TRUE. AppliesTo scripting serves several purposes across LogicMonitor, including:
- Associating LogicModules with resources. AppliesTo scripting expressions, as entered into the Applies To field of a LogicModule definition, determine which resources a LogicModule (DataSource, PropertySource, EventSource, TopologySource, and so on) applies to. For a detailed explanation on how LogicMonitor associates LogicModules with resources, see How DataSources Get Applied to Resources.
- Dynamically grouping resources. As discussed in Device Groups Overview, AppliesTo scripting expressions are used to dynamically organize resources into groups.
- Applying custom resource dashboard templates to resources. AppliesTo scripting can be used to display custom resource dashboards for subsets of resources, as discussed in Graphs Tab.
- Returning resource counts for inclusion on dashboards. Various dashboard widgets including the Pie Chart widget and Big Number widget can be customized to return resource counts based on the results of an AppliesTo scripting query.
- Creating custom AppliesTo functions. As discussed in User-Defined AppliesTo Functions, AppliesTo scripting can be used to create custom AppliesTo functions for reuse across your platform.
AppliesTo Scripting Syntax
The majority of LogicMonitor’s out-of-the-box LogicModules feature AppliesTo expressions that require no customization. However, if you are updating/creating LogicModules, or if you are building AppliesTo expressions in other areas of the product, it’s important to understand how the scripting language operates.
Note: If you are updating an AppliesTo expression for the purpose of changing which resources a LogicModule is associated with, do so with extreme caution as all historical data collected by a LogicModule is lost upon disassociation. As best practice, always test AppliesTo scripting changes before updating the LogicModule definition, as discussed in the Building and Testing AppliesTo Statements section of this support article.
The following operators are available for use in AppliesTo expressions.
false() match all or no resources, respectively. As the
true() function will match every resource in your portal, use sparingly, if at all, and with caution. The
false() function can be useful to globally disable a LogicModule without deleting it (though be aware any historical data will be lost when a LogicModule is disassociated from a resource). The
false() function can also be used with a LogicModule under development to prevent it from being applied to any resources prematurely. Neither function accepts parameters.
LogicMonitor maintains a number of built-in functions to identify common categories of resources. Most of these functions inspect the
system.sysinfo property (which is populated via WMI (for Windows devices) or SNMP (for Linux, NetApp, Netscaler, Cisco)) and/or the
system.categories property (which is most typically populated by PropertySources, although it can be populated manually). Convenience functions do not accept parameters.
Functions that Operate on Arrays
While most resource properties, whether system or custom, are string or numeric type, there are several which are array type, notably:
There are specific AppliesTo functions for working with arrays.
This function returns TRUE if the specified string matches an array element. The match is a complete match on the search string, case insensitive. Regex is not supported.
Matches groups (dynamic and static) at the root of the Resources tree named “network”, “Network”, “nEtWoRk”, and so on.
system.groups property cannot be used in AppliesTo scripting expressions that are intended to dynamically organize resources into groups. As discussed in Device Groups Overview, if you wish to create a dynamic group that is dependent on group membership, you must use the
system.staticgroups property (for example,
Matches child groups of “Acme Corp” named “Prod” or “prod”, but not those named “production”, “Prod_QA”, and so on.
Note: Only static group membership (not dynamic group membership) is queried when the
system.staticgroups property is referenced.
Matches resources with an IP address of 192.168.170.1.
This function flattens an array to a string with array elements separated by the designated separator. Required parameters are the array name (for example,
system.groups) and the string separator (for example, “,”). Unlike
contains(), partial match and regex are supported. When used alone it returns TRUE for resources which have any value set for the specified array property.
Matches resources in groups with names like “Prod”, “production”, “Prod1”, and so on at any level of the Resources tree.
Matches resources in any non-dynamic child group whose name contains “dev”, “Dev”, “DEV”, and so on.
Matches any resource for which
system.categories is empty. Equivalent to
This function queries the
system.categories property for an array element that is a complete, case insensitive match for the specified string. Regex is not supported. Returns TRUE if there is a match.
Functions that Operate on Strings and Numbers
The following functions operate on properties that are string or numeric type.
This function returns TRUE if the specified value is assigned to any of the resource’s properties.
This function returns the sum of the numbers passed as parameters.
This function returns TRUE if the property value starts with the value specified in the function. Typically the value will be a string and should be enclosed in double quotes. Partial match from the beginning of the string is supported; regex is not. It is possible to pass the value as a number, without double quotes. However, partial match is not supported for numeric values, so the match must be complete for the function to return TRUE.
Matches Windows resources.
Matches resources monitored by Collector versions 28.xxx.
Matches resources monitored by Collector version 28.102. Note that this is equivalent to
This is an alias to the
system.sysoid property that removes the need to escape periods in the OID. Use with the
!~ operators to compare resources’ system OIDs to the specified value. For a partial match, use
!~. When used alone, it returns TRUE for resources which have a value set for
Matches resources with system OIDs that are not “184.108.40.206.4.1.8072.3.2.10”.
Matches resources with system OIDs containing “8741.1”.
When no value is specified, returns TRUE for all resources which have a value set for this property.
Any property name can be referenced as an AppliesTo function. When used alone, it returns TRUE for any resource which has a value set for the specified property. It can be used with operators for comparison purposes.
Matches resources monitored by Collectors version 28.000 and higher.
Returns TRUE for resources not being monitored by their preferred Collector.
Returns TRUE for resources with values for the
auto.serial.number property which start with “C0E”.
If the device property name contains special characters such as ":", "/", "*", "=", or spaces, you will need to use the
getPropValue("<property name>") function. We recommend not having special characters in your property names, but if it can’t be avoided, this function allows you to use the property in an AppliesTo expression.
For example, if you have a property named “SiteA:unit”, and you want to return resources with this property having values 10 to 19, you might initially try:
However, you will receive a syntax error informing you that characters in regular expressions must be escaped. To get past the error you will need to use this expression instead:
Note the property name is enclosed in double quotes.
getPropValue("<property name>") is used alone it returns TRUE for all resources which have a value set for the specified property.
You can define your own AppliesTo convenience functions globally, and those functions can then be called from any location within LogicMonitor that takes AppliesTo scripting as input. As discussed in User-Defined AppliesTo Functions, user-defined convenience functions are created and managed from the AppliesTo Functions page.
- Regex matching is not case sensitive. However, this is not a problem since property names and values are not case sensitive in the backend. You can enter mixed-case names and values, and they will be displayed as mixed case where you set them, but this has no effect on how they are processed by AppliesTo functions.
- Regex tokens used in string values should not be escaped.
- For a regex token in a string value to be treated as a literal character it must be escaped with “\\”.
All property names are referenced as unquoted strings exactly as they appear on the resource Info tab.The exception is when used as a parameter in the
getPropValue("<property name>") function, where the property name must be enclosed in double quotes.
Multiple AppliesTo expressions can be grouped and linked by Boolean operators to make the AppliesTo statement as specific as is required.
isWindows() && (system.sysinfo =~ “x64” || system.sysinfo =~ “Vista”)
Returns Windows resources running a 64-bit operating system or Vista.
hasCategory("snmp") && !isWindows()
Returns all resources with “snmp” listed as a value in the
system.categories property, excluding Windows resources.
isLinux() && system.collectorversion>=28000 && (location=~"Austin" || join(system.groups,",")=~"dev|qa")
Returns Linux resources being monitored by Collector version 28 or higher which are either located in Austin or members of a group with a name containing “dev” or “qa”.
Building and Testing AppliesTo Statements
Wherever AppliesTo scripting is accepted as input across the LogicMonitor platform, you will see an Applies To field. The Applies To field directly carries the AppliesTo statement. Accompanying this field is a wizard for more intuitive statement building and test functionality for verifying that the statement is working as intended.
Note: If you are updating an AppliesTo expression for the purpose of changing which resources a LogicModule is associated with, do so with extreme caution as all historical data collected by a LogicModule for a resource is lost upon dissociation. As best practice, always test AppliesTo scripting changes before updating the LogicModule definition.
Building Statements with the AppliesTo Wizard
While you can manually enter an AppliesTo statement directly into the Applies To field, you may find it more efficient to take advantage of the AppliesTo wizard for help in building statements.
Click the Wizard button to open the wizard. The AppliesTo wizard allows you to quickly generate AppliesTo statements that use any of the following criteria to determine resource association:
- Resource type. Selecting the select resource type option allows you to narrow association to those resources that fall into one of several common resource type categories, which are defined using LogicMonitor’s built-in convenience functions. For example, selecting “Cisco” results in an AppliesTo statement consisting of the
isCisco()convenience function. If none of the provided resource types are applicable for your use case, select “Others” to build a statement that queries the
system.categoriesproperty for a particular value.
- Resource group membership. Selecting the select resource groups option allows you to narrow association to those resources that belong to one or more groups and, optionally, their subgroups.
- Resource name or description. Selecting the select resources option allows you to narrow association to manually selected resources, or resources whose hostname or display name contain a particular string.
- Custom. Use the custom query option to manually edit or build upon a statement created by one of the three previous options.
After building an AppliesTo statement using the wizard, click the Save button to save it to the Applies To field. It is strongly recommended that you test the statement (either using the Test button on the wizard or the one located directly beneath the Applies To field) before performing the final form save, as discussed in the following section.
After creating or editing an AppliesTo statement, it is strongly recommended that you test the statement before saving the form and putting the new statement into production. You can test an AppliesTo statement by clicking the Test button from the wizard or the Test AppliesTo button located directly under the Applies To field.
As shown next, the test functionality returns a simple count of resources returned by the AppliesTo statement, along with a “Show me” hyperlink that, when clicked, opens a window listing details for the matching resources.
If you are making updates to an existing AppliesTo statement, the Affected Items window also lists any resources that were included by the previous query, but would be excluded if the current query was saved and put into production.
The ability to view soon-to-be excluded resources upon statement testing is especially critical if you are making AppliesTo updates within a LogicModule definition. This is because removing the association between a LogicModule and a resource also permanently removes all historical data previously collected by that LogicModule for that resource. By testing first, you are ensuring that any dissociations (and resulting data loss) are intentional.
In this Article: