Hi all,
I’m a bit lost after trying and reading for 2 days now..
Using Telegraf to collect data from an OPCUA server
Problem is, that I can only read each value as separate value and this should be handled as a tag for easier filtering and alerting
example
Temperature -203.2
sensor 001
type 2
group 01
limit min
I tried to use starlark, filtering, processors..(pivot) but nothing works. Or I’m just too stupid
What would be the way forward to something like
opcua_temperature sensor=“001”, type=“2”,group=“01”,limit=“min”,value= -203.2 1618488000000000999
instead of
opcua_temperature,value= -203.2 1618488000000000999
opcua_sensor,value=001 1618488000000000999
opcua_type,value=2 1618488000000000999
…
in the inputs.opcua plugin i can define each sensor tag by hand with inputs.opcua.nodes instead of inputs.opcua.group, but this would take me to edit 2000 Sensor manually and the values might change
any hints please?
R290
May 14, 2025, 9:13am
2
Can you post the Telegraf config you are using? The merge aggregator is probably a good starting point: telegraf/plugins/aggregators/merge/README.md at master · influxdata/telegraf · GitHub . You can set the period to match your acquisition interval.
[[inputs.opcua]]
name = "opcua"
endpoint = "opc.tcp://10.10.0.28:4840"
connect_timeout = "10s"
request_timeout = "5s"
session_timeout = "120s"
security_policy = "None"
security_mode = "None"
auth_method = "Anonymous"
timestamp = "source"
# username = "admin"
# password = "password"
## Sensor 01
# Group 1
[[inputs.opcua.group]]
name = "Temp1"
namespace ="3"
identifier_type ="s"
default_tags = { type = "val1", sensor = "08", group = "01" }
nodes = [
{name="Temp1", identifier='"dataDB"."pt100Array"[1]."Temp"'},
{name="Min", identifier='"dataDB"."pt100Array"[1]."Min"'},
{name="Max", identifier='"dataDB"."pt100Array"[1]."Max"'},
{name="group", identifier='"dataDB"."pt100Array"[1]."groupId"'},
]
if I understand correctly the “merge” combines metrics with the same name (by series key)
like
cpu..
cpu..
but I get
opcua_Temp1…
opcua_Min
opcua_Max
So that does not work?
I would have chosen the same name, but the plugin gives me an error doing this
R290
May 14, 2025, 12:55pm
4
Removing the line name = "Temp1"
in:
[[inputs.opcua.group]]
name = "Temp1"
should set the measurement to name to opcua
for all metrics? With your current configuration you are overwriting the metric name for the group to Temp1
. Or is this intentional?
1 Like
Yes thanks ! that helps a lot
This gives me the following
[[inputs.opcua.group]]
# name = "Temp1"
namespace ="3"
identifier_type ="s"
default_tags = { type = "val1", sensor = "01", group = "01" }
nodes = [
{name="Temp", identifier='"dataDB"."pt100Array"[1]."Temp"'},
{name="Min", identifier='"dataDB"."pt100Array"[1]."Min"'},
{name="Max", identifier='"dataDB"."pt100Array"[1]."Max"'},
{name="group", identifier='"dataDB"."pt100Array"[1]."groupId"'},
]
[[inputs.opcua.group]]
# name = "Temp2"
namespace ="3"
identifier_type ="s"
default_tags = { type = "val1", sensor = "02", group = "01" }
nodes = [
{name="Temp", identifier='"dataDB"."pt100Array"[2]."Temp"'},
{name="Min", identifier='"dataDB"."pt100Array"[2]."Min"'},
{name="Max", identifier='"dataDB"."pt100Array"[2]."Max"'},
{name="group", identifier='"dataDB"."pt100Array"[2]."groupId"'},
]
Query
for opcua_Temp
* {__name__="opcua_Temp", db="db_name", group="01", id="ns=3;s="dataDB"."pt100Array"[1]."Temp"", sensor="01", type="val1"}
* {__name__="opcua_Temp", db="db_name", group="01", id="ns=3;s="dataDB"."pt100Array"[2]."Temp"", sensor="02", type="val1"}
But how can I merge information like “group” into the “opcua_Temp” as Tag? So i don’t have to do it manually, because this may change in the future at OPCUA-side
Is there a way?
R290
May 14, 2025, 6:08pm
6
The converter processor should be able to do this? telegraf/plugins/processors/converter at master · influxdata/telegraf · GitHub
[[processors.converter]]
[processors.converter.fields]
tag = ["group"]
1 Like