◷ Reading Time: 4 minutes
Using domain events is the best way to collect relevant information and build Dashboards, Audit trails, Log entries, etc. FlexRule Server is an extensible event-driven platform, which means that when anything happens in FlexRule Server, a set of events will be published.
Any actions on the FlexRule Server by users or applications will raise domain events (i.e., events). You can subscribe to these events by their type and then channelize them to any data store and/or dashboard of your choice. This design maintains your ability to use any other platform (i.e., Splunk, Prometheus, datadoghq, Google Analytics, etc.) as your time-series event store. Or you can simply write a custom channel that pushes the events to your own custom location (e.g., MSSQL Server, MongoDB, etc.).
FlexRule Server uses a publish-subscribe pattern. You can write a subscriber and listen to raising events. Events have two states, before and after which allows listeners to capture one or both states.
There are different categories of events:
In FlexRule Server you can create your own event monitoring plugin and register it as an event listener in the configuration file on either the Master or Agents. Each of the listeners in the monitoring can subscribe to multiple events which then redirect that to specific channel.
In monitoring the events section, use add to register listeners. monitoring/add has the attributes below:
- event: name of an event from the above list. You can add multiple event names to listen to by separating them with a comma.
- channel: the name of a channel that is registered in the channel section
- level: allows you to store an event as an Error, Information, Warning, etc.
Inside channel registers different channels to which to push the events. channels/add has the attributes shown below:
- initialData: allows you to provide data to initialize a channel (e.g., folder name, database connection, log service end-point address, etc.).
- type: address of to the channel. You can use any TraceListener here. By default FlexRule Server uses two TraceListener for channels:
- Windows Event Log channel: EventLogTraceListener
- name: name of the channel to be referenced by listeners
Below is the structure of listener and channels that can be managed by both Master and Agents.
<monitoring enabled="true" includeDetails="true" prettifyDetails="true"> <add event="..." channel="..." level="..." /> <channels> <add initializeData="..." type="..." name="..." /> </channels> </monitoring>
For example below is a sample configuration that registers AuthorizationTraceEvent events to be stored in a file located at c:\securefolder\authorizationErrors.log
<monitoring enabled="true" includeDetails="true" prettifyDetails="true"> <add event="AuthorizationTraceEvent" channel="authorizationErrors" level="Error" /> <channels> <add initializeData="c:\securefolder\authorizationErrors.log" type="TextWriterTraceListener" name="authorizationErrors" /> </channels> </monitoring>
You can also create custom channels to store the events in anywhere that you need. For instance in a database, Azure blob storage and etc.
Read more about it at Delivery Custom Channel.