Managed Service UI's add-on for email history tracking and reporting comes with predefined line, bar and pie charts. All charts are stored in a single PHP file and can be modified easily by copying it to a new file named settings-stats.php in the same folder.
Each chart is configured as an object with some predefined aggregation queries:
$statsSettings['aggregations']['line'] = [
'action' => [
'label' => 'Action',
'groupby' => 'Inbound',
'buckets' => (new StatsBucket())
->addAggregation($statsAgg['histogram'])
->addAggregation($statsAgg['listener']['in'])
->addAggregation($statsAgg['action'])
->toArray()
]
];
The type of this chart is "line", and it supports other types like "bar" and "pie". The first aggregation in this query, histogram, will be used as X axis data, and the last aggregation, action, will be broken down as Y axis data.
If you want to add a new chart, you can simply add a new object in the line array and give it a unique key. Say we want to show the amount of inbound spam classification on a histogram line chart, without using the predefined objects.
$statsSettings['aggregations']['line'] = [
'action' => [
'label' => 'Action',
'groupby' => 'Inbound',
'buckets' => (new StatsBucket())
->addAggregation($statsAgg['histogram'])
->addAggregation($statsAgg['listener']['in'])
->addAggregation($statsAgg['action'])
->toArray()
],
'classifications' => [
'label' => 'Spam classifications',
'groupby' => 'Inbound',
'buckets' => (new StatsBucket())
->addAggregation([
'key' => 'time',
'type' => 'histogram',
'field' => 'receivedtime'
])
->addAggregation([
'key' => 'listener',
'type' => 'filters',
'filters' => [
'inbound' => [
'type' => 'phrase',
'field' => 'serverid.keyword',
'value' => 'mailserver:inbound'
]
]
])
->addAggregation([
'key' => 'spam',
'type' => 'filters',
'filters' => [
'non-spam' => [
'type' => 'phrase',
'field' => 'score_rpd',
'value' => '0'
],
'suspect' => [
'type' => 'phrase',
'field' => 'score_rpd',
'value' => '10'
],
'valid-bulk' => [
'type' => 'phrase',
'field' => 'score_rpd',
'value' => '40'
],
'bulk' => [
'type' => 'phrase',
'field' => 'score_rpd',
'value' => '50'
],
'spam' => [
'type' => 'phrase',
'field' => 'score_rpd',
'value' => '100'
]
]
])
]
];
The filter will try to match a value (e.g. 100) in Elasticsearch by its field name (e.g. score_rpd). And in the chart it will be translated to the key name of the object, e.g. spam.
After saving the file, the chart should now be available under the line icon in MSUI.
Comments
0 comments
Article is closed for comments.