grafana-wizzy / wizzy

Manage & automate Grafana with easy wizzy
https://grafana-wizzy.com
Apache License 2.0
468 stars 60 forks source link

[Feature] Support configuration with environment variables #146

Open forzagreen opened 5 years ago

forzagreen commented 5 years ago

It would be nice if wizzy can load json files containing environment variables. This is useful for conf/wizzy.json and datasources. The conf/wizzy.json file would look like:

{
  "config": {
    "grafana": {
      "url": "https://mygrafana.example.com",
      "username": "${ADMIN_USERNAME}",
      "password": "${ADMIN_PASSWORD}"
    }
  }
}

Example of a datasource datasources/my-influxdb.json:

{
  "orgId": 1,
  "name": "my-influxdb",
  "type": "influxdb",
  "url": "http://localhost:8086",
  "user": "${DB_USER}",
  "password": "${DB_PASSWORD}",
  "database": "${DB_NAME}"
}

It can achieved e.g. with Mustache.js.

FYI, Grafana support using environment variables in its config file: cf. https://grafana.com/docs/installation/configuration/#using-environment-variables

Sytten commented 5 years ago

I also agree with this idea, I have some dashboards that could use variables before export.

johnsudaar commented 5 years ago

I thought of that too. It would be really nice. Actually I'm asking if integrating an entire templating engine wouldn't be nice. Having thinks like conditions loops and support for environment variables would be really nice.

johnsudaar commented 5 years ago

I think that i'll try to PoC adding a templating engine to the current js files.

Edit: The PoC is available at #148

Sytten commented 5 years ago

Postponed to 0.8.0