Collector http/rest
  • 11 Aug 2021
  • 6 Minutes to read
  • Contributors
  • Dark
    Light
  • PDF

Collector http/rest

  • Dark
    Light
  • PDF

Article Summary

The purpose of this article is to be a reference for the Modbus collector part of the full Data Collection Module documentation.

Prerequisite

A Starter package (SiteManager + accounts)
A webserver capable device


Config main

The Config main (array of objects, mandatory) contain the following fields:

FunctionTypeImportanceDescription
ConfigNamestringmandatoryUnique name for this configuration file. Follows the rules for names.
ConfigDescriptionstringoptionaltext describing this configuration.
CheckpointIntervalinteger == 0 or >= 60optionalThe interval with which all data from the internal datasample cache is saved to disk. This more unstable (power) the SiteManager, the more often data should be saved. Saving it often, however will also cost performance and wear on the hard-disk/flash. A value of 0 means, never checkpoint, otherwise it means interval in seconds between saves. If not specified the value 15 * 60 (15 minutes) is used.
AlarmsSavedinteger >= 4optionalThe number of alarms saved in the store-and-forward database. If this values is not specified, it will default to 32.
WaitForNTPbooleanoptionalSynchronize DCM data collection with NTP time. If this parameter is true, all DCM collectors will not begin collecting data until NTP is enabled and configured and NTP has synchronized date/time. If not specified, the value is true.

Since the JSON format itself doesn't define a comment notation, DCM accepts a fieldname comment with any type of value in any section.

Example of comment

"Comment": "Example of a comment for use in any section.": 


Collector main

The Collectors (array of objects, mandatory) list elements contain the following fields:

FunctionTypeImportanceDescription
CollectorNamestringmandatoryUnique name (within this configuration file) of a device to collect data from (this is the name used in the agent configuration). Follows the normal rules for names.
CollectorDescriptionstringoptionalDescription of this collector. For your use, no system function.
CollectorIPAddrstringoptionalDefault IP address (or DNS name) for the device to be polled. The agent Target IP address will take precedence over this.
CollectorPortnointeger > 0 and < 65535optionalDefault port number for the device to be polled. The agent Target Port Number will take precedence over this. If neither CollectorPortno , nor agent Target Port Number, is specified, the appropriate port will be used, depending on the Protocol parameter value.
AliasstringoptionalThis is the CollectorName of another collector from which all the parameters (expect CollectorName, CollectorDescription, CollectorIPAddr and CollectorPortno) are copied. An alias cannot refer to another alias.
Protocolstring-enummandatoryThe protocol used to collect data. Currently 3 possible values exists: "OPC-UA/TCP", "Modbus/TCP", "Http/GET" and "Simulator".
ConnectRetryMininteger > 0mandatoryThe minimum number of seconds before trying to reestablish a connection to the device being sampled. An exponential backoff algorithm is used to retry connection establishment, starting after ConnectRetryMin and increasing to ConnectRetryMax.
ConnectRetryMaxinteger > 0mandatoryMaximum number of seconds before trying to reestablish a connection to the device being sampled.
HTTPGETAccess
objectoptionalcollection of parameters needed to access a given HTTP server via GET.
SamplePointsarray of objectsmandatoryList of samples to be collected, possibly aggregated and stored in the Store'n'Forward database.


HTTPGETAccess

The HTTPGETAccess objects contain the following elements:

FunctionTypeImportanceDescription
HTTPGETs
array of objectsmandatoryList of HTTP GET URLs to be performed during collection of data if the Protocol is "Http/GET".
HTTPGETUsername
string
optionalUsername for login to HTTP server.
HTTPGETPassword
string
optionalPassword for login to HTTP server.
HTTPGETUrlRootCertificate
string
optional
Name of ROOT certificate to use for verifying the HTTPS/FTPS server used in the URL.
HTTPGETTimeout
integer > 0
optional
Timeout (in millisecond) for all Http/Get requests. If not present, the value 500 is used.


HTTPGETs

The HTTPGETs objects contain the following elements:

FunctionTypeImportanceDescription
HTTPGETID
integer >= 0
mandatoryis a unique ID (within this Collectors element) for this entry. (Used by the SamplePoints entries.)
HTTPGETUrl
string
mandatory
The URL used for this access. It must adhere to the syntax proto://[user[:password]@]host[:port]][/path]. The supported "proto" values are "http". "https", "ftp" and "ftps". Note that the host, port, user and password of this URL will be replaced by CollectorIPAddr, CollectorPortno, HTTPGETUrlUsername and HTTPGETUrlPassword.
HTTPGETUrlUsername
stringoptional
Username for login to HTTP server for this specific URL. If not present, the value of HTTPGETUsername references by HTTPGETID is used.
HTTPGETUrlPassword
string
optional
Password for login to HTTP server.
HTTPGETUrlRootCertificate
string
optional
Root certificate name for the HTTP server accessed. If not present, the peer validate of the server is not performed.
HTTPGETSampleInterval
integer >= 0mandatoryNumber of seconds between each collection of data using this URL. If the interval is 0, only event-driven polling is used.
HTTPGETUrlTimeout
integer > 0optionalTimeout (in milliseconds) for these Modbus FC requests. If not present, the value is that of ModbusTimeout referenced by the ModbusFCID.
HTTPGETFormat
string-enum
mandatory
The expected type of content of the response from the device. Currently 3 values exists: "json", "xml", "raw". Note that there is no check for the HTML content-type, only an attempt to run a "json" or "xml" parser on the returned data.


Samplepoint items

The SamplePoints objects contain the following elements:

FunctionTypeImportanceDescription
SampleNamestringmandatoryName of this sampled value (sometimes called a tagname). Follows the normal rules for names.
SampleDescriptionstringoptionalIs a text description of this sample value.
SampleUnitstringoptionalIs a description of the unit of messurement for this sample.
SampleGroupstringoptionalDesignates (in some datasrvs) that all samplepoints in that group should be handled (displayed) together. The DCM system itself places no meaning on this group affiliation.
SamplesSavedinteger > 0mandatoryIs the number of values collected that is saved as minimum in the Store'n'Forward database. If set to 0 the samplepoint isn't stored in the S'n'F database and thus not delivered to cloud, but can be used for aggregations.
OnlySaveOnChangedbooloptionalControl if new sample values should only be saved to the Store'n'Forward database if the values have changed since last sample. If not set, it is false.
ChangeLimit
integer/double
optional
Only used if OnlySaveOnChanged is true. This describes a limit for what "changed" means. If a new sample value is this amount less or more than the previous sample value, it is considered the "same" value. This is a simple hysteresis to filter out inaccurate (jitter) measurements.
SampleDataTypestring-enummandatoryThe type of data collected. The possible values are:
"bool" (1 bit),
"sbyte" (8 bit signed),
"byte" (8 bit unsigned),
"int16" (16 bit signed),
"uint16" (16 bit unsigned),
"int32" (32 signed),
"uint32" (32 bit unsigned),
"int64" (64 bit signed),
"uint64" (64 bit unsigned),
"float" (32 bit),
"double" (64 bit),
"string" (variable text up to 24575 bytes. Includes terminating NULL),
"data" (variable data up to 24575 bytes).
Note that not all collectors can handle all data types.
SampleLowerLimitinteger/doubleoptionalThe lower limit for the collected data. If the collected data value is less than SampleLowerLimit, it is evaluated in accordance with SampleLimitDiscard and SampleLimitAlarm.
SampleUpperLimitinteger/doubleoptionalThe upper limit for the collected data. If the collected data value is more than SampleUpperLimit, it is evaluated in accordance with SampleLimitDiscard and SampleLimitAlarm.
SampleLimitDiscardboolmaybe-optionalControls if a sample limit violation results in the sample value being discarded. Mandatory if either SampleLowerLimit or SampleUpperLimit is present.
SampleLimitAlarmboolmaybe-optionalControls if a sample limit violation generates an alarm. Mandatory if either SampleLowerLimit or SampleUpperLimit is present.
HTTPGETValue
objectmaybe-optionalDescription of how to address a specific HTTPGET value, when collecting values from it. Mandatory if the protocol type is "Http/GET".


HTTPGETValue

TheHTTPGETValue object contains the following elements:





HTTPGETREFinteger >= 0mandatoryThis is a reference to the HTTPGETs element with the same value of it's field HTTPGETID.
Selectstring
maybe-optionalThis expression selects element from which, the value is to be extracted. Mandatory if HTTPGETFormat has the value "json" or "xml". When the format is "json", the string must adhere to RFC6901 JSON pointer notation. When it is "xml", it must adhere to XPath 1.0 (W3C Recommendation) notation.


http Collector examples 

{
            "comment": "Collecting from a simple JSON formatted webserver",
            "CollectorDescription": "Production simulation",
            "CollectorName": "fake",
            "ConnectRetryMax": 240,
            "ConnectRetryMin": 20,
            "HTTPGETAccess": {
                "HTTPGETTimeout": 2000,
                "HTTPGETs": [
                    {
                        "HTTPGETFormat": "json",
                        "HTTPGETID": 1,
                        "HTTPGETSampleInterval": 2,
                        "HTTPGETUrl": "http://10.0.0.249/fake.html"
                    }
                ]
            },
            "Protocol": "Http/GET",
            "SamplePoints": [
                {
                    "HTTPGETValue": {
                        "HTTPGETREF": 1,
                        "Select": "/status"
                    },
                    "SampleDataType": "string",
                    "SampleDescription": "PLC status",
                    "SampleName": "PLCStatus",
                    "SamplesSaved": 30
                }
            ]
        }

{
            "comment": "Collecting from a simple webserver with raw", 
            "CollectorDescription": "Production simulation 2",
            "CollectorName": "fake2",
            "ConnectRetryMax": 240,
            "ConnectRetryMin": 20,
            "HTTPGETAccess": {
                "HTTPGETTimeout": 2000,
                "HTTPGETs": [
                    {
                        "HTTPGETFormat": "raw",
                        "HTTPGETID": 1,
                        "HTTPGETSampleInterval": 2,
                        "HTTPGETUrl": "http://10.0.0.249/fake2.html"
                    }
                ]
            },
            "Protocol": "Http/GET",
            "SamplePoints": [
                {
                    "HTTPGETValue": {
                        "HTTPGETREF": 1,
                        "Select": "/Heading"
                    },
                    "SampleDataType": "string",
                    "SampleDescription": "PLC status",
                    "SampleName": "PLCStatusSTRING",
                    "SamplesSaved": 30
                },
{
                    "HTTPGETValue": {
                        "HTTPGETREF": 1,
                        "Select": "/Heading"
                    },
                    "SampleDataType": "data",
                    "SampleDescription": "PLC status",
                    "SampleName": "PLCStatusDATA",
                    "SamplesSaved": 30
                }
            ]
        }
{
            "comment": "Collecting from a XML formatted webserver",
            "CollectorDescription": "Production simulation",
            "CollectorName": "fakeXML",
            "ConnectRetryMax": 240,
            "ConnectRetryMin": 20,
            "HTTPGETAccess": {
                "HTTPGETTimeout": 2000,
                "HTTPGETs": [
                    {
                        "HTTPGETFormat": "xml",
                        "HTTPGETID": 1,
                        "HTTPGETSampleInterval": 2,
                        "HTTPGETUrl": "http://10.0.0.249/fakeXML.html"
                    }
                ]
            },
            "Protocol": "Http/GET",
            "SamplePoints": [
{
                    "HTTPGETValue": {
                        "HTTPGETREF": 1,
                        "Select": "/value1"
                    },
                    "SampleDataType": "string",
                    "SampleDescription": "version",
                    "SampleName": "version",
                    "SamplesSaved": 30
                },
{
                    "HTTPGETValue": {
                        "HTTPGETREF": 1,
                        "Select": "/value2"
                    },
                    "SampleDataType": "string",
                    "SampleDescription": "number",
                    "SampleName": "number",
                    "SamplesSaved": 30
                }
            ]
        }

See complete http/rest examples in the related articles section below. 


Was this article helpful?