Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tolleiv/json-exporter
Prometheus exporter which fetches JSON from a URL and exports one of the values as gauge metrics
https://github.com/tolleiv/json-exporter
docker jsonpath metrics prometheus prometheus-exporter
Last synced: about 2 months ago
JSON representation
Prometheus exporter which fetches JSON from a URL and exports one of the values as gauge metrics
- Host: GitHub
- URL: https://github.com/tolleiv/json-exporter
- Owner: tolleiv
- Created: 2017-06-16T13:17:15.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-03-16T08:35:44.000Z (almost 6 years ago)
- Last Synced: 2024-06-20T17:05:52.818Z (7 months ago)
- Topics: docker, jsonpath, metrics, prometheus, prometheus-exporter
- Language: Go
- Size: 7.81 KB
- Stars: 24
- Watchers: 2
- Forks: 18
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Json Exporter
![TravisCI build status](https://travis-ci.org/tolleiv/json-exporter.svg?branch=master)
[![Docker Build Statu](https://img.shields.io/docker/build/tolleiv/json-exporter.svg)](https://hub.docker.com/r/tolleiv/json-exporter/)This Prometheus exporter operates similar to the Blackbox exporters. It downloads a JSON file and provides a numerical gauge value from within that file.
Which value to pick is defined through JsonPath.## Parameters
- `target`: URL / Json-file to download
- `jsonpath`: the field name to read the value from, this follows the syntax provided by [oliveagle/jsonpath](https://github.com/oliveagle/jsonpath)## Docker usage
docker build -t json_exporter .
docker -d -p 9116:9116 --name json_exporter json_exporter
The related metrics can then be found under:
http://localhost:9116/probe?target=http://validate.jsontest.com/?json=%7B%22key%22:%22value%22%7D&jsonpath=$.parse_time_nanoseconds## Prometheus Configuration
The json exporter needs to be passed the target and the json as a parameter, this can be
done with relabelling.Example config:
```yml
scrape_configs:
- job_name: 'json'
metrics_path: /probe
params:
jsonpath: [$.parse_time_nanoseconds] # Look for the nanoseconds field
static_configs:
- targets:
- http://validate.jsontest.com/?json=%7B%22key%22:%22value%22%7D
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: 127.0.0.1:9116 # Json exporter.
metric_relabel_configs:
- source_labels: value
target_label: parse_time```
## License
MIT License