Using Dynamic Variables in Alarm Messages
Update an alarm in Monitoring to include values of alarm message parameters in messages.
How Dynamic Variables are Rendered
Insert dynamic variables that respect the maximum length for all supported use cases. Dynamic variables that exceed the maximum are considered invalid. For example, consider a dynamic variable for use in
title
. A supported use case for title
is an email subject line, at a maximum length of 250 characters. In this case, the dynamic variable for a resource name ({{dimensions.<dimension-name>}}
) is invalid because it's 256 characters and thus exceeds the maximum.The value of an alarm message parameter is rendered in an alarm message when you insert the associated dynamic variable into supported fields. For example, enter the following as the alarm body:
{{severity}} alarm triggered because threshold got breached due to {{metricValues}} at {{timestamp}}
In the following image of an alarm message, the alarm body (Body) is rendered as: CRITICAL alarm triggered because threshold got breached due to [CpuUtilization[1m].mean():92] at 2023-08-15T19:51:00Z
Dynamic variables appear in notifications that contain body elements.
- If data is available for a dynamic variable, then the variable is resolved and data appears in its place. The previous example alarm message shows
[CpuUtilization[1m].mean():92]
in place of the dynamic variable{{metricValues}}
. - If no data is available for a dynamic variable, then the variable is unresolved and it appears as coded. For example, if no metric values are available for the dynamic variable
{{metricValues}}
, such as when the alarm is in the OK state, then the dynamic variable{{metricValues}}
appears in the alarm message. - SMS messages lack body elements, so dynamic variables aren't resolved.
Looking Up Dynamic Variables
To look up a dynamic variable for a parameter, see Dynamic Variables.
Use the oci monitoring alarm update command and required parameters to update an alarm to use dynamic variables in the field that you want:
oci monitoring alarm update --alarm-summary <text-including-dynamic-variables> --body <text-including-dynamic-variables> --notification-title <text-including-dynamic-variables> [...]
With line breaks:
oci monitoring alarm update --alarm-summary <text-including-dynamic-variables> --body <text-including-dynamic-variables> --notification-title <text-including-dynamic-variables> [...]
For a complete list of parameters and values for CLI commands, see the Command Line Reference for Monitoring.
Run the UpdateAlarm operation to update an alarm to use the message format option that you want.
When defining details for UpdateAlarmDetails, set the field that you want (
alarmSummary
,body
, ornotificationTitle
) to the text that you want, including dynamic variables.