Skip to content
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

Allow creation of multiple tags/fields with regex processor #5505

Closed
sslupsky opened this issue Feb 28, 2019 · 3 comments · Fixed by #13971
Closed

Allow creation of multiple tags/fields with regex processor #5505

sslupsky opened this issue Feb 28, 2019 · 3 comments · Fixed by #13971
Assignees
Labels
feature request Requests for new plugin and for new features to existing plugins help wanted Request for community participation, code, contribution size/m 2-4 day effort

Comments

@sslupsky
Copy link

sslupsky commented Feb 28, 2019

Feature Request

Opening a feature request kicks off a discussion.

Proposal:

Allow creation of multiple tags/fields when using the regex processor

Current behavior:

When using named subgroups, it is possible to create a tag/field using the result_key parameter. Presently, if you want to create multiple tag/fields from multiple subgroups, you need to create (instantiate?) another processor. For example, in the following configuration a regex is used to extract the gateway, uid and channel from the path. In order to create a new tag, three processors are required:

[[processors.regex.tags]]
  key = "path"
  pattern = "^/motescan/(?P<gateway>scannet[0-9]+)/csv/l(?P<uid>[0-9A-Fa-f]+)[0-9]+\.csv_channel(?P<channel>[A-Za-z]?[A-Za-z0-9]+)\.csv$"
  replacement = "${gateway}"
  result_key = "gateway"

[[processors.regex.tags]]
  key = "path"
  pattern = "^/motescan/(?P<gateway>scannet[0-9]+)/csv/l(?P<uid>[0-9A-Fa-f]+)[0-9]+\.csv_channel(?P<channel>[A-Za-z]?[A-Za-z0-9]+)\.csv$"
  replacement = "${uid}"
  result_key = "uid"

[[processors.regex.tags]]
  key = "path"
  pattern = "^/motescan/(?P<gateway>scannet[0-9]+)/csv/l(?P<uid>[0-9A-Fa-f]+)[0-9]+\.csv_channel(?P<channel>[A-Za-z]?[A-Za-z0-9]+)\.csv$"
  replacement = "${channel}"
  result_key = "channel"

Desired behavior:

It would improve resource usage if only one processor was used as the regex would be executed once instead of multiple times.

Use case: [Why is this important (helps with prioritizing requests)]

Using a regex to create/extract metadata from another tag/field.

@danielnelson danielnelson added the feature request Requests for new plugin and for new features to existing plugins label Feb 28, 2019
@hackery
Copy link
Contributor

hackery commented Jan 17, 2020

I was just looking to do this too. Would the following syntax be suitable?

replacements = { gateway = "${gateway}", uid = "${uid}", channel = "${channel}" }

@reimda
Copy link
Contributor

reimda commented Aug 18, 2022

@sslupsky and @hackery it looks like the next step for this is to find someone to implement the change. Are either of you able to put together a PR to change the regex processor to allow multiple regex groups to produce multiple tags/fields?

@reimda reimda added help wanted Request for community participation, code, contribution size/m 2-4 day effort labels Aug 18, 2022
powersj added a commit to powersj/telegraf that referenced this issue Aug 23, 2023
powersj added a commit to powersj/telegraf that referenced this issue Aug 29, 2023
@srebhan srebhan self-assigned this Sep 8, 2023
@srebhan
Copy link
Member

srebhan commented Sep 21, 2023

@sslupsky please test the binary in PR #13971 which implements the possibility of using named groups to create a bunch of new tags/fields using the group names and values. Let me know if this is what you had in mind...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Requests for new plugin and for new features to existing plugins help wanted Request for community participation, code, contribution size/m 2-4 day effort
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants