Forrester Total Economic Impactâ„¢ study finds Edwin AI delivered a 313% ROI for composite organization.

Read more

The Groovy or PowerShell script that you specify in a DiagnosticSource and RemediationSource runs on a Collector and has access to resource-level host properties such as system.displayName and custom resource properties.

To provide context about the alert that triggered the DiagnosticSource or RemediationSource, you can use alert properties in the script. When LogicMonitor runs a Groovy script, it provides alert properties to the script using the alertProps variable. This provides the script with alert information such as the datapoint that breached the threshold, the datapoint value when the alert triggered, the instance that generated the alert, the DataSource associated with the alert, and other relevant alert metadata such as alert ID, start time, or threshold. You can incorporate this data into conditional logic for context-driven automated diagnostics and remediation.

In the following image, you can view the output of a RemediationSource run result with available alert properties for the resource:

Alert Properties displayed in RemediationSource Output

Note: There is no impact on the existing scripts that do not use alertProps. They will continue to work without any modification.

Alert Properties for DiagnosticSource and RemediationSource Scripts

When configuring a DiagnosticSource or RemediationSource Groovy script, you can use the following set of standard alert properties:

Property KeyDescription
alert.datapointName of the alerting datapoint
Example—CPUBusyPercent
alert.datapoint.valueRaw value that triggered the alert
Example—95.3
alert.severityAlert severity level
Example—critical / error / warning
alert.instanceDisplay name of the alerting instance
Example—Total
alert.instance.wildvalueWild value of the alerting instance
Example—eth0
alert.datasourceName of the DataSource that triggered the alert
Example—Linux_SSH_CPU
alert.idUnique alert identifier
Example—DS98765
alert.thresholdThreshold expression configured in the LogicModule that was breached
Example—>= 90
alert.resource.idResource ID for which an alert was triggered
Example—42
alert.resource.nameResource name for which an alert was triggered
Example—prod-server-01
alert.external.ticket.idExternal ticket ID mapped to the alert.
alert.value.display.nameDisplays the readable status display name associated with the datapoint value that triggered the alert, instead of the numeric value.
Example—AlertPropsSingleDisplay
alert.start.epochThe time (in unix epoch time) when this alert started
Example—1781109605

Alert Property Access

Alert properties provide contextual information about the alert that triggered the script. You can access these properties in the following ways:

  • Inline Token Substitution—Use ##ALERT.*## tokens to insert alert property values directly into the script before execution.
  • Runtime Variable Access—Use the alertProps runtime variable to retrieve alert property values programmatically during script execution.
  • Manual Script Execution—Understand how alert properties behave when a DiagnosticSource or RemediationSource is run manually without alert context.

Inline Token Substitution

You can use inline token substitution in Groovy and PowerShell scripts. It uses the same template ##TOKEN## that is used for host properties. For example, ##SYSTEM.HOSTNAME##.

def datapointName = "##ALERT.DATAPOINT##"
def currentValue  = "##ALERT.DATAPOINT.VALUE##"
def severity      = "##ALERT.SEVERITY##"

Note: When a DiagnosticSource or RemediationSource is manually triggered from a resource, the inline tokens do not contain alert property values.

Runtime Variable Access

You can use runtime variable access in the Groovy script.

def dpName   = alertProps.get("alert.datapoint")
def dpValue  = alertProps.get("alert.datapoint.value")
def severity = alertProps.get("alert.severity")
def instance = alertProps.get("alert.instance")
println "Alert on ${dpName} = ${dpValue} (${severity}) for instance ${instance}"
if (dpValue.toDouble() > 90.0) {
    // perform targeted remediation based on actual alert value
}

Manual Script Trigger from Resources

When you manually run a DiagnosticSource or RemediationSource without alert context, the alertProps in the Groovy script do not contain alert property values.

Note: During DiagnosticSource or RemediationSource configuration, when you test the script, the alert properties are not available.

Design your script to gracefully handle cases where alert context is unavailable.

if (alertProps.containsKey("alert.datapoint")) {
    // alert-aware execution path
} else {
    // fallback for manual execution
}

14-day access to the full LogicMonitor platform