PI Adapter For MQTT 1.1 User Guide
PI Adapter For MQTT 1.1 User Guide
OSIsoft, the OSIsoft logo and logotype, Managed PI, OSIsoft Advanced Services, OSIsoft Cloud Services, OSIsoft
Connected Services, OSIsoft EDS, PI ACE, PI Advanced Computing Engine, PI AF SDK, PI API, PI Asset
Framework, PI Audit Viewer, PI Builder, PI Cloud Connect, PI Connectors, PI Data Archive, PI DataLink, PI
DataLink Server, PI Developers Club, PI Integrator for Business Analytics, PI Interfaces, PI JDBC Driver, PI Manual
Logger, PI Notifications, PI ODBC Driver, PI OLEDB Enterprise, PI OLEDB Provider, PI OPC DA Server, PI OPC HDA
Server, PI ProcessBook, PI SDK, PI Server, PI Square, PI System, PI System Access, PI Vision, PI Visualization Suite,
PI Web API, PI WebParts, PI Web Services, RLINK and RtReports are all trademarks of OSIsoft, LLC.
All other trademarks or trade names used herein are the property of their respective owners.
Use, duplication or disclosure by the US Government is subject to restrictions set forth in the OSIsoft, LLC license
agreement and/or as provided in DFARS 227.7202, DFARS 252.227-7013, FAR 12-212, FAR 52.227-19, or their
successors, as applicable.
Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Principles of operation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Text parser. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
JSONPath syntax for value retrieval. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Installation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
System requirements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Install the adapter. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Installation using Docker. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Upgrade the adapter. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Uninstall the adapter. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Security. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Configuration tools. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
System components. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
System and adapter. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Data source (generic). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Data source (Sparkplug B). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Client settings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Discovery. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Data source discovery (generic). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Data source discovery (Sparkplug B). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Data selection (generic). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Data selection (Sparkplug B). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Data filters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
Diagnostics and metadata. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
Metadata. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
Buffering. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
Logging. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Egress endpoints. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
Prepare egress destinations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Configure a network proxy. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
Health endpoints. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Configuration examples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
Administration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
Start and stop an adapter. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
Start and stop ingress component. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
Delete an adapter component. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
Retrieve product version information. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
3 iii
Next health message expected. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
Diagnostics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
System. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
Stream count. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
IO rate. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
Error rate. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
Egress. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
Troubleshooting. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
Troubleshoot PI Adapter for MQTT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
Adapter installation
You can install the adapter with a download kit that you can obtain from the OSIsoft Customer Portal. You
can install the adapter on devices running either Windows or Linux operating systems.
Adapter configuration
Using REST API, you can configure all functions of the adapter. The configurations are stored in JSON files.
For data ingress, you must define an adapter component in the system components configuration for each
device to which the adapter will connect. You configure each adapter component with the connection
information for the device and the data to collect. For data egress, you must specify destinations for the
data, including security for the outgoing connection. Additional configurations are available to egress health
Once you have configured the adapter and it is sending data, you can use administration functions to
manage the adapter or individual ingress components of the adapter. Health and diagnostics functions
monitor the status of connected devices, adapter system functions, the number of active data streams, the
rate of data ingress, the rate of errors, and the rate of data egress.
EdgeCmd utility
OSIsoft also provides the EdgeCmd utility, a proprietary command line tool to configure and administer an
adapter on both Linux and Windows operating systems. EdgeCmd utility is installed separately from the
adapter.
Adapter configuration
To start data collection for the MQTT adapter, configure the following:
• Data source: Provide the data source from which the adapter should collect data.
For more details, see the data source topics PI Adapter for MQTT data source configuration and PI
Adapter for MQTT Sparkplug B data source configuration.
• Data selection: Select MQTT items to which the adapter should subscribe for data.
For more details, see the data selection topics PI Adapter for MQTT data selection configuration and
PI Adapter for MQTT Sparkplug B data selection configuration.
• Logging: Set up the logging attributes to manage the adapter logging behavior.
Connection
The adapter uses either the Transmission Control Protocol (TCP) or WebSocket protocol (WS) to speak to an
MQTT server. For more information on how to configure which protocol should be used, see PI Adapter for
MQTT data source configuration and PI Adapter for MQTT Sparkplug B data source configuration.
Data collection
The adapter collects time-series data from the MQTT server using Topics. The generic MQTT adapter only
supports data from devices producing JSON payload, the MQTT Sparkplug B adapter also supports data
from devices adhering to the Sparkplug B specification. For more information see PI Adapter for MQTT data
selection configuration and PI Adapter for MQTT Sparkplug B data selection configuration.
Data types
The following sections list both MQTT generic and MQTT Sparkplug B data types and their respective
stream data types.
Int16 Int16
Int32 Int32
Int64 Int64
UInt16 UInt16
UInt32 UInt32
UInt64 UInt64
Float32 Float32
Float64 Float64
Boolean Boolean
String String
Date-Time Date-Time
The following table lists MQTT complex types that the adapter collects data from and the type of streams
that will be created.
Geolocation Float32
Coordinates Float32
Int8 Int8
Int16 Int16
Int32 Int32
Int64 Int64
UInt8 UInt8
UInt16 UInt16
UInt32 UInt32
UInt64 UInt64
Float Float32
Double Float64
Boolean Boolean
String String
DateTime UInt64
Text String
Stream creation
The MQTT adapter creates a stream with two properties for each selected MQTT item. The properties are
described in the following table.
Timestamp String The response time of the stream data from the MQTT device
Value Specified by the data selection The value of the stream data from the MQTT device
Certain metadata are sent with each stream created. The following metadata are common for every adapter
type:
• ValueField: Specifies the JsonPath expression used to extract the data value from a property within
the payload supplied by the MQTT server
Note: A configured metadata level allows you to set the amount of metadata for the adapter. Specify the
metadata level in General configuration. For the MQTT adapter, the following metadata are sent for the
individual level:
• None: No metadata
Each stream created for the selected measurement has a unique identifier (stream Id). If you specify a
custom stream Id for the measurement in the data selection configuration, the adapter uses that stream Id
to create the stream. Otherwise, the adapter constructs the stream Id using the following format:
<AdapterComponentId>.<Topic>.<ValueField>
• Group_Id: Specifies the element of the topic namespace that logically groups MQTT EoN1 nodes into
the MQTT server and the consuming MQTT clients
• Edge_Node_Id: Specifies the element of the topic namespace that uniquely identifies the MQTT
EoN1 node within the infrastructure
• Device_Id: Specifies the element of the topic namespace that identifies a device attached to the
MQTT EoN1 node
Note: A configured metadata level allows you to set the amount of metadata for the adapter. Specify the
metadata level in General configuration. For the MQTT adapter, the following metadata are sent for the
individual level:
• None: No metadata
Each stream created for the selected measurement has a unique identifier (stream Id). If you specify a
custom stream Id for the measurement in the data selection configuration, the adapter uses that stream Id
to create the stream. Otherwise, the adapter constructs the stream Id using the following format:
<AdapterComponentId>.<BaseTopic>.<MetricName>
Text parser
PI Adapter for MQTT includes the text parser component which ensures consistent parsing of text from
different files. This adapter supports parsing of .json files.
Designed to be a document parser, the text parser parses a semantically complete document in its entirety.
The text parser produces OMF compatible output, which in turn is compatible with the OCS backing SDS
(Sequential Data Store) that stores data in streams consisting of multiple values and indexes.
• DateTime
• DateTimeOffset
• TimeSpan
• sbyte
• byte
• short
• ushort
• int
• uint
• long
• ulong
• float
• double
• decimal
• bool
• char
Note: Not all data types supported by the text parser are also supported by OMF.
* empty string
` empty string
? empty string
; -
\| -
\ -
{ (
} )
[ (
] )
Culture support
Some numeric values and datetimes support cultures when they are being parsed. The default culture is
en-US (US English) (InvariantCulture). OSIsoft recommends that you leave the adapter at the default
unless you expect culturally variant input.
Note: Installed cultures vary by machine with both Linux and Windows. If the specified culture is not
installed, the text parser fails to parse input that requires that culture.
You can specify date and time formats when you configure data selection. Set the date and time using the
IndexFormat property. If you leave the IndexFormat property unset, the data selection configuration
defaults to the ISO 8601 date format.
If you are using a culture other than default en-US, use the name of day or month specific to the culture.
For example, use "Juni" instead of "June" for the de-DE culture.
The following date and time syntaxes have been tested and are supported.
• For more documentation on standard datetime formats, which fit most use cases, see Standard date
and time format strings.
[
{
"time": "2020-08-10T12:10:46.0928791Z",
"value": 1.234567890
},
{
"time": "2020-08-10T12:10:47.0928791Z",
"value": 12.34567890
},
{
"time": "2020-08-10T12:10:48.0928791Z",
"value": 123.4567890
},
{
"time": "2020-08-10T12:10:49.0928791Z",
"value": 1234.567890
},
{
"time": "2020-08-10T12:10:50.0928791Z",
"value": 12345.67890
},
{
"time": "2020-08-10T12:10:51.0928791Z",
"value": 123456.7890
},
{
"time": "2020-08-10T12:10:52.0928791Z",
"value": 12345678.90
},
{
The following MQTT data selection configuration reads a series of values. The configuration assumes that
the JSON was sent to MQTT Topic "Test":
[
{
"Topic": "Test",
"ValueField": "$.[*].value",
"DataFields": null,
"IndexField": "$.[*].time",
"DataType": "float64",
"IndexFormat": null,
"Selected": true,
"Name": null,
"StreamId": "TestValues",
"DataFilterId": null
}
]
{
"StreamData": {
"TPPrototype.uflsample.value_time": [
{
"StreamId": "TPPrototype.uflsample.value_time",
"DataType": "Double",
"Timestamp": "2013-12-01T06:00:00Z",
"Value": 339.0
},
{
"StreamId": "TPPrototype.uflsample.value_time",
"DataType": "Double",
[
{
"Topic": "Test",
"ValueField": "$['StreamData'].['TPPrototype.uflsample.value_time'][*].Value",
"DataFields": null,
"IndexField": "$['StreamData'].['TPPrototype.uflsample.value_time'][*].Timestamp",
"DataType": "float64",
"IndexFormat": null,
"Selected": true,
"Name": null,
"StreamId": "TestPrototypeValues",
"DataFilterId": null
}
]
The following example reads specific values from a complex nested JSON:
{
"success": true,
"error": null,
"result": {
"type": "runtime_history",
"chart": {
The following MQTT data selection configuration reads Sunday Average Indoor Temperature.
The timestamp is the Adapter local time. The configuration assumes that the JSON was sent to MQTT Topic
"Test":
[
{
"Topic": "Test",
"ValueField": "$.result.table.series[3].data[2]",
"DataFields": null,
"IndexField": null,
"DataType": "float64",
"IndexFormat": null,
"Selected": true,
"Name": null,
"StreamId": "TestSundayTemperature",
"DataFilterId": null
}
]
Error handling
If you encounter text parser related errors that is errors for the ValueField or IndexField, check the
StreamId associated with the error message.
Additional help
PI Adapter for MQTT's discovery feature helps you find collectible data without manually creating the data
selection file. For information on discovery, see Data source discovery generic.
Alternatively, you can build custom installers or containers for Linux. For more information, see the Docker
instructions in the documentation of the respective adapter.
Alternatively, you can use tar.gz files with binaries to build your own custom installers or containers for
Linux. For more information on installing the adapter with Docker containers, see Installation using Docker.
Windows
Complete the following steps to install a PI adapter on a Windows computer:
4. Optional: To verify the installation, run the following curl command with the port number that you
specified during installation:
curl http://localhost:5590/api/v1/configuration
If you receive an error, wait a few seconds and try the script again. If the installation was successful, a
JSON copy of the default system configuration is returned.
Linux
Complete the following steps to install an adapter on a Linux computer:
2. Open a terminal.
3. Run the sudo apt update command to update available packages information.
4. Run the sudo apt install command against the Linux distribution file (PI-Adapter-for-
MQTT_1.0.0.167-platform_.deb) selected in step 1 of this procedure.
5. Optional: To verify the installation, run the following curl command with the port number that you
specified during installation:
curl http://localhost:5590/api/v1/configuration
If you receive an error, wait a few seconds and run the command again. If the installation was
successful, a JSON copy of the default system configuration is returned.
Notes:
1. Use a text editor to create a script similar to one of the following examples:
ARM32
#!/bin/sh
if [ -z $portnum ] ; then
exec /PI-Adapter-for-MQTT_1.0.0.167-arm_/OSIsoft.Data.System.Host
else
exec /PI-Adapter-for-MQTT_1.0.0.167-arm_/OSIsoft.Data.System.Host --port:$portnum
fi
ARM64
#!/bin/sh
if [ -z $portnum ] ; then
exec /PI-Adapter-for-MQTT_1.0.0.167-arm64_/OSIsoft.Data.System.Host
else
exec /PI-Adapter-for-MQTT_1.0.0.167-arm64_/OSIsoft.Data.System.Host --port:$portnum
fi
AMD64
#!/bin/sh
if [ -z $portnum ] ; then
exec /PI-Adapter-for-MQTT_1.0.0.167-x64_/OSIsoft.Data.System.Host
else
exec /PI-Adapter-for-MQTT_1.0.0.167-x64_/OSIsoft.Data.System.Host --port:$portnum
fi
1. Create the following Dockerfile in the directory where you want to create and run the container.
Note: Dockerfile is the required name of the file. Use the variation according to your operating
system:
ARM32
FROM ubuntu:20.04
WORKDIR /
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y ca-certificates li
bicu60 libssl1.1 curl
COPY mqttdockerstart.sh /
RUN chmod +x /mqttdockerstart.sh
ADD ./PI-Adapter-for-MQTT_1.0.0.167-arm_.tar.gz .
ENTRYPOINT ["/mqttdockerstart.sh"]
ARM64
FROM ubuntu:20.04
WORKDIR /
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y ca-certificates li
bicu66 libssl1.1 curl
COPY mqttdockerstart.sh /
RUN chmod +x /mqttdockerstart.sh
ADD ./PI-Adapter-for-MQTT_1.0.0.167-arm64_.tar.gz .
ENTRYPOINT ["/mqttdockerstart.sh"]
AMD64 (x64)
FROM ubuntu:20.04
WORKDIR /
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y ca-certificates li
bicu66 libssl1.1 curl
4. Run the following command line in the same directory (sudo may be necessary):
Port 5590 is accessible from the host and you can make REST calls to the adapter from applications on the
local host computer. In this example, all data stored by the adapter is stored in the container itself. When
you delete the container, the stored data is also deleted.
Port 5590 is accessible from the host and you can make REST calls to the adapter from applications on the
local host computer. In this example, all data that is written to the container is instead written to the host
directory and the host directory is a directory on the local machine, /mqtt. You can specify any directory.
This command accesses the REST API with port 6000 instead of port 5590. The following curl command
returns the configuration for the container.
curl http://localhost:6000/api/v1/configuration
Windows upgrade
Complete the following steps to upgrade a PI adapter on a Windows computer:
2. Run PI-Adapter-for-MQTT_1.0.0.167-x64_.msi.
4. Optional: To verify the upgrade, run the following curl command with the port number that you
specified when completing the wizard:
Upon successful upgrade, the JSON response lists the updated application version:
{
"Application Version": "1.0.0.167", // upgraded version
".Net Core Version": ".NET Core 3.1.15",
"Operating System": "Microsoft Windows 10.0.19041"
}
Linux upgrade
Complete the following steps to upgrade a PI adapter on a Linux computer:
1. Download the appropriate Linux distribution file from the OSIsoft Customer Portal.
3. Move the Linux distribution file to the target host and run the sudo apt upgrade command.
Platform Command
4. Optional: To verify the upgrade, run the following curl command with the port number that you
specified:
{
"Application Version": "1.0.0.167", // upgraded version
".Net Core Version": ".NET Core 3.1.15",
"Operating System": "Microsoft Windows 10.0.19041"
}
Windows
1. To delete the PI adapter program files from a Windows device, use the Windows Control Panel
uninstall application process.
Note: The configuration, data, and log files are not deleted by the uninstall process.
2. Optional: To delete data, configuration, and log files, delete the directory:
%ProgramData%\OSIsoft\Adapters\MQTT
This deletes all data processed by the adapter, in addition to the configuration and log files.
Linux
1. To delete PI Adapter software from a Linux device, open a terminal window and run the following
command:
2. Optional: To delete data, configuration, and log files, run the following command:
sudo rm -r /usr/share/OSIsoft/Adapters/MQTT
This deletes all data processed by the adapter, in addition to the configuration and log files.
The examples in the configuration topics use curl, a commonly available tool on both Windows and Linux.
You can configure the adapter with any programming language or tool that supports making REST calls or
with the EdgeCmd utility. For more information, see the EdgeCmd utility documentation. To validate
successful configurations, you can perform data retrieval (GET commands) with a browser, if available, on
your device.
Quick start
This Quick Start guides you through setup of each configuration file available for PI Adapter for MQTT. As
you complete each step, perform each required configuration to establish a data flow from a data source to
one or more endpoints. Some configurations are optional.
Important: If you want to complete the optional configurations, complete those tasks before the required
tasks.
5. Optional: Configure data filters, diagnostics and metadata, buffering, logging, and if there is a proxy
between the adapter and your egress endpoints, define it.
See the following topics:
• Data filters
• Buffering
• Logging
Configuration tools
You can configure PI adapters with the EdgeCmd utility, OSIsoft's proprietary tool for configuring adapters,
or a commonly-used REST tool.
EdgeCmd utility
The EdgeCmd utility enables adapter configuration on both Linux and Windows operating systems. For
more information on using the EdgeCmd utility, see the EdgeCmd utility documentation.
REST tools
The following tools are available to make REST calls:
curl
curl is a command line tool used to make HTTP calls and is supported on both Windows and Linux operating
systems. You can script curl with Bash or PowerShell on Linux or Windows and you can use it to perform
adapter administrative and programming tasks. curl commands are used in configuration and
management examples throughout this document. For more information, see curl (https://curl.haxx.se/).
Postman
Postman is a REST tool for systems with GUI components. PI adapters are supported on platforms without
GUIs. Postman is particularly useful for learning more about PI Adapter REST APIs. For more information,
see Postman (https://www.postman.com/).
System components
PI Adapter for MQTT uses JSON configuration files in a protected directory on Windows and Linux to store
configuration that is read on startup. While the files are accessible to view, OSIsoft recommends that you
use REST or the EdgeCmd utility for any changes you make to the files.
As part of making adapters as secure as possible, any passwords or secrets that you configure are stored in
encrypted form where cryptographic key material is stored separately in a secure location. If you edit the
files directly, the adapter may not work as expected.
2. Copy and paste an example configuration for system components into the file.
6. Enter the following cURL command (which uses the PUT method) to initialize the system components
configuration.
Notes:
• If you installed the adapter to listen on a non-default port, update 5590 to the port number in
use.
• For a list of other REST operations you can perform, like updating or deleting a system
components configuration, see REST URLs.
Windows: %ProgramFiles%\OSIsoft\Adapters\AdapterName\Schemas
Linux: /opt/OSIsoft/Adapters/AdapterName/Schemas
ComponentId Required string The ID of the component1 . It can be any alphanumeric string. A
properly configured ComponentID follows these rules:
Cannot contain leading or trailing space
Cannot use the following characters:
> < / : ? # [ ] @ ! $ & * " ( ) \\ + , ; = `
ComponentType Required string The type of the component. There are two types of components:
OmfEgress and the adapter.1
1Note: The OmfEgress component is required to run the adapter. Both its ComponentId and
ComponentType are reserved and should not be modified.
Examples
Default system components configuration
The default System_Components.json file for the System component contains the following information.
[
{
"ComponentId": "OmfEgress",
"ComponentType": "OmfEgress"
}
]
[
{
"componentId": "OmfEgress",
"componentType": "OmfEgress"
},
{
"componentId": "MQTT1",
"componentType": "MQTT"
},
REST URLs
Relative URL HTTP verb Action
2. Copy and paste an example configuration for system and adapter into the file.
For sample JSON, see the corresponding adapter configuration examples topic.
5. Enter the following cURL command (which uses the PUT method) to initialize the system and adapter
configuration.
Notes:
• If you installed the adapter to listen on a non-default port, update 5590 to the port number in
use.
• In order for some of the adapter specific configurations to take effect, you have to restart the
adapter.
• Discoveries and HistoryRecoveries facet details are not required to be supplied as part of the
configuration and supplied values will be ignored. Their results will be restored from the
previous states.
If the operation fails due to errors in the configuration, the count of the error and suitable error messages
are returned in the result.
REST URLs
Relative URL HTTP verb Action
2. Copy and paste an example configuration for an MQTT data source into the file.
For a table of all available parameters, see MQTT data source parameters.
6. Enter the following cURL command (which uses the PUT method) to initialize the data source
configuration.
Notes:
• If you installed the adapter to listen on a non-default port, update 5590 to the port number in
use.
• If you use a component ID other than MQTT1, update the endpoint with your chosen
component ID.
• For a list of other REST operations you can perform, like updating or deleting a data source
configuration, see REST URLs.
For more information, see PI Adapter for MQTT data selection configuration.
• Windows: %ProgramFiles%\OSIsoft\Adapters\MQTT\Schemas
• Linux: /opt/OSIsoft/Adapters/MQTT/Schemas
Port Optional integer Port number of the MQTT server. Required only if Protocol
is TCP.
Protocol Optional enum The protocol used to communicate to the MQTT broker
TLS Optional enum Determines if TLS should be used and what version
UserName Optional string User name or client Id for accessing the MQTT server
Password Optional string Password or token for accessing the MQTT server
StreamIdPrefix Optional string Specifies what prefix is used for stream Ids. The naming
convention is {StreamIdPrefix}{StreamId}. An
empty string means no prefix is added to the stream Ids and
names. A null value defaults to ComponentId followed by
a period.
Example: Mqtt1.{Topic}.{ValueField}
DefaultStreamIdPattern Optional string Specifies the default stream Id pattern to use. Possible
parameters: {Topic}, {ValueField}, {DataType}.
TimeZone Optional string Specifies the time zone associated with data received from
the configured MQTT broker and its topics.
Runtime changes
When you set up a new data source configuration, the adapter automatically connects to the new data
source. When you delete a data source configuration, the adapter automatically disconnects from the data
source and stops data collection for all streams associated with that data source. Additionally, when you
update existing data source properties, the changes are reflected at runtime.
Note: Runtime changes also handle validation of configuration, which means that an invalid data source
configuration is rejected.
{
"HostNameOrIpAddress" : "125.0.0.0" ,
"Port" : 8765
}
{
"StreamIdPrefix" : null,
"DefaultStreamIdPattern" : "{Topic}.{ValueField}",
"HostNameOrIpAddress" : "125.0.0.0",
"Port" : 8765,
"Protocol" : "Tcp",
"TLS" : "Tls12",
"UserName": null,
"Password": null,
"ClientId" : "Test-Client-Id",
"MQTTVersion" : "3.1.1",
"ValidateServerCertificate" : true
"timeZone": "UTC",
"streamIdPrefix": "MyPrefix.",
"defaultStreamIdPattern": "{Topic}.{ValueField}"
}
REST URLs
Relative URL HTTP verb Action
api/v1/configuration/ POST Creates the MQTT data source configuration. The adapter starts
<ComponentId>/ collecting data after the following conditions are met:
DataSource
• The MQTT data source configuration POST request is received.
• A MQTT data selection configuration is active.
api/v1/configuration/ DELETE Deletes the MQTT data source configuration. After the request is
<ComponentId>/ received, the adapter stops collecting data.
DataSource
Note: Replace <ComponentId> with the Id of your MQTT component. For example, Mqtt1.
2. Copy and paste an example configuration for an MQTT Sparkplug B data source into the file.
For a table of all available parameters, see MQTT Sparkplug B data source parameters.
6. Enter the following cURL command (which uses the PUT method) to initialize the data source
configuration.
• If you installed the adapter to listen on a non-default port, update 5590 to the port number in
use.
• If you use a component ID other than MQTTSparkplugB1, update the endpoint with your
chosen component ID.
• For a list of other REST operations you can perform, like updating or deleting a data source
configuration, see REST URLs.
For more information, see PI Adapter for MQTT Sparkplug B data selection configuration.
• Windows: %ProgramFiles%\OSIsoft\Adapters\MQTT\Schemas
• Linux: /opt/OSIsoft/Adapters/MQTT/Schemas
Port Optional integer Port number of the MQTT server. Required only if Protocol
is TCP.
PrimaryHostId Optional string The Id of the primary host. The adapter is considered the
primary application.
Protocol Optional enum The protocol used to communicate to the MQTT broker
TLS Optional enum Determines if TLS should be used and what version
UserName Optional string User name or client Id for accessing the MQTT server
Password Optional string Password or token for accessing the MQTT server
StreamIdPrefix Optional string Specifies what prefix is used for stream Ids. The naming
convention is {StreamIdPrefix}{StreamId}. An
empty string means no prefix is added to the stream Ids and
names. A null value defaults to ComponentId followed by
a period.
Example: MqttSparkplugB1.{Topic}.
{MetricName}
DefaultStreamIdPattern Optional string Specifies the default stream Id pattern to use. The MQTT
{BaseTopic} string has the following format:
{namespace}/{groupId}/{edgeNodeId}/
{deviceId} Possible parameters: {BaseTopic},
{Topic}, {MetricName}.
Runtime changes
When you set up a new data source configuration, the adapter automatically connects to the new data
source. When you delete a data source configuration, the adapter automatically disconnects from the data
source and stops data collection for all streams associated with that data source. Additionally, when you
update existing data source properties, the changes are reflected at runtime.
Note: Runtime changes also handle validation of configuration, which means that an invalid data source
configuration is rejected.
{
"HostNameOrIpAddress" : "148.101.185.11",
{
"HostNameOrIpAddress" : "148.101.185.11",
"Port" : 1883,
"PrimaryHostId" : "Optimus",
"Protocol" : "Tcp",
"TLS" : "Tls12",
"UserName" : "SampleUser",
"PassWord" : "SamplePassword",
"ClientId" : "734029baf8f04bb2be99750381d6602a",
"MQTTVersion" : "3.1.1",
"ValidateServerCertificate" : true,
"StreamIdPrefix" : null,
"DefaultStreamIdPattern" : "{Topic}.{MetricName}"
}
REST URLs
Relative URL HTTP verb Action
api/v1/configuration/ POST Creates the MQTT Sparkplug B data source configuration. The adapter
<ComponentId>/ starts collecting data after the following conditions are met:
DataSource
• The MQTT Sparkplug B data source configuration POST request is
received.
• A MQTT Sparkplug B data selection configuration is active.
api/v1/configuration/ DELETE Deletes the MQTT Sparkplug B data source configuration. After the
<ComponentId>/ request is received, the adapter stops collecting data.
DataSource
Note: Replace <ComponentId> with the Id of your MQTT Sparkplug B component. For example,
MqttSparkplugB1.
Client settings
The client settings configuration is automatically generated when a new data source is added. If you
experience problems with timeouts or when MQTT limits are exceeded in terms of browse or subscription
operation, you can change the client settings configuration.
2. Copy and paste an example configuration for MQTT client settings into the file.
For a table of all available parameters, see MQTT client settings parameters.
6. Enter the following cURL command (which uses the PUT method) to initialize the client settings
configuration.
Notes:
• If you use a component ID other than MQTT1, update the endpoint with your chosen
component ID.
• For a list of other REST operations you can perform, like updating or deleting a client settings
configuration, see REST URLs.
Windows: %ProgramFiles%\OSIsoft\Adapters\MQTT\Schemas
Linux: /opt/OSIsoft/Adapters/MQTT/Schemas
KeepAlivePeriod Optional string The maximum time that can elapse between sending two data
(timespan) items.
QosLevel Optional integer Defines the guarantee of delivery for a specific item.
or Allowed value:
0 or AtMostOnce: There is no guarantee of item delivery
enum 1 or AtLeastOnce: An item is delivered at least one time
2 or ExactlyOnce: Each item is received only one time.
Default value: 2
MaxClientQueueSize Optional integer Maximum number of items that can be in the adapter internal
queue.
{
"keepAlivePeriod": "0:00:30",
"qosLevel": 2,
"maxClientQueueSize": 1000
}
REST URLs
Relative URL HTTP verb Action
Note: Replace ComponentId with the Id of your MQTT component, for example MQTT1.
Discovery
You can perform a data discovery for existing data items on demand. Data discovery is initiated through
REST calls and it is tied to a specific discovery Id, which you can either specify or let the adapter generate it.
Data discovery includes different routes. For example, you can choose to do the following:
• Retrieve results from a current discovery and compare it with results from a previous or discovery
• Retrieve results from a current discovery and compare it with results from a current data selection
configuration
2. Run a POST command with the Id of the discovery and autoSelect set to either true or false
to the following endpoint: http://localhost:5590/api/v1/configuration/
<ComponentId>/Discoveries.
Notes:
• Including an Id is optional. If you do not include one, the adapter automatically generates one.
• 5590 is the default port number. If you selected a different port number, replace it with that
value.
Discovery parameters
Parameter Type Description
Notes:
• You cannot run multiple discoveries with the same Id.
• Including an id is optional. If you do not include one, the adapter automatically
generates one.
query string A filter that is specific to the data source. The query filter can limit the scope of the
discovery.
itemsFound integer Number of data items that the discovery found on the data source
newItems integer Number of new data items that the discovery found in comparison to the previous
discovery
resultUri string URL at which you can access the results of the discovery
autoSelect boolean When set to true, the result of the discovery gets pushed to the data selection
configuration.
[
{
"id": "8ff855f1-a636-490a-bb31-207410a6e607",
"query": null,
"startTime": "2020-09-30T19:34:01.8180401+02:00",
"endTime": "2020-09-30T19:34:01.8368776+02:00",
"progress": 30,
"itemsFound": 4,
"newItems": 0,
"resultUri": "http://127.0.0.1:5590/api/v1/Configuration/<ComponentId>/Discoveries/8ff855f1-a636
-490a-bb31-207410a6e607/result",
"autoSelect": false,
"status": "Complete",
"errors": null
}
]
REST URLs
Relative URL HTTP verb Action
api/v1/configuration/<componentId>/ GET Returns the difference between the result and the
discoveries/<discoveryId>/result? previous result
diff=previousId
Topics Optional The topics that the adapter subscribes to when the discovery posts.
Note: If you want to specify multiple topics in the query, you must separate the topic
names with a comma. If you do not specify a topic, the adapter subscribes to all topics.
WaitTime Optional The time window in which the adapter performs the discovery by listening for specified
topics. Once the wait time elapses, the discovery results are available.
Query rules
The following rules apply when specifying the query string:
• Only one query at a time is supported. That query can contain as many topics with the same wait time
as needed. If you need different wait times for different topics, you need to create a new query once
the query from the previous discovery has completed.
• Special characters are replaced by the text parser. For more information, see Text parser
Note: The data source might contain large amounts of metrics. Use the # judiciously and narrow down the
query string to something specific or break down the query into different discoveries.
• # must not be used more than once and can only be used at the end of the topic.
{
"id" : "SampleA",
"query" : "Topics=Sample1,Sample2;WaitTime=00:00:30"
}
[
{
"id" : "SampleA",
"query" : "Topics=Sample1,Sample2;WaitTime=00:00:00:30",
"startTime": "2020-12-14T14:19:01.4383791-08:00",
"endTime": "2020-12-14T14:19:31.8549164-08:00",
"progress": 30,
"itemsFound": 700,
"newItems": 200,
"resultUri": "http://127.0.0.1:5590/api/v1/Configuration/mqttComponentId/Discoveries/40/result",
"autoSelect": false,
"status": "Complete",
"errors": null
[
{
"Topic": "Sample1",
"ValueField": "$.Value4",
"IndexField": null,
"DataType": "Single",
"IndexFormat": "null",
"Selected": false,
"Name": null,
"StreamId": "Sample1.$.Value4",
"DataFilterId": null
},
{
"Topic": "Sample2",
"ValueField": "$.Value1",
"IndexField": null,
"DataType": "Single",
"IndexFormat": "null",
"Selected": false,
"Name": null,
"StreamId": "Sample1.$.Value1",
"DataFilterId": null
}
]
Group_Id Optional This element of the Topic namespace logically groups MQTT EoN nodes into the
MQTT server and the consuming MQTT clients.
Message_Type Optional This element of the Topic namespace indicates how to handle the MQTT payload of
the message. The message type is typically NDATA or DDATA. For more information,
see Data selection (Sparkplug B).
Edge_Node_Id Optional This element of the Sparkplug Topic namespace uniquely identifies the MQTT EoN
node within the infrastructure.
Device_Id Optional This element of the Sparkplug Topic namespace identifies a device attached to the
MQTT EoN node (physically or logically).
WaitTime Optional The time window in which the adapter will perform the discovery by listening for
specified topics. Once the wait time has elapsed, the discovery results will be
available.
Query rules
The following rules apply for specifying the query string:
Note: The data source might contain large amounts of metrics. Use the # judiciously and narrow down the
query string to something specific or break down the query into different discoveries.
• # must not be used more than once and can only be used at the end of the topic.
{
"id" : "40",
"query" : "topics=group1/edgeNode1,group2/edgeNode2;waitTime=00:00:30"
}
[
{
"id": "40",
"query": "topics=group1/edgeNode1,group2/edgeNode2;waitTime=00:00:30",
"startTime": "2020-12-14T14:19:01.4383791-08:00",
"endTime": "2020-12-14T14:19:31.8549164-08:00",
"progress": 30,
"itemsFound": 700,
"newItems": 200,
"resultUri": "http://127.0.0.1:5590/api/v1/Configuration/mqttComponentId/Discoveries/40/result",
"autoSelect": false,
"status": "Complete",
"errors": null
2. Copy and paste an example configuration for an MQTT data selection into the file.
For a table of all available parameters, see MQTT data selection parameters.
6. Enter the following cURL command (which uses the PUT method) to initialize the data selection
configuration.
Notes:
• If you installed the adapter to listen on a non-default port, update 5590 to the port number in
use.
• If you use a component ID other than MQTT1, update the endpoint with your chosen
component ID.
• Windows: %ProgramFiles%\OSIsoft\Adapters\MQTT\Schemas
• Linux: /opt/OSIsoft/Adapters/MQTT/Schemas
Name Optional string The optional friendly name of the data item collected
from the data source.
StreamId Optional string The custom stream Id that is used to create the streams.
If you do not specify the StreamId, the adapter
generates a default stream Id based on the DataSource
parameter. For more information, see PI Adapter for
MQTT data source configuration. A properly configured
custom stream Id follows these rules:
Is not case-sensitive
Can contain spaces
Can contain front slashes (/)
Can contain a maximum of 100 characters
Cannot start with two underscores (__)
Cannot start or end with a period
Cannot contain consecutive periods
Cannot consist of only periods
ValueField Required string The JSONPath expression used to extract the data value
from a property within the payload supplied by the
MQTT server. A valid JSONPath expression starts with
$. 1
IndexFormat Optional string The time format of the timestamp value specified in the
IndexField property. 2
DataType Required string The expected data type of the values for the specified
field.
DataFields Required dictionary<string, A dictionary of values with key-value pairs. The keys are
string> specific fields for a complex type and the values are the
JSONPath expression used to extract the data value
from a property within the payload supplied by the
MQTT server. A valid JSONPath expression starts with
$. 1
1 ValueField and DataFields are mutually exclusive. For example, if you specify ValueField, you cannot
specify DataFields and vice versa.
2 If you do not specify IndexField and IndexFormat, the adapter automatically sets the latter to Adapter,
which uses an adapter-supplied timestamp for the data. The timestamp is taken after the data is published
to the adapter while the adapter processes it. If you specify IndexFormat only with a value other than
Adapter, the validation fails and the adapter throws an error.
After the CSV file is created, you can use type <fileName>.csv to display the contents of the file. The
output will look similar to the following example in which the keywords are in the first line and the values,
including complex types, are in the second line:
topic,valueField,dataFields,indexField,dataType,indexFormat,selected,name,streamId,dataFilterId
mqtt/Boilers/Boiler1,,"{""X"":"".xValue]"",""Y"":""$.yValue"",""Z"":""$.zValue""}",$['Timestamp'],Coordi
nates,,True,,mqtt/Boilers/Boiler1.$.xValue.$.yValue.$.zValue,
Runtime changes
When you create a new data selection item with a new Topic property, the adapter automatically subscribes
the topic to the data source and starts data collection for the stream associated with the data selection item.
When you delete a data selection item, the adapter automatically stops collecting data for that item.
Additionally, when you update a data selection item, the adapter updates the stream and continues data
collection.
[
{
"Topic" : "RandomTopic",
"ValueField" : "$.TestNode[:1].Value",
"DataType" : "uint64"
}
]
[
{
"Selected" : true,
"Name" : null,
"StreamId" : "RandomStreamId",
"DataFilterId" : null,
"Topic" : "RandomTopic",
"ValueField" : null,
"IndexField" : "$.Timestamp",
"IndexFormat" : null,
"DataType" : "Geolocation",
"DataFields" : { "Latitude": "$.Float1", "Longitude": "$.Float2" }
},
{
"Selected" : true,
"Name" : null,
"StreamId" : "RandomStreamId",
"DataFilterId" : null,
"Topic" : "RandomTopic",
"ValueField" : null,
"IndexField" : "$.Timestamp",
"IndexFormat" : null,
1 Note: Both ValueField and IndexField require the correct structure of the JSON payload to be specified (in
other words, what the data source returns). The previous examples use the following JSON payload
structure:
{
"TestNode": [
{
"Time": "02/17/2021 12:01:36 AM PST",
"Value": "4578"
}
]
}
REST URLs
Relative URL HTTP verb Action
api/v1/configuration/ GET Retrieves the MQTT data selection configuration, including all data
<ComponentId>/ selection items.
DataSelection
api/v1/configuration/ PUT Configures or updates the MQTT data selection configuration. The
<ComponentId>/ adapter starts collecting data for each data selection item when the
DataSelection following conditions are met:
api/v1/configuration/ DELETE Deletes the active MQTT data selection configuration. The adapter
<ComponentId>/ stops collecting data.
DataSelection
api/v1/configuration/ PUT Updates or creates a new data selection item by StreamId. For new
<ComponentId>/ items, the adapter starts collecting data after the request is
DataSelection/<StreamId> received.
api/v1/configuration/ DELETE Deletes a data selection item from the configuration by StreamId.
<ComponentId>/ The adapter stops collecting data for the deleted item.
DataSelection/<StreamId>
Note: Replace ComponentId with the Id of your MQTT component. For example, Mqtt1.
2. Copy and paste an example configuration for an MQTT Sparkplug B data selection into the file.
For a table of all available parameters, see MQTT Sparkplug B data selection parameters.
6. Enter the following cURL command (which uses the PUT method) to initialize the data selection
configuration.
Notes:
• If you installed the adapter to listen on a non-default port, update 5590 to the port number in
use.
• For a list of other REST operations you can perform, like updating or deleting a data selection
configuration, see REST URLs.
Selected Optional boolean Selects or clears a measurement. To select an item, set to true. To
remove an item, leave the field empty or set to false.
Name Optional string The optional friendly name of the data item collected from the data
source
Topic Required string The MQTT topic string in the following format: {namespace}/
{groupId}/{messageType}/{edgeNodeId}/{deviceId}
Examples:
spBv1.0/DemoCenters/DDATA/EPIC-DC004/DC004
spBv1.0/DemoCenters/NDATA/EPIC-DC004
StreamId Optional string The custom stream Id that is used to create the streams. If you do not
specify the StreamId, the adapter generates a default stream Id based on
the measurement configuration. A properly configured custom stream Id
follows these rules:
Is not case-sensitive
Can contain spaces
Can contain front slashes (/)
Can contain a maximum of 100 characters
Cannot start with two underscores (__)
Cannot start or end with a period
Cannot contain consecutive periods
Cannot consist of only periods
Runtime changes
When you create a new data selection item with a new Topic property, the adapter automatically subscribes
the topic to the data source and starts data collection for the stream associated with the data selection item.
When you delete a data selection item, the adapter automatically stops collecting data for that item.
Additionally, when you update a data selection item, the adapter updates the stream and continues data
collection.
Note: Runtime changes also handle validation of configuration, which means that an invalid data selection
configuration is rejected.
[
{
"Topic" : "spBv1.0/group1/DDATA/EdgeNode1/Device1",
[
{
"Selected" : true,
"Name" : "Temperature",
"Topic" : "spBv1.0/group1/DDATA/edgeNode1/device1",
"MetricName" : "Device1 Temperature",
"StreamId" : "Device1.Temperature.Stream",
"DataFilterId" : null
}
]
REST URLs
Relative URL HTTP verb Action
api/v1/configuration/ DELETE Deletes the active MQTT Sparkplug B data selection configuration.
<ComponentId>/ The adapter stops collecting data.
DataSelection
api/v1/configuration/ PUT Updates or creates a new data selection item by StreamId. For new
<ComponentId>/ items, the adapter starts collecting data after the request is received.
DataSelection/<StreamId>
api/v1/configuration/ DELETE Deletes a data selection item from the configuration by StreamId.
<ComponentId>/ The adapter stops collecting data for the deleted item.
DataSelection/<StreamId>
Note: Replace ComponentId with the Id of your MQTT Sparkplug B component. For example,
MqttSparkplugB1.
Data filters
PI adapters can be configured to perform data filtering to save network bandwidth. Every data item in the
data selection configuration can be assigned the Id of a data filter. The adapter will then filter data for those
data items based on the data filter configuration.
Note: If data filters are enabled and data quality changes, both the old and current data quality values are
passed on.
2. Copy and paste an example configuration for data filters into the file.
6. Enter the following cURL command (which uses the PUT method) to initialize the data filters
configuration.
• If you installed the adapter to listen on a non-default port, update 5590 to the port number in
use.
• For a list of other REST operations you can perform, like updating or deleting a data filters
configuration, see REST URLs.
On successful execution, the change that you have made to data filters takes effect immediately during
runtime.
Windows: %ProgramFiles%\OSIsoft\Adapters\<AdapterName>\Schemas
Linux: /opt/OSIsoft/Adapters/<AdapterName>/Schemas
AbsoluteDeadband Optional double Specifies the absolute change in data value that should cause
the current value to pass the filter test.
Note: You must specify AbsoluteDeadband or
PercentChange.
PercentChange Optional double Specifies the percent change from previous value that should
cause the current value to pass the filter test.
Note: You must specify AbsoluteDeadband or
PercentChange.
ExpirationPeriod Optional timespan The length in time that can elapse after an event before
automatically sending the next event, regardless of whether the
next event passes the filter or not. The expected format is
HH:MM:SS.### or SSS.*
* Note: For example, "ExpirationPeriod": 5:00 and "ExpirationPeriod": 300 both specify
an expiration period of 5 minutes and 0 seconds.
[
{
"Id": "DuplicateData",
"AbsoluteDeadband": 0,
"PercentChange": null,
"ExpirationPeriod": "01:00:00"
}
]
REST URLs
Relative URL HTTP verb Action
api/v1/configuration/ComponentId/ PUT Replaces data filter by id. Fails if data filter does not
DataFilters/id exist.
Configure general
1. Start any of the Configuration tools capable of making HTTP requests.
2. Run a PUT command to the following endpoint, setting EnableDiagnostics to either true or
false, MetadataLevel to None, Low, Medium, or High and HealthPrefix to a string or
null: http://localhost:5590/api/v1/configuration/system/general
Note: 5590 is the default port number. If you selected a different port number, replace it with that
value.
General schema
The full schema definition for the general configuration is in the System_General_schema.json file
located in one of the following folders:
Windows: %ProgramFiles%\OSIsoft\Adapters\<AdapterName>\Schemas
Linux: /opt/OSIsoft/Adapters/<AdapterName>/Schemas
HealthPrefix Optional reference Prefix to use for health and diagnostics stream and asset IDs.
Default value: null
Example
Retrieve the general configuration
Example using curl:
Sample output:
{
"EnableDiagnostics": true,
"MetadataLevel": "Medium",
"HealthPrefix": "Machine1"
}
REST URLs
Relative URL HTTP verb Action
Metadata
If the metadataLevel is set to Low, Medium, or High in the General configuration, adapter streams created
by the ingress components include the following metadata:
Datasource: {ComponentId}
AdapterType: {ComponentType}
ComponentId corresponds to the adapter components' data source configured in the Components
configuration. ComponentType corresponds to the adapter type.
If you enable diagnostics in General configuration, metadata are included in the diagnostics streams
(Stream count, IO rate, Error rate) together with ComponentId and ComponentType.
The adapter may also send its own stream metadata not including health and diagnostics streams. For more
information about what custom metadata is included in each stream, see the user guide for your adapter.
Note:
• Currently, the only endpoint that persists sent metadata is OCS (OSIsoft Cloud Services).
Buffering
You can configure PI adapters to buffer data egressed from the adapter to endpoints. Buffering is configured
through the buffering configuration parameters in the system configuration.
Note: OSIsoft recommends that you do not modify the default buffering location unless it is necessary.
Changes to the buffering configuration parameters only take effect during adapter service startup.
2. Copy and paste an example configuration for buffering into the file.
6. Enter the following cURL command (which uses the PUT method) to initialize the buffering
configuration.
Notes:
• If you installed the adapter to listen on a non-default port, update 5590 to the port number in
use.
• For a list of other REST operations you can perform, like updating or replacing a buffering
configuration, see REST URLs.
Buffering schema
The full schema definition for the system buffering is in the System_Buffering_schema.json file
located in one of the following folders:
Windows: %ProgramFiles%\OSIsoft\Adapters\<AdapterName>\Schemas
Linux: /opt/OSIsoft/Adapters/<AdapterName>/Schemas
MaxBufferSizeMB Optional integer Defines the maximum size of the buffer that is persisted on
disk 1 or used in memory 2. The unit is specified in MB (1
Megabyte = 1048576 bytes). Consider the capacity and the
type of storage medium to determine a suitable value for
this parameter.
Minimum value: 1
Maximum value: 2147483647
Default value: 1024
BufferLocation Required string Defines the location of the buffer files. Absolute paths are
required. Consider the access-control list (ACL) when you
set this parameter. BufferLocation is used to buffer files
when EnablePersistentBuffering is true.
• Data is only written to the disk buffer if queued in the memory buffer for more than 5 seconds.
• The MaxBufferSizeMB is applied per configured endpoint except the health endpoint.
• When MaxBufferSizeMB is reached, the oldest buffer file is deleted and a new buffer file is created.
• The health endpoint is fixed at 20 MB. When the health endpoint buffer file becomes full, a new buffer
file is created and the previous buffer file is deleted.
Note: The following rules apply in case of an error when creating a new buffer file:
• If a buffer file is corrupted, an attempt is made to recover individual records and any failure to recover
records is logged.
• The MaxBufferSizeMB is applied per configured endpoint except the health endpoint.
• When MaxBufferSizeMB is reached, the oldest messages in the memory buffer are removed.
Depending on the size of a new message, several old messages may be removed.
• The health endpoint is fixed at 20 MB. When the health endpoint buffer file becomes full, the oldest
messages in the memory buffer are removed and new messages are added.
Examples
The following examples are buffering configurations made through thecurl REST client.
Sample output:
{
"bufferLocation": "C:/ProgramData/OSIsoft/Adapters/<AdapterName>/Buffers",
"maxBufferSizeMB": 1024,
"enablePersistentBuffering": true
}
REST URLs
Relative URL HTTP verb Action
Logging
PI adapters write daily log messages for the adapter, the system, and OMF egress to flat text files in the
following locations:
• Windows: %ProgramData%\OSIsoft\Adapters{AdapterInstance}\Logs
• Linux: /usr/share/OSIsoft/Adapters/{AdapterInstance}/Logs
Each message in the log displays the message severity level, timestamp, and the message itself.
Configure logging
Complete the following steps to configure logging. Use the PUT method in conjunction with the http://
localhost:5590/api/v1/configuration/<ComponentId>/Logging REST endpoint to
initialize the configuration.
2. Copy and paste an example configuration for logging into the file.
6. Enter the following cURL command (which uses the PUT method) to initialize the logging
configuration.
Notes:
• If you installed the adapter to listen on a non-default port, update 5590 to the port number in
use.
• For a list of other REST operations you can perform, like updating or retrieving a logging
configuration, see REST URLs.
• Any parameter not specified in the updated configuration file reverts to the default schema
value
On successful execution, the log-level change takes effect immediately during runtime. The other
configurations (log file size and file count) are updated after the adapter is restarted.
Logging schema
The full schema definition for the logging configuration is in the component specific logging file:
AdapterName_Logging_schema.json, OmfEgress_Logging_schema.json, or
System_Logging_schema.json file located in one of the following folders:
Windows: %ProgramFiles%\OSIsoft\Adapters\<AdapterName>\Schemas
Linux: /opt/OSIsoft/Adapters/<AdapterName>/Schemas
Logging parameters
The following parameters are available for configuring logging:
LogLevel Optional reference The logLevel sets the minimum severity for messages to be
included in the logs.
Messages with a severity below the level set are not included.
LogFileSizeLimitBytes Optional integer The maximum size (in bytes) of log files that the service will
create for the component. The value must be a positive
integer.
LogFileCountLimit Optional integer The maximum number of log files that the service will create
for the component. The value must be a positive integer.
Minimum value: 1
Maximum value: 2147483647
Default value: 31
LogLevel
Level Description
Trace Logs that contain the most detailed messages. These messages may contain sensitive application
data like actual received values, which is why these messages should not be enabled in production
environment.
Debug Logs that can be used to troubleshoot data flow issues by recording metrics and detailed flow related
information.
Information Logs that track the general flow of the application. Any non-repetitive general information like the
following can be useful for diagnosing potential application errors:
- Version information related to the software at startup
- External services used
- Data source connection string
- Number of measurements
- Egress URL
- Change of state “Starting” or “Stopping”
- Configuration
Warning Logs that highlight an abnormal or unexpected event in the application flow that does not otherwise
cause the application execution to stop. Warning messages can indicate an unconfigured data source
state, an insecure communication channel in use, or any other event that could require attention but
that does not impact data flow.
Error Logs that highlight when the current flow of execution is stopped due to a failure. These should
indicate a failure in the current activity and not an application-wide failure. It can indicate an invalid
configuration, unavailable external endpoint, internal flow error, and so on.
Critical Logs that describe an unrecoverable application or system crash or a catastrophic failure that
requires immediate attention. This can indicate application wide failures like beta timeout expired,
unable to start self-hosted endpoint, unable to access vital resource (for example, Data Protection
key file), and so on.
Example
Default logging configuration
By default, logging captures Information, Warning, Error, and Critical messages in the message logs. The
following logging configuration is the installation default for a component:
{
"logLevel": "Information",
"logFileSizeLimitBytes": 34636833,
"logFileCountLimit": 31
}
REST URLs
Relative URL HTTP verb Action
Egress endpoints
PI adapters collect time series data, which they can send to a permanent data store (endpoint). This
operation is called data egress. The following endpoints are available for data egress:
For long term storage and analysis, you can configure any adapter to send time series data to one or several
of these endpoints in any combination. An egress endpoint is comprised of the properties specified under
Egress endpoint parameters.
Data egress to a PI server creates a PI point in the PI adapter configuration. Data egress to OCS creates a
stream in the PI adapter configuration.
The name of the PI point or OCS stream is a combination of the StreamIdPrefix specified in the adapter data
source configuration and the StreamId specified in the adapter data selection configuration.
2. Copy and paste an example configuration for egress endpoints into the file.
6. Enter the following cURL command (which uses the PUT method) to initialize the egress endpoints
configuration.
Notes:
• If you installed the adapter to listen on a non-default port, update 5590 to the port number in
use.
• For a list of other REST operations you can perform, like updating or replacing an egress
endpoints configuration, see REST URLs.
Windows: %ProgramFiles%\OSIsoft\Adapters\<AdapterName>\Schemas
Linux: /opt/OSIsoft/Adapters/<AdapterName>/Schemas
Username Required for string Basic authentication to the PI Web API OMF endpoint
PI server
endpoint PI server:
Allowed value: any string
Default: null
Note: If your username contains a backslash, you
must add an escape character, for example, type
OilCompany\TestUser as OilCompany\
\TestUser.
Password Required for string Basic authentication to the PI Web API OMF endpoint
PI server
endpoint PI server:
Allowed value: any string
Default: null
ClientId Required for string Authentication with the OCS OMF endpoint
OCS
endpoint Allowed value: any string, can be null if the endpoint
URL schema is HTTP
Default: null
ClientSecret Required for string Authentication with the OCS OMF endpoint
OCS
endpoint Allowed value: any string, can be null if the endpoint
URL schema is HTTP
Default: null
TokenEndpoint Optional for string Retrieves an OCS token from an alternative endpoint
OCS
endpoint Allowed value: well-formed http or https endpoint
string
Default value: null
* %2a
' %27
` %60
" %22
? %3f
; %3b
| %7c
\ %5c
{ %7b
} %7d
[ %5b
] %5d
Examples
The following examples are valid egress configurations:
[{
"Id": "OCS",
"Endpoint": "https://<OCS OMF endpoint>",
"ClientId": "<clientid>",
"ClientSecret": "<clientsecret>"
}]
[{
"Id": "PI Web API",
"Endpoint": "https://<pi web api server>:<port>/piwebapi/omf/",
"UserName": "<username>",
REST URLs
Relative URL HTTP verb Action
• If you delete an egress endpoint, data flow immediately stops for that endpoint. Buffered data in a
deleted endpoint is permanently lost.
• Type, container, and data items are batched into one or more OMF messages when egressing. As per
the requirements defined in OMF, a single message payload will not exceed 192KB in size.
Compression is automatically applied to outbound egress messages. On the egress destination, failure
OCS
To prepare OCS to receive OMF messages from the adapter, create an OMF connection in OCS. Creating an
OMF connection results in an available OMF endpoint that can be used by the adapter egress mechanism.
Complete the following steps to create an OMF connection:
1. Create a Client.
The Client Id and Client Secret will be used for the corresponding properties in the egress
configuration.
The connection should link the created client to an existing namespace where the data will be stored.
The OMF Endpoint URL for the connection will be used as the egress configuration Endpoint
property.
PI Server
To prepare a PI Server to receive OMF messages from the adapter, a PI Web API OMF endpoint must be
available. Complete the following steps:
1. Install PI Web API and enable the OSIsoft Message Format (OMF) Services feature.
• During configuration, choose an AF database and PI Data Archive where metadata and data will
be stored.
• The account used in an egress configuration needs permissions to create AF elements, element
templates, and PI points.
For complete steps, as well as best practices and recommendations, see the following topic in the PI
Web API User Guide: Authentication methods.
Notes:
• The certificate used by PI Web API must be trusted by the device running the adapter, otherwise the
egress configuration ValidateEndpointCertificate property needs to be set to false (this can be the
case with a self-signed certificate but should only be used for testing purposes).
• Windows: setx
• Ubuntu: EnvironmentVariables
• Debian: EnvironmentVariables
The value of this environment variable must contain the URL of the proxy server, beginning with http. The
format of the string is [user[:password]@]http://hostname[:port].
user Optional The user name for the HTTPS forward proxy.
password Optional The password for the HTTPS forward proxy specified user name. If you specify user,
password remains optional.
Note: Usage of the https_proxy environment variable may affect other .NET or .NET Core applications.
If you set this environment variable, it will affect the adapter egress endpoints and the adapter health
endpoints.
Examples:
myUser@http://192.168.2.2
http://proxymachine.domain
Example:
[{
"Id": "PI Web API Through Proxy",
"Endpoint": "https://<reverseProxy>:<port>/piwebapi/omf/",
"UserName": "<piWebApiUser>",
"Password": "<piWebApiPassword>"
}]
Complete the following steps to configure health endpoints. Use the PUT method in conjunction with the
http://localhost:5590/api/v1/configuration/system/healthendpoints REST
endpoint to initialize the configuration.
2. Copy and paste an example configuration for health endpoints into the file.
6. Enter the following cURL command (which uses the PUT method) to initialize the health endpoint
configuration.
Notes:
• If you installed the adapter to listen on a non-default port, update 5590 to the port number in
use.
• For a list of other REST operations you can perform, like updating or replacing a health
endpoints configuration, see REST URLs.
Windows: %ProgramFiles%\OSIsoft\Adapters\<AdapterName>\Schemas
Linux: /opt/OSIsoft/Adapters/<AdapterName>/Schemas
Endpoint Required string The URL of the OMF endpoint to receive this
health data
Username Required for PI string The username used to authenticate with a PI Web
Web API API OMF endpoint
endpoints
PI server:
Allowed value: any string
Default: null
Password Required for PI string The password used to authenticate with a PI Web
Web API API OMF endpoint
endpoints
PI server:
Allowed value: any string
Default: null
ClientId Required for string The client ID used for authentication with an
OCS endpoints OSIsoft Cloud Services OMF endpoint
ClientSecret Required for string The client secret used for authentication with an
OCS endpoints OSIsoft Cloud Services OMF endpoint
{
"Id": "OCS",
"Endpoint": "https://<OCS OMF endpoint>",
"ClientId": "<clientid>",
"ClientSecret": "<clientsecret>"
}
{
"Id": "PI Web API",
"Endpoint": "https://<pi web api server>:<port>/piwebapi/omf/",
"UserName": "<username>",
"Password": "<password>"
}
Note: When you use an adapter with a PI Web API health endpoint, the AF structure is required. If the
elements are deleted, the adapter recreates the elements; if the account used to authenticate to the PI Web
API has its permissions removed on the AF Server, the adapter retries sending health data to the PI Web API
until the permissions are restored.
REST URLs
Relative URL HTTP verb Action
Configuration examples
The following tables provide examples for all configurations available for PI Adapter for MQTT.
Note: The examples in this topic are using the default port number 5590. If you selected a different port
number, replace it with that value.TEST
[
{
"componentId": "OmfEgress",
"componentType": "OmfEgress"
},
{
"componentId": "MQTT1",
"componentType": "MQTT"
},
{
"componentId": " MQTTSparkplugB1",
"componentType": "MQTTSparkplugB"
{
"Mqtt1": {
"Logging": {
"logLevel": "Information",
"logFileSizeLimitBytes": 34636833,
"logFileCountLimit": 31
},
"DataSource": {
"StreamIdPrefix" : null,
"DefaultStreamIdPattern" : "{Topic}.{ValueField}",
"HostNameOrIpAddress" : "125.0.0.0",
"Port" : 8765,
"Protocol" : "Tcp",
"TLS" : "Tls12",
"UserName": null,
"Password": null,
"ClientId" : "Test-Cliendt-Id",
"MQTTVersion" : "3.1.1",
"ValidateServerCertificate" : true
},
"DataSelection": [
{
"Selected" : true,
"Name" : null,
"StreamId" : "RandomStreamId",
"DataFilterId" : null,
"Topic" : "RandomTopic",
"ValueField" : "$.TestNode[:1].Value",
"IndexField" : "$.TestNode[:1].Time",
"DataType" : "uint64",
"IndexFormat" : null
}
]
},
"System": {
{
"HostNameOrIpAddress" : "125.0.0.0" ,
"Port" : 8765
}
{
"StreamIdPrefix" : null,
"DefaultStreamIdPattern" : "{Topic}.{ValueField}",
"HostNameOrIpAddress" : "125.0.0.0",
"Port" : 8765,
"Protocol" : "Tcp",
"TLS" : "Tls12",
"UserName": null,
"Password": null,
"ClientId" : "Test-Cliendt-Id",
"MQTTVersion" : "3.1.1",
"ValidateServerCertificate" : true
}
{
"HostNameOrIpAddress" : "Host1",
"Port" : 4321,
}
{
"HostNameOrIpAddress" : "Host1",
"Port" : 4321,
"PrimaryHostId" : "Optimus",
"Protocol" : "Tcp",
"TLS" : "Tls12",
"UserName" : "RandomUser",
"PassWord" : "RandomPassword",
"ClientId" : "Random-Client-Id",
"MQTTVersion" : "3.1.1",
"ValidateServerCertificate" : true,
"StreamIdPrefix" : null,
"DefaultStreamIdPattern" : "{PointId}"
}
{
"KeepAlivePeriod" : true,
"QosLevel" : 2,
"MaxInternalQueueSize" : 350000
}
[
{
"Topic" : "RandomTopic",
"ValueField" : "$.TestNode[:1].Value",
"DataType" : "uint64"
}
]
[
{ "Selected" : true,
"Name" : null,
"StreamId" : "RandomStreamId",
"DataFilterId" : null,
"Topic" : "RandomTopic",
"ValueField" : "$.TestNode[:1].Value",
"IndexField" : "$.TestNode[:1].Time",
"DataType" : "uint64",
"IndexFormat" : null
}
]
[
{
"Topic" : "Home/Sensors",
"PropertyName" : "Temperature"
}
]
[
{
The examples in the administration topics use curl, a commonly available tool on both Windows and
Linux. You can use the same operations with any programming language or tool that supports making REST
calls. You can also configure PI adapters with the EdgeCmd utility. For more information, see the EdgeCmd
utility documentation. To validate successful configurations, you can accomplish data retrieval steps (GET
commands) using a browser, if available on your device.
Windows
1. Open Windows services.
3. Depending on whether your adapter is running or not, click either Start or Stop.
Linux
1. Open command line.
2. Depending on whether your adapter is running or not, type one of the following commands:
Example:
Example:
3. Press Enter.
Note: 5590 is the default port number. If you selected a different port number, replace it with that
value.
2. Run a POST command to the following endpoint, replacing <ComponentId> with the ingress
component that you want to stop: http://localhost:5590/api/v1/administration/
<ComponentId>/Stop
Note: 5590 is the default port number. If you selected a different port number, replace it with that
value.
Note: You must make an empty DELETE command against the Id of the component you want to
delete.
5590 is the default port number. If you selected a different port number, replace it with that value.
File relocation
All configuration and log files are renamed and moved. The files are renamed according to the timestamp of
removal, for example, FileName.json_removed_yyyy-MM-dd--hh-mm-ss.
Windows: %programdata%\OSIsoft\Adapters\AdapterName\Configuration\Removed
Linux: /usr/share/OSIsoft/Adapters/AdapterName/Configuration/Removed
Windows: %programdata%\OSIsoft\Adapters\AdapterName\Logs\Removed
Linux: /usr/share/OSIsoft/Adapters/AdapterName/Logs/Removed
In the following example, one adapter service is installed on a particular Windows node with the name
<Adapter>Service1. An adapter component with the name <Adapter>DeviceX was added and
configured to this adapter and later removed. Linux follows a similar behavior. This is the resulting
relocation and renaming scheme after deletion:
Complete the following steps to retrieve the product version information of a PI adapter:
Note: 5590 is the default port number. If you selected a different port number, replace it with that
value.
Example result:
{
"Application Name": "PI Adapter for <AdapterName>",
"Adapter Framework Version": "1.3.0.351",
"Application Version":"1.2.0.37",
".Net Core Version":".NET Core 3.1.5",
"Operating System":"Linux 4.15.0-106-generic #107-Ubuntu SMP Thu Jun 4 11:27:52 UTC 2020"
}
PI Adapters also produce diagnostic data. You can use diagnostic data to find more information about a
particular adapter instance. Diagnostic data lives alongside the health data and you can egress it using a
health endpoint and setting EnableDiagnostics totrue. You can configure EnableDiagnostics in
the system's General configuration. For more information on available adapter diagnostics data, see
diagnostics.
In OSIsoft Cloud Services (OCS), both health and diagnostics data are created as assets. The data are
available in the Asset Explorer and you can use them in the OCS Trend feature. For more information, see
the OCS documentation Assets.
• PI Web API
There are a few differences in how these two systems treat the associated health and diagnostics data.
• PI Web API parses the information and sends it to configured PI servers for the OMF endpoint. The
static data is used to create an AF structure on a PI AF server. The dynamic health data is time-series
data that is stored in PI points on a PI Data Archive. You can see it in the AF structure as PI point data
reference attributes.
• OCS does not currently provide a way to store the static metadata. For OCS-based adapter health
endpoints, only the dynamic data is stored. Each value is its own stream with the timestamp property
as the single index.
AF structure
With a health endpoint configured to a PI server, you can use PI System Explorer to view the health and
diagnostics of an adapter. The element hierarchy is shown in the following image.
• Below Adapters, you will find one or more adapter nodes. Each node's title is defined by the node's
corresponding computer name and service name in this format: {ComputerName}.
{ServiceName}. For example, in the following image, MachineName is the computer name and
OpcUa is the service name.
• To see the health and diagnostics values, click on an adapter node and select Attributes.
To egress health related data, you have to configure an adapter health endpoint first. See Health endpoint
configuration.
• Device status
Device status
The device status indicates the health of this component and if it is currently communicating properly with
the data source. This time-series data is stored within a PI point or OCS stream, depending on the endpoint
type. During healthy steady-state operation, a value of Good is expected.
Status Meaning
Good The component is connected to the data source and it is collecting data.
ConnectedNoData The component is connected to the data source but it is not receiving data from it.
Starting The component is currently in the process of starting up and is not yet connected to the
data source.
DeviceInError The component encountered an error either while connecting to the data source or
attempting to collect data.
Shutdown The component is either in the process of shutting down or has finished.
Removed The adapter component has been removed and will no longer collect data.
NotConfigured The adapter component has been created but is not yet configured.
Diagnostics
The adapter and its components produce various kinds of diagnostics data that is sent to all health
endpoints. The System_Diagnostics.json file contains a flag that determines whether diagnostics
are enabled. You can change this at runtime through REST calls or the EdgeCmd utility. Diagnostics data are
collected by default.
To egress diagnostics related data, you have to configure an adapter health endpoint first. See Health
endpoint configuration.
• System
• Stream count
• IO rate
System
The Diagnostics.System dynamic type includes the following values which are logged in a stream with
the Id System.Diagnostics. This diagnostic stream contains system level information related to the
host platform that the adapter is running on.
WorkingSet long Amount of physical memory in bytes, allocated for the host process
TotalProcessorTime double Total processor time for the host process expressed in seconds
TotalUserProcessorTime double User processor time for the host process expressed in seconds
TotalPrivilegedProcessorTime double Privileged processor time for the host process expressed in seconds
PrivateMemorySize double Amount of paged memory in bytes allocated for the host process
Unit of Measure = megabytes
PeakPagedMemorySize double Maximum amount of memory in the virtual memory paging file in
bytes used by the host process.
Unit of Measure = megabytes
StorageTotalSize double Total size of the storage medium in use by the system
Unit of Measure = megabytes
Stream count
The Diagnostics.StreamCountEvent dynamic type includes the following values, which are logged
in a stream with the Id {componentid}.StreamCount. The StreamCount and TypeCount include
only types and streams created for sequential data received from a data source.
IO rate
The Diagnostics.Adapter.IORate dynamic type includes the following values, which are logged in a
stream with the Id {componentid}.IORate. IORate includes only sequential data collected from a
data source.
Error rate
The Diagnostics.Adapter.ErrorRate dynamic type includes the following values, which are
logged in a stream with the Id {componentid}.ErrorRate.
Egress
The Egress component of the adapter produces the following diagnostics stream:
IO rate
The Diagnostics.Egress.IORate dynamic type includes the following values, which are logged in a
stream with the Id {machineName}.{serviceName}.OmfEgress.{EndpointId}.IORate.
IORate includes only sequential data successfully sent to an egress endpoint.
Note: Make sure to also check the troubleshooting information specific to your adapter in this user guide.
Logs
Messages from the System and OmfEgress logs provide information on the status of the adapter. For
example, they show if a connection from the adapter to an egress endpoint exists.
Perform the following steps to view the System and OmfEgress logs:
Example:
A successful connection to a PI Web API egress endpoint displays the following message in the
OmfEgress log:
2020-11-02 11:08:51.870 -06:00 [Information] Data will be sent to the following OMF endpoint:
Id: <omfegress id>
Endpoint: <pi web api URL> (note: the pi web api default port is 443)
ValidateEndpointCertificate: <true or false>
2. Optional: Change the log level of the adapter to receive more information and context. For more
information, see Logging configuration.
Wireshark
Wireshark is a protocol-specific troubleshooting tool that supports all current adapter protocols. Perform
the following steps if you want to use Wireshark to capture traffic from the data source to the adapter or
from the adapter to the OMF destination.
• NextHealthMessageExpected
• IORate
OCS connection
Perform the following steps to determine if a connection to the OCS endpoint exists:
1. Open OCS.
2. Click Sequential Data Store > Streams.
3. Makes sure that the following streams have been created for your egress endpoint:
• DeviceStatus
• IORate
TCP connection
Perform the following steps to see all established TCP sessions in Linux:
1. Open a terminal.
2. Type the following command: ss -o state established -t -p
3. Press Enter.
Check configurations
Incorrect configurations can interrupt data flow and cause errors in values and ranges. Perform the following
steps to confirm correct configuration for your adapter.
1. Navigate to data source configuration and verify the following for each configured data source item
below:
• Port - The correct port number is referenced. With an incorrect port number specified, the
adapter cannot communicate to the MQTT server.
• Protocol - The correct protocol is referenced. With an incorrect Protocol specified, the adapter
cannot communicate to the MQTT broker.
• ValidateServerCertificate - If enabled (and TLS is enabled), the adapter validates the server
certificate. When the server certificate is not trusted, you can either add it to the OS certificate
store or set ValidateServerCertificate to false.
2. Navigate to data selection configuration and verify that the following data selection items are correct:
• Topic - The topic string is valid. An incorrect topic string causes the adapter to not receive any
values for this data selection item.
• MetricName - The metric name string is valid. With an incorrect metric name, the adapter
cannot extract a data value from the MQTT server payload.
• ValueField - The JsonPath expression is valid. With an invalid JsonPath expression, the adapter
cannot extract a data value from the MQTT server payload.
• IndexField - The JsonPath expression is valid. With an invalid JsonPath expression, the adapter
cannot extract a timestamp from the MQTT server payload.
• IndexFormat - The correct time format is referenced. A time format that does not match the
value from IndexField means that the adapter cannot convert timestamp from the MQTT
server payload.
3. Navigate to egress endpoints configuration. For each configured endpoint, verify that the Endpoint
and authentication properties are correct.
Check connectivity
Perform the following steps to verify active connections to the data source and egress endpoints.
1. Start PI Web API and verify that the PI point values are updating or start OCS and verify that the
stream values are updating.
2. If configured, use a health endpoint to determine the status of the adapter.
For more information, see Health and diagnostics.
Check logs
Perform the following steps to view the adapter and endpoint logs to isolate issues for resolution.
Overview
PI Adapter for MQTT collects time-series data from MQTT servers, its service nodes/devices adhering to the
SparkplugB specification, but also generic producing JSON payload. It then sends the data to configured
OMF endpoints such as PI Web API and OSIsoft Cloud Services.
PI Adapter for MQTT is capable of collecting health and diagnostics information. It supports buffering,
unsolicited data collection, automatic discovery of available data items on a SparkplugB data source, various
Windows and Linux-based operating systems, and containerization.
Fixes
The following items were resolved in release 1.1.0.114:
Item Description
313786 The issue related to parsing DBIRTH messages causing data loss on startup is fixed.
318285 The issue related to parsing multilevel wildcards has been fixed.
Known issues
There are no known issues at this time.
Setup
System requirements
Refer to System requirements.
Vulnerability communication
The practice of publicly disclosing internally discovered vulnerabilities is consistent with the Common
Industrial Control System Vulnerability Disclosure Framework developed by the Industrial Control Systems
Joint Working Group (ICSJWG). Despite the increased risk posed by greater transparency, OSIsoft is sharing
this information to help you make an informed decision about when to upgrade to ensure your PI System
has the best available protection.
Vulnerability scoring
OSIsoft has selected the Common Vulnerability Scoring System (CVSS) to quantify the severity of security
vulnerabilities for disclosure. To calculate the CVSS scores, OSIsoft uses the National Vulnerability Database
(NVD) calculator maintained by the National Institute of Standards and Technology (NIST). OSIsoft uses
High, Medium and Low categories to aggregate the CVSS Base scores. This removes some of the opinion-
related errors of CVSS scoring. As noted in the CVSS specification, Base scores range from 0 for the lowest
severity to 10 for the highest severity.
Technical support
For technical assistance with PI Adapters, contact OSIsoft Technical Support through the OSIsoft Customer
Portal. We can help you identify the problem, provide workarounds and address any concerns you may have.
Remote access to your facilities may be necessary during the session.
Note: You must have an account set up in the OSIsoft Customer Portal before you can open a case. If you do
not have a portal account, see How to Get a Login to OSIsoft Customer Portal.
When you contact OSIsoft Technical Support, be prepared to provide this information:
• Details about your computer platform (CPU type, operating system, and version number)
• Summary of the issue, including any relevant log files during the time the issue occurred
Product feedback
To submit product feedback for PI Adapters, visit the PI Adapters feedback page. The product team at
OSIsoft regularly monitors the page.
Documentation feedback
To submit documentation feedback for PI Adapters, send an email to [email protected]. Be sure
to include the following information with your feedback:
The technical documentation team will review and address your feedback in future documentation updates.