Monitor Extensions (Beta)
Page Contents
Monitor Extensions are the most recently added extension type. They fill a very different functionality than the other extension types: they enable you to monitor your Agillic instance’s activities.
Monitor Extensions are in a beta phase. This means it is fully available on all instances, and is mature for production usage. In addition, you can expect feature expansions and improvements in future releases. Read our release notes, and this documentation to keep up to date! Feedback is welcome at product.feedback@agillic.com
Monitor Extensions have access to a 7-day history of your instance’s logs for a set of attributes relevant to the instance’s data ingress and egress, outbound communications, flow executions, and more. Instead of extension code affecting the recipients in your instance, in monitors you can write code to parse the instance’s data and verify your marketing/data-relevant operational statuses. The results can be delivered to a set of email addresses as HTML or provided as JSON requested via an API call (outbound HTTP calls to other endpoints are also supported). Results are classified as information or as errors.
Note that the word error in this Monitor Extension documentation refers to issues your monitor finds in the data, not an exception thrown in running the monitor. Read more details about the reporter, where errors are inserted.
There is no UI in the Agillic interface to view this extension type.
Here are some examples use cases which monitors can be written for, with the operational questions that can be answered:
Import Monitor
- Did all files we expect get imported successfully?
- Did any fail?
- Did some never show up?
- Is the row count of the file reasonable compared to previous files?
Flow Monitor
- Did all expected flows run?
- Is the recipient count entering the flow reasonable?
- Are recipients being kicked, or failing at some point?
Outbound Communication Monitor
- Are we sending a reasonable amount of this particular communication over the course of a day?
It’s also important to understand what Monitor Extensions cannot provide solutions for. They will not:
- Get values of the Instance’s internal application logs, memory usage, or other server details
- Do predictions of future campaigns
- Provide status of incomplete, currently executing jobs
- Show detailed Statistics of campaign performance (Like the Reporter and Activity Exports do)
Execution Method
The execution method for a Monitor Extension must be called monitor
. This method does not have a return type, and the output of a Monitor Extension does not affect recipients, as other extension types do.
Execution Details
In addition to the monitor
execution method, the monitor’s execution requires more details. These details are provided in the configuration function executionInfo
, which has a response type of a JavaScript Map. We recommend keeping the setup a single statement, as shown in our example below, which utilizes all attributes.
Here is each allowed attribute described:
Attribute | Description |
---|---|
urlTrigger |
Enables the execution of a Monitor Extension to be triggered by an endpoint protected with Basic Authentication using API Credentials:
https://{instanceName}-prod.agillic.eu/api/v2/monitor/execute/{MonitorId}
The results are delivered as a JSON Object derived from the reporter argument in the execution method.
|
responseCodeForError |
If reporter response contains errors, the response code will be as designated here. Otherwise, the monitor will return a 200. |
async |
Allows for asynchronous execution, so the monitor can be triggered, providing an immmediate 202 response, while the monitor runs. Calling the same the same triggering url will either return 202 if it is still running, a 200 if the monitor ran with no errors, or the urlTrigger.responseCodeForError value if there was an error present. |
cacheInMinutes |
Duration of time the monitor's response is cached, in minutes. The minimum and default time is 10 minutes, and a monitor cannot be run more than once every 10 minutes. |
scheduled |
Enables the execution of a Monitor Extension to be scheduled, and deliver the results by email, with the results accessible by URL. |
alertEmails |
List of emails monitor should send alert emails to, containing HTML describing of reporter.error . Can be empty, but then no email is sent when an error details are found. |
statusEmails |
List of emails monitor should send status emails to, containing HTML describing reporter.info details. Can be empty, but then no email is sent when information details are found. |
hours |
List of hours when monitor is scheduled to be run. Monitor results are evaluated 5 minutes after the hour start, and depending on the contents of the reporter argument, send emails to the statusEmails or alertEmails list. |
urlExposed |
Enables the fetching of the JSON results of the more recent scheduled run, via an endpoint protected with Basic Authentication using API Credentials: https://{instanceName}-prod.agillic.eu/api/v2/monitor/result/{MonitorId} The results are delivered as a JSON Object derived from the reporter argument in the execution method. |
The Email lists do not have to be filled out if you would rather the monitor results to your own endpoint. See an example here: Notify Endpoint
Arguments
The input arguments for Monitor Extensions are unique to the type, but in general are readable/writable in a similar fashion to the other more standard input arguments.
activity:
This is a read-only variable which contains the data describing the Instance's last 7 days of logs.reporter:
This variable is where results are written, to inform the relevant stakeholders of general information, or raise an alarm if necessary.
Details on activity
Reading activity object
Imports |
|
Attribute |
imports Array with each entry containing a import file log. Import files is still being processed are not included. |
---|---|
Object Details |
|
Iteration & Reading Example |
|
Executions |
|
Attribute |
executions Array with each entry containing current status of a scheduled flow execution. Flow executions of 0 recipients and trigger flows are not included. |
Object Details |
|
Iteration & Reading Example |
|
Uploads |
|
Attribute |
uploads Array with each entry containing Export Flow generated files, uploaded to external services using an Export Profile |
Object Details |
|
Iteration & Reading Example |
|
Activity Exports |
|
Attribute |
activityExports Array with each entry containing generated and exported(if relevant) Activity Export Files. |
Object Details |
|
Iteration & Reading Example |
|
Outbound |
|
Attribute |
outbound Array with each entry containing all types of outbound activity with day granularity. |
Object Details |
|
Iteration & Reading Example |
|
Activities where nothing occurs are not logged in the activity
argument. For example, flow executions with 0 recipients, outbound communications with 0 sent or errored: all are not present in these logs.
Details on reporter
Writing to reporter object
The reporter
input argument provides a standardized way to mark results of the Monitor extension as errors, or just information. Both errors and information support 2 different ways to store information, with a flag or increment, as shown below:
Attribute | Example Output |
---|---|
reporter.error.flag Any attributes written to this entry point will create a flag which will be classified as an error for the provided primary headline, and secondary headline. reporter.error.flag("Files not Imported","File1");
|
|
reporter.error.inc Any attributes written to this entry point will increment a counter which will be classified as an error for the provided primary headline, and secondary headline. reporter.error.inc("Rows Missing","rows",-128);
|
|
reporter.info.flag Any attributes written to this entry point will will create a flag which will be classified as information for the provided primary headline, and secondary headline. reporter.info.flag("Files Imported","File2");
|
|
reporter.info.inc Any attributes written to this entry point will increment a counter which will be classified as information for the provided primary headline, and secondary headline. reporter.info.inc("File Row Count","File2",1024);
|
Reading reporter object
In some cases, you may want to read the reporter
as a JSON Object. You can achieve this by calling the reporter with the jsonString
method, and parsing it as a JSON Object:
var reporterJSON = JSON.parse(reporter.jsonString);
//now you can access it as a JSON Object
var reporterJSONError = reporterJSON.errors;
var reporterJSONInfo = reporterJSON.info;
The main use-case that you may want to use the reporter as a JSON Object, is if you wanted to send the results of a monitor to an endpoint. See below for an example implementation of a this setup.
Notify an Endpoint
If you are using a URL triggered monitor with the asynchronous option, or just want a scheduled monitor which also sends results to a particular endpoint, you can use our Http Helper to send an HTTP request. An example implementation could look like:
This approach works for both scheduled and triggered executions, as all code is executed in order.
Examples
You can view these example monitor extensions in the Examples section: