Python Module to consume Grafana's API.
$ sudo pip install pygrafana
URL = http://<USERNAME>:<PASSWORD>@<SERVER>:<PORT>
>>> from pygrafana import GrafanaManager
>>> gm = GrafanaManager("http://admin:admin@localhost:3000")
TO-DO: Add all the Datastore types
Supported Datastores by now:
- Zabbix
- MySQL
>>> gm.zbx_user = "admin"
>>> gm.zbx_pswd = "zabbix"
>>> gm.zbx_url = "http://localhost/api_jsonrpc.php"
>>> gm.CreateDatastore("Zabbix")
>>> gm.mysql_host = "10.0.0.1"
>>> gm.mysql_port = "3306"
>>> gm.mysql_db = "database1"
>>> gm.mysql_user = "user"
>>> gm.mysql_pswd = "password"
>>> gm.CreateDatastore("MySQL")
>>> gm.ImportDashboard("./example_dashboard.json")
>>> gm.DeleteDashboard("example-dashboard")
>>> gm.EnablePlugin("alexanderzobnin-zabbix-app")
>>> gm.ChangeTheme("light")
>>> gm.StarDashboard("3")
>>> gm.CreateOrganization("OrganizationName")
>>> gm.proxies = {'http':'http://localhost:8080','https':'https://localhost:8443'}
- Example 1: Auto-configuring Grafana-Zabbix API and importing a dashboard.
#!/usr/bin/python2.7
from pygrafana import GrafanaManager
gm = GrafanaManager("http://admin:admin@localhost:3000")
gm.EnablePlugin("alexanderzobnin-zabbix-app")
gm.zbx_user = "admin"
gm.zbx_pswd = "zabbix"
gm.zbx_url = "http://localhost/api_jsonrpc.php"
gm.CreateDatastore("Zabbix")
gm.ImportDashboard("./zabbix_dashboard.json")