title: Unable to calculate the ratio of two metrics in Prometheus
body: <p>I am collecting ZFS metrics in Prometheus v.2.19 from Linux servers using <a href="https://github.com/mac133k/zfs_exporter" rel="nofollow noreferrer">ZFS Exporter</a>. The data is being collected from all targets and the values are correct, however there is this strange issue: I want to calculate the percentage of the ratio of ARC misses vs. ARC hits, so I use the following formula:</p>
  <pre><code>100 * rate(zfs_arc_stats{stat='misses'}[5m]) / rate(zfs_arc_stats{stat='hits'}[5m])
  </code></pre>
  <p>but it produces no data. I can get the values from each of the rate expressions individually, but not from the above formula. If I use the formula with the same labels, ie.:</p>
  <pre><code>100 * rate(zfs_arc_stats{stat='hits'}[5m]) / rate(zfs_arc_stats{stat='hits'}[5m])
  </code></pre>
  <p>it gives the correct results of 100, because the ratio of misses to misses or hits to hits is always 1:1. I tried similar formulas with metrics from other sources (ie. PCP, Collectd) and those work fine, ie. I could calculate ratios of same metrics with different labels, so it seems like the problem could be specific to the metrics from ZFS Exporter. This exporter has a very few metrics, but each metric has many different stats identified by the value of the 'stat' label. All the metrics are of gauge type, but I do not think it really matters for the <code>rate</code> function in PromQL. Anyway like I mentioned before the rates can be computed separately, only the ratio fails. Somebody please suggest how to tackle this issue.</p>