title: Prometheus metric value age
body: <p>Using the Prometheus blackbox exporter I'm wondering how to retrieve the "age" of a metric or value a.k.a "How long is the monitored service up?". I know that I can resolve this be writing my own exporter which carries a gauge metric for the related timestamps, but I wonder if I could use the existing functions somehow?</p>
  
  <p>My setup....Prometheus scrape config:</p>
  
  <pre><code>scrape_configs:
  - job_name: 'blackbox'
    scrape_interval: 120s
    scrape_timeout: 10s
    metrics_path: /probe
  
    params:
      module: [http_2xx]
  
    static_configs:
      - targets:
        - https://example.org
  </code></pre>
  
  <p>The related values can be queried with <code>up{job="blackbox"}</code> which brings up:</p>
  
  <pre><code>Element                                             Value
  up{instance="https://example.org/",job="blackbox"}  1
  </code></pre>
  
  <p>What I'd love to do:</p>
  
  <pre><code>time()-last_change(up{instance="https://example.org/",job="blackbox"})
  </code></pre>
  
  <p>Any suggestions?</p>