carrotcakeslayer
carrotcakeslayer

Reputation: 998

PromQL delta over time

We would like to see the difference of exposed metrics by a combination of node/ip over time. Nodes or ips could exist at any given point but not neccesarily will exist in another.

The metric itself (some_metric) is of type "gauge" and in this case, it could be that server1 announces IP 10.0.0.1 and server2 announces 10.0.0.2. Now let's pretend that server1 dissapears, so now server2 also announces 10.0.0.1.

So currently only server2 is announcing both IPs: count(some_metric) by (node,ip)

some_metric{node=server2,ip=10.0.0.1} = 1
some_metric{node=server2,ip=10.0.0.2} = 1

One hour ago each node was annnouncing each IP: count(some_metric offset 1h) by (node,ip)

some_metric{node=server1,ip=10.0.0.1} = 1
some_metric{node=server2,ip=10.0.0.2} = 1

Bringin back server1 online, would make query results like this: count(some_metric) by (node,ip)

some_metric{node=server1,ip=10.0.0.1} = 1
some_metric{node=server2,ip=10.0.0.2} = 1

What we need, is to be accountable for the times each announced an IP over a period (let's say 30 minutes) of time. So we would end up with something like:

some_metric{node=server1,ip=10.0.0.1} = 2
some_metric{node=server2,ip=10.0.0.2} = 1
some_metric{node=server2,ip=10.0.0.1} = 1

Upvotes: 0

Views: 1054

Answers (1)

carrotcakeslayer
carrotcakeslayer

Reputation: 998

I think this does it. Just leaving it here for others that may find it useful:

count(increase(some_metric[30m])) by (node,ip)

Other options are welcome of course :)

Upvotes: 1

Related Questions