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

String replacer function to strings plugin #4686

Merged
merged 3 commits into from
Sep 27, 2018

Conversation

doublerainbo
Copy link
Contributor

Required for all PRs:

  • Signed CLA.
  • Associated README.md updated.
  • Has appropriate unit tests.

In reference to #4599

Adding the ability to replace substrings in a field, tag, or measurement. Also adding the ability to
match on multiple of the resource with '*'. With that active, the dest field is ignored and the same data is written back to the same field name to avoid writing all modified data to the same field name.

@doublerainbo
Copy link
Contributor Author

@danielnelson i added a bit more than just the substring replacement in this PR since we need the ability to run a replace on every metric going through, but i'd imagine '*' should be fairly contained since it's likely not a valid name for the existing tags/fields/metrics 🤞 . If you can take a look that'd be awesome. Thanks!

@danielnelson danielnelson added this to the 1.9.0 milestone Sep 14, 2018
@danielnelson danielnelson added the feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin label Sep 14, 2018
@doublerainbo doublerainbo mentioned this pull request Sep 17, 2018
3 tasks
if c.Dest != "" {
dest = c.Dest
for tag, value := range tags {
dest := tag
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe reuse tag in place of dest, to save an allocation.

if fv, ok := fv.(string); ok {
metric.AddField(dest, c.fn(fv))
for tag, value := range fields {
dest := tag
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, just use tag instead of dest

@danielnelson danielnelson merged commit 8cbd395 into influxdata:master Sep 27, 2018
rgitzel pushed a commit to rgitzel/telegraf that referenced this pull request Oct 17, 2018
otherpirate pushed a commit to otherpirate/telegraf that referenced this pull request Mar 15, 2019
otherpirate pushed a commit to otherpirate/telegraf that referenced this pull request Mar 15, 2019
dupondje pushed a commit to dupondje/telegraf that referenced this pull request Apr 22, 2019
athoune pushed a commit to bearstech/telegraf that referenced this pull request Apr 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants