Metadata-Version: 2.1
Name: grafana-pandas-datasource
Version: 0.1.2
Summary: Serve Pandas dataframes to Grafana
Home-page: https://community.panodata.org/t/grafana-python-datasource-using-pandas-for-timeseries-and-table-data/148
License: Apache-2.0
Keywords: grafana,pandas,datasource,grafana-plugin,grafana-datasource,pandas-dataframe
Author: Andreas Motl
Author-email: andreas.motl@panodata.org
Requires-Python: >=3.6.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 :: Apache Software License
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.6
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.2,<2.0.0)
Requires-Dist: flask-cors (>=3.0.9,<4.0.0)
Requires-Dist: numpy (>=1.19.2,<2.0.0)
Requires-Dist: pandas (>=1.1.2,<2.0.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

#########################
Grafana Pandas Datasource
#########################


*****
About
*****
A REST API based on Flask for serving Pandas Dataframes to Grafana.

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

It was inspired by and is compatible with the simple json datasource.

https://gist.github.com/linar-jether/95ff412f9d19fdf5e51293eb0c09b850

Setup
=====
::

    pip install grafana-pandas-datasource

Resources
=========
- https://github.com/grafana/grafana
- https://grafana.com/grafana/plugins/grafana-simple-json-datasource


*******
Example
*******
This is a demo program which generates a sine wave for data and
annotations for designating midnight times. For both, we are using NumPy.

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

    Image: Sinewave data and midnights annotations, both generated using NumPy.


Acquire example files
=====================
::

    export EXAMPLES_BASEURL=https://raw.githubusercontent.com/panodata/grafana-pandas-datasource/0.1.0/examples

    wget ${EXAMPLES_BASEURL}/sinewave-midnights/demo.py \
        --output-document=sinewave-midnights-demo.py

    wget ${EXAMPLES_BASEURL}/sinewave-midnights/datasource.json \
        --output-document=sinewave-midnights-datasource.json

    wget ${EXAMPLES_BASEURL}/sinewave-midnights/dashboard.json \
        --output-document=sinewave-midnights-dashboard.json


Invoke
======
::

    # Run Grafana.
    docker run --rm -it \
        --publish=3000:3000 --volume="$(pwd)/var/lib/grafana":/var/lib/grafana \
        --env='GF_SECURITY_ADMIN_PASSWORD=admin' --env='GF_INSTALL_PLUGINS=grafana-simple-json-datasource' \
        grafana/grafana:7.3.6

    # Run Grafana Pandas Datasource demo.
    python sinewave-midnights-demo.py


Configure
=========
.. note::

    The host where the datasource service is running can be accessed from the
    Grafana Docker container using the hostname ``host.docker.internal``.

You can have a quickstart by putting ``examples/sinewave-midnights/datasource.json``
and ``examples/sinewave-midnights/dashboard.json`` into Grafana::

    # Login to Grafana.
    export GRAFANA_URL=http://localhost:3000
    http --session=grafana ${GRAFANA_URL} --auth=admin:admin

    # Create datasource.
    cat sinewave-midnights-datasource.json | \
        http --session=grafana POST ${GRAFANA_URL}/api/datasources

    # Create dashboard.
    cat sinewave-midnights-dashboard.json | \
        http --session=grafana POST ${GRAFANA_URL}/api/dashboards/db

    open ${GRAFANA_URL}

