Skip to content

Latest commit

 

History

History
51 lines (38 loc) · 1.94 KB

README.md

File metadata and controls

51 lines (38 loc) · 1.94 KB

Json Exporter

TravisCI build status Docker Build Statu

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 values to pick is defined through jsonpath.[METRIC_NAME_M]=[JSON PATH_N].

Parameters

  • target: URL / Json-file to download
  • jsonpath.[METRIC_NAME_1]=[JSON PATH_1]: the field name to read the value from, this follows the syntax provided by oliveagle/jsonpath
  • jsonpath.[METRIC_NAME_N]=[JSON PATH_N]: the field name to read the value from, this follows the syntax provided by 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.nanoseconds=$.parse_time_nanoseconds&jsonpath.size=$.size

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:

scrape_configs:
  - job_name: 'json'
    metrics_path: /probe
    params:
      jsonpath.nanoseconds: [$.parse_time_nanoseconds] # Look for the nanoseconds field
      jsonpath.size: [$.size]
    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.

License

MIT License