I write a program that accesses to Grafana, and
get alert info in json-format.
However,this program returns the following message.
Along with tutrial on the official site,
I added authentication info that specifies api key I generated to Http-Request header,Grafana may not recognize it.
message “Unauthorized”
Envirment
OS :Linux Mint 18.2
Grafana:v5.0.0(without Apache)
CODE in Python
#coding:utf-8
import json, urllib2
import requests
iparams={‘Authorization’:’ Bearer '}
url = ‘http://myserver/api/alerts’
try:
# add api-key to the request header.
response = requests.get(url, params=iparams)
except Exception, e:
print e