fix(inputs.opcua): Add metric tags to node (#11993)
This commit is contained in:
parent
430ec5b960
commit
beba64e006
|
|
@ -208,9 +208,16 @@ func tagsSliceToMap(tags [][]string) (map[string]string, error) {
|
|||
// InitNodes Method on OpcUA
|
||||
func (o *OpcUA) InitNodes() error {
|
||||
for _, node := range o.RootNodes {
|
||||
nodeTags, err := tagsSliceToMap(node.TagsSlice)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
o.nodes = append(o.nodes, Node{
|
||||
metricName: o.MetricName,
|
||||
tag: node,
|
||||
metricTags: nodeTags,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -186,8 +186,8 @@ auth_method = "Anonymous"
|
|||
username = ""
|
||||
password = ""
|
||||
nodes = [
|
||||
{name="name", namespace="1", identifier_type="s", identifier="one"},
|
||||
{name="name2", namespace="2", identifier_type="s", identifier="two"},
|
||||
{name="name", namespace="1", identifier_type="s", identifier="one", tags=[["tag0", "val0"]]},
|
||||
{name="name2", namespace="2", identifier_type="s", identifier="two", tags=[["tag0", "val0"], ["tag00", "val00"]]},
|
||||
]
|
||||
[[inputs.opcua.group]]
|
||||
name = "foo"
|
||||
|
|
@ -226,6 +226,8 @@ additional_valid_status_codes = ["0xC0"]
|
|||
|
||||
require.NoError(t, o.InitNodes())
|
||||
require.Len(t, o.nodes, 4)
|
||||
require.Len(t, o.nodes[0].metricTags, 1)
|
||||
require.Len(t, o.nodes[1].metricTags, 2)
|
||||
require.Len(t, o.nodes[2].metricTags, 3)
|
||||
require.Len(t, o.nodes[3].metricTags, 2)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue