fix(inputs.opcua): Add metric tags to node (#11993)

This commit is contained in:
R290 2022-10-12 18:41:44 +02:00 committed by GitHub
parent 430ec5b960
commit beba64e006
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -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,
})
}

View File

@ -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)