1e41f4b71Sopenharmony_ci# HiSysEvent 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ciHiSysEvent is a built-in tool that helps you subscribe to real-time system events and query historical system events. To use this tool, access the target device with [hdc](hdc.md) and then run **hisysevent** commands in the command-line interface (CLI). 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci## Subscribing to Real-Time System Events 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_ci- Run the **hisysevent -r** command to subscribe to system events. 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci  10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ci- To specify the type of system event to subscribe to, use the **-g** option. 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci > **NOTE**<br> 14e41f4b71Sopenharmony_ci > With the **-g** option, four event types are available: **FAULT**, **STATISTIC**, **SECURITY**, and **BEHAVIOR**. 15e41f4b71Sopenharmony_ci > 16e41f4b71Sopenharmony_ci > If no event type is specified, HiSysEvent subscribes to all types of system events. 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ci Example: Subscribe to system events of the **FAULT** type. 19e41f4b71Sopenharmony_ci 20e41f4b71Sopenharmony_ci  21e41f4b71Sopenharmony_ci 22e41f4b71Sopenharmony_ci- To subscribe to system events by event domain and event name, use the **-o**, **-n**, and **-c** options. **-o** specifies the event domain, **-n** specifies the event name, and **-c** specifies the rule for matching the specified event domain and name. 23e41f4b71Sopenharmony_ci 24e41f4b71Sopenharmony_ci > **NOTE**<br> 25e41f4b71Sopenharmony_ci > With the **-c** option, the following matching rules are available: **WHOLE_WORD**, **PREFIX**, and **REGULAR**. 26e41f4b71Sopenharmony_ci > 27e41f4b71Sopenharmony_ci > If no matching rule is specified, the **WHOLE_WORD** matching rule is used by default. 28e41f4b71Sopenharmony_ci 29e41f4b71Sopenharmony_ci Example 1: Subscribe to the system event that matches the domain of **AAFWK** and event name of **CONNECT_SERVICE**. 30e41f4b71Sopenharmony_ci 31e41f4b71Sopenharmony_ci  32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ci Example 2: Subscribe to system events that match the domain prefix of **AAF** and event name prefix of **CONNECT**. 34e41f4b71Sopenharmony_ci 35e41f4b71Sopenharmony_ci  36e41f4b71Sopenharmony_ci 37e41f4b71Sopenharmony_ci Example 3: Subscribe to system events whose domain matches the **AA\*** regular expression and whose event name matches the **CONNE\*** regular expression. 38e41f4b71Sopenharmony_ci 39e41f4b71Sopenharmony_ci  40e41f4b71Sopenharmony_ci 41e41f4b71Sopenharmony_ci- To subscribe to system events by event tag, use the **-t** and **-c** options. **-t** specifies the event tag, and **-c** specifies the rule for matching the event tag. 42e41f4b71Sopenharmony_ci 43e41f4b71Sopenharmony_ci Example 1: Subscribe to system events whose tag is **ability**. 44e41f4b71Sopenharmony_ci 45e41f4b71Sopenharmony_ci  46e41f4b71Sopenharmony_ci 47e41f4b71Sopenharmony_ci Example 2: Subscribe to system events whose tag prefix is **abili**. 48e41f4b71Sopenharmony_ci 49e41f4b71Sopenharmony_ci  50e41f4b71Sopenharmony_ci 51e41f4b71Sopenharmony_ci Example 3: Subscribe to system events whose tag matches the **abi\*** regular expression. 52e41f4b71Sopenharmony_ci 53e41f4b71Sopenharmony_ci  54e41f4b71Sopenharmony_ci 55e41f4b71Sopenharmony_ci## Querying Historical System Events 56e41f4b71Sopenharmony_ci 57e41f4b71Sopenharmony_ci- Run the **hisysevent -l** command to query system events that are stored. 58e41f4b71Sopenharmony_ci 59e41f4b71Sopenharmony_ci  60e41f4b71Sopenharmony_ci 61e41f4b71Sopenharmony_ci- To specify the type of system event to query, use the **-g** option. 62e41f4b71Sopenharmony_ci 63e41f4b71Sopenharmony_ci > **NOTE**<br> 64e41f4b71Sopenharmony_ci > With the **-g** option, four event types are available: **FAULT**, **STATISTIC**, **SECURITY**, and **BEHAVIOR**. 65e41f4b71Sopenharmony_ci > 66e41f4b71Sopenharmony_ci > If no event type is specified, HiSysEvent queries all types of system events. 67e41f4b71Sopenharmony_ci 68e41f4b71Sopenharmony_ci Example: Query system events of the **SECURITY** type. 69e41f4b71Sopenharmony_ci 70e41f4b71Sopenharmony_ci  71e41f4b71Sopenharmony_ci 72e41f4b71Sopenharmony_ci- To query historical system events within the specified period of time, use the **-s** and **-e** options to specify raw timestamps. **-s** specifies the start timestamp, and **-e** the end timestamp. 73e41f4b71Sopenharmony_ci 74e41f4b71Sopenharmony_ci > **NOTE**<br> 75e41f4b71Sopenharmony_ci > The raw timestamps are of millisecond precision. 76e41f4b71Sopenharmony_ci 77e41f4b71Sopenharmony_ci Example: Query all system events reported between 1708604541551 and 1708604558551. 78e41f4b71Sopenharmony_ci 79e41f4b71Sopenharmony_ci  80e41f4b71Sopenharmony_ci 81e41f4b71Sopenharmony_ci- You can use the **-S** and **-E** options to specify formatted start and end timestamps, respectively. 82e41f4b71Sopenharmony_ci 83e41f4b71Sopenharmony_ci > **NOTE**<br> 84e41f4b71Sopenharmony_ci > The timestamp format is YYYY-MM-DD hh:mm:ss. 85e41f4b71Sopenharmony_ci 86e41f4b71Sopenharmony_ci Example: Query all system events reported between 2024-02-22 20:22:21 and 2024-02-22 20:22:38. 87e41f4b71Sopenharmony_ci 88e41f4b71Sopenharmony_ci  89e41f4b71Sopenharmony_ci 90e41f4b71Sopenharmony_ci- To query system events by event domain and event name, use the **-o**, **-n**, and **-c** options. **-o** specifies the event domain, **-n** specifies the event name, and **-c** specifies the rule for matching the specified event domain and name. 91e41f4b71Sopenharmony_ci 92e41f4b71Sopenharmony_ci > **NOTE**<br> 93e41f4b71Sopenharmony_ci > The **-c** option for querying historical system events must be **WHOLE_WORD**. 94e41f4b71Sopenharmony_ci > 95e41f4b71Sopenharmony_ci > If no matching rule is specified, the **WHOLE_WORD** matching rule is used by default. 96e41f4b71Sopenharmony_ci 97e41f4b71Sopenharmony_ci Example: Query the system event that matches the domain of **AAFWK** and event name of **CONNECT_SERVICE**. 98e41f4b71Sopenharmony_ci 99e41f4b71Sopenharmony_ci  100e41f4b71Sopenharmony_ci 101e41f4b71Sopenharmony_ci- You can use the **-m** option to set the maximum number of historical events that can be queried. 102e41f4b71Sopenharmony_ci 103e41f4b71Sopenharmony_ci > **NOTE**<br> 104e41f4b71Sopenharmony_ci > If **-m** is not specified, a maximum of 10,000 system events are queried by default. 105e41f4b71Sopenharmony_ci 106e41f4b71Sopenharmony_ci  107e41f4b71Sopenharmony_ci 108e41f4b71Sopenharmony_ci  109e41f4b71Sopenharmony_ci 110e41f4b71Sopenharmony_ci## Checking System Event Validity 111e41f4b71Sopenharmony_ci 112e41f4b71Sopenharmony_ciTo enable system event validity check, use the **-v** option. 113e41f4b71Sopenharmony_ci 114e41f4b71Sopenharmony_ciIf system event validity check is enabled, invalid content contained in system events will be highlighted in red. 115e41f4b71Sopenharmony_ci 116e41f4b71Sopenharmony_ci> **NOTE**<br> 117e41f4b71Sopenharmony_ci> 118e41f4b71Sopenharmony_ci> Invalid content is defined as follows: 119e41f4b71Sopenharmony_ci> 120e41f4b71Sopenharmony_ci> - Custom parameter key that is not configured 121e41f4b71Sopenharmony_ci> - Type mismatch 122e41f4b71Sopenharmony_ci 123e41f4b71Sopenharmony_ciExample: For the system event named **INTERACTION_APP_JANK** of the **ACE** domain, the <!--RP1-->[system event configuration](../../device-dev/subsystems/subsys-dfx-hisysevent-logging-config.md)<!--RP1End--> does not contain the custom parameters **DURITION** and **DISPLAY_ANIMATOR**. If these parameters are contained in the event saved, they will be highlighted in red when system event validity check is enabled. 124e41f4b71Sopenharmony_ci 125e41f4b71Sopenharmony_ci 126