JSON Settings
Either the MQTT collector or the REST API collector can be configured to read values from JSON.
Collector settings
IgnoreJsonPathErrors
Description: The IgnoreJsonPathErrors setting determines whether errors in JSONPath expressions should be logged or not.
- Use IgnoreJsonPathErrors = false if your JSON structure should always contain specific fields, and you want to log missing or malformed JSONPath expressions.
- Use IgnoreJsonPathErrors = true if your JSON format is dynamic and you expect some fields to be missing. Errors resulting from missing paths or invalid expressions are ignored.
Required: No Default: false
Measurement settings
The measurement settings reflect the configuration possibilities for mapping a JSON message. The values are extracted from the messages using JSONPath. JSONPath documentation can be found here , jsonpath.com is a useful tool to test JSONPath expressions.
The path expressions can either yield a single value, or a list of values. The expressions for the timestamp(s), status(es), and tags and values have to either yield the same amount of results as the expression for the Measurement(s), or only a single value, in which case that single value will be used for all found measurements.
Topic
Description: The topic to listen to. When the topic is specified here, it will override the topic that was set in the collector. Required: No
CollectionType
Description: The way this measurement should be collected from the OPC-UA server. Required: No Default: raw Options:
- raw: Raw measurements collect all points as they are received from the MQTT broker. No filtering is applied to them whatsoever.
- downsampled: For downsampled measurements, the DownsamplingInterval setting indicates how much time needs to have passed since the last datapoint before the next one is written. If less time has passed, the new point is ignored. If more time has passed, the point is collected and its timestamp becomes the new reference time to which new points are compared. No filtering is applied to points with quality other than Good.
- Monitoring: Monitored measurements collect data on every change of the measurements value. Incoming points are ignored if their value is equal to that of the last point before it. Typically, monitored measurements are configured for boolean or string data types that indicate an equipments state, f.e. for a valve that opens and/or closes only a few times per hour. No filtering is applied to points with quality other than Good.
DownsamplingInterval
Description: The minimum interval between points (only used for CollectionType downsampled). Required: No Default: 0
MeasurementPath
Description: The json path that leads to a value, or a list of values in the message Required: Yes
TimestampPath
Description: The JSONPath that leads to a timestamp, or a list of timestamps in the message Required: No If Empty: The collector's timestamp will be assigned to data points.
StatusPath
Description: The json path that leads to a status, or a list of statuses in the message. If not set, status will default to ‘Good’ Required: No
TagNamesAndTagValuePaths
Description: Map describing tags, where keys are the tag names, and the values are the json paths of the tag values Required: No
TimestampLayout
Description: A timestamp layout is used to correctly interpret the resulting timestamp(s) from the TimestampPath. A list of available timestamp formats, along with their string representations, can be found in the Golang Time package documentation. Required: No If Empty: The default RFC3339 timestamplayout e.g. 2006-01-02T15:04:05Z07:00 is used.
For timestamps in UNIX format, one of the following values can be used: UNIX (time in s), UNIXMILLIS (time in ms), UNIXMICROS (time in μs), or UNIXNANOS (time in ns).
For other timestamp formats, see the examplesexamples below.
Warning: The measurement TimestampLayout setting overrides the collector's TimestampLayout setting.
Timestamp Layout Examples:
Timestamp in JSON message | TimestampLayout |
|---|---|
2024-03-31T14:30:00Z | 2006-01-02T15:04:05Z07:00 |
2024-03-31T14:30:00+02:00 | 2006-01-02T15:04:05Z07:00 |
1711895400 | UNIX |
1711895400123 | UNIXMILLIS |
Custom Timestamp Layout Examples:
Timestamp in JSON message | TimestampLayout |
|---|---|
31-03-2024 14:30:00.123 | 02-01-2006 15:04:05.000 |
Sunday, 31 Mar 2024 14:30:00 UTC | Monday, 02 Jan 2006 15:04:05 MST |
Custom timestamp layouts allow flexibility for different timestamp representations. You can define them according to your needs using Go’s time layout reference here.
Important: If your timestamps use a different structure, make sure to adjust the timestamp layout accordingly