telegraf: [regression] v1.27 shell-like expansion replaces non-environment variables

Relevant telegraf.conf

[[processors.regex]]
order = 50
namepass = ["wallbox_status"]

[[processors.regex.fields]]
    key = "0_chargingRate"
    pattern = "Charging rate: (.*)kw.*\\[(.*)A (.*)pf \\]"
    replacement = "${1}"
    result_key = "charge_kW"

Logs from Telegraf

---

System info

Telegraf 1.27.0

Docker

No response

Steps to reproduce

This is the string used as input to regex plugin: "Charging rate: 0kw 3 phase [0A pf ] "

Expected behavior

field “charge_kW” should contain “0”

Actual behavior

field “charge_kW” contains “1}”

Additional info

changing replacement = “${1}” to replacement = “$1”

makes it work as expected again in Telegraf 1.27. However, the documentation of the regex plugin is suggesting to use “${1}”, which was working up to 1.26.x

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 2
  • Comments: 19 (13 by maintainers)

Commits related to this issue

Most upvoted comments

@srebhan Using the binary from https://github.com/influxdata/telegraf/pull/13457#issuecomment-1598580800 I can confirm above config is working as expected. Furthermore, using $1 is working as well.

I just found the right package in the PR build artifacts and installed it 😃 And: yes, this would fix the issue. Both is working then: $1 and ${1}.

@peerfiet can you please test the binary in #13457 once CI finished the tests successfully? We needed to change the behavior again as we found other cases where the implementation broke existing configs… So now your original config )(the one with replacement = "${1}" should just work ™… 😉 Please let me know if you find any issues!