Hi Franky, I saw this, but I have not a file. It is part of MQTT consumer. Instead JSON I get this XML format.
Is is possible to combine this? Or do I need a own plugin?
Thanks.
Yes, this will be send by a visualisation software (named VISU+ or Movicon). Normally this is used to send from one device to another device over MQTT Broker (it is xml silmilar). Well. it seems that it is not possible to send universal topics with this kind of software
<DataValue xmlns="http://opcfoundation.org/UA/2008/02/Types.xsd" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><Value><Value><UInt16>16</UInt16></Value></Value><StatusCode><Code>0</Code></StatusCode><SourceTimestamp>0001-01-01T00:00:00</SourceTimestamp><SourcePicoseconds>0</SourcePicoseconds><ServerTimestamp>2021-08-03T13:38:42.656Z</ServerTimestamp><ServerPicoseconds>0</ServerPicoseconds></DataValue>type or paste code here
Hi Franky, that sounds good. Thanks,
Now I need to transfer to MQTT plugin and XML parser, right?
Similar like that?
## Data format to consume.
## Each data format has its own unique set of configuration options, read
## more about them here:
## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md
data_format = "xml"
[[inputs.mqtt_consumer.xml]]
#metric_selection = "/Bus/child::Sensor"
#metric_name = "string('example')"
timestamp = "/DataValue/ServerTimestamp"
timestamp_format = "2006-01-02T15:04:05.999Z"
## Tag definitions using the given XPath queries.
[inputs.mqtt_consumer.xml.tags]
name = "substring-after(Sensor/@name, ' ')"
device = "string('the ultimate sensor')"
## Integer field definitions using XPath queries.
[inputs.mqtt_consumer.xml.fields_int]
value = "/DataValue/Value/Value/UInt16"
statuscode = "/DataValue/StatusCode/Code"
## Non-integer field definitions using XPath queries.
[inputs.mqtt_consumer.xml.fields]
[[inputs.mqtt_consumer]]
## Broker URLs for the MQTT server or cluster. To connect to multiple
## clusters or standalone servers, use a seperate plugin instance.
## example: servers = ["tcp://localhost:1883"]
## servers = ["ssl://localhost:1883"]
## servers = ["ws://localhost:1883"]
servers = ["ssl://aaaaaaaaaaa-ats.iot.us-east-2.amazonaws.com:8883"]
## Topics that will be subscribed to.
topics = [
"/TestAlex1",
]
## The message topic will be stored in a tag specified by this value. If set
## to the empty string no topic tag will be created.
# topic_tag = "topic"
## QoS policy for messages
## 0 = at most once
## 1 = at least once
## 2 = exactly once
##
## When using a QoS of 1 or 2, you should enable persistent_session to allow
## resuming unacknowledged messages.
# qos = 0
## Connection timeout for initial connection in seconds
# connection_timeout = "30s"
## Maximum messages to read from the broker that have not been written by an
## output. For best throughput set based on the number of metrics within
## each message and the size of the output's metric_batch_size.
##
## For example, if each message from the queue contains 10 metrics and the
## output metric_batch_size is 1000, setting this to 100 will ensure that a
## full batch is collected and the write is triggered immediately without
## waiting until the next flush_interval.
# max_undelivered_messages = 1000
## Persistent session disables clearing of the client session on connection.
## In order for this option to work you must also set client_id to identify
## the client. To receive messages that arrived while the client is offline,
## also set the qos option to 1 or 2 and don't forget to also set the QoS when
## publishing.
# persistent_session = false
## If unset, a random client ID will be generated.
# client_id = ""
## Username and password to connect MQTT server.
# username = "telegraf"
# password = "metricsmetricsmetricsmetrics"
## Optional TLS Config
tls_ca = "/etc/telegraf/AmazonRootCA1.pem"
tls_cert = "/etc/telegraf/aaaaaaaa.crt"
tls_key = "/etc/telegraf/cccccccccccc-private.pem.key"
## Use TLS but skip chain & host verification
insecure_skip_verify = true
## Data format to consume.
## Each data format has its own unique set of configuration options, read
## more about them here:
## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md
data_format = "xml"
[[inputs.mqtt_consumer.xml]]
timestamp = "/DataValue/ServerTimestamp"
timestamp_format = "2006-01-02T15:04:05.999Z"
[inputs.mqtt_consumer.xml.fields_int]
value = "/DataValue/Value/Value/UInt16"
statuscode = "/DataValue/StatusCode/Code"