-
Notifications
You must be signed in to change notification settings - Fork 263
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
Add option to merge SNMP configs (custom with embedded) #2633
Conversation
💻 Deploy preview deleted. |
docs/sources/reference/components/prometheus/prometheus.exporter.snmp.md
Outdated
Show resolved
Hide resolved
docs/sources/reference/components/prometheus/prometheus.exporter.snmp.md
Outdated
Show resolved
Hide resolved
@@ -218,6 +220,10 @@ func (a *Arguments) UnmarshalAlloy(f func(interface{}) error) error { | |||
return errors.New("config and config_file are mutually exclusive") | |||
} | |||
|
|||
if a.ConfigMergeStategy != "replace" && a.ConfigMergeStategy != "merge" { | |||
return errors.New("config_merge_strategy must be `replace` or `merge`") | |||
} |
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.
nit: I would recommend a switch instead of an if here where the case "replace", "merge" does nothing and the default case returns the error. It avoids repeating the a.ConfigMergeStategy !=
for every case which makes it scale better with the number of values
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.
done
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.
you did not change it to a switch here (if you want to keep it as an if that's also ok for me, just a nit)
…er.snmp.md Co-authored-by: William Dumont <[email protected]>
…er.snmp.md Co-authored-by: William Dumont <[email protected]>
…ana/alloy into vzhuravlev/multiple-configs
internal/static/integrations/snmp_exporter/snmp_exporter_test.go
Outdated
Show resolved
Hide resolved
internal/static/integrations/snmp_exporter/snmp_exporter_test.go
Outdated
Show resolved
Hide resolved
@@ -218,6 +220,10 @@ func (a *Arguments) UnmarshalAlloy(f func(interface{}) error) error { | |||
return errors.New("config and config_file are mutually exclusive") | |||
} | |||
|
|||
if a.ConfigMergeStategy != "replace" && a.ConfigMergeStategy != "merge" { | |||
return errors.New("config_merge_strategy must be `replace` or `merge`") | |||
} |
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.
you did not change it to a switch here (if you want to keep it as an if that's also ok for me, just a nit)
@clayton-cornell over to you for a review of the small doc changes |
Co-authored-by: William Dumont <[email protected]>
Co-authored-by: William Dumont <[email protected]>
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.
Minor doc tweak
docs/sources/reference/components/prometheus/prometheus.exporter.snmp.md
Outdated
Show resolved
Hide resolved
…er.snmp.md Co-authored-by: Clayton Cornell <[email protected]>
thanks fro the reviews! Anything else we need to merge it? |
sorry I thought I merged it already, merged! |
PR Description
This PR adds
config_merge_strategy
inprometheus.exporter.snmp
to optionally merge custom snmp config with embedded config instead of replacing. Useful for providing SNMP auths.Which issue(s) this PR fixes
Fixes #2493
Notes to the Reviewer
PR Checklist