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

Usage of rule update_tag_value.go #12

Open
guro23 opened this issue Oct 6, 2021 · 6 comments
Open

Usage of rule update_tag_value.go #12

guro23 opened this issue Oct 6, 2021 · 6 comments

Comments

@guro23
Copy link

guro23 commented Oct 6, 2021

We are using this project to change some of the values in our influxdb. Renaming tags works fine.

When we try to use the update_tag_value rule, we get an error for an unregistrated rule.

We tried adding it to registry.go. But no success of registrating it.

The update_tag_value.go is missing a code snippet for configuration or is it used in another way inside the TOML configuration file?

@oktal
Copy link
Member

oktal commented Oct 6, 2021

Hello.

You are right, the UpdateTagValue rule was not properly plugged in the configuration system.

I implemented it in af40eef

Could you try and let me know how it goes ?

@guro23
Copy link
Author

guro23 commented Oct 7, 2021

Thank you very much. It works if you change the config from example.

[[rules.update-tag-value]]
to="NewValue"
[rules.update-tag**-value**.measurement.strings]
equal="Measurement"
[rules.update-tag**-value**.key.strings]
equal="KeyValue"
[rules.update-tag**-value**.value.strings]
equal="OldValue"

Unluckily it is not changing values inside our files. It shows changed Values for our rules but result is not noticeable inside our queries.

@oktal
Copy link
Member

oktal commented Nov 9, 2021

Thanks, I'll update the example accordingly !

Unluckily it is not changing values inside our files. It shows changed Values for our rules but result is not noticeable inside our queries.

Which kind of index are you using ? memory or tsi ? If you are using the TSI, make sure to rebuild the index

@hiroshi-kawazoe
Copy link

As far as I tried, I needed to change the FilterKey() in UpdateTagValueRule to return true, although I'm not sure if this is the right modification.
https://github.com/Abc-Arbitrage/infix/blob/master/rules/update_tag_value.go#L68

Also, when comparing measurement names, equal did not work well, while contains seemed to work, though not perfectly.

[[rules.update-tag-value]]
    to="NewValue"
    [rules.update-tag-value.measurement.strings]
        contains="Measurement"
    [rules.update-tag-value.key.strings]
        equal="KeyValue"
    [rules.update-tag-value.value.strings]
        equal="OldValue"

mayeranalytics pushed a commit to mayeranalytics/infix that referenced this issue Aug 2, 2022
Fixed example `UpdateTagValueRule` as per issue [Abc-Arbitrage#12](Abc-Arbitrage#12).
@mayeranalytics
Copy link
Contributor

mayeranalytics commented Aug 8, 2022

When I build a test database with content like this

insert linux.test,region=amazon-us value=1 1439856000

the unaltered example in UpdateTagValueRule just seems to delete everything.
(I'm running Influxdb 1.6, which doesn't seem to have influx_inspect for rebuilding the index, yet.)
I would caution against using UpdateTagValueRule without thorough testing in a copy of the target database.

@pencil
Copy link

pencil commented Jun 20, 2023

I tried running infix with the following rule (to change the tag value of "instance" from "wlan0" to "wl0-ap0" on all measurments):

[[rules.update-tag-value]]
        to="wl0-ap0"
        [rules.update-tag-value.measurement.pattern]
           pattern=".*"
        [rules.update-tag-value.value.strings]
           equal="wlan0"
        [rules.update-tag-value.key.strings]
           equal="instance"

This did not appear to change any data.

I then implemented the change suggested by @hiroshi-kawazoe:

As far as I tried, I needed to change the FilterKey() in UpdateTagValueRule to return true, although I'm not sure if this is the right modification. https://github.com/Abc-Arbitrage/infix/blob/master/rules/update_tag_value.go#L68

The script took a lot longer to run and it ended with an output indicating that the tag values were changed as expected:

[UpdateTagValueRule] Updating tag for measurement 'interface_rx' instance=wlan0 to instance=wl0-ap0: #148 actions
[UpdateTagValueRule] Updating tag for measurement 'interface_tx' instance=wlan0 to instance=wl0-ap0: #148 actions
[UpdateTagValueRule] Updating tag for measurement 'iwinfo_value' instance=wlan0 to instance=wl0-ap0: #185 actions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants