Skip to content

Commit

Permalink
Feature to create new dashboard in grafana
Browse files Browse the repository at this point in the history
  • Loading branch information
rishubhjain authored and root committed Aug 3, 2017
1 parent edb9c82 commit c4a8b6d
Show file tree
Hide file tree
Showing 34 changed files with 4,898 additions and 2 deletions.
97 changes: 97 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
.idea/
htmlcov/
.tox/
/.tox
.testrepository/
.coverage/
cover/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# IPython Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# dotenv
.env

# virtualenv
venv/
ENV/

# Spyder project settings
.spyderproject

# Rope project settings
.ropeproject

# conf file
graphite.conf.yml
19 changes: 19 additions & 0 deletions HACKING.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Style Commandments
==================

- Tendrl coding style is inspired by one of the largest python projects, OpenStack
http://docs.openstack.org/developer/hacking/ (excluding the license and trademark sections)


Developer Workflow
------------------
Refer: http://nvie.com/posts/a-successful-git-branching-model/


Creating Unit Tests
-------------------
For every new feature, unit tests should be created that both test and
(implicitly) document the usage of said feature. If submitting a pull request for a
bug that had no unit test, a new passing unit test should be added. If a
submitted bug fix does have a unit test, be sure to add a new one that fails
without the patch and passes with the patch.
2 changes: 0 additions & 2 deletions README.md

This file was deleted.

129 changes: 129 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@


Monitoring-Integration
=======================


Functionalities
----------------

- Create a new dashboard in Grafana


Environment Setup
-----------------

#. Clone the monitoring-integration repository

::

$ git clone https://github.com/Tendrl/monitoring-integration.git
$ cd monitoring-integration


.. note::

All the commands mentioned below are run as a regular user that has ``sudo``
privileges.
These commands are assumbed to be run from a single directory, which
contains the code of monitoring-integration.

#. Install python pip


https://pip.pypa.io/en/stable/installing/


#. Install python dependencies

::

$ python setup.py install


#. Install Grafana


http://docs.grafana.org/installation/


#. Configure grafana for anonymous login.

::

$ cp etc/grafana/grafana.ini /etc/grafana/.

.. note::

This will overwrite present grafana.ini.

Prerequisites
--------------

* Grafana instance is set-up and running on the server node.

* Graphite instance is set-up and running on the same server node.

* Monitoring-Integration is installed on same server node.


Usage Details
--------------

.. note::

Configuration file monitoring-integration.conf.yaml needed by monitoring-integration
is present under

' /etc/tendrl/monitoring-integration/'

If configuration file is not present.

::

$ cp etc/tendrl/monitoring-integration/monitoring-integration.conf.yaml.sample
/etc/tendrl/monitoring-integration/monitoring-integration.conf.yaml

Default dashboards that are to be created in grafana are present under

' /etc/tendrl/monitoring-integration/grafana/dashboards/ '

If the dashboards are not present.

::

$ mkdir /etc/tendrl/monitoring-integration/grafana
$ mkdir /etc/tendrl/monitoring-integration/grafana/dashboards
$ cp etc/tendrl/monitoring-integration/grafana/dashboards/*
/etc/tendrl/monitoring-integration/grafana/dashboards/.


* Development setup

* Create a json file in /etc/tendrl/monitoring-integration/grafana/dashboards/ and provide json
for the dashboard that is to be created.

* Provide the file-name of the json file created in above step under "dashboards"
in /etc/tendrl/monitoring-integration/monitoring-integration.conf.yaml.

* Make one of the dashboards listed under "dashboards" as home_dashboard.

* Provide grafana instance's credential under "credentials" in monitoring-integration.conf.yaml file

* Provide name of datasource to be created in grafana under "datasource_name" in
monitoring-integration.conf.yaml file

* Make sure a datasource with same name as given in monitoring-integration.conf.yaml file
doesnot exist in grafana.

* By default true is passed under "isDefault" in monitoring-integration.conf.yaml
to set the datasource as the default datasource in grafana.

* Follow the commands provided below to run __init__.py file to create dashboards and datasource
in grafana.

::

$ cd tendrl/monitoring_integration/
$ python __init__.py

Empty file added __init__.py
Empty file.
45 changes: 45 additions & 0 deletions check_commit_msg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/python

import os

import requests

commit_msg = str(os.environ['TRAVIS_COMMIT_MSG'])
tendrl_bug_id = None
tendrl_spec = None
github_base_url = "http://github.com"


# Extract "tendrl-bug-id" and "tendrl-spec" name from the commit message
for line in commit_msg.split("\n"):
if "tendrl-bug-id" in line:
try:
tendrl_bug_id = line.split("tendrl-bug-id:")[-1].strip()
except Exception as ex:
print(ex)

if "tendrl-spec" in line:
try:
tendrl_spec = line.split("tendrl-spec:")[-1].strip()
except Exception as ex:
print(ex)

if tendrl_bug_id is None:
raise Exception("Please add 'tendrl-bug-id:Tendrl/<tendrl_repo>#issue_id'"
" to your commit msg")

if tendrl_bug_id:
issue = "%s/%s" % (github_base_url, tendrl_bug_id.replace("#", "/issues/"))
if requests.get(issue).status_code != 200:
raise Exception("Tendrl Bug specified in git commit msg not "
"found!!\n"
"%s" % issue)
print("Tendrl Bug specified in git commit msg found!!\n%s" % issue)

if tendrl_spec:
spec = "%s/%s.adoc" % ("https://github.com/Tendrl/specifications/tree"
"/master/specs", tendrl_spec)
if requests.get(spec).status_code != 200:
raise Exception("Tendrl Spec specified in git commit msg not found\n"
"%s" % spec)
print("Tendrl Spec specified in git commit msg found!!\n%s" % spec)
Loading

0 comments on commit c4a8b6d

Please sign in to comment.