You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a containerised app, the current implementation doesn't seem to support using either a secret and/or an environment variable to set the secret parts of the connection string and/or to adjust the list of collectors. These are both in the root config file, which although it can be treated as an entire secret, means that whoever needs to configure the e.g. scrape timeout offset, also would need access to the secrets.
A solution I have implemented locally allows an optional environment variable that can set the DSN or the collectors list (the second I am not sure if it is as useful). This code is very simple:
func (t*TargetConfig) UnmarshalYAML(unmarshalfunc(interface{}) error) error {
typeplainTargetConfigiferr:=unmarshal((*plain)(t)); err!=nil {
returnerr
}
// My new block below// Look for env variable to overwriteifval, ok:=os.LookupEnv("SQLEXPORTER_DSN"); ok {
t.DSN=Secret(val)
}
// Check required fieldsift.DSN=="" {
returnfmt.Errorf("missing data_source_name for target %+v", t)
}
// etc.
I am not sure if there are other ways to achieve the same thing but this allows my deployment tool to inject an environment variable with the correct DSN passwords in it per-environment.
If you are happy with this, I am happy to create a PR but as a Go noob, I don't know if I have missed any edge cases (like Nil errors)
The text was updated successfully, but these errors were encountered:
Hi @lukos, there's already the environment variable which allows you to override the DSN in the config file, it's SQLEXPORTER_TARGET_DSN.
As for collectors list, I'm not sure we want to have it as an environment variable for the time being.
Besides, all the environment variables coming with the respective driver can also be applied (e.g. postgresql). For that you'd need to check the driver's repository.
Please let me know if it the environment variable doesn't work as expected.
As a containerised app, the current implementation doesn't seem to support using either a secret and/or an environment variable to set the secret parts of the connection string and/or to adjust the list of collectors. These are both in the root config file, which although it can be treated as an entire secret, means that whoever needs to configure the e.g. scrape timeout offset, also would need access to the secrets.
A solution I have implemented locally allows an optional environment variable that can set the DSN or the collectors list (the second I am not sure if it is as useful). This code is very simple:
I am not sure if there are other ways to achieve the same thing but this allows my deployment tool to inject an environment variable with the correct DSN passwords in it per-environment.
If you are happy with this, I am happy to create a PR but as a Go noob, I don't know if I have missed any edge cases (like Nil errors)
The text was updated successfully, but these errors were encountered: