Skip to main content

Creating Item Insights 🆕

Introduction​

Item insights are shown in an insights menu after selecting a specific item and provide information about the selected item.

Report Category​

The portal uses the category of the insight report to determine which menu item to show the report in. Additional properties are sent to the report with the selected item id.

These are defined in the following table:

Portal ViewReport CategoryProperties
Master DataMaster Data InsightsID = object _id
DataData InsightsID = data _id excluding the ondate
EventsEvent InsightsID = event id
CurvesCurve Management InsightsID = curve _id + ONDATE = selected ondate
DatasetsDataset Monitoring InsightsDSID = dataset id + ONDATE = selected ondate
ProcessesProcess InsightsID = process _id
ExecutionsProcess InsightsID = process _id, EXECID = execution _id
QueuesQueue InsightsID = queue _id
TypesType InsightsID = type _id
CalendarsCalendar InsightsID = calendar _id
ScriptsScript InsightsID = script _id
AlertsAlert InsightsID = alert _id

Creating Insights​

We have created a few pre-defined template functions based on the layout of the insight report:

  • singleTableReport

    A single table showing the data from a query.

  • masterDetailTableReport

    2 tables showing master data and selected detailed data.

  • chartTableReport

    A chart and a table for data.

note

Just place {{> #insight }} at the top of your mustache script to use one of them

singleTableReport​

A single table report takes the following configuration object:

PropertyTypeExampleDescription
serviceStringcalendarThe name of the service to get the data from
sourceStringprivateThe source of the data
filterObject{'dsid': ReportProperties().DSID}A filter to be applied to the query
columnDefsArray(Object)See columnDefs belowAn array of column definitions for the table
inputsArray(Input)See Inputs belowA list of optional inputs to all the user to select from
dataCallbackFunctiongetDataAn optional callback function that allows you to override the requesting and formatting of the data sent back to Excel
rangeSelectorObjectSee rangeSelector belowAn optional range selector configuration to allow the user to select a range of dates

masterDetailTableReport​

A single table report takes the following configuration object:

PropertyTypeExampleDescription
serviceStringcalendarThe name of the service to get the data from
sourceStringprivateThe source of the data
filterObject{'dsid': ReportProperties().DSID}A filter to be applied to the query
columnDefsArray(Object)See columnDefs belowAn array of column definitions for the table
detailColumnDefsArray(Object)See columnDefs belowAn array of column definitions for the detail table
inputsArray(Input)See Inputs belowA list of optional inputs to all the user to select from
dataCallbackFunctiongetDataAn optional callback function that allows you to override the requesting and formatting of the data sent back to Excel
rangeSelectorObjectSee rangeSelector belowAn optional range selector configuration to allow the user to select a range of dates

chartTableReport​

A single table report takes the following configuration object:

PropertyTypeExampleDescription
serviceStringcalendarThe name of the service to get the data from
sourceStringprivateThe source of the data
filterObject{'dsid': ReportProperties().DSID}A filter to be applied to the query
columnDefsArray(Object)See columnDefs belowAn array of column definitions for the table
inputsArray(Input)See Inputs belowA list of optional inputs to all the user to select from
dataCallbackFunctiongetDataAn optional callback function that allows you to override the requesting and formatting of the data sent back to Excel
rangeSelectorObjectSee rangeSelector belowAn optional range selector configuration to allow the user to select a range of dates
projectionObject{ondate:true, score:true, scoreinfo:true}A projection for fields to show in the chart
chartDefinitionObjectSee chartDefinition belowThe definition of the chart

Inputs Configuration​

PropertyTypeExampleDescription
typeStringselectThe type of input, can be one of (select,text,date,datetime,integer,check)
nameStringTenor TypeThe label to use for the input
helpString'Select something'Help text to display to the user
fieldString_idThe name of the field that will be used in the filter

For select type fields, there are also the following properties:

PropertyTypeExampleDescription
dataArray(String)['test1','test2']An optional list of items to display in the drop-down list. If not used, the system will get a distinct list of items using the field name
serviceStringcalendarThe service to use to get the items for the drop-down list, defaults to the top-level service
sourceStringprivateThe source to use for the items in the drop-down list, defaults to the top-level source
filterObject{category='test'}An optional filter to use to get the items for the drop-down list
multipleBooleantrueIf true, allows multiple selections to be made
selectAllBooleantrueIf this is a multiple selector, this adds an optional 'Select All' option

rangeSelector Configuration​

PropertyTypeExampleDescription
includeTimeBooleanfalseAllow the user to select times as well as dates
timestampFieldStringtimestampThe name of the field containing the dates to filter on, defaults to timestamp
rangesArray(String)['thisyear','nextyear']Optional list of preset ranges to provide to the user
defaultRangeStringthisyearThe default range to select from the list

Selectable ranges​

The following table lists the range names that can be used in the ranges array:

namedescription
yesterday1 calendar day back from today
todayToday
lastmonthThe full previous calendar month
thismonthThe full current calendar month
nextmonthThe full next calendar month
lastyearThe full previous calendar year
thisyearThe full current calendar year
nextyearThe full next calendar year
lastnThe last n calendar days, e.g. last7
nextnThe next n calendar dayes, e.g. next7

Examples​

Example singleTableReport​

The following example shows data corrections for a selected DSID.

Here is the mustache file configuring the insight report:

{{> #insight }}

<script>
singleTableReport({
rangeSelector: {
includeTime : true,
timestampField: 'timestamp'
},
source: 'all',
service: 'correction',
filter: {'dsid': ReportProperties().DSID},
columnDefs: [
{field: 'dsid', headerName: 'Dataset'},
{field: 'ondate', headerName: 'Date'},
{field: 'origin', headerName: 'Origin'},
{field: 'property', headerName: 'Property'},
{field: 'tenor', headerName: 'Tenor'},
{field: 'previous', headerName: 'Previous'},
{field: 'new', headerName: 'New'}
]
});
</script>

Here is the configuration of the report itself:

ir = InsightReport()
ir.id = "DMI_CORRECTIONS"
ir.name = "Corrections"
ir.description = "Corrections Reports"

ir.category = "Dataset Monitoring Insights" // This tells Dataset Monitoring to add it to the list of Insights
ir.template = "insight-ds-corrections" // The name of the mustache file
ir.icon = "bookmark-check" // The icon to use from https://icons.getbootstrap.com/
ir.hideList = true // Don't show this report in the portal report list
ir.hideExcel = true // Don't show this report in the reports menu in Excel
save ir

Example masterDetailTableReport​

The following example shows audit records for a selected DSID (both dataset and dataset feed).

Here is the mustache file configuring the insight report:

{{> #insight }}

<script>
let dsid = ReportProperties().DSID;
let parts = dsid.split(".");
let dsf = parts[0] + "." + parts[1];
let filter = {"$or":[{"service":"dataset_feed","key":dsf},{"service":"dataset","key":dsid}]};

masterDetailTableReport({
rangeSelector: {
includeTime : true,
timestampField: 'timestamp'
},
source: 'private',
service: 'audit',
filter: filter,
columnDefs: [
{field: "user", headerName: "User", width:120},
{field: "action", headerName: "Action", width:90},
{field: "service", headerName: "Service", width:100},
{field: "key", headerName: "Key", width:150},
{field: "timestamp", valueParser: params => Date(params.oldValue), sort: 'desc', headerName: "Date", width:180},
{field: "description", headerName: "Description"}
],
detailColumnDefs: [
{field: "kind", headerName: "Kind", width:40},
{field: "path", headerName: "Path"},
{field: "lhs", headerName: "Change From"},
{field: "rhs", headerName: "Change To"},
]
});
</script>

Here is the configuration of the report itself:

ir = InsightReport()
ir.id = "DMI_AUDIT"
ir.name = "Audit Report"
ir.description = "Audit Report"

ir.category = "Dataset Monitoring Insights" // This tells Dataset Monitoring to add it to the list of Insights
ir.template = "insight-ds-audit" // The name of the mustache file
ir.icon = "body-text" // The icon to use from https://icons.getbootstrap.com/
ir.hideList = true // Don't show this report in the portal report list
ir.hideExcel = true // Don't show this report in the reports menu in Excel
save ir

Example chartTableReport​

The following example shows data delivery scores for a selected DSID.

Here is the mustache file configuring the insight report:

{{> #insight }}

<script>
chartTableReport({
rangeSelector: {
includeTime : false,
timestampField: 'ondate',
ranges: ["last7", "last30", "last60", "thismonth", "lastmonth", "all"],
defaultRange: "last30"
},
service: 'dataset_delivery',
filter: {dsid:ReportProperties().DSID, 'score':{'$ne':0}},
projection: {ondate:true, score:true, scoreinfo:true},
columnDefs: [
{field: 'ondate', headerName: 'Date'},
{field: 'score', headerName: 'Score'},
{field: 'scoreinfo', headerName: 'Details'}
],
chartDefinition: {
credits: {
enabled: false
},
chart: {
type: 'column'
},
title: {text:"Score Report"},
legend:{enabled:false},
xAxis: {
type: 'datetime'
},
yAxis: {
allowDecimals: false
},
series: [
{
name:"Scores",
data:[],
zones: [{
value: 4,
color: 'red'
}, {
color: 'green'
}]
},
]
},
chartX: 'ondate',
chartY: 'score'
})
</script>

Here is the configuration of the report itself:

ir = InsightReport()
ir.id = "DMI_SCORES"
ir.name = "Score Report"
ir.description = "Delivery Score Report"

ir.category = "Dataset Monitoring Insights" // This tells Dataset Monitoring to add it to the list of Insights
ir.template = "insight-ds-scores" // The name of the mustache file
ir.icon = "bar-chart-steps" // The icon to use from https://icons.getbootstrap.com/
ir.hideList = true // Don't show this report in the portal report list
ir.hideExcel = true // Don't show this report in the reports menu in Excel
save ir