Enable data aggregation
- Data aggregation is enabled by editing the config/services.json file. Set
"enabled"tofalseas shown below:
{
"serviceName": "aggregation",
"serviceLibrary": "./aggregation/cttimestamp.dll",
"enabled": false
}- Restart the server.
Requirements:
- The table to be aggregated must have at least one
CT_TIMESTAMPauto-timestamp field. - The auto-timestamp field must be the first segment of any index on that table.
Supported field types:
- Signed integer types:
CT_TINYINTCT_SMALLINTCT_INTEGERCT_BIGINT
- Unsigned integer types:
CT_UTINYINTCT_USMALLINTCT_UINTEGERCT_UBIGINT
- Float types:
CT_SFLOATCT_EFLOATCT_DFLOAT
The automatic data aggregation feature is configured using a plugin configuration file, cttimestamp.json.
Configure data aggregation
- Navigate to and open the
cttimestamp.jsonfile in theconfigfolder (server\aggregation\ctTimeStamp.dll). - Observe the format of the
cttimestamp.jsonfile:
{
"debug": false,
"sourceTableList": [
{
"database": "ctreeSQL",
"sourceTableName": "sensor",
"aggregatedTableList": [
{
"aggregatedTableName": "aggregation1",
"timestampFieldName": "ts",
"unitOfTime": "second",
"unitOfTimeValue": 20,
"aggregatedTableInSQL": true,
"aggregatedTableOwner": "admin",
"aggregatedFieldList": [
{
"aggregatedFieldName": "TempAverage",
"sourceFieldName": "temperature",
"aggregateFunction": "average"
}
]
}
]
}
]
}
- Edit the
config/services.jsonfile. Adjust the following section to changefalsetotrue:
{
"serviceName": "aggregation",
"serviceLibrary": "./aggregation/cttimestamp.dll",
"enabled": true
}
- Restart the server.
Example
{
"sourceTableList": [
{
"database": "ctreeSQL",
"sourceTableName": "sensor",
"aggregatedTableList": [
{
"aggregatedTableName": "aggregation1",
"timestampField": "ts",
"unitOfTime": "second",
"unitOfTimeValue": 20,
"aggregatedFieldList": [
{
"aggregatedFieldName": "TempAverage",
"sourceFieldName": "temperature",
"aggregateFunction": "average"
},
{
"aggregatedFieldName": "PressMax",
"sourceFieldName": "pressure",
"aggregateFunction": "maximum"
}
]
}
]
}
]
}
Property summary
| Property | Description | Default | Type | Limits (inclusive) |
|---|---|---|---|---|
"debug" |
The "debug" property enables timestamp/aggregation debugging. |
true |
Boolean |
|
"sourceTableList" |
The "sourceTableList" contains an array of source tables. |
array |
"aggregatedTableList"
"aggregatedTableList" property summaries
| Property | Description | Default | Type | Limits (inclusive) |
|---|---|---|---|---|
aggregatedTableName |
The "aggregatedTableName" property defines the name of an aggregation table. |
string | ||
timestampFieldName |
The "timestampFieldName" property defines the source table field name with auto-timestamp value to monitor. |
string | ||
unitOfTime |
The
This parameter sets the width of the aggregation sample window, in units of time — for example, setting |
string | ||
unitOfTimeValue |
The
This parameter sets the width of the aggregation sample window, in units of time — for example, setting |
integer | ||
aggregatedTableInSQL |
The "aggregatedTableInSQL" property indicates if the aggregation table is available. |
Boolean |
|
|
aggregatedTableOwner |
The "aggregatedTableOwner" property sets the SQL owner of the aggregation table. |
Inherited from the source table or "admin"
|
string | |
aggregatedFieldList |
The "aggregatedFieldList" property contains a list of aggregated values to include in the aggregation table where each value is one field in the table. |
array | ||
|
aggregatedFieldList .aggregatedFieldName |
The "aggregatedFieldName" property defines the aggregated field name to store in this aggregation table. |
string | ||
|
aggregatedFieldList .sourceFieldName |
The "sourceFieldName" property contains the field name from the source table to aggregate. |
string | ||
|
aggregatedFieldList .aggregateFunction |
The
|
string |
|