Package: libmetric
Python library for querying metrics from several time-series databases into
Pandas DataFrames.It support two types of metric queries, the first isinstantmetric,
returning the value in precise moment in time. The second is therangemetric, giving you the series of values for given time range and step.InstallationInstall the required dependencies on Debian based systems.apt-get-yinstalllibrrd-devlibpython-devInstall library frompippackage.pipinstalllibmetricInstall library from source.gitclonehttps://github.com/cznewt/python-libmetric.gitcdpython-libmetricpythonsetup.pyinstallInput ParametersParameters can be either set by environmental parameters or passed as command
arguments.For example passing the parameters as environmental parameters.exportLIBMETRIC_ENGINE='prometheus'exportLIBMETRIC_URL='https://metric01:9090'exportLIBMETRIC_QUERY='alertmanager_notifications_total'exportLIBMETRIC_START='2017-11-12T00:00:00Z'exportLIBMETRIC_END='2017-11-16T00:00:00Z'exportLIBMETRIC_STEP='3600s'range_metricAnd the example of passing parameters as command arguments.range_metric--engineprometheus--url'https://metric01:9090'--query'...'Common ParametersLIBMETRIC_ENGINEType of the endpoint to make query.LIBMETRIC_URLURL of the endpoint service.LIBMETRIC_PARTITIONData partition on target service endopoint.LIBMETRIC_QUERYQuery to get the metric time-series or value.Range ParametersParameters that apply only for therangemeters.LIBMETRIC_STARTTime range start.LIBMETRIC_ENDTime range end.LIBMETRIC_STEPQuery resolution step width.Instant ParametersParameters that apply only for theintantmeters.LIBMETRIC_MOMENTSingle moment in time.Alarm ParametersParameters that apply only for the all meters/alarms. Except theLIBMETRIC_AGGREGATIONis applicable only forrangemeters.LIBMETRIC_ALARM_THRESHOLDThreshold for the alarms.LIBMETRIC_ALARM_OPERATORArithmetic operator for alarm evaluation. [gt, lt, gte, lte, eq]LIBMETRIC_AGGREGATIONAggregation function for the given time-series [min, max, sum, avg]Supported EndpointsThelibmetricsupports several major time-series databases to get the
results in normalised way. The endpoints are queried thru HTTP API calls.GraphiteExample configuration to query the Graphite server.exportLIBMETRIC_ENGINE='graphite'exportLIBMETRIC_URL='http://graphite.host:80'exportLIBMETRIC_QUERY='averageSeries(server.web*.load)'...InfluxDbExample configuration to query the InfluxDb server.exportLIBMETRIC_ENGINE='influxdb'exportLIBMETRIC_URL='http://influxdb.host:8086'exportLIBMETRIC_USER='user'exportLIBMETRIC_PASSWORD='password'exportLIBMETRIC_PARTITION='prometheus'exportLIBMETRIC_QUERY='SELECT mean("value") FROM "alertmanager_notifications_total"'...PrometheusExample configuration to query the Prometheus server.exportLIBMETRIC_ENGINE='prometheus'exportLIBMETRIC_URL='https://prometheus.host:9090'exportLIBMETRIC_QUERY='alertmanager_notifications_total'...Round-Robin DatabaseExample configuration to query the RRD file. The query is theconsolidation functionand the partition is thedata set.exportLIBMETRIC_ENGINE='rrd'exportLIBMETRIC_URL='file:///tmp/port.rrd'exportLIBMETRIC_PARTITION='INOCTETS'exportLIBMETRIC_QUERY='AVERAGE'...Alarm OptionsFollowing lists show allowed values for alarm functions, the alarm arithmetic
operators and aggregation function forrangemeters.Supported Alarm OperatorsgtGreater than>.gteGreater or equal than>=.ltLower than<.lteLower or equal than<=.eqEquals to==.Supported Time-series AggregationsavgArithmetic average of the series values.minUse the minimal value from series.maxUse the maximal value from series.sumSum the values together.More Informationhttps://prometheus.io/docs/prometheus/latest/querying/api/http://graphite.readthedocs.io/en/latest/render_api.htmlhttps://docs.influxdata.com/influxdb/v1.3/guides/querying_data/https://oss.oetiker.ch/rrdtool/doc/rrdtool.en.html