-
What Grafana version and what operating system are you using?
Grafana open source in a container, itself in an Azure web app -
What are you trying to achieve?
Using a Jupyter Notebook & Python, I would like to programmatically retrieve the list of dashboards in my Grafana instance, and for each of them, retrieve the JSON file that describes their layouts. -
How are you trying to achieve it?
-
I created a Service Account in my Grafana, granted myself an Admin role, and generated a token.
-
Using Jupyter Notebook, I ran the following code:
headers = {"Authorization": f"Bearer {os.getenv(myToken)}"}
s = requests.Session()
s.headers = headers
r = s.get(url + "/api/search?query=&", headers=headers)
dashboards = r.json()
print(dashboards)
- What happened?
I’m getting this response:
'{"extra":null,"message":"Invalid API key","messageId":"api-key.invalid","statusCode":401,"traceID":""}\n'
-
What did you expect to happen?
I expected my token to be a valid API key (I believe these terms share the same meaning?). -
Can you copy/paste the configuration(s) that you are having problems with?
-
Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
I am not sure how to access the logs. -
Did you follow any online instructions? If so, what is the URL?
I tried to follow: -
Grafana’s documentation, although it does not provide Python code snippets;
Can you please help? Thank you so much!