Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/grafana-toolbox/grafana-pandas-datasource

Grafana Pandas Datasource - using Python for generating timeseries-, table-data and annotations
https://github.com/grafana-toolbox/grafana-pandas-datasource

datasource grafana grafana-datasource grafana-json-datasource grafana-plugin grafana-plugins kotori-daq numpy pandas pandas-dataframe python

Last synced: 1 day ago
JSON representation

Grafana Pandas Datasource - using Python for generating timeseries-, table-data and annotations

Awesome Lists containing this project

README

        

.. image:: https://img.shields.io/pypi/pyversions/grafana-pandas-datasource.svg
:target: https://pypi.org/project/grafana-pandas-datasource/

.. image:: https://img.shields.io/badge/Grafana-6.x%20--%208.x-blue.svg
:target: https://github.com/grafana/grafana
:alt: Supported Grafana versions

.. image:: https://img.shields.io/pypi/v/grafana-pandas-datasource.svg
:target: https://pypi.org/project/grafana-pandas-datasource/

.. image:: https://img.shields.io/pypi/l/grafana-pandas-datasource.svg
:target: https://github.com/panodata/grafana-pandas-datasource/blob/main/LICENSE

.. image:: https://img.shields.io/pypi/status/grafana-pandas-datasource.svg
:target: https://pypi.org/project/grafana-pandas-datasource/

.. image:: https://img.shields.io/pypi/dm/grafana-pandas-datasource.svg
:target: https://pypi.org/project/grafana-pandas-datasource/

|

#########################
Grafana pandas datasource
#########################

*****
About
*****

A HTTP API based on Flask_ for serving pandas_ data frames to Grafana_,
generated by NumPy_. The `Grafana Simple JSON Datasource`_ is used to interface
Grafana with the HTTP API.

This way, a pure Python application can be used to directly supply data to
Grafana, both easily and powerfully.

The framework supports feeding both timeseries data as well as annotations
through corresponding ``/query`` and ``/annotations`` endpoints and also
provides ``/search`` and ``/panels`` endpoints.

***********
Screenshots
***********

.. figure:: https://user-images.githubusercontent.com/453543/103137119-78dab480-46c6-11eb-829f-6aa957239804.png

Image: Sinewave data and midnights annotations, both generated using NumPy_,
see `Sinewave/Midnights example`_.

*****
Setup
*****

`Grafana pandas datasource setup`_ outlines how to install all software
prerequisites needed to run this project. Please read this section carefully.

::

pip install grafana-pandas-datasource

********
Synopsis
********

Test drive::

# Run Grafana pandas datasource demo.
python examples/sinewave-midnights/demo.py

# Submit a timeseries data request.
echo '{"targets": [{"target": "sine_wave:24"}], "range": {"from": "2022-02-22T15", "to": "2022-02-22T20"}}' | http http://127.0.0.1:3003/query

# Submit an annotation data request.
echo '{"annotation": {"query": "midnights:xx"}, "range": {"from": "2022-02-20", "to": "2022-02-22"}}' | http http://127.0.0.1:3003/annotations

When the environment has been properly configured, both requests above will
yield appropriate responses.

Then, configure the Grafana entities. You will need a datasource object and a
dashboard object.

********
Examples
********

There are `different demo programs`_ accompanied with Grafana datasource and
dashboard definition files.

After confirming the sandbox environment has been installed successfully,
please head over to the `Sinewave/Midnights example`_ page in order to learn
how to provision Grafana with corresponding resources.

**********************
Custom implementations
**********************

In order to conceive your own `pandas`_-based data source, please use the
`Sinewave/Midnights demo.py`_ as a blueprint. If you think it would be a
valuable contribution to the community, we will be happy to add it to the
repository.

*******
Credits
*******

Kudos to Linar, who conceived the initial version of this software the other
day at https://gist.github.com/linar-jether/95ff412f9d19fdf5e51293eb0c09b850.

**************
Other projects
**************

Oz Tiram conceived a similar piece of software with Python. He uses the Bottle
web framework.

- https://gitlab.com/oz123/grafana-python-datasource
- https://oz123.github.io/writings/2019-06-16-Visualize-almost-anything-with-Grafana-and-Python/index.html

.. _different demo programs: https://github.com/panodata/grafana-pandas-datasource/tree/main/examples
.. _Flask: https://github.com/pallets/flask
.. _Grafana: https://github.com/grafana/grafana
.. _Grafana pandas datasource setup: https://github.com/panodata/grafana-pandas-datasource/blob/main/docs/setup.rst
.. _Grafana Simple JSON Datasource: https://grafana.com/grafana/plugins/grafana-simple-json-datasource/
.. _NumPy: https://numpy.org/
.. _pandas: https://github.com/pandas-dev/pandas
.. _Sinewave/Midnights demo.py: https://github.com/panodata/grafana-pandas-datasource/blob/main/examples/sinewave-midnights/demo.py
.. _Sinewave/Midnights example: https://github.com/panodata/grafana-pandas-datasource/tree/main/examples/sinewave-midnights