Giter Club home page Giter Club logo

Comments (3)

samber avatar samber commented on May 29, 2024

I think this is a general question, not linked to this specific library.

You can try something like:

function generateQueries(rateInterval) {
   return {
      load15: `node_load15`,
      cpuUsage: `sum by(instance) (irate(node_cpu_seconds_total{instance="localhost:9100",job="node", mode="system"}[${rateInterval}])) / on(instance) group_left sum by (instance)((irate(node_cpu_seconds_total{instance="localhost:9100",job="node"}[${rateInterval}])))`,
      memoryUsage: `node_memory_MemTotal_bytes{instance="localhost:9100",job="node"} - node_memory_MemFree_bytes{instance="localhost:9100",job="node"} - (node_memory_Cached_bytes{instance="localhost:9100",job="node"} + node_memory_Buffers_bytes{instance="localhost:9100",job="node"} + node_memory_SReclaimable_bytes{instance="localhost:9100",job="node"})`,
  };
}

from prometheus-query-js.

thechromosomes avatar thechromosomes commented on May 29, 2024

I think this is a general question, not linked to this specific library.

You can try something like:

function generateQueries(rateInterval) {
   return {
      load15: `node_load15`,
      cpuUsage: `sum by(instance) (irate(node_cpu_seconds_total{instance="localhost:9100",job="node", mode="system"}[${rateInterval}])) / on(instance) group_left sum by (instance)((irate(node_cpu_seconds_total{instance="localhost:9100",job="node"}[${rateInterval}])))`,
      memoryUsage: `node_memory_MemTotal_bytes{instance="localhost:9100",job="node"} - node_memory_MemFree_bytes{instance="localhost:9100",job="node"} - (node_memory_Cached_bytes{instance="localhost:9100",job="node"} + node_memory_Buffers_bytes{instance="localhost:9100",job="node"} + node_memory_SReclaimable_bytes{instance="localhost:9100",job="node"})`,
  };
}

Here, the question is the rateInterval provided as params. how to calculate this interval dynamically. using given time range and step.

from prometheus-query-js.

samber avatar samber commented on May 29, 2024

oh! i see

Rate interval and step can be set independently. Rate interval could eventually be greater than or equal to step.

Step = (time frame end date - time frame start date) / 100 data points
Rate interval = step

Prometheus supports up to 11.000 data points per query. But most of time, such accuracy is pointless.

from prometheus-query-js.

Related Issues (15)

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.