Steps to reproduce:
1. Create item with 9 captured groups in regexp and all 10 possible groups in "output template":
2. Append to logfile a string: ABCDEFGHIJKLMNOPQRSTUVWXYZ
Result is correct:
3. Reduce number of captured groups in regexp to 3, but leave all 10 groups in "output template" (do not restart agent):
4. Append to logfile a string: ABCDEFGHIJKLMNOPQRSTUVWXYZ
Result is incorrect:
Not-captured groups happen to contain their old values, although documentation https://www.zabbix.com/documentation/current/manual/config/items/itemtypes/zabbix_agent#supported_item_keys says that not-captured group is "an empty string if the N exceeds the number of captured groups".
This bug is not limited to log and logrt items. Similar results can be demonstrated with item preprocessing if output template references capture groups which do not exist in the regexp.