A command line tool for parsing Prometheus metrics
Project description
Parse and filter metrics from Prometheus endpoints so that they can be visualized, stored into InfluxDB, or used as Juju charm metrics.
Installation
Run pip install firestealer. This will make the fsteal command available.
Usage
Print JSON formatted samples from a Prometehus endpoint:
$ fsteal http://localhost:8000/metrics
Filter metrics using a regular expression against the sample name:
$ fsteal http://localhost:8000/metrics -m '^myservice(Downloads|Uploads)'
Store samples into InfluxDB:
$ fsteal localhost:8000/metrics influxdb://user:passwd@10.0.0.1:8086/mydb
Store a subset of samples into InfluxDB:
$ fsteal localhost:8000/metrics influxdb://user:passwd@10.0.0.1:8086/mydb -m '^myservice'
In the example above the InfluxDB connection info is provided using a influxdb://$user:$passwd@$host:$port/$database connection string.
Only print specific metrics values (useful when executing fsteal in order to retrieve charm metrics):
$ fsteal localhost:8000/metrics a-single-specific-key --format values-only
API
An API is exposed so that firestealer can be used as a library from Python applications. For instance, a charm could propagate metrics from Prometheus to Juju with the following snippet placed in the collect-metrics hook:
from firestealer import ( add_metrics, retrieve_metrics, ) url = 'https://localhost:8000/metrics' with open('metrics.yaml') as f: metrics = yaml.safe_load(f) samples = retrieve_metrics(url, metrics, noverify=True) add_metrics(samples)
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 firestealer-0.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 161ac74dd69022bc29a0414333bcea7392935d23c431e2a6ac22f30c21d9573d |
|
MD5 | 93035f4698635d5797202c4e0abc02f8 |
|
BLAKE2b-256 | d90f924ecbbe030955f5eb8d258eb8ab5eaa62b9ad6bdc2225b086da7159315a |