-
Notifications
You must be signed in to change notification settings - Fork 12.2k
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
Support for environment variables in provisioning #12896
Comments
Not entirely sure if this is a case we should support or not, but it's a recent enough feature request in the grafana-docker repo that I didn't want to just close it without moving it here first. This could make provisioning more dynamic but also potentially more error-prone. |
+1 |
I need this feature too. When using Grafana from Docker, a workaround is to run envsubst on the YAML file in the |
I need this as well so I can inject datasource secrets (the password) from kubernetes environment variable secrets. I don’t even have a good work-around for the grafana helm chart right now... |
@CharlesEdouardCady Did you just build a custom grafana docker image to apply the envsubst change? |
@dtshepherd Yes, because we basically customized the entrypoint to something like:
It works for what we need it for (get database credentials). Our full Dockerfile looks like this:
|
+1 |
dupe of #12368 ? If the purpose is to get the token from k8s I don't think it should be stored as an ENV variable. |
@bergquist agreed. |
@bergquist @xlson It's very common to get secrets from environment variables in k8s. For example, the grafana chart uses environment variables for secrets and allows you to inject addition secrets through environment variables: https://github.com/helm/charts/blob/master/stable/grafana/templates/deployment.yaml#L162-L200 I'm guessing if #12368 was implemented, we can get by, but it would require more tooling for our secret deployment than using the existing environment variables. It seems these two issues are different feature requests, but maybe could be solved by the same PR... |
Your right. Since ENV var is supported now we should support that in provisioning configs as well. I would like to add support for reading all passwords/secrets from files and recommend that later on. But that's another issue. Thank you for the feedback. |
I'm running into the same issue, where I need to deploy the same Grafana image for different sites. The only difference is the url and password of the provisioned datasource. Thank you |
+1 to this. I've been able to get around it by treating dashboards as templates that I can inject variables at build time. ENV vars would be a good improvement. |
Would like this as well. |
+1 |
+1 to this. I'm willing to submit a PR that implements this feature. @bergquist anything you want me to consider before starting on it? |
I was just thinking about this issue on the bus... :) I dont see any obvious way of solving this issue. Supporting ENV vars in Replace vars when parsing config files using go templating datasources:
- name: gdev-graphite
type: graphite
access: proxy
password: {{NAME_OF_THE_ENV_VAR}}
url: http://localhost:8080 This however might cause problems if a field contains Add support for overriding fields datasources:
- name: gdev-graphite
type: graphite
access: proxy
password:
password_from_env: CUSTOM_ENV_VAR
password_from_file: /var/token
url: http://localhost:8080 I think this would be better if we could implement a custom parser. So we can reuse it for all fields. If anyone else have a good idea for how to implement this? Feedback would be very appricated :) |
I may be oversimplifying things but is having rudimentary template parsing using either I fully agree that it should definitely be implemented as a custom parser which is able to scan any and every property for an environment variable. In my use case, I'd definitely also like to inject properties like The template parsing solution, however, does not immediately solve reading from a file. I feel it's less desirable to have 1 |
Without knowing everything there is to know about data sources; is it really feasibly that two different sources would want to use the same env vars but with different values? My best example is to provision Prometheus data source. To be the best way to do it would be |
+1 |
1 similar comment
+1 |
Original feature request: grafana/grafana-docker#163
Make it possible to reference environment variables in datasource and dashboard provisioning files to make provisioning more dynamic when working with several similar environments.
The text was updated successfully, but these errors were encountered: