Machine Metrics Query and App Usage Report

We are nearly completed with our fly integration two critical components are still missing.

Machine Metrics
I have made several attempts to construct a query that will return basic machine metrics, memmory usage and CPU Load

I see this in the docs

Metrics on Fly · Fly Docs

But have not been able to construct an Instance Series - query

Any help or guidance would be greatly appreciated.

App usage/billing API

I have seen mention of a billing API but have not found ii in the docs it looks like it might be part of the graphql api but I have been unable construct a query which returns usage for an APP. We need to pass our Fly fees to our customers. Our customers may have multiple fly apps. A billing/usage report per app is what we are after. Again any help and guidance on this would be greatly appreciated.


1 Like

I see this example request

> curl$ORG_SLUG/api/v1/query \
>   --data-urlencode 'query=sum(increase(fly_edge_http_responses_count)) by (app, status)' \
>   -H "Authorization: Bearer $TOKEN"

and these instance end points?

fly_instance_cpu{cpu_id, mode} (Counter, centiseconds)

But not able to construct a query please help :upside_down_face:

OK I figured out the metrics memory and CPU query. Would have been nice to have more examples in the docs. The formatting of the query was not obvious, well at least to me it wasn’t. Had to look at the HTTP request in the Grafana Interface

curl$ORG_SLUG/api/v1/query \

–data-urlencode ‘query=fly_instance_memory_mem_total{instance=“$MACHINE_ID”}’
-H “Authorization: Bearer $TOKEN”

 curl$ORG_SLUG/api/v1/query \

–data-urlencode ‘query=sum(fly_instance_load_average{instance=“$MACHINE_ID”})by(minutes)’
-H “Authorization: Bearer $TOKEN”

Still in search of a usage/billing API.

1 Like

We don’t have an API with granular billing data yet. If you need to bill your users for specific machines, the best thing to do is fetch the machine events from /v1/apps/<app>/machines/<id> and use those for billing.

We are now 1 machine per app, our end users may have multiple apps. We have been flying under the billing radar so have yet to see a bill greater than 0. Will the invoices be broken down by apps? Or are fees summed up in a org?

Also I see that the the VM mem and cpu metrics query used in the APP metrics report was displayed in the UI. I’m not in the UI a lot so i missed that when looking to see how to query these metrics.

I don’t think that will work for us. What is the api for accessing any billing/usage data. Even it a non granular level.