title: Correctly detecting a change in a Prometheus count metric
body: <p>I have tried to write a PromQL query for detecting a change in a count metric.</p>
  
  <p>My scrape interval is 15 seconds.</p>
  
  <p>I query the metric like this:</p>
  
  <pre><code>http_server_requests_seconds_count{outcome!="REDIRECTION",outcome!="SUCCESS"}
  </code></pre>
  
  <p>It shows how many of all <code>http_server_requests</code> that were not redirects and not successful.</p>
  
  <p>My attempt at writing an alert expression using this metric looks like this:</p>
  
  <pre><code>sum by(service, method, outcome, status, uri) (
    rate(
      http_server_requests_seconds_count{
        outcome!="REDIRECTION",
        outcome!="SUCCESS"
      }[1m]
    )
  ) * 60
  </code></pre>
  
  <p>My thinking is that the rate for [1m] multiplied by 60 seconds would be <code>1</code> when a change occurs, but as far as I can tell I get <code>2</code>?</p>
  
  <p>These graphs show this clearly:</p>
  
  <p><a href="https://i.stack.imgur.com/9s7zX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9s7zX.png" alt="Prometheus graph"></a></p>
  
  <p>The top graph is the sum expression, and the bottom graph is the change in server request count. When the bottom graph counts +1, the top graph should temporarily go up to <code>1</code> as well (but actually it goes up to <code>2</code>).</p>
  
  <p>What am I doing wrong? Did I misunderstand something? How can I write a query that gives me the value <code>1</code> when a change occurs? Should I expect to be able to write such a query?</p>
  
  <p>Thanks!</p>