Updated: 2021-10-24 01:45:51 +0800 +08

Prometheus Scrape and Metrics





A counter starts at 0, and is incremented. At each scrape Prometheus takes a sample of this state.

what happens when the process restarts and the counter is reset to 0?
rate() will automatically handle this. Any time a counter appears to decrease it’ll be treated as though there was a reset to 0 right after the first data point.


  • rate()
    • returns per second values,
    • rate(counter[5s]) is (v5 - v1) / (t5 - t1)
  • increase()
    • returns the total across the time period.
    • increase(counter[5s]) is exactly rate(counter[5s]) * 5
  • irate()
    • only looks at the last two samples
    • useful for high precision graphs over short time frames.
    • irate(counter[5s]) is (v5 - v4) / (t5 - t4)
  • offset
    • counter - counter offest 5s
    • it can’t handle reset situation
  • resets()
    • how often the counter resets
    • useful for debugging.


Useful Query Example