Metrics rest endpoint vs containers?recursion=2 endpoint


some insights provided by the /1.0/metrics API endpoint are also in the /1.0/instances?recursion=2 result. Namely, the path state.cpu.usage or state.distk.root.usage in the later call for a given instance. Both are also available in the metrics endpoint as lxd_cpu_seconds_total or lxd_filesystem_size_bytes.

Are the values in both endpoints coming from the same source, or are they retrieved differently?

The metrics documentation mentions it is resource heavy. Is the instance call cheaper?

Thank you,

They’re using the same internal calls.

1 Like

Depending on the context, you may be able to request just a single instance, rather than all of them using /1.0/instances/<instance_name>?recursion=2

1 Like

I don’t think we do recursion=2 on a single instance though, do we?

You’d need to hit /1.0/instances/NAME/state instead.

1 Like

Sorry, yes, we have recursion=1 on that endpoint (but recursion=2 or higher works also). Both populate the state field.

Or hit /1.0/instances/NAME/state works also.

1 Like