Reporting on scenario runs

Dataiku DSS provides the means to add reporters in a scenario. These reporters can be used to inform teams of users about scenario activities. For example, scenario reporters can update users about the training of models or changes in data quality. Reporters can also create actionable messages that users can receive within their email or through other messaging channels.

Note

See our tutorial on reporting scenario activities to learn how to send scenario updates to messaging channels.

Executing scenario reporters

You can instruct a reporter to send messages at any point of a scenario run:

  • To send a message right before a scenario run starts, add a reporter to the scenario in the Settings pane, and set the value of “Send on scenario” to Start.

  • To send a message during the scenario run, add a Send message step (in a step-based scenario) or use get_message_sender() on the Scenario object (in a script scenario).

  • To send a message right after a scenario run ends, add a reporter to the scenario in the Settings pane, and set “Send on scenario” to End. You can further control whether the reporter runs at the end of the scenario, by specifying the “Run condition” as one of the expressions: outcome == 'SUCCESS' or outcome == 'FAILED' or outcome == 'ABORTED'. You can set up several reporters, each having a run condition and a corresponding message.

Building the message contents

Each reporter defines the content to report and, when applicable, channel variables to pass to the reporter.

Before using an instance-level channel, an administrator must configure a messaging channel of the relevant type. In-place Webhooks do not require a configured messaging channel: their URL and HTTP request information are configured directly in the scenario reporter settings.

Reporting by mail provides the most versatility when building messages.

Mail reporter

Select any configured mail messaging channel available to you. Several mail channel types are supported; see Configure a messaging channel.

Dataiku DSS sends messages by mail in either HTML or plain text format, and two engines are available to build the messages:

In both cases, the results of the scenario run are offered to the engines as named variables.

Dataiku DSS comes with a default Freemarker-based template. Use the email template selector to select another template or write your own message.

The “To”, “Cc”, and “Bcc” fields of the mail reporter can take a list of recipients in any of the following syntaxes:

  • regular: john.doe@here.com, jane.smith@there.org

  • JSON-array style: ["john.doe@here.com", "jane.smith@there.org"]

To send one individualized mail to each recipient, the syntax for the “Recipients” field is :

{
   "mails": [
      {
         "to": "[email protected]",
         "variables": {
            "variable1": "Sir",
            "variable2": "some special message for john"
         }
      },
      {
         "to": "[email protected]",
         "variables": {
            "variable1": "Madam"
         }
      }
   ]
}

The variables object for each recipient is then available for replacement in the mail message as a JSON string mailVariables, and its fields as mailVariables_variableName. For example, you can type:

Dear ${mailVariables_variable1},

${if(parseJson(mailVariables).hasField("variable2"), parseJson(mailVariables).get("variable2"), "message for not-john")}

Yours truly,
    A humble documentation

Using email templates from the Enterprise Asset Library

Scenario mail reporters and Send message steps can reuse message bodies and delivery settings from the Enterprise Asset Library. To use an email template, you need at least Reader rights on the collection containing it.

In the email settings, choose Select a template, or Select another template if a template is already selected. Select a template and choose Use email template.

Applying a template replaces the current message body and its Send format and Template type settings, and opens Preview. You can edit the copied body in Code. Later changes to the template do not update this message.

A template can also supply the channel, sender, recipients (To, Cc and Bcc) and subject. Applying it replaces only the supplied delivery settings.

For editable bodies, the settings below the preview and editor control the send format (HTML or Raw text) and the template engine (Freemarker or DSS formulas). For example, a Freemarker message can include ${scenarioName} and ${outcome}. Preview shows the formatting without evaluating variables in editable bodies; variables are evaluated when the email is sent.

The selector also includes a Template files collection. File templates remain linked to their source: Code is read-only, and changes to the file apply to future emails.

To start from the default email content, choose Use base template in the selector. This opens Code with the default HTML content and Freemarker template engine, ready to edit.

Slack, Microsoft Teams, Google Chat, Webhook and Twilio reporters

These reporters only offer variable-based formatting using Dataiku DSS formulas for the message body. These reporters also take additional parameters, like message color or sender alias, that can be computed using Dataiku DSS formulas. Note that Slack uses a specific format for its messages, and leaves html as-is.

For Google Chat, configure a webhook URL directly in the reporter when the destination is specific to that reporter, or select an instance-level Google Chat messaging channel to reuse its configuration across reporters.

Microsoft Teams channels support simple text messages and Adaptive Cards created as JSON.

Here is an example of a card that displays a message with a title and a color depending on the outcome of the scenario:

{
   "attachments":[
      {
         "contentType":"application/json",
         "content":{
            "$schema":"http://adaptivecards.io/schemas/adaptive-card.json",
            "type":"AdaptiveCard",
            "version":"1.0",
            "body":[
               {
                  "type":"Container",
                  "items":[
                     {
                        "type":"TextBlock",
                        "text":"${scenarioName} run report",
                        "weight":"bolder",
                        "size":"medium",
                        "style":"heading",
                        "wrap":true,
                        "color":"${if(outcome == 'FAILED', 'attention', 'default')}"
                     },
                     {
                        "type":"TextBlock",
                        "wrap":true,
                        "text":"[${scenarioName}](${scenarioRunURL}): **${outcome}**"
                     },
                     {
                        "type":"FactSet",
                        "facts":[
                           {
                              "title":"Project",
                              "value":"${scenarioProjectKey}"
                           },
                           {
                              "title":"Triggered by",
                              "value":"${triggerName}"
                           }
                        ]
                     }
                  ]
               }
            ]
         }
      }
   ]
}

Note that you can also send messages to Teams in custom scenarios. See Custom scenarios for some examples.

Shell reporter

Dataiku DSS sends results of the scenario run to the shell script. You can use Dataiku DSS formulas in the Administration section to specify values for environment variables that define the shell script.

Dataset reporter

The Send to dataset reporter appends one row to a dataset for each reported scenario event. Configure the reporter with the project key and dataset name, then define the row as a JSON object that maps dataset column names to string values. The values can contain scenario reporter variables.

Each mapped column must already exist in the dataset and have the string type. You can also specify an existing date column in which Dataiku records the event timestamp.

Scenario run URL

In order to use the reporter variable ${scenarioRunURL}, an administrator must configure the “Dataiku DSS URL” under Administration > Settings > Notifications & Integrations > Dataiku DSS Location > Dataiku DSS URL.

Common variables

You can use variables from the Dataiku DSS instance, project, and scenario run, in the message. Two mechanisms are also available to help with customizing the message:

  • Define new variables with a custom Python script.

  • Handle variables in the message as Dataiku DSS formulas.