Metadata-Version: 2.1
Name: grafana-pandas-datasource
Version: 0.2.0
Summary: Serve NumPy data via pandas data frames to Grafana
Home-page: https://community.panodata.org/t/grafana-python-datasource-using-pandas-for-timeseries-and-table-data/148
License: AGPL-3.0
Keywords: grafana,pandas,datasource,grafana-plugin,grafana-datasource,pandas-dataframe
Author: Andreas Motl
Author-email: andreas.motl@panodata.org
Requires-Python: >=3.7.1,<4.0.0
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: Information Technology
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: GNU Affero General Public License v3
Classifier: Operating System :: MacOS
Classifier: Operating System :: POSIX
Classifier: Operating System :: Unix
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Topic :: Communications
Classifier: Topic :: Database
Classifier: Topic :: Internet
Classifier: Topic :: Internet :: WWW/HTTP :: Indexing/Search
Classifier: Topic :: Scientific/Engineering :: Atmospheric Science
Classifier: Topic :: Scientific/Engineering :: GIS
Classifier: Topic :: Scientific/Engineering :: Human Machine Interfaces
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Classifier: Topic :: Scientific/Engineering :: Interface Engine/Protocol Translator
Classifier: Topic :: Scientific/Engineering :: Visualization
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: System :: Archiving
Classifier: Topic :: Text Processing
Classifier: Topic :: Utilities
Requires-Dist: flask (>=1.1.4,<2.0.0)
Requires-Dist: flask-cors (>=3.0.10,<4.0.0)
Requires-Dist: pandas (>=1.3,<2.0)
Project-URL: Issues, https://github.com/panodata/grafana-pandas-datasource/issues
Project-URL: Repository, https://github.com/panodata/grafana-pandas-datasource
Description-Content-Type: text/x-rst

.. image:: https://github.com/panodata/grafana-pandas-datasource/workflows/Tests/badge.svg
    :target: https://github.com/panodata/grafana-pandas-datasource/actions?workflow=Tests

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

.. 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/v/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/

.. 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/badge/Grafana-6.x%20--%208.x-blue.svg
    :target: https://github.com/grafana/grafana
    :alt: Supported Grafana versions

|

#########################
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 native Python application can be used to directly supply data to
Grafana 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.


*******************
Sandbox environment
*******************

In order to work efficiently with the resources provided by this repository, we
recommend to install some programs upfront. This will optimally work on Linux
and macOS. Windows users might use the WSL subsystem.

Install prerequisites::

    # Debian Linux
    apt install git python3 python3-pip httpie docker.io
    pip install poetry

    # macOS / Homebrew
    brew install git python3 poetry httpie docker

Acquire sources and bootstrap sandbox environment::

    git clone https://github.com/panodata/grafana-pandas-datasource
    cd grafana-pandas-datasource
    poetry install
    poetry shell

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.


********
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.


*****
Setup
*****

When aiming to run a dedicated service, without needing to invoke the examples,
you can add the package ``grafana-pandas-datasource`` to the list of your
project requirements.

::

    pip install grafana-pandas-datasource


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

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


.. _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 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 example: https://github.com/panodata/grafana-pandas-datasource/tree/main/examples/sinewave-midnights

