-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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 add items to array config via ENV #7323
Conversation
@miry, thanks for your PR! By analyzing the annotation information on this pull request, we identified @gunnaraasen and @e-dard to be potential reviewers |
af25447
to
a3b9e7c
Compare
@gunnaraasen and @e-dard can you check this PR? |
@jackzampolin does this look like what you were after in #6943 ? |
@e-dard Yeah that's basically it. Want to make it easy to do graphite parsing by setting templates with ENV. I would also ask @gunnaraasen as he worked on this code too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
case reflect.Bool: | ||
boolValue, err := strconv.ParseBool(value) | ||
if err != nil { | ||
return fmt.Errorf("failed to apply %v to %v using type %v and value '%v'", prefix, structKey, element.Type().String(), value) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unnecessary newline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed. thank you.
case reflect.Float32, reflect.Float64: | ||
floatValue, err := strconv.ParseFloat(value, element.Type().Bits()) | ||
if err != nil { | ||
return fmt.Errorf("failed to apply %v to %v using type %v and value '%v'", prefix, structKey, element.Type().String(), value) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unnecessary newline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed. thank you.
} | ||
element.SetFloat(floatValue) | ||
case reflect.Slice: | ||
for j := 0; j < element.Len(); j++ { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add in the comment from the existing code back in here?
If the type is s slice, apply to each using the index as a suffix, e.g. GRAPHITE_0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added comment. also added comment bellow few lines.
key = strings.ToUpper(fmt.Sprintf("%s_%s", prefix, configName)) | ||
} | ||
element.SetFloat(floatValue) | ||
case reflect.Slice: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This case should also handle reflect.Array
. I don't think arrays are used in the configuration at this moment, but might as well cover all the bases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have array if I understand correctly. In next example there is templates
option:
[[graphite]]
protocol = "udp"
templates = [
"default.* .template.in.config"
]
And arrays converted as slice
.
@gunnaraasen I have updated code according the comments. |
@miry looks good. Can you add an entry to the |
@miry can you also rebase from master and push. I think the test failure is because Circle is testing the head ref rather than the merge result of this PR and |
@e-dard sure |
8cab286
to
ae5478a
Compare
ae5478a
to
de2ad5b
Compare
@e-dard updated Changelog and rebased against master. |
de2ad5b
to
c2f5c2e
Compare
awesome fix !! when could we expect to see that in a released version of Influxdb ? |
Great fix! waiting it to be merged! |
Allow to create a new templates or tags configs, if there are no records in the default config. Fixes: influxdata#6943
c6e0f4e
to
65b08e5
Compare
@e-dard @gunnaraasen @jackzampolin I have rebased against master. |
@e-dard who can merge this pr? |
Thanks @miry! |
INFLUXDB_GRAPHITE_TEMPLATES expects multiple templates to be separated by ',' (see influxdata/influxdb#7323), in the same time ',' is used to separate multiple additional tags for a single template (see https://docs.influxdata.com/influxdb/v1.8/supported_protocols/graphite/#adding-tags) So unfortunately it's impossible to configure a template with multiple additional tags thru INFLUXDB_GRAPHITE_TEMPLATES env variable, and providing a config file with templates is the only available option for this. in order to check the whole influxdb config (including default values) you should start docker-compose setup and attach to the influxdb container (note that execution of docker compose commands is done in the metrics directory): cd metrics docker compose up -d docker compose exec influxdb bash then you can run this command in the influxdb container's shell: influxd config the default configuration file for influxdb container is located at '/etc/influxdb/influxdb.conf', you can print its content or check how the whole configuration looks like with it using these commands: cat /etc/influxdb/influxdb.conf INFLUXDB_CONFIG_PATH=/etc/influxdb/influxdb.conf influxd config
INFLUXDB_GRAPHITE_TEMPLATES expects multiple templates to be separated by ',' (see influxdata/influxdb#7323), in the same time ',' is used to separate multiple additional tags for a single template (see https://docs.influxdata.com/influxdb/v1.8/supported_protocols/graphite/#adding-tags) So unfortunately it's impossible to configure a template with multiple additional tags thru INFLUXDB_GRAPHITE_TEMPLATES env variable, and providing a config file with templates is the only available option for this. in order to check the whole influxdb config (including default values) you should start docker-compose setup and attach to the influxdb container (note that execution of docker compose commands is done in the metrics directory): cd metrics docker compose up -d docker compose exec influxdb bash then you can run this command in the influxdb container's shell: influxd config the default configuration file for influxdb container is located at '/etc/influxdb/influxdb.conf', you can print its content or check how the whole configuration looks like with it using these commands: cat /etc/influxdb/influxdb.conf INFLUXDB_CONFIG_PATH=/etc/influxdb/influxdb.conf influxd config
INFLUXDB_GRAPHITE_TEMPLATES expects multiple templates to be separated by ',' (see influxdata/influxdb#7323), in the same time ',' is used to separate multiple additional tags for a single template (see https://docs.influxdata.com/influxdb/v1.8/supported_protocols/graphite/#adding-tags) So unfortunately it's impossible to configure a template with multiple additional tags thru INFLUXDB_GRAPHITE_TEMPLATES env variable, and providing a config file with templates is the only available option for this. in order to check the whole influxdb config (including default values) you should start docker-compose setup and attach to the influxdb container (note that execution of docker compose commands is done in the metrics directory): cd metrics docker compose up -d docker compose exec influxdb bash then you can run this command in the influxdb container's shell: influxd config the default configuration file for influxdb container is located at '/etc/influxdb/influxdb.conf', you can print its content or check how the whole configuration looks like with it using these commands: cat /etc/influxdb/influxdb.conf INFLUXDB_CONFIG_PATH=/etc/influxdb/influxdb.conf influxd config
INFLUXDB_GRAPHITE_TEMPLATES expects multiple templates to be separated by ',' (see influxdata/influxdb#7323), in the same time ',' is used to separate multiple additional tags for a single template (see https://docs.influxdata.com/influxdb/v1.8/supported_protocols/graphite/#adding-tags) So unfortunately it's impossible to configure a template with multiple additional tags thru INFLUXDB_GRAPHITE_TEMPLATES env variable, and providing a config file with templates is the only available option for this. in order to check the whole influxdb config (including default values) you should start docker-compose setup and attach to the influxdb container (note that execution of docker compose commands is done in the metrics directory): cd metrics docker compose up -d docker compose exec influxdb bash then you can run this command in the influxdb container's shell: influxd config the default configuration file for influxdb container is located at '/etc/influxdb/influxdb.conf', you can print its content or check how the whole configuration looks like with it using these commands: cat /etc/influxdb/influxdb.conf INFLUXDB_CONFIG_PATH=/etc/influxdb/influxdb.conf influxd config
Allow to create a new templates or tags configs, if there are no records
in the default config.
Support next cases:
As you see from the first example
INFLUXDB_GRAPHITE_TEMPLATES
separate rules by,
.Fixes: #6943
Required for all non-trivial PRs
Required only if applicable
You can erase any checkboxes below this note if they are not applicable to your Pull Request.