diff --git a/README.md b/README.md index 3497a1b34d37ff38937e214dbf76932ed9b23645..345cfd30dd8d2225691de1d31ec526d595f984a5 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ You need to add the following to your `.bashrc` or execute once before using the # do not use a trailing slash! export GRAFANA_URL=http://some.host.org:3000 export GRAFANA_TOKEN=eyJrIjoidUhaU2ZQQndrWFN3RRVkUnVfrT56a1JoaG9KWFFObEgiLCJuIjoiYWRtaW4iLCJpZCI6MX0= +export GRAFANA_HEADERS=Host:some.host.org ``` There is [official documentation](http://docs.grafana.org/http_api/auth/) how to obtain the `TOKEN` for your installation. @@ -38,7 +39,7 @@ _OUTPUT_/ ## Docker Replace variables below to use docker version of this tool -* `{YOUR_GRAFANA_TOKEN}`: Your grafana site token. +* `{YOUR_GRAFANA_TOKEN}`: Your grafana site token. * `{YOUR_GRAFANA_URL}`: Your grafana site url. * `{YOUR_BACKUP_FOLDER_ON_THE_HOST}`: The backup folder on the host machine. diff --git a/src/grafanaSettings.py b/src/grafanaSettings.py index a17ecd7e0e6f35b9ec7628697f179c108bd138e1..7442b7133f947130dcc7fd38897cb51664376805 100644 --- a/src/grafanaSettings.py +++ b/src/grafanaSettings.py @@ -2,8 +2,9 @@ import os GRAFANA_URL = os.getenv('GRAFANA_URL', 'http://localhost:3000') TOKEN = os.getenv('GRAFANA_TOKEN', 'eyJrIjoiSkQ5NkdvWllHdnVNdlVhWUV3Tm5LSGc4NG53UFdSTjQiLCJuIjoiYWRtaW4iLCJpZCI6MX0=') -HTTP_GET_HEADERS = {'Authorization': 'Bearer ' + TOKEN} -HTTP_POST_HEADERS = {'Authorization': 'Bearer ' + TOKEN, 'Content-Type': 'application/json'} +EXTRA_HEADERS = dict(h.split(':') for h in os.getenv('GRAFANA_HEADERS').split(',') if 'GRAFANA_HEADERS' in os.environ) +HTTP_GET_HEADERS = {'Authorization': 'Bearer ' + TOKEN, **EXTRA_HEADERS} +HTTP_POST_HEADERS = {'Authorization': 'Bearer ' + TOKEN, 'Content-Type': 'application/json', **EXTRA_HEADERS} SEARCH_API_LIMIT = 5000 DEBUG = True VERIFY_SSL = False