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 Name Data Type Description
AlarmID VT_I4 The unique ID of the alarm or event in the Historian alarm database.
ItemID VT_BSTR The 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.
Source VT_BSTR The unique identifier used by the OPC AE Collector for the alarm or event.
DataSource VT_BSTR The collector interface name associated with the alarm or event.
Tagname VT_BSTR The Historian tag name associated with the alarm. This value is NULL unless the tag is also collected by Historian.
AlarmType VT_BSTR The 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.
EventCategory VT_BSTR The OPC event category of the alarm or event.
Condition VT_BSTR The OPC condition of the alarm. Does not apply to event data. This value combined with the Source value comprises an alarm.
SubCondition VT_BSTR The OPC subcondition of the alarm. Does not apply to event data. This value represents the state of the alarm.
StartTime VT_DBTimeStamp The start time or timestamp of the alarm or event.
EndTime VT_DBTimeStamp The end time of the alarm. Does not apply to event data.
AckTime VT_DBTimeStamp The time the alarm was acknowledged. Does not apply to event data.
Microseconds VT_I4 The microsecond portion of the date and time.
Message VT_BSTR The message attached to the alarm or event.
Acked VT_BOOL Stores the acknowledgement status of the alarm. If the alarm is acknowledged, this is set to TRUE.
Severity VT_I4 The severity of the alarm or event. Stored as an integer value with a range of 1–1000.
Actor VT_BSTR The operator who acknowledged the alarm, or caused the tracking event.
Quality VT_VARIANT The quality of the alarm or event. Stored as a string, with values of GOOD or BAD.
TimeZone VT_BSTR

The type of time zone used:

  • Client
  • Server
  • Explicit bias number (number of minutes from GMT)
DaylightSavingTime VT_BOOL Indicates whether Daylight Saving Time logic should be applied to timestamps.
RowCount VT_I4 The maximum number of rows returned by the current query.
User-Defined Variable #X VT_VARIANT User-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.