Flat JSON to Time Series Conversion Block

Table 1.
Type
'flattotimeseries
This block is used to convert data formatted as Flat JSON into the Predix Time Series data format. A description of this format is in Pushing Time Series Data.
Table 2.
FieldTypeRequiredDefault
attributesObject
log_levelString'off'
log_nameString<block_name>

attributes

The attributes field is an object with key/value pairs that will be directly injected into all output data as Time Series attributes.

log_level and log_name

For details about the log_level and log_name fields, see Generic CDP Blocks.

Examples

The following is a sample configuration for this block.
"flat_to_time_series": {
	"type": "flattotimeseries",
	"config": {
		"attributes": {
			"source": "Albuquerque"
		}
	}
}

An example of input data (Flat JSON) and output data (Predix Time Series) resulting from the above configuration block is as follows. Its configuration fields are as follows.

Input Flat JSON
Input Flat JSON:
{
	"timestamp": "1504739531776",
	"data": {
		"temperature": {
			"val": 15,
			"type": "int16"
		},
		"pressure": {
			"val": 16.2,
			"type": "float"
		}
	}
}
Output Predix Time Series
{
	"messageId": "flex-pipe",
	"body": [
		{
			"name": "temperature",
			"datapoints": [
				[1504739531776, 15, 3]
			],
			"attributes": {
				"source": "Albuquerque"
			}
		},
		{
			"name": "pressure",
			"datapoints": [
				[1504739531776, 16.2, 3]
			],
			"attributes": {
				"source": "Albuquerque"
			}
		}
	]
}
Since no configuration fields for this block are required, the entire ‘config’ field can be omitted:
"flat_to_time_series": {
	"type": "flattotimeseries"
}