Difference between revisions of "Computed measurement"
Line 27: | Line 27: | ||
=== Examples === | === Examples === | ||
− | ==== Example 1 ==== | + | ==== Example 1: Temperature Scale Conversion ==== |
+ | |||
+ | This example shows a simple usage of computed measurement. | ||
+ | |||
+ | Imagine you have a temperature sensor that sends raw temperature values in degrees Farenheit (℉) and you want to show the temperature in degrees Celsius (°C) instead. This is the temperature measurement from the temperature sensor that you have as input: | ||
+ | |||
+ | { | ||
+ | "tm_source": xxxxxxxxxx, | ||
+ | "site_id" xxxxxxxx, | ||
+ | "tag1": "xxxxxxxx", | ||
+ | "tag2": "xxxxxxxx", | ||
+ | "temperatureF": xxxxxxxxx, | ||
+ | ... | ||
+ | } | ||
+ | |||
+ | And this is the computed measurement that you want to output: | ||
+ | |||
+ | { | ||
+ | "tm_source": xxxxxxxxxx, | ||
+ | "site_id" xxxxxxxx, | ||
+ | "tag1": "xxxxxxxx", | ||
+ | "tag2": "xxxxxxxx", | ||
+ | "temperatureC": xxxxxxxxx, | ||
+ | ... | ||
+ | } | ||
+ | |||
+ | You can use the following script to perform the temperature metric conversion: | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
... give a trivial example ... | ... give a trivial example ... | ||
==== Example 2 ==== | ==== Example 2 ==== | ||
... give a more complex example ... | ... give a more complex example ... |
Revision as of 10:28, 16 September 2019
This page describes computed measurement in detail.
Contents
Overview
As described here, computed measurement is a type of data that is generated from other data sources.
... describe in detailed ... ... include a diagram to describe the parts that the developer needs to know ... ... describe the lifecycle of those parts ...
Design
The first thing to do when designing a computed measurement is to decide what are the inputs and what to output. A computed measurement can specify multiple measurements as input. Metrics and tags in those measurement will then be available to the function that is responsible for generating the output.
... what are valid inputs ... ... what is a valid output ...
Implementation
... describe what functions the developer must override, and what is the expected behaviour of those functions ... ... Junhao feedback that it is unclear that you must output a valid measurement. he thought he has to always output something, like NULL during initial invocation ...
Testing
... how to test ... ... limitations of the test environment ...
Execution
... describe when the compute function will be run. ... ... describe caveats when using multiple measurements - eg. measurement 1 and measurement 2 can come in at different times, and compute will be called twice ...
Examples
Example 1: Temperature Scale Conversion
This example shows a simple usage of computed measurement.
Imagine you have a temperature sensor that sends raw temperature values in degrees Farenheit (℉) and you want to show the temperature in degrees Celsius (°C) instead. This is the temperature measurement from the temperature sensor that you have as input:
{ "tm_source": xxxxxxxxxx, "site_id" xxxxxxxx, "tag1": "xxxxxxxx", "tag2": "xxxxxxxx", "temperatureF": xxxxxxxxx, ... }
And this is the computed measurement that you want to output:
{ "tm_source": xxxxxxxxxx, "site_id" xxxxxxxx, "tag1": "xxxxxxxx", "tag2": "xxxxxxxx", "temperatureC": xxxxxxxxx, ... }
You can use the following script to perform the temperature metric conversion:
... give a trivial example ...
Example 2
... give a more complex example ...