Serve NumPy data via pandas data frames to Grafana
Project description
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.
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.2.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 507a0720dc710fc9f3b01e59529b8e4e638f30e4005db8d44437d20a4ca10e41 |
|
MD5 | e359a0515b9d6879fa90067fbd5c3f64 |
|
BLAKE2b-256 | 2aaf28984757a622feb414abf45e93543891a5175afc365efeacd3d1f6b9a083 |
Hashes for grafana_pandas_datasource-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e2aa74d23f6b459e87d9a8609fc7d97294ea97ef96ee16cd464922d5c4eed53 |
|
MD5 | ce89b1661dd2c0b1b522114cb4892b30 |
|
BLAKE2b-256 | 26afdc6d6e5052c2f4c3b00a1cfa5e68bf942e39483177d4beb92946329144c6 |