-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
[inputs/modbus] Add possibility to specify measurement per register #7231
Conversation
Normally I would suggest against multiple measurements per device. I'd be interested to hear more about why it would be helpful to have multiple measurements, perhaps you could attach your configuration with these changes? |
@danielnelson this is the config for one of our energy meters without the PR applied: While this works and does what we want, we create 12 TCP connections to the meter. However, some meters allow only a very limited number of simultaneous connections (down to 4) and you easily get into trouble. Furthermore, the plugin optimizes register access for the queries by grouping consecutive registers. This cannot be done when split over multiple instances. This is the configuration with the PR applies: I think we will have the same problem as above with all multi-metric sensors, especially in cases where there are connection limits... |
Alright, but let's try using SeriesGrouper to build up the metric groups? We could remove the duplicate name check completely, I think it's not worth it. Just a suggestion, but have you considered joining the measurement with the field key or using another method to fully describe the value? I think in some respects (but not all) this will be more flexible to work with, in particular if you need to work with values from In other words, switching from:
To something like this:
|
…roup the resulting multiple series using a SeriesGrouper.
3e55bbc
to
ddccb3d
Compare
This now uses the SeriesGrouper making the code look much cleaner and the diff smaller. Thanks for the suggestion!
I left it in because it's neither a lot of code nor a big diff and it saved me a few times already when copy-pasting... :-)
We used this scheme in the past, however having different sensors with different sets of measurements completely destroys discoverability for people working with the data in my experience. Anyway with the PR applied, people will have the chance to do both... ;-) |
Required for all PRs:
With this PR it is possibile to specify an (optional) measurement property per register definition to group those registers as fields of the specified measurement. In case the measurement property is missing modbus is used for the measurement name just as before.
The reasoning behind this is that some devices have restrictions for the number of simultaneous connections. When reading multiple metrics (e.g. voltage, current, work, power) from one device, assigning each them to different measurements would take multiple instances of the modbus plugin, each with a
name_override
. Thus these multiple instances will concurrently connect to device potentially exceeding the number of maximum allowed connections.With the PR applied, one modbus plugin can read all required registers from the device (with one connection) and then sort the fields into the specified measurements.