The apikey is now optional
Grafana 2.1.0 added basic auth support. With that in mind, the api key is now optional. Change-Id: Ie186fa9ce48ca4ae222f75345e9b660f5ffa2909 Signed-off-by: Paul Belanger <pabelanger@redhat.com>
This commit is contained in:
parent
f83e3e45d8
commit
8029107fc8
|
@ -97,4 +97,4 @@
|
|||
#url = http://grafana.example.org
|
||||
|
||||
# API key for access grafana. (string value)
|
||||
#apikey =
|
||||
#apikey = <None>
|
||||
|
|
|
@ -23,7 +23,7 @@ grafana_opts = [
|
|||
'url', default='http://grafana.example.org',
|
||||
help='URL for grafana server.'),
|
||||
cfg.StrOpt(
|
||||
'apikey', default='',
|
||||
'apikey', default=None,
|
||||
help='API key for access grafana.'),
|
||||
]
|
||||
|
||||
|
|
|
@ -21,12 +21,15 @@ except ImportError:
|
|||
|
||||
|
||||
class Grafana(object):
|
||||
def __init__(self, url, key):
|
||||
def __init__(self, url, key=None):
|
||||
self.url = urljoin(url, 'api/dashboards/db')
|
||||
self.session = requests.Session()
|
||||
self.session.headers.update({
|
||||
'Authorization': 'Bearer %s' % key,
|
||||
})
|
||||
# NOTE(pabelanger): Grafana 2.1.0 added basic auth support so now the
|
||||
# api key is optional.
|
||||
if key:
|
||||
self.session.headers.update({
|
||||
'Authorization': 'Bearer %s' % key,
|
||||
})
|
||||
|
||||
def create_dashboard(self, data, overwrite=False):
|
||||
data['overwrite'] = overwrite
|
||||
|
|
Loading…
Reference in New Issue