Giter Club home page Giter Club logo

http-json-query-exporter's Introduction

http-json-query-exporter

https://travis-ci.com/coliquio/http-json-query-exporter.svg?branch=master

Query http endpoints, transform and export response to prometheus.

docs/concept.png

Features

Run

Using nodejs

Install dependencies

npm install

Start server

CONFIG_FILE=example/config.yml npm start

Get metrics

  1. Queries https://httpbin.org/json
  2. Runs transformation
  3. Returns prometheus metrics
curl localhost:8000/all/metrics
# HELP items_per_slide_count this is my metric
# TYPE items_per_slide_count counter
items_per_slide_count{title="Wake up to WonderWidgets!"} 0
items_per_slide_count{title="Overview"} 2

Using docker

docker run --rm -p 8000 coliquiode/http-json-query-exporter

Configuring tasks

The configuration contains a collection of tasks. Each task consists of 3 steps:

  1. query
  2. transformation
  3. prometheusMetric

Short example:

tasks:
  # task
  - query:
      url: 'https://httpbin.org/json'
    transformation: |
      $.slideshow.slides.{"title": title, "value": $count(items)}
    prometheusMetric:
      name: 'items_per_slide_count'
      type: 'counter'
      description: 'this is my metric'
  # further task(s)
  # - ...

This produces metrics like:

# HELP items_per_slide_count this is my metric
# TYPE items_per_slide_count counter
items_per_slide_count{title="Wake up to WonderWidgets!"} 0
items_per_slide_count{title="Overview"} 2

Detailed process

docs/task.png

1. query step

Define a http query here, the only mandatory argument is url and it must return valid JSON.

All valid axios.request({...}) parameters like method, body, etc. are accepted https://github.com/axios/axios#request-config.

2. transformation step

Define JSONata queries to transform the http query result into a array of objects for exporting metrics:

  • The object value keys are used reserved and used as metric value
  • All other object keys are used as metric labels

Test transformations in http://try.jsonata.org/.

3. prometheusMetric step

Specify metric name, description and type. All labels and the value must be produced by previous transformation step.

CI Environment

https://travis-ci.com/coliquio/http-json-query-exporter.svg?branch=master

See https://travis-ci.com/coliquio/http-json-query-exporter

License

See LICENSE.

Disclaimer

This is a project for the community, from developers for developers. This is NOT an official coliquio product. I.e. Maintenance and support are provided by the individual developers but not officially by coliquio.

http-json-query-exporter's People

Contributors

alainvanhoof avatar bsingr avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

rgbwoo qwzhou89

http-json-query-exporter's Issues

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.