ihAlarms Table

The ihAlarms table contains collected alarms and events data. The following table describes the columns of the ihAlarms table.

CAUTION: When you perform joins of the ihRawData and ihAlarms tables, you can easily construct queries that temporarily consume all your system resources. Although this scenario typically does not affect data collection, it can interfere with data analysis. To avoid this issue, always define a start and end time for the query to limit the number of rows returned.
Table 1. ihAlarms Table
Column NameData TypeDescription
AlarmIDVT_I4The unique ID of the alarm or event in the Historian alarm database.
ItemIDVT_BSTRThe OPC ItemID of the alarm. This contains the source address of the data access tag with which the alarm is associated. This can contain a NULL value if an alarm is not associated with a tag.
SourceVT_BSTRThe unique identifier used by the OPC AE Collector for the alarm or event.
DataSourceVT_BSTRThe collector interface name associated with the alarm or event.
TagnameVT_BSTRThe Historian tag name associated with the alarm. This value is NULL unless the tag is also collected by Historian.
AlarmTypeVT_BSTRThe alarm type:
  • Alarms: In Historian, the full life cycle of an alarm is stored as a single record in the alarm archive.
  • Alarm_History: The separate transitions for all alarms. One row per transition is returned.
  • Events: The simple and tracking events.
EventCategoryVT_BSTRThe OPC event category of the alarm or event.
ConditionVT_BSTRThe OPC condition of the alarm. Does not apply to event data. This value combined with the Source value comprises an alarm.
SubConditionVT_BSTRThe OPC subcondition of the alarm. Does not apply to event data. This value represents the state of the alarm.
StartTimeVT_DBTimeStampThe start time or timestamp of the alarm or event.
EndTimeVT_DBTimeStampThe end time of the alarm. Does not apply to event data.
AckTimeVT_DBTimeStampThe time the alarm was acknowledged. Does not apply to event data.
MicrosecondsVT_I4The microsecond portion of the date and time.
MessageVT_BSTRThe message attached to the alarm or event.
AckedVT_BOOLStores the acknowledgement status of the alarm. If the alarm is acknowledged, this is set to TRUE.
SeverityVT_I4The severity of the alarm or event. Stored as an integer value with a range of 1–1000.
ActorVT_BSTRThe operator who acknowledged the alarm, or caused the tracking event.
QualityVT_VARIANTThe quality of the alarm or event. Stored as a string, with values of GOOD or BAD.
TimeZoneVT_BSTR

The type of time zone used:

  • Client
  • Server
  • Explicit bias number (number of minutes from GMT)
DaylightSavingTimeVT_BOOLIndicates whether Daylight Saving Time logic should be applied to timestamps.
RowCountVT_I4The maximum number of rows returned by the current query.
User-Defined Variable #XVT_VARIANTUser-defined variables. This is a dynamic list of columns that varies based on the collectors running on the Historian system.
Note: Additional fields may be added by third-party products such as iFIX. Please consult the relevant product documentation for further information.

ihAlarms Examples

Example 1: Show All Alarms for the Last Two Hours, Including Vendor Attributes

SELECT * FROM ihAlarms
SELECT * FROM ihAlarms WHERE alarmtype = alarms //same as above

Example 2: Show Alarm History

SELECT * FROM ihAlarms WHERE alarmtype = alarm_history

Example 3: Show Tracking and System Events

SELECT * FROM ihAlarms WHERE alarmtype = events

Example 4: Return All Closed Events and Associated Tag Data

SELECT
alarmid, ihalarms.tagname, ihalarms.starttime, ihalarms.endTime, ihrawdata.timestamp, ihrawdata.value
FROM ihalarms, ihrawdata
WHERE ihalarms.tagname=ihrawdata.tagname
AND ihalarms.starttime <= ihrawdata.timestamp
AND ihalarms.endtime >= ihRawdata.timestamp
AND ihalarms.subcondition == "OK"
OR ihalarms.quality = "Bad"
ORDER BY ihalarms.starttime
Note: When you join data from the ihRawData and ihAlarms tables, be sure to specify a timestamp range.

Example 5: Return All Open Alarms and Associated Tag Data

SELECT
alarmid, ihalarms.tagname, ihalarms.starttime, ihalarms.endTime, ihrawdata.timestamp, ihrawdata.value
FROM ihalarms, ihrawdata
WHERE ihalarms.tagname=ihrawdata.tagname
AND ihalarms.starttime <= ihrawdata.timestamp
AND ihalarms.endtime >= ihRawdata.timestamp
AND ihalarms.subcondition <> "OK"
AND ihalarms.quality = "Good"
ORDER BY ihalarms.starttime
Note: When you join data from the ihRawData and ihAlarms tables, be sure to specify a timestamp range.