Apama 10.3.1 | Apama Documentation | Connecting Apama Applications to External Components | Standard Connectivity Plug-ins | The Cumulocity IoT Transport Connectivity Plug-in | Using alarms | Querying for alarms
 
Querying for alarms
To search for an alarm or a collection of alarms, send the com.apama.cumulocity.FindAlarm event to Cumulocity IoT, with a unique reqId to the com.apama.cumulocity.FindAlarm.CHANNEL channel.
The transport will then respond with zero or more com.apama.cumulocity.FindAlarmResponse events and then one com.apama.cumulocity.FindAlarmResponseAck event on the com.apama.cumulocity.FindAlarmResponse.CHANNEL channel.
Example:
integer reqId := integer.incrementCounter("CumulocityRequestId");
 
com.apama.cumulocity.FindAlarm request := new com.apama.cumulocity.FindAlarm;
request.reqId := reqId;
 
// Filter based on alarms type
request.params.add("type", "c8y_UnavailabilityAlarm");
 
// Subscribe to com.apama.cumulocity.FindAlarmResponse.CHANNEL to listen
// for responses
monitor.subscribe(com.apama.cumulocity.FindAlarmResponse.CHANNEL);
 
// Listen for responses based on reqId
on all com.apama.cumulocity.FindAlarmResponse(reqId=reqId) as response
// Avoid listener leaks by terminating the listener on completion of the request
and not com.apama.cumulocity.FindAlarmResponseAck(reqId=reqId)
{
log "Received Alarm " + response.toString() at INFO;
}
 
// Listen for com.apama.cumulocity.FindAlarmResponseAck,
// this indicates that all responses have been received
on com.apama.cumulocity.FindAlarmResponseAck(reqId=reqId) as requestCompleted
{
log "Received all Alarm(s) for request " +
requestCompleted.reqId.toString() at INFO;
 
// Request is completed and we can unsubscribe from this channel
monitor.unsubscribe(com.apama.cumulocity.FindAlarmResponse.CHANNEL);
}
 
// Send request to find available alarms
send request to com.apama.cumulocity.FindAlarm.CHANNEL;
Supported query parameters
You can provide the following query parameters with the request:
Parameter
Description
id
Search for an alarm based on alarmId. When searching for an alarm based on Id, all the query parameters listed below are ignored.
source
Search for alarms based on the device identifier or asset identifier of the source.
status
Search for alarms based on the status. The status can be any of ACTIVE, ACKNOWLEDGED or CLEARED.
severity
Search for alarms based on the severity. The severity can be any of CRITICAL, MAJOR, MINOR or WARNING.
type
Search for alarms based on the type.
fromDate
Search for alarms from a start date. The date and time is provided as seconds since the epoch.
toDate
Search for alarms within a time range. This is to be used in combination with fromDate. The date and time is provided as seconds since the epoch.
resolved
A boolean parameter used for filtering, based on the resolved state.
pageSize
Indicates how many entries of the collection are to be retrieved from Cumulocity IoT.

Copyright © 2013-2019 | Software AG, Darmstadt, Germany and/or Software AG USA, Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.