Code Monkey home page Code Monkey logo

iapetus's Introduction

Iapetus

CircleCI Go Report Card

This project is unstable yet. So breaking change may be happened no notice.

Overview

Iapetus is a reverse proxy for Prometheus that dispatches queries to Prometheus nodes depending on the content of a query, such a label and a timestamp. Iapetus also supports relabeling feature, so you can configure relabeling rules for each node. To simplify, Iapetus does not query multiple nodes and aggregate that results. It only does dispatch.

Install

Binary

Go to https://github.com/kobtea/iapetus/releases

Building from source

$ go get -d github.com/kobtea/iapetus
$ cd $GOPATH/src/github.com/kobtea/iapetus
$ make build

Usage

$ iapetus --help
usage: iapetus --config=CONFIG [<flags>]

Flags:
  --help                         Show context-sensitive help (also try --help-long and --help-man).
  --config=CONFIG                iapetus config file path.
  --listen.addr=":19090"         address to listen.
  --listen.prefix=LISTEN.PREFIX  path prefix of this endpoint. remove this prefix when dispatch to a backend.
  --log.level=LOG.LEVEL          log level (debug, info, warn, error)
  --version                      Show application version.

configuration format is below.

# config.yml
log:
  # debug, info, warn, error. default is info.
  level: info
# Multi clusters are not support yet. So iapetus use 1st cluster setting.
clusters:
  - name: <string>
    # list prometheus as node
    nodes:
      - name: <string>
        url: <string>
        relabels:
          # support relabelling rules at prometheus
          [ - <relabel_config> ... ]
        min_step: <duration>
    # proxy rules
    # each rule are pair of `target: <node_name>` and some rule.
    # support rules are below.
    # - default: <bool>, use when no match other rules
    # - start: <op duration>, compare `start` at request parameter
    # - end: <op duration>, compare `end` at request parameter
    # - range: <op duration>, range is between `start` and `end` at request parameter
    # - required_labels: [ <label_name>: <label_value> ... ], find labels from `query` or `match[]` parameter(s). If a request satisfy this rule, Iapetus send not matched metrics but whole query send to the target. It is mean that Iapetus does not calculate values.
    rules:
      [ - <rules>, ...]

sample

log:
  level: info
clusters:
  - name: cluster1
    nodes:
      - name: primary
        url: http://localhost:9090
      - name: archive
        url: http://localhost:9091
        relabels:
          - source_labels: [__name__]
            target_label: __name__
            replacement: ${1}_avg
        min_step: 10m
    rules:
      - target: primary
        default: true
      - target: archive
        range: "> 1d"
      - target: archive
        start: "< now-1d"

Roadmap

Cluster

Handling multi prometheus clusters. Proxy rule is TBD. It may be a same rule as node, (or not).

License

MIT

iapetus's People

Contributors

kobtea avatar mtanda avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

iapetus's Issues

Support same labels

Expected Behavior

In Prometheus, queries containing same labels can be executed.

up{job="node", job=~"no.+"}

I want to support same labels queries in Iapetus too.

Current Behavior

In Iapetus, each value of same labels are override into one value.

iapetus_1      | level=info ts=2021-04-09T09:02:18.2869586Z caller=proxy.go:86 target=primary query="up{job=\"no.+\",job=~\"no.+\"}" match[]=[] origin="query=up%7Bjob%3D%22node%22%2C%20job%3D~%22no.%2B%22%7D&start=1617955335&end=1617958935&step=15"

Environment

iapetus v0.2.2

Labels not matched are given

environment: https://github.com/kobtea/iapetus/tree/0d52a78975d8ce929ada51c551d428d0b776dbdc/example/docker-compose

$ curl -s 'http://localhost:19090/api/v1/query_range?query=\{job="prometheus"\}&start=1535968260&end=1535969175&step=15' | jq .
{
  "status": "success",
  "data": {
    "resultType": "matrix",
    "result": []
  }
}

iapetus_1      | level=debug ts=2018-09-03T10:31:56.5195797Z caller=proxy.go:81 request="://localhost:19090/api/v1/query_range?query={job=\"prometheus\"}&start=1535968260&end=1535969175&step=15"
iapetus_1      | level=debug ts=2018-09-03T10:31:56.5196187Z caller=proxy.go:82 backend="http://prometheus2:9090/api/v1/query_range?end=1535969175&query=_avg%7Bjob%3D%22prometheus%22%7D&start=1535968260&step=15"
iapetus_1      | level=info ts=2018-09-03T10:31:56.5196373Z caller=proxy.go:83 target=archive query="_avg{job=\"prometheus\"}" match[]=[] origin="query={job=\"prometheus\"}&start=1535968260&end=1535969175&step=15"
  • expect query: {job="prometheus"}
  • but got: _avg{job="prometheus"}

Invalid regex-match

environment: https://github.com/kobtea/iapetus/blob/bff53ff57bde3a6ec006e43aed7df98693f7236c/example/docker-compose/docker-compose.yml

$ curl -s 'http://localhost:19090/api/v1/query_range?query=%7B__name__%3D~%22node_arp_entries%22%7D&start=1545061395&end=1545061710&step=15' | jq .
{
  "status": "error",
  "errorType": "bad_data",
  "error": "parse error at char 46: metric name must not be set twice: \"node_arp_entries\" or \"node_arp_entries\""
}

iapetus_1      | level=debug ts=2018-12-17T15:48:59.5897001Z caller=proxy.go:84 request="http://localhost:19090/api/v1/query_range?query=%7B__name__%3D~%22node_arp_entries%22%7D&start=1545061395&end=1545061710&step=15"
iapetus_1      | level=debug ts=2018-12-17T15:48:59.5899841Z caller=proxy.go:85 backend="http://prometheus1:9090/api/v1/query_range?end=1545061710&query=node_arp_entries%7B__name__%3D~%22node_arp_entries%22%7D&start=1545061395&step=15"
iapetus_1      | level=info ts=2018-12-17T15:48:59.5900249Z caller=proxy.go:86 target=primary query="node_arp_entries{__name__=~\"node_arp_entries\"}" match[]=[] origin="query=%7B__name__%3D~%22node_arp_entries%22%7D&start=1545061395&end=1545061710&step=15"
  • expect query: {__name__=~"node_arp_entries"}
  • but got: node_arp_entries{__name__=~"node_arp_entries"}

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.