Python library for querying metrics into Pandas DataFrames
Project description
Python library for querying metrics from several time-series databases into Pandas DataFrames.
It support two types of metric queries, the first is instant metric, returning the value in precise moment in time. The second is the range metric, giving you the series of values for given time range and step.
Installation
Install the required dependencies on Debian based systems.
apt-get -y install python-lxml
Intall library from pip package.
pip install libmetric
Intall library from source.
git clone https://github.com/cznewt/python-libmetric.git
cd python-libmetric
python setup.py install
Input Parameters
Parameters can be either set by environmental parameters or passed as command arguments.
For example passing the parameters as environmental parameters.
export LIBMETRIC_ENGINE='prometheus'
export LIBMETRIC_URL='https://metric01:9090'
export LIBMETRIC_QUERY='alertmanager_notifications_total'
export LIBMETRIC_START='2017-11-12T00:00:00Z'
export LIBMETRIC_END='2017-11-16T00:00:00Z'
export LIBMETRIC_STEP='3600s'
range_meter
And the example of passing parameters as command arguments.
range_meter --engine prometheus --url 'https://metric01:9090' --query '...'
Common Parameters
- LIBMETRIC_ENGINE
Type of the endpoint to make query.
- LIBMETRIC_URL
URL of the endpoint service.
- LIBMETRIC_PARTITION
Data partition on target service endopoint.
- LIBMETRIC_QUERY
Query to get the metric time-series or value.
Range Parameters
Parameters that apply only for the range meters.
- LIBMETRIC_START
Time range start.
- LIBMETRIC_END
Time range end.
- LIBMETRIC_STEP
Query resolution step width.
Instant Parameters
Parameters that apply only for the intant meters.
- LIBMETRIC_MOMENT
Moment in time.
Supported MetaData Endpoints
The libmetric supports several major time-series databases to get the results in normalised way. The endpoints are queried thru HTTP API calls.
Graphite
Example configuration to query the Graphite server.
export LIBMETRIC_ENGINE='graphite'
export LIBMETRIC_URL='http://graphite.host:80'
export LIBMETRIC_QUERY='averageSeries(server.web*.load)'
...
InfluxDb
Example configuration to query the InfluxDb server.
export LIBMETRIC_ENGINE='influxdb'
export LIBMETRIC_URL='http://influxdb.host:8086'
export LIBMETRIC_USER='user'
export LIBMETRIC_PASSWORD='password'
export LIBMETRIC_PARTITION='prometheus'
export LIBMETRIC_QUERY='SELECT mean("value") FROM "alertmanager_notifications_total"'
...
Prometheus
Example configuration to query the Prometheus server.
export LIBMETRIC_ENGINE='prometheus'
export LIBMETRIC_URL='https://prometheus.host:9090'
export LIBMETRIC_QUERY='alertmanager_notifications_total'
...
More Information
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
Hashes for libmetric-0.3.0.linux-x86_64.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | c4ca053c77df0f9e3ff6d86b90f37be06f899aa219781a62cb42bbcad8051cf1 |
|
MD5 | b1dc8c04e3c0b6b7c08b6b1fd164cdc8 |
|
BLAKE2b-256 | 59f2ad5b4355d9586c2b71a9e82cd5cae76329c70b37c114cd83a031e8d75af4 |