Sometimes the data stream doesn't provide you with all the information you need. For example, timestamp or asset name is in the file name - fe.: "Device1_20180605.dat". Or with REST Server you can get an information about the sender node/application and IP. This article describes what metadata you can get in the PI Connector for UFL.

 

Table of all the keywords for meta information:

VARIABLEDESCRIPTION
__DSNAMEThe name of the configured data source (on the connector administration page)
__DSDESCRIPTIONData source description  (on the connector administration page)
__DSADDRESSData source address  (on the connector administration page)
__MESSAGEThe content of the current message (line)
__STREAMINFOStream information (described below)

 

__STREAMINFO

For the File channel, this variable has the following format: filename|modification date|creation date, for example: a.txt|07-Jun-2016 04:35:39.676|03-Jun-2016 02:51:31.173 (replaces PFN parameter in the UFL Interface)

For the REST server channel, this variable has the following format: Source IP Address|Port, for example: 10.105.0.106|5687

For the REST Client channel, the format is following: Endpoint address and server, for example: https://restcountries.eu/rest/v1/alpha/LIE|nginx

 

How to parse meta information?

In the following example for File channel we parse all the meta information as static attributes and create an asset.

[FIELD]
FIELD(1).Name = "FileName"
FIELD(2).Name = "TimestampCreated"
FIELD(2).Type = "DateTime"
FIELD(2).Format = "dd-MMM-yyyy hh:mm:ss.nnn",_
"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec"
FIELD(3).Name = "TimestampModified"
FIELD(3).Type = "DateTime"
FIELD(3).Format = "dd-MMM-yyyy hh:mm:ss.nnn",_
"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec"
FIELD(4).Name = "StatAttrCol"
FIELD(4).Type = "Collection"
FIELD(5).Name = "Temp"

[MSG]
MSG(1).NAME="Data"

[Data]
Data.FILTER = C1=="*"

Temp = __MESSAGE
__MESSAGE = __STREAMINFO
FileName = ["(*)|*"]
TimestampModified = ["*|(*)|*"]
TimestampCreated = ["*|*|(*)"]
__MESSAGE = Temp
StatAttrCol = Clear()

StatAttrCol = Add("Data Source name",__DSNAME)
StatAttrCol = Add("Data Source description",__DSDESCRIPTION)
StatAttrCol = Add("Data source address",__DSADDRESS)
StatAttrCol = Add("StreamInfo string",__STREAMINFO)
StatAttrCol = Add("Streamdata string",__MESSAGE)
StatAttrCol = Add("File name",FileName)
StatAttrCol = Add("File created",TimestampCreated)
StatAttrCol = Add("File modified",TimestampModified)
StatAttrCol = Add("Processing started",NOW())

StoreElement("LastFileInfo","FileInfoTemplate",StatAttrCol)

 

The result:

metadata.jpg