Coder Social home page Coder Social logo

yileye / prometheus-jsonpath-exporter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from project-sunbird/prometheus-jsonpath-exporter

0.0 2.0 0.0 15 KB

Converts JSON data from a http url to prometheus metrics using jsonpath

License: MIT License

Dockerfile 11.13% Python 88.87%

prometheus-jsonpath-exporter's Introduction

prometheus-jsonpath-exporter

Converts json data from a http url into prometheus metrics using jsonpath

Config

exporter_port: 9158 # Port on which prometheus can call this exporter to get metrics
log_level: info
json_data_url: http://stubonweb.herokuapp.com/kong-cluster-status # Url to get json data used for fetching metric values
metric_name_prefix: kong_cluster # All metric names will be prefixed with this value
metrics:
- name: total_nodes # Final metric name will be kong_cluster_total_nodes
  description: Total number of nodes in kong cluster
  path: $.total
- name: alive_nodes # Final metric name will be kong_cluster_alive_nodes
  description: Number of live nodes in kong cluster
  path: count($.data[@.status is "alive"])

See the example below to understand how the json data and metrics will look for this config

Run

Using code (local)

# Ensure python 2.x and pip installed
pip install -r app/requirements.txt
python app/exporter.py example/config.yml

Using docker

docker run -p 9158:9158 -v $(pwd)/example/config.yml:/etc/prometheus-jsonpath-exporter/config.yml sunbird/prometheus-jsonpath-exporter /etc/prometheus-jsonpath-exporter/config.yml

JsonPath Syntax

This exporter uses objectpath python library. The syntax is documented here

Example

For the above config, if the configured json_data_url returns

{
  "data": [
    {
      "address": "x.x.x.15:7946",
      "status": "failed"
    },
    {
      "address": "x.x.x.19:7946",
      "status": "alive"
    },
    {
      "address": "x.x.x.12:7946",
      "status": "alive"
    }
  ],
  "total": 3
}

Metrics will available in http://localhost:9158

$ curl -s localhost:9158 | grep ^kong
kong_cluster_total_nodes 3.0
kong_cluster_alive_nodes 2.0

prometheus-jsonpath-exporter's People

Contributors

endeepak avatar vrayulu avatar kochhar avatar

Watchers

James Cloos avatar lyi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.