This guide will help you get started by building a report and then publishing data to it.
For more information about reporting, please view the topic page: Reports
The following guide will walk you through creating a ficticious temperature report that collects a temperature and customer field from each device, and then generates several aggregations.
Follow the steps below to create a new report.
Reports
in the navigation menu.New report
.Temperature Report
.temperature
. This value is used when publishing data to a report from triggers.Follow the steps below to add two fields to the report, temperature
and customer
.
+ Add Field
.name
to Temperature
.key
to temperature
.data type
to number
.+ Add Field
.name
to Customer
.key
to customer
.data type
to customer
.Follow the steps below to add two aggregations to the report.
Temperature
aggregation. This will be a range aggregation to create multiple buckets depending on the value of the field.Temperature
tab to select the field.+
button next to Aggregations to add a new aggregation.name
to Temperature
.Pivot on field
blank.range
since this is a numeric field.low
and set to
to 10
, leave from
blank to indicate any smaller value.mid
and set from
to 10
and to
to 20
.high
and set from
to 20
, leave to
blank to indicate any larger value.Save
to save the aggregation.Devices by Customer
aggregation, this will be a terms aggregation to count records with distinct values.Customer
tab to select the field.+
button next to Aggregations to add a new aggregation.name
to Devices by Customer
.Pivot on field
blank.terms
since this is a string field.Save
to save the aggregation.Temperature by Customer
aggregation. This will be a range aggregation to create multiple buckets depending on the value of the field, but in addition, the groups will be sub-grouped by customer.Temperature
tab to select the field.+
button next to Aggregations to add a new aggregation.name
to Temperature by Customer
.Pivot on field
to Customer
.range
since this is a numeric field.low
and set to
to 10
, leave from
blank to indicate any smaller value.mid
and set from
to 10
and to
to 20
.high
and set from
to 20
, leave to
blank to indicate any larger value.Save
to save the aggregationReports are published from triggers. Below we will create a sample trigger to publish data to the report.
Triggers
.New trigger
.Name
to Populate Report
.Event type
to Generic
.Filter generic key
field to report-gen
.Generic sample
field to {}
.report.publish('temperature','sensor1',event.ts,{name: 'Sensor1', values: { temperature: random.double(0.0, 30.0), customer: 'customer1'}})
report.publish('temperature','sensor2',event.ts,{name: 'Sensor2', values: { temperature: random.double(0.0, 30.0), customer: 'customer1'}})
report.publish('temperature','sensor3',event.ts,{name: 'Sensor3', values: { temperature: random.double(0.0, 30.0), customer: 'customer1'}})
report.publish('temperature','sensor4',event.ts,{name: 'Sensor4', values: { temperature: random.double(0.0, 30.0), customer: 'customer2'}})
report.publish('temperature','sensor5',event.ts,{name: 'Sensor5', values: { temperature: random.double(0.0, 30.0), customer: 'customer2'}})
report.publish('temperature','sensor6',event.ts,{name: 'Sensor6', values: { temperature: random.double(0.0, 30.0), customer: 'customer3'}})
report.publish('temperature','sensor7',event.ts,{name: 'Sensor7', values: { temperature: random.double(0.0, 30.0), customer: 'customer3'}})
report.publish('temperature','sensor8',event.ts,{name: 'Sensor8', values: { temperature: random.double(0.0, 30.0), customer: 'customer3'}})
Save and close
.Populate Report
trigger and click the triangle
icon to start the trigger.running man
icon to execute the trigger.Execute
button in the popup.Reports
.Temperature Report
.Temperature
aggregation, with a rollup of data by range bucket.Devices by Customer
aggregation, this shows the terms aggregation with number of entries for each customer.Temperature by Customer
aggregation with the pivoted data showing the number of devices in each range band grouped by customer.This was a simple example of how to build a report, but you can build upon this basic model to create any custom report you may need.