Skip to content

Technical

Components

Integration Monitor consists of the following components:

  • Data structure in Lime CRM
  • Web component
  • Custom endpoint
  • Scheduled Task

Data Structure in Lime CRM

The data structure of Integration Monitor consists of three tables, Integration Monitor, Integration Monitor Batch and Integration Monitor Log. These tables and their fields can be created by LIP.

Table database name: integration_monitor

Each integration (or equivalent) to be monitored through this package needs to have its own integration monitor object, where the key in the integration_key field needs to be unique. The value in integration_key is then used to map other objects to the integration monitor object.

There are two different types of monitors - batch and message.

batch (integration_monitor_batch) is intended to be used in a flow where several message (integration_monitor_log) objects are created, for example in an integration that creates objects in different tables. The message objects are then linked to the batch object.

message (integration_monitor_log) is intended to be used where only one message object needs to be created in a flow, for example in a scheduled job that updates objects in a single table.

See scheduled task update_integration_monitor to find out how the monitoring works.

The integration monitor object is meant to be created manually in Lime.

Database Field Name Field Type Comments
name Text field (32)
integration_key Text field (32) key
type Option field Options: batch, message
active yesno field
alert_interval Integer field
alert_no_creates_deceeds Integer field
alert_no_updates_deceeds Integer field
alert_no_deletes_deceeds Integer field
alert_timestamp Date field
alertstatus Option field Options: notcalculated, ok, error
alerttext Text field (256)
integration_monitor_log Relation (tab)
integration_monitor_batch Relation (tab)

Table database name: integration_monitor_batch

It is recommended to create a batch object at the start of the custom work flow, and updating the batch object with the result at the end of the work flow.

The integration_monitor_batch object is supposed to be created in your code, and not created manually in Lime.

Database Field Name Field Type Comments
integration_monitor Relation (field)
logstatus Option field Options: ok, running, error, donewitherror
integrationid Text field (64)
starttime Date and Time field Default value: GETDATE()
endtime Date and Time field
duration Text field (32)
no_created Integer field
no_updated Integer field
no_deleted Integer field
logtext Text field (256)
errormsg Text field (1024)

Table database name: integration_monitor_log

The integration_monitor_log object is supposed to be created in your code, and not created manually in Lime.

Database Field Name Field Type Comments
integration_monitor Relation (field)
integration_monitor_batch Relation (field)
logstatus Option field Options: ok, running, error, donewitherror
integrationid Text field (64)
logtext Text field (256)
errormsg Text field (1024)
message Text field (1024)

Web component

Custom endpoint

UpdateIntegrationMonitor

Triggers the task "update_integration_monitor". For more information, see below.

Scheduled Task

update_integration_monitor

Scheduled task which calculates alert status and alert text for all active integration monitors. The task fetches the last run integration monitor batch / log (related to the integration monitor) based on type of monitor, and mirrors the result on the integration monitor object.

Task is run every 15 minutes.

Helper functions

How to import: import limepkg_integration_monitor.base_helpers as im_helpers

fetch_integration_monitor

Helper function for fetching an integration monitor by integration key.

Args:

  • app (LimeApplication)
  • integration_key (str, optional): Integration key found on integration monitor object.

Raises:

  • MissingIntegrationKey (Exception): If integration_key argument is an empty string.

Returns:

  • Union[LimeObject, None]: Returns LimeObject if found by integration_key, else None.

create_integration_monitor_batch

Helper function for creating an integration monitor batch object.

Args:

  • app (LimeApplication)
  • integration_key (str): Key to integration monitor object.
  • integration_id (str): Integration ID if it exists. Defaults to ''.
  • batch_status (str, optional): Batch status. Defaults to "running".
  • Available batch statuses (included in base package): See data structure above.
  • Note: Possible to add your own statuses in LISA.
  • batch_text (str, optional): Batch text describing status. Defaults to ''.
  • error_msg (str, optional): Error message if it exists. Defaults to ''. Maximum allowed characters: 1024.

Raises:

  • IntegrationMonitorNotFound (Exception): If integration monitor not found by integration_key.

Returns:

  • Integration Monitor Batch object (Union[LimeObject, None]): Returns LimeObject if success on creation, else None.

create_integration_monitor_log

Helper function for creating an integration monitor log object. If the log should have logstatus error, use the function "create_integration_monitor_log_error" instead.

Args:

  • app (LimeApplication)
  • integration_monitor_batch (LimeObject, optional): Integration monitor batch object. Defaults to None.
  • integration_key (str, optional): Key to integration monitor object. Used to fetch integration monitor object if not provided in parameter "integration_monitor". Defaults to ''.
  • integration_id (str, optional): Integration ID if it exists. Defaults to ''.
  • log_status (str, optional): Log status. Defaults to "ok".
  • Available log statuses (included in base package): See data structure above.
  • Note: Possible to add your own statuses in LISA.
  • log_text (str, optional): Log text describing status. Defaults to ''.
  • message (str, optional): Message if it exists. Defaults to ''.

Raises:

  • IntegrationMonitorNotFound (Exception): If integration monitor not found by integration_key parameter.

Returns:

  • Integration Monitor Log object (Union[LimeObject, None]): Returns LimeObject if success on creation, else None.

create_integration_monitor_log_error

Helper function for creating an integration monitor log object with status error.

Args:

  • app (LimeApplication)
  • integration_monitor_batch (LimeObject, optional): Integration monitor batch object. Defaults to None.
  • integration_key (str, optional): Key to integration monitor object. Used to fetch integration monitor object if not provided in parameter "integration_monitor". Defaults to ''.
  • integration_id (str, optional): Integration ID if it exists. Defaults to ''.
  • log_status (str, optional): Log status. Defaults to "error".
  • Available log statuses (included in base package): See data structure above.
  • Note: Possible to add your own statuses in LISA.
  • log_text (str, optional): Log text describing status. Defaults to ''.
  • error_msg (str, optional): Error message if it exists. Defaults to ''.

Raises:

  • IntegrationMonitorNotFound (Exception): If integration monitor not found by integration_key parameter.

Returns:

  • Integration Monitor Log object (Union[LimeObject, None]): Returns LimeObject if success on creation, else None.

update_integration_monitor_batch

Helper function for updating an integration monitor batch object.

Args:

  • app (LimeApplication)
  • integration_monitor_batch (LimeObject): Integration monitor batch object. Defaults to None (to catch exception).
  • batch_status (str, optional): Batch status. Defaults to "ok".
  • Available batch statuses (included in base package): See data structure above.
  • Note: Possible to add your own statuses in LISA.
  • no_created (int): Amount of created objects. Defaults to 0.
  • no_updated (int): Amount of updated objects. Defaults to 0.
  • no_deleted (int): Amount of deleted objects. Defaults to 0.
  • batch_text (str, optional): Batch text describing status. Defaults to ''.
  • error_msg (str, optional): Error message if it exists. Defaults to ''.
  • endtime (datetime, optional): Endtime if it exists. Defaults to None.

Raises:

  • IntegrationMonitorBatchNotFound (Exception): If integration monitor batch is not provided in function call.

Returns:

  • Integration Monitor Batch object (Union[LimeObject, None]): Returns LimeObject if success on creation, else None.