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.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c96462dd981e12dc74bdb1c53fbcc5f1424bbd9f022015d78777bc4b9331972 |
|
MD5 | af743cc19b5dc84a4e34977446f62c32 |
|
BLAKE2b-256 | 32ee040ee04ae0c2d2f3fde57eb38192e4d73f4f12eee68c14afd40d035ea214 |
Hashes for grafana_pandas_datasource-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92a84dbce893c49aa66406ebd3d574d7daa7544d74617530c37a0f69acd279fc |
|
MD5 | 4643dc7509a5d763eb2b017ce052883d |
|
BLAKE2b-256 | ca82f4908050c1f60448f32865402db9ba63e129fe04190887cef35ce98d9f46 |