title: How to remove no longer valid Gauges
body: <p>I use the Prometheus Java Client to export session information of my application. We want to show how long sessions have been idle.</p>
  
  <p>The problem is that we have a maximum of 1000 sessions and sessions are removed after a certain period. Unfortunately they do not disappear from Prometheus:</p>
  
  <p><a href="https://i.stack.imgur.com/G78Kr.png" rel="noreferrer"><img src="https://i.stack.imgur.com/G78Kr.png" alt="Current and expired sessions"></a></p>
  
  <p>My code looks like this:</p>
  
  <pre><code>static final Gauge sessionInactivity = Gauge.build()
      .name("sessions_inactivity_duration")
      .labelNames("internal_key", "external_key", "browser")
      .help("Number of milliseconds a certain session has been inactive")
      .register();
  
  sessionInactivity.labels(internalKey, externalKey, browser).set(inactivityTime);
  </code></pre>
  
  <p>I tried to do <code>sessionInactivity.clear()</code> during scrapes but obviously this does not empty the content of the Gauge.</p>