def upload_to_grafana(json, server, api_key, verify=True):
'''
upload_to_grafana tries to upload dashboard to grafana and prints response
:param json - dashboard json generated by grafanalib
:param server - grafana server name
:param api_key - grafana api key with read and write privileges
'''
headers = {'Authorization': f"Bearer <apikey>","Accept": "application/json", 'Content-Type': 'application/json'}
r = requests.post(f"<endpoint url of the Azure managed grafana instance ", data=json, headers=headers, verify=False)
# TODO: add error handling
print(f"{r.status_code} - {r.content}")
I used this function to upload the dashboard created using python to the Azure managed Grafana instance .I assigned the user role as User Access administrator .When calling this function (using https )it returns 401 error and it returns connection error when using http. How do I solve this ..Thanks in advance for the help
2
Answers
As per this MSFT doc of Troubleshoot issues for Azure Managed Grafana:
Make sure that you enable API key support on the Azure Managed Grafana resource. By default the service blocks API key requests, you need to explicitly turn it on. The service also supports using AAD service principals which might be a better option from a credential management standpoint.