skip to Main Content

I have the following metrics in prometheus: it counts memcached command by sec:

sum (irate (memcached_commands_total{instance="memcached-instance"}[5m])) by (command)

Result:

{command="delete"}  0
{command="flush"}   0
{command="get"} 62.733333333333334
{command="incr"}    0
{command="set"} 93.43333333333334
{command="touch"}   NaN
{command="cas"} 0
{command="decr"}    0

I want to count commands by sec (without separate rate for different commands). I have tried the following formula:

sum (irate (memcached_commands_total{instance="memcached-instance"}[5m]))

But the result is:

{}  NaN

I expect about 155, but it is NaN. I suppose it is command=”touch” the culprit. It is possible to exclude NaN from the sum?

2

Answers


  1. Chosen as BEST ANSWER

    I have figured it out:

    sum (irate (memcached_commands_total{instance="memcached-instance"}[5m]) > 0)
    

    returns the correct number. >0 does the trick.


  2. The only way irate can produce a NaN is if it’s being given a NaN as input. Given that irate is meant to work on counters, that should be impossible. I’d suggest looking into why memcached_commands_total is producing NaN.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search