Search code examples
node.jsprometheuspromql

How to graph a count of HTTP request per minute with Prometheus & Nodejs


I have nodejs app and need to graph a count of HTTP request per minute. Install [prom-client], with using a Counter. Now i have graph with total count of HTTP request. But idk how to graph per minute.

First option - Im considering is prometheus collect the metric once a minute, later resetting the value. What do u think?

Second option - using Increase, but i got float value.


Solution

  • The proper approach is to use increase() function for the counter metric. For example, the following query returns per-minute increase per each time series matching foo filter:

    increase(foo[1m])
    

    If this query is used for building graph in Grafana, then every point on the graph shows counter increase over the last minute, which ends at the given point.

    Prometheus may return unexpected results from increase() function because of extrapolation - see this issue. Prometheus developers are aware of this issue and are going to solve it eventually - see this design doc.

    P.S. you can use an alternative Prometheus-like monitoring system I work on - VictoriaMetrics if you need exact results from the increase() function, without extrapolation and missing counter increases.