Serve Pandas dataframes to Grafana
Project description
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
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.
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
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}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for grafana-pandas-datasource-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4cf41449e4818c906021667c01361af04c2027438792214f1a3a90e50b6a20d2 |
|
MD5 | a47712b820922f862ee26b332fcd0620 |
|
BLAKE2b-256 | 1b45077d98e51fcb6e4bf911f990fc43a37503ecaaaa9d828ad67d8ae4a8c3d2 |
Hashes for grafana_pandas_datasource-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2940746f2dd77cb84f5e20b41e6be368f47bf53ebf510b9c8a47ba08e8a296e6 |
|
MD5 | 09f7d75ea37e8fb118020608bbb100da |
|
BLAKE2b-256 | 2aa877388b3ee5299768c9589fd57c23d4df05a28b091cb81156ac2b4c77da54 |