Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sec4you/pygrafana
Python Library to consume Grafana's API.
https://github.com/sec4you/pygrafana
api dashboard grafana zabbix
Last synced: 4 months ago
JSON representation
Python Library to consume Grafana's API.
- Host: GitHub
- URL: https://github.com/sec4you/pygrafana
- Owner: sec4you
- License: gpl-3.0
- Created: 2017-09-05T02:51:45.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-08-09T12:28:43.000Z (over 6 years ago)
- Last Synced: 2024-09-27T15:41:03.371Z (4 months ago)
- Topics: api, dashboard, grafana, zabbix
- Language: Python
- Size: 24.4 KB
- Stars: 8
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# pygrafana
Python Module to consume Grafana's API.
## Instalation
```
$ sudo pip install pygrafana
```## Login into Grafana
```
URL = http://:@:
>>> from pygrafana import GrafanaManager
>>> gm = GrafanaManager("http://admin:admin@localhost:3000")
```## Create Datastore
> TO-DO: Add all the Datastore types
Supported Datastores by now:
- Zabbix
- MySQL### Zabbix
```
>>> gm.zbx_user = "admin"
>>> gm.zbx_pswd = "zabbix"
>>> gm.zbx_url = "http://localhost/api_jsonrpc.php"
>>> gm.CreateDatastore("Zabbix")
```### MySQL
```
>>> 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")
```## Import Dashboard
```
>>> gm.ImportDashboard("./example_dashboard.json")
```## Delete Dashboard
```
>>> gm.DeleteDashboard("example-dashboard")
```## Enable Plugin
```
>>> gm.EnablePlugin("alexanderzobnin-zabbix-app")
```## Change Grafana's Theme
```
>>> gm.ChangeTheme("light")
```## Star a Dashboard
```
>>> gm.StarDashboard("3")
```## Create an Organization
```
>>> gm.CreateOrganization("OrganizationName")
```## Through Proxy
```
>>> gm.proxies = {'http':'http://localhost:8080','https':'https://localhost:8443'}
```## Examples
- **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")
```