inputs.modbus plugin supports custom maxBatchSize

Hello, I found that while using the inputs.modbus plugin, the maximum number of single requests for coils and discrete is 2000, and the maximum number of single requests for holding registers and input registers is 125. However, the device does not support this. I would like to customize the maximum read limit. How can I set it? Can you help me develop it if it’s not supported? Thank you

2025-04-24T08:06:51Z I! [inputs.modbus::inputs@modbus@3OSIS9jSTq] Got 5 request(s) touching 501 holding registers for 498 fields (slave 1) on device “3OSIS9jSTq”
2025-04-24T08:06:51Z D! [inputs.modbus::inputs@modbus@3OSIS9jSTq] #1: @0 with length 125
2025-04-24T08:06:51Z D! [inputs.modbus::inputs@modbus@3OSIS9jSTq] #2: @125 with length 125
2025-04-24T08:06:51Z D! [inputs.modbus::inputs@modbus@3OSIS9jSTq] #3: @250 with length 125
2025-04-24T08:06:51Z D! [inputs.modbus::inputs@modbus@3OSIS9jSTq] #4: @375 with length 124
2025-04-24T08:06:51Z D! [inputs.modbus::inputs@modbus@3OSIS9jSTq] #5: @499 with length 2
2025-04-24T08:06:51Z I! [inputs.modbus::inputs@modbus@3OSIS9jSTq] Got 5 request(s) touching 501 inputs registers for 498 fields (slave 1) on device “3OSIS9jSTq”
2025-04-24T08:06:51Z D! [inputs.modbus::inputs@modbus@3OSIS9jSTq] #1: @0 with length 125
2025-04-24T08:06:51Z D! [inputs.modbus::inputs@modbus@3OSIS9jSTq] #2: @125 with length 125
2025-04-24T08:06:51Z D! [inputs.modbus::inputs@modbus@3OSIS9jSTq] #3: @250 with length 125
2025-04-24T08:06:51Z D! [inputs.modbus::inputs@modbus@3OSIS9jSTq] #4: @375 with length 124
2025-04-24T08:06:51Z D! [inputs.modbus::inputs@modbus@3OSIS9jSTq] #5: @499 with length 2
2025-04-24T08:06:51Z I! [inputs.modbus::inputs@modbus@3OSIS9jSTq] Got 3 request(s) touching 5000 discrete registers for 5000 fields (slave 1) on device “3OSIS9jSTq”
2025-04-24T08:06:51Z D! [inputs.modbus::inputs@modbus@3OSIS9jSTq] #1: @0 with length 2000
2025-04-24T08:06:51Z D! [inputs.modbus::inputs@modbus@3OSIS9jSTq] #2: @2000 with length 2000
2025-04-24T08:06:51Z D! [inputs.modbus::inputs@modbus@3OSIS9jSTq] #3: @4000 with length 1000
2025-04-24T08:06:51Z I! [inputs.modbus::inputs@modbus@3OSIS9jSTq] Got 3 request(s) touching 5000 coil registers for 5000 fields (slave 1) on device “3OSIS9jSTq”
2025-04-24T08:06:51Z D! [inputs.modbus::inputs@modbus@3OSIS9jSTq] #1: @0 with length 2000
2025-04-24T08:06:51Z D! [inputs.modbus::inputs@modbus@3OSIS9jSTq] #2: @2000 with length 2000
2025-04-24T08:06:51Z D! [inputs.modbus::inputs@modbus@3OSIS9jSTq] #3: @4000 with length 1000

I’m not sure @skartikey do you know? Thank you!

@zqm6133 Welcome to the InfluxData community!

I see you’ve already opened an issue for this feature request. You’re correct that we currently don’t support customizing the maximum read limits in the Modbus plugin.

The Telegraf Modbus plugin has hardcoded maximum read limits:

  • Coils and Discrete registers: 2000 units per request
  • Holding and Input registers: 125 units per request

Unfortunately, these limits are not currently configurable through the plugin configuration.

Workaround Solutions

While waiting for official support, here’s an approach you can consider:

Split Your Requests

If your device doesn’t support the full 125/2000 limits, you can manually split your requests by configuring the addresses to be non-contiguous. This forces the plugin to create multiple smaller requests.

For example, instead of requesting addresses 0-500, you could configure separate request sections:

[[inputs.modbus.request]]
slave_id = 1
fields = [
  { address=0, name="reg1", type="UINT16" },
  { address=1, name="reg2", type="UINT16" },
  # ... up to around your device's limit (e.g., 50)
]

[[inputs.modbus.request]]
slave_id = 1
fields = [
  { address=60, name="reg61", type="UINT16" },
  { address=61, name="reg62", type="UINT16" },
  # ... continue with the next batch
]

This workaround will respect your device’s limitations while we work on implementing the feature request.

ok, thank you for your reply :grinning_face: