A Python library for exporting JSON data as metrics for Prometheus
Project description
JSON Exporter
This is a simple Prometheus exporter using:
Features
- Automatic query caching
- Full async
- Robust logging
- POST/GET
- Automatic label creation from JSON values
Installation
This project is on pypi and can be installed with:
pip install --user json_exporter
Usage
Configuration is required and is specified in the following format:
#listen_ip = '127.0.0.1'
#listen_port = 9809
cache_life = 300
# GET request example
[json.website]
endpoint = "https://api.example.com"
[json.website.headers]
auth_key = 'g5s9ZyklWpY/wRf6gai2DtC0GKUO9qsNYON+rkQzzbeD7Nmvn9UCg5hQMdtPN49x'
[json.website.metrics.test]
path = "result.path.test"
type = "counter"
help = "Test counter"
[json.website.metrics.example]
path = "result.another.path.example"
type = "gauge"
help = "Example gauge"
[json.website.json_labels]
api_user = "response.user"
# POST example
[json.website2]
endpoint = "https://api.example2.com"
cache_life = 60
[json.website2.post_data]
method = 'get_data'
api_key = 'aVDZvzwuT86KhFF33VkS95Ui/D1E37PDoShc6Wy9w1uTVMP776CP6AZHp5eyzcij'
[json.website2.metrics.example]
path = "results.path.example"
type = "gauge"
help = "Example gauge"
GET requests are used unless a
post_data
config section is specified.
An example for OpenWeather:
listen_ip = '0.0.0.0'
listen_port = '1234'
cache_life = 120
[json.openweather]
endpoint = 'https://api.openweathermap.org/data/2.5/weather'
[json.openweather.params]
appid = 'API KEY HERE'
lat = '1.23'
lon = '-4.56'
[json.openweather.metrics.ow_temp]
path = "main.temp"
type = "gauge"
help = "Temperature in Kelvin"
[json.openweather.metrics.ow_pressure]
path = "main.pressure"
type = "gauge"
help = "Atmospheric pressure in hPa"
[json.openweather.metrics.ow_humidity]
path = "main.humidity"
type = "gauge"
help = "Humidity in %"
[json.openweather.metrics.ow_feels_like]
path = "main.feels_like"
type = "gauge"
help = "What the temperature feels like in Kelvin."
[json.openweather.json_labels]
city = 'name'
country = 'sys.country'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
json_exporter-1.0.0.tar.gz
(13.3 kB
view details)
File details
Details for the file json_exporter-1.0.0.tar.gz
.
File metadata
- Download URL: json_exporter-1.0.0.tar.gz
- Upload date:
- Size: 13.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b8c7957d607fb69c904e99735169ce20c735041f0a553fd20e40ddcc209521d2 |
|
MD5 | 88dce085bca092911a4d3062c51d35e1 |
|
BLAKE2b-256 | 4f20bdb62f8d4c5cf468c12e95991b7bd64ac08e0665a7cf82522933c0c7ec8d |