Previous 14.1 Specifics of measurement server types Next

14.1.29 MQTT measurement servers

The MQTT measurement server is an active but non-discoverable PVSR module which does irregular (non-periodic) measurements: it subscribes to a topic on an MQTT server and if an appropriate message arrives in one of the queues then it processes the messages and turns it into a measurement, by default with the message arriving time as the measurement time (this of course can be overridden with the SET_TIME measurement expression variable). Beside the basic attributes, the equipment has the following additional parameters (the code of the parameter is given in parenthesis; see Subsection 7.5.6 on Parameters of non-SNMP data collectors):

·       IP address (MQTT EQ 1 IP): mandatory parameter, the IP address of the MQTT broker server

·       Topic (MQTT EQ 2 TOPIC): mandatory parameter, the collector subscribes to this topic. The # and the + special characters can be used in the topic name. The # sign means any number of levels in the topic hierarchy while the + sign means exactly one level. The system matches the name of the queue in which the message arrived to the topic name given here and uses the actual values of these special place holders to match the Index parameter of the measurements up to the first point character (.) if there is any or to match the whole Index parameter if it does not contain a point character. Examples:

o   if the parameter's value is a/b/+/+ and the messages arrives in the a/b/c/d queue then the Index of the measurements must be c/d

o   if the parameter's value is a/b/# and the messages arrives in the a/b/c/d queue then the Index of the measurements must be c/d

o   if the parameter's value is a/b/c/d and the messages arrives in the a/b/c/d queue then the Index of the measurement is not relevant

·       Optional user name and password for the MQTT connection:

o   Message Broker user (MQTT EQ 3 USER)

o   Message Broker password (MQTT EQ 4 PASSWORD)

 

The system contains several measurement types and one equipment template for collecting Mosquitto MQTT server related data.

 

The variables in the measurement expressions can be one of two types. In the first case the system interprets the message coming in the queue as simple text, i.e. it will be passed to the measurement calculation engines as it is. To use this mode the variable in the measurement expression must be set to “simple”. In the second case the system interprets the message as JSON and processes it as described in the REST collector documentation (14.1.28 REST measurement servers). To use this mode the variable in the measurement expression must begin with “json_”. There are three differences in the processing compared to the REST collector:

·       Since the data collector does not support discovery, only the PVSR_RETURN type can be used

·       Although the PVSR_PORT1, PVSR_PORT2, … parameters can be used for filtering as described at the REST collector ([${PVSR_PORT2}=value]), it is important to note that the part of the Index parameter before the first dot (.) is interpreted as part of the queue name as described in the Topic parameter, so only the PVSR_PORT2, PVSR_PORT3, … are suitable for filtering

·       If we only want one return parameter then the PVSR_RETURN1= part is optional

 

JSON examples:

·       First example

o   Let the topic value be a/b/#

o   Let the JSON example shown at the REST collector arrive in the queue a/b/c/d

o   Let the Index parameter of the measurement be “c/d.124”

o   Let the variable in the measurement expression be:

json_PVSR_RETURN1=Level1/Array1/[ArrayKey2=${PVSR_PORT2}]/ArrayKey4

o   In this case the result of the variable will be “789”

·       Second example

o   Let the topic value be a/b/c/d

o   Let the JSON example shown at the REST collector arrive in the queue a/b/c/d

o   Let the Index parameter of the measurement be “.124”

o   Let the variable in the measurement expression be:

json_PVSR_RETURN1=Level1/Array1/[ArrayKey2=${PVSR_PORT2}]/ArrayKey4

o   In this case the result of the variable will be “789”

·       Third example

o   Let the topic value be a/b/#

o   Let the JSON example shown at the REST collector arrive in the queue a/b/c/d

o   Let the Index parameter of the measurement be “c/d.124”

o   Let the variable in the measurement expression be:

json_Level1/Array1/[ArrayKey2=${PVSR_PORT2}]/ArrayKey4

o   In this case the result of the variable will be “789”

·       Fourth example

o   Let the topic value be a/b/#

o   Let the JSON example shown at the REST collector arrive in the queue a/b/c/d

o   Let the Index parameter of the measurement be “c/d.124”

o   Let the variable in the measurement expression be (in one line):

json_PVSR_RETURN1=Level1/Array1/[ArrayKey2=${PVSR_PORT2}]/ArrayKey4,

PVSR_RETURN2=Level1/Array1/[ArrayKey2=${PVSR_PORT2}]/ArrayKey1

o   In this case the result of the variable will be “789 Other value”

 

14.1.29.1 JSON measurement expression test

The purpose of the collector specific page is to aid the creation of JSON type measurement expression variables. First we must select a measurement which has JSON processing in its variable, and then give an example JSON text. The page calculates the variables in the measurement expression using this example JSON text and shows the results. The screenshot shows the testing of the fourth example from above: