Giter Club home page Giter Club logo

promql-sdk's Introduction

promql-sdk

promql-sdk make tsdb can use promql, implemented by prometheus remote-read.

How to use it

1. init

c := &promql_sdk.ReadConfig{
    URL:     "http://127.0.0.1:8086/api/v1/prom/read?db=prometheus",    //influxdb
    Timeout: 1 * time.Minute,
}
configs := []*promql_sdk.ReadConfig{c}
err := promql_sdk.Init(configs)

2. query instant

query := `(1 - avg by(instance) (rate(node_cpu_seconds_total{mode="idle"}[5m])))* 100`
res, err := promql_sdk.Query(query)

query result:

{"resultType":"vector","result":[{"metric":{"instance":"node1"},"value":[1652086175.251,"76.00700000021607"]},{"metric":{"instance":"node2"},"value":[1652086175.251,"72.67599999997765"]}]}

3. query range

query := `(1 - avg by(instance) (rate(node_cpu_seconds_total{mode="idle"}[5m])))* 100`
res, err = promql_sdk.QueryRange(query, startTs, endTs, step)

query range result:

 {"resultType":"matrix","result":[{"metric":{"instance":"node1"},"values":[[1652086115,"88.31412083342268"],[1652086175,"76.00700000021607"]]},{"metric":{"instance":"node2"},"values":[[1652086115,"87.37343999993503"],[1652086175,"72.67599999997765"]]}]}

promql-sdk's People

Contributors

lwangrabbit avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  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.