Events in FlexRule Server

◷ 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.).

Events

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.

Events are in the form of Static Types or JSON objects and they have a timestampunique identifiercorrelation id, and duration.

There are different categories of events:

Package

  • PackageOwnershipChangedEvent
  • PackageSettingsUpdatedEvent
  • PackageDeletedEvent
  • PackageSavedEvent
  • PackageStatusChangedEvent

Service

  • ServiceExecutionRequestedEvent
  • ServiceExecutedEvent
  • ServiceDeletedEvent
  • ServiceUpdatedEvent
  • ServiceStatusChangedEvent

Security

  • CredentialRoleUpdatedEvent
  • RoleDeletedEvent
  • RoleCreatedEvent
  • RoleUpdatedEvent

File

  • FileChangesCommittedEvent
  • FilePinStrategyCahangedEvent

Agent

  • AgentCacheRefereshReceivedEvent
  • AgentListUpdatedEvent

Trace

  • AuthorizationTraceEvent
  • ConfigReadTraceEvent
  • DbTraceEvent
  • DomainServiceTraceEvent
  • ExceptionTraceEvent
  • ExceptionTraceEvent
  • HttpMessageTraceEvent
  • ValidationTraceEvent
  • WebApiTraceEvent
  • UnsuccessfulHttpResponseTraceEvent

Subscription

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.

Listeners

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.

Channels

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:
    • TextWriterTraceListener
    • Windows Event Log channel: EventLogTraceListener
  • name: name of the channel to be referenced by listeners

Details of different types of channels are explained here.

Register

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.

Custom Channels

Read more about it at Delivery Custom Channel.

Updated on November 2, 2020

Was this article helpful?

Related Articles