GithubHelp home page GithubHelp logo

anthrax3 / pygrafana Goto Github PK

View Code? Open in Web Editor NEW

This project forked from m4n3dw0lf/pygrafana

0.0 1.0 0.0 26 KB

Python Library to consume Grafana's API.

License: GNU General Public License v3.0

Python 100.00%

pygrafana's Introduction

pygrafana

Python Module to consume Grafana's API.

Instalation

$ sudo pip install pygrafana

Login into Grafana

URL = http://<USERNAME>:<PASSWORD>@<SERVER>:<PORT>
>>> 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")

pygrafana's People

Contributors

m4n3dw0lf avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.