Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add node groups to opcua input plugin #8389

Merged
merged 21 commits into from
Dec 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
41146ce
Remove extra toml section header in the sample config
reimda Oct 29, 2020
98ba434
Remove data type of node. It's never used in the code
reimda Nov 6, 2020
ff62dbe
Remove description of node. It's never used in the code.
reimda Nov 6, 2020
8464ba5
Uncapitalize quality field name. Update readme.
reimda Nov 6, 2020
1ac5f81
Disambiguate the two settings called 'name'. Rename the one in main c…
reimda Nov 10, 2020
2e0e7a9
Add ability to assign a different metric name to a group of nodes. G…
reimda Nov 10, 2020
6c36ee7
Remove name tag that duplicates the opc ua value's field name
reimda Nov 10, 2020
d1546f7
Expose read errors and successes as selfstats
reimda Nov 10, 2020
b4f7288
Update the readme
reimda Nov 11, 2020
79db300
Update the readme
reimda Nov 11, 2020
24112ae
revert changing name fields
reimda Nov 17, 2020
d69e9a2
revert removal of node's data_type and description fields
reimda Nov 17, 2020
6dc2ea9
revert lowercasing Quality field
reimda Nov 17, 2020
ac14f75
revert settings name changes in unit tests
reimda Nov 17, 2020
c83b6da
Add ability to set tags for a group or a node
reimda Nov 17, 2020
1d36187
make fmt
reimda Nov 17, 2020
0d869c8
fix missing tags
reimda Nov 18, 2020
6f7614f
Update duplicate check to respect metric name and metric tags
reimda Dec 2, 2020
48b6fda
Update duplicate check to respect tag values. Check that tag key and…
reimda Dec 2, 2020
ee63c41
simplify tag validation loop
reimda Dec 2, 2020
56dd521
Add documentation for node groups
reimda Dec 3, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 82 additions & 19 deletions plugins/inputs/opcua/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ Plugin minimum tested version: 1.16

```toml
[[inputs.opcua]]
## Device name
# name = "localhost"
## Metric name
# name = "opcua"
#
## OPC UA Endpoint URL
# endpoint = "opc.tcp://localhost:4840"
Expand Down Expand Up @@ -47,34 +47,97 @@ Plugin minimum tested version: 1.16
# password = ""
#
## Node ID configuration
## name - the variable name
## namespace - integer value 0 thru 3
## identifier_type - s=string, i=numeric, g=guid, b=opaque
## identifier - tag as shown in opcua browser
## data_type - boolean, byte, short, int, uint, uint16, int16,
## uint32, int32, float, double, string, datetime, number
## name - field name to use in the output
## namespace - OPC UA namespace of the node (integer value 0 thru 3)
## identifier_type - OPC UA ID type (s=string, i=numeric, g=guid, b=opaque)
## identifier - OPC UA ID (tag as shown in opcua browser)
## tags - extra tags to be added to the output metric (optional)
## Example:
## {name="ProductUri", namespace="0", identifier_type="i", identifier="2262", data_type="string", description="http://open62541.org"}
nodes = [
{name="", namespace="", identifier_type="", identifier="", data_type="", description=""},
{name="", namespace="", identifier_type="", identifier="", data_type="", description=""},
]
## {name="ProductUri", namespace="0", identifier_type="i", identifier="2262", tags=[["tag1","value1"],["tag2","value2]]}
# nodes = [
# {name="", namespace="", identifier_type="", identifier=""},
# {name="", namespace="", identifier_type="", identifier=""},
#]
#
## Node Group
## Sets defaults for OPC UA namespace and ID type so they aren't required in
## every node. A group can also have a metric name that overrides the main
## plugin metric name.
##
## Multiple node groups are allowed
#[[inputs.opcua.group]]
## Group Metric name. Overrides the top level name. If unset, the
## top level name is used.
# name =
#
## Group default namespace. If a node in the group doesn't set its
## namespace, this is used.
# namespace =
#
## Group default identifier type. If a node in the group doesn't set its
## namespace, this is used.
# identifier_type =
#
## Node ID Configuration. Array of nodes with the same settings as above.
# nodes = [
# {name="", namespace="", identifier_type="", identifier=""},
# {name="", namespace="", identifier_type="", identifier=""},
#]
```

### Example Node Configuration
An OPC UA node ID may resemble: "n=3,s=Temperature". In this example:
### Node Configuration
An OPC UA node ID may resemble: "n=3;s=Temperature". In this example:
- n=3 is indicating the `namespace` is 3
- s=Temperature is indicting that the `identifier_type` is a string and `identifier` value is 'Temperature'
- This example temperature node has a value of 79.0, which makes the `data_type` a 'float'.
- This example temperature node has a value of 79.0
To gather data from this node enter the following line into the 'nodes' property above:
```
{name="LabelName", namespace="3", identifier_type="s", identifier="Temperature", data_type="float", description="Description of node"},
{field_name="temp", namespace="3", identifier_type="s", identifier="Temperature"},
```

This node configuration produces a metric like this:
```
opcua,id=n\=3;s\=Temperature temp=79.0,quality="OK (0x0)" 1597820490000000000

```

### Group Configuration
Groups can set default values for the namespace, identifier type, and
tags settings. The default values apply to all the nodes in the
group. If a default is set, a node may omit the setting altogether.
This simplifies node configuration, especially when many nodes share
the same namespace or identifier type.

### Example Output
The output metric will include tags set in the group and the node. If
a tag with the same name is set in both places, the tag value from the
node is used.

This example group configuration has two groups with two nodes each:
```
[[inputs.opcua.group]]
name="group1_metric_name"
namespace="3"
identifier_type="i"
tags=[["group1_tag", "val1"]]
nodes = [
{name="name", identifier="1001", tags=[["node1_tag", "val2"]]},
{name="name", identifier="1002", tags=[["node1_tag", "val3"]]},
]
[[inputs.opcua.group]]
name="group2_metric_name"
namespace="3"
identifier_type="i"
tags=[["group2_tag", "val3"]]
nodes = [
{name="saw", identifier="1003", tags=[["node2_tag", "val4"]]},
{name="sin", identifier="1004"},
]
```
opcua,host=3c70aee0901e,name=Random,type=double Random=0.018158170305814902 1597820490000000000

It produces metrics like these:
```
group1_metric_name,group1_tag=val1,id=ns\=3;i\=1001,node1_tag=val2 name=0,Quality="OK (0x0)" 1606893246000000000
group1_metric_name,group1_tag=val1,id=ns\=3;i\=1002,node1_tag=val3 name=-1.389117,Quality="OK (0x0)" 1606893246000000000
group2_metric_name,group2_tag=val3,id=ns\=3;i\=1003,node2_tag=val4 Quality="OK (0x0)",saw=-1.6 1606893246000000000
group2_metric_name,group2_tag=val3,id=ns\=3;i\=1004 sin=1.902113,Quality="OK (0x0)" 1606893246000000000
```
Loading