Clarify replacement string behavior in regex processor

This commit is contained in:
Daniel Nelson 2019-06-13 10:27:17 -07:00
parent ae1aee3207
commit 58e6eb6f07
No known key found for this signature in database
GPG Key ID: CAAD59C9444F6155
2 changed files with 7 additions and 3 deletions

View File

@ -14,10 +14,12 @@ The `regex` plugin transforms tag and field values with regex pattern. If `resul
key = "resp_code" key = "resp_code"
## Regular expression to match on a tag value ## Regular expression to match on a tag value
pattern = "^(\\d)\\d\\d$" pattern = "^(\\d)\\d\\d$"
## Pattern for constructing a new value (${1} represents first subgroup) ## Matches of the pattern will be replaced with this string. Use ${1}
## notation to use the text of the first submatch.
replacement = "${1}xx" replacement = "${1}xx"
[[processors.regex.fields]] [[processors.regex.fields]]
## Field to change
key = "request" key = "request"
## All the power of the Go regular expressions available here ## All the power of the Go regular expressions available here
## For example, named subgroups ## For example, named subgroups

View File

@ -27,14 +27,16 @@ const sampleConfig = `
# key = "resp_code" # key = "resp_code"
# ## Regular expression to match on a tag value # ## Regular expression to match on a tag value
# pattern = "^(\\d)\\d\\d$" # pattern = "^(\\d)\\d\\d$"
# ## Pattern for constructing a new value (${1} represents first subgroup) # ## Matches of the pattern will be replaced with this string. Use ${1}
# ## notation to use the text of the first submatch.
# replacement = "${1}xx" # replacement = "${1}xx"
# [[processors.regex.fields]] # [[processors.regex.fields]]
# ## Field to change
# key = "request" # key = "request"
# ## All the power of the Go regular expressions available here # ## All the power of the Go regular expressions available here
# ## For example, named subgroups # ## For example, named subgroups
# pattern = "^/api(?P<method>/[\\w/]+)\\S*" # pattern = "^/api(?P<method>/[\\w/]+)\\S*"
# replacement = "${method}" # replacement = "${method}"
# ## If result_key is present, a new field will be created # ## If result_key is present, a new field will be created
# ## instead of changing existing field # ## instead of changing existing field