Query to subtract value from another query

What would be the advised way to subtract values produced by querys.

collectd/ceph are eg. storing only the total and in, and I would like to get out. So I need to do total - in = out.

I would get the Total with this:
SELECT last(“value”) FROM “ceph_value” WHERE “type” = ‘ceph_bytes’ AND “type_instance” = ‘Cluster.numOsd’

I would get the In with this:
SELECT last(“value”) FROM “ceph_value” WHERE “type” = ‘ceph_bytes’ AND “type_instance” = ‘Cluster.numOsdIn’

Is this even possible? It looks like subquries won’t work, or should this ‘out’ be created via a running query?

1 Like