Skip to main content
Illustration by Annie Ruygt of some Machines strutting along The Fly.io platform includes a fully-managed metrics solution to help you easily monitor your Fly apps. It includes the following components:
  • Prometheus on Fly.io: Managed Prometheus-compatible time series storage
  • Dashboards: Managed Grafana with detailed visualizations of all built-in metrics
  • Built-in Metrics: Metrics automatically sent from every Fly app you deploy
  • Custom Metrics: Expose additional metrics from Fly apps for further customization

Prometheus on Fly.io

Prometheus is a popular open source monitoring system used to store and query metrics efficiently, with a stable HTTP querying API compatible with a range of systems. Prometheus on Fly.io is a fully-managed service based on VictoriaMetrics. It supports most common Prometheus querying API endpoints: Note that remote read (/api/v1/read) remote storage integration is not supported.

MetricsQL

Prometheus queries are typically based on the PromQL query language. Prometheus on Fly.io queries use VictoriaMetrics MetricsQL, a backwards-compatible query language that fixes user experience issues and adds useful features and functions on top of PromQL. Key features:
  • Better rate() and increase() functions that just work. No need for irate workarounds or appending Grafana’s magical $__rate_interval selector to every query. In fact, you can even omit the square brackets entirely and MetricsQL will do the right thing.
  • Many more label manipulation functions such as drop_common_labels, label_set, etc.
  • topk_avg, which returns the top k time series averaged across the entire series range (not just individual points), plus the sum of all remaining series in an “other” label. Useful for giving a small, filtered view across a potentially large number of series.

Querying

Queries can be sent to the following endpoint:
You’ll need to authenticate with a Fly Access Token. Depending on the token type, the header uses either the Bearer format (Authorization: Bearer <token>) or the FlyV1 format (Authorization: FlyV1 <token>). You may only query series scoped to your organizations.

Manually

Find your Organization slug List your organizations, find the org slug and set it as a local variable.
Get an access token
Test it out!

Retention, cost, and limits

Prometheus on Fly.io retains metric data for approximately 15 days and is intended for operational monitoring. If you need longer retention, run your own monitoring stack. Fly.io’s Observability for User Apps guide deploys a ready-made stack, or you can federate from the Fly.io endpoint into your own Prometheus installation. There’s currently no additional charge for the managed Prometheus and Grafana. Pricing could change in the future, and Fly.io will give advance notice. A couple of practical limits to be aware of:
  • We cap your app’s metrics endpoint response at 16 MB and drop anything larger.
  • We may drop very high-cardinality custom metrics.

Dashboards

For more advanced metrics monitoring, you can use dashboards to organize and visualize complex Prometheus queries. The Metrics tab on the Fly.io Dashboard provides an overview of your Fly apps using the built-in metrics stored in Prometheus.

Managed Grafana

Grafana is a popular open source data visualization web application, that allows you to compose queries against data sources into dynamic, reusable dashboards. We provide a managed Grafana instance at fly-metrics.net, preconfigured with your Prometheus data source and detailed dashboards covering the full set of built-in metrics. You can also use the Explore panel to run ad-hoc queries against the preconfigured Prometheus datasource, or create/import additional dashboards for further customization or to visualize custom metrics. Switch between your Fly.io Organizations by clicking the “Switch organization” link beneath the user icon in the lower-left of the screen.

External or self-hosted Grafana

You can also configure your Prometheus endpoint with an existing Grafana installation, or host one on Fly.io. Either way, you can set it up like this:
  1. Add a Prometheus data source (Settings -> Data Sources -> Add data source -> Prometheus)
  2. Fill the form with the following:
  • HTTP -> URL: https://api.fly.io/prometheus/<org-slug>/
  • Custom HTTP Headers -> + Add Header:
    • Header: Authorization
    • Value: FlyV1 <token> (for tokens created with fly tokens create)
    • Value: Bearer <token> (only for tokens from flyctl auth token)
You’re all set. We publish our Fly.io Dashboards to Grafana.com for use with external Grafana instances. To install, just import the dashboard using the listed IDs. If you’d like to contribute changes to the dashboards, we have created a repository for them.

Alerting

Fly.io doesn’t include built-in alerting on metrics, so you’ll need to set up alerting yourself against the Prometheus endpoint. Two common approaches:
  • Grafana alerting: connect the Fly.io Prometheus data source to a Grafana instance (see the External or self-hosted Grafana section), then create Grafana alert rules on queries against the data source and send the alerts to a contact point such as email, Slack, or PagerDuty.
  • Prometheus and Alertmanager: run your own Prometheus that federates from the Fly.io endpoint and use Alertmanager to send notifications.
If you don’t already run Grafana or Prometheus, Fly.io’s Observability for User Apps guide deploys a ready-made stack (VictoriaMetrics and Grafana) you can build alerts on.

Built-in metrics

Fly apps automatically publish a number of built-in metrics. Metric types are all Gauges unless otherwise marked. Metrics with names ending in _count are all Counters. Histogram metrics with a base name of <name> expose multiple series:
  • <name>_bucket{le}
  • <name>_sum
  • <name>_count

Standard Labels

All published series include the following labels:
  • app: App name
  • region: Fly.io Region
  • host: 4-character host ID (lowercase hexadecimal)
  • instance: App instance ID (for all series except fly_edge_ and fly_volume_)
If your app exposes custom metrics with the same labels, they will be overwritten.

Proxy series

Any app using a TCP-based handler (HTTP, TLS or straight TCP) publishes edge and app proxy metrics: Labels:
  • proxy_id: “blue” or “green” (flips when the proxy is restarted/updated)

Edge - fly_edge_

App - fly_app_

Instance series - fly_instance_

Derived from the /proc file system of your app VMs. fly_instance_up = 1 shows the VM is reporting correctly.

Instance exit - fly_instance_exit_

Information about instance exits. These metrics help you understand why your instances are terminating and can be used for alerting and debugging.
  • fly_instance_exit_code: The exit code of the main process when the instance terminates. A value of 0 typically indicates normal termination, while non-zero values indicate errors or abnormal termination.
  • fly_instance_exit_oom: A boolean flag (0 or 1) indicating whether the instance was killed due to out-of-memory (OOM). A value of 1 means the instance was terminated because it exceeded its memory limits.
  • fly_instance_exit_vm_code: The VM-level exit code, which may differ from the application exit code. This can help distinguish between application-level failures and VM-level issues.

Instance memory - fly_instance_memory_

Derived from /proc/meminfo. All units are in bytes.

Instance Load and CPU

  • load_average is derived from /proc/loadavg (getloadavg). It’s a “system load average” measuring the number of processes in the system run queue, with samples representing averages over 1, 5, and 15 minutes.
  • cpu is derived from /proc/stat, and counts the amount of time each CPU (cpu_id) has spent performing different kinds of work (mode, which may be one of user, nice, system, idle, iowait, irq, softirq, steal, guest, guest_nice). The time unit is ‘clock ticks’ of centiseconds (0.01 seconds).
The following CPU metrics are related to CPU Performance:
  • cpu_baseline is the baseline quota in number of CPUs, calculated from the CPU type and number of vCPUs.
  • cpu_balance is the accrued CPU burst balance in clock ticks (centiseconds).
  • cpu_throttle is derived from the throttled_time field of the cgroup cpu.stat, and counts the amount of time the CPU was throttled after exhausting its quota, in ‘clock ticks’ (centiseconds).

Instance Disks - fly_instance_disk_

Counters derived from fields 1-11 of /proc/diskstats. The unit for time_ series is milliseconds, and the unit for sectors_ is 512-byte sectors. Labels:
  • device: Published for the ephemeral VM root disk (vdb) and any mounted Volume (vdc).

Instance Networking - fly_instance_net_

Counters derived from /proc/net/dev. Labels:
  • device: interface name, either eth0 or dummy0 (ignore).

Instance File Descriptors - fly_instance_filefd_

Information about allocated, and maximum allowed allocated file descriptors derived from /proc/sys/fs/file-nr.

Instance Filesystem - fly_instance_filesystem_

Filesystem metrics derived from VFS File System Information. Labels:
  • mount: mount point name(s), / and if using Volumes, the destination name in fly.toml.

Volumes - fly_volume_

Labels:
  • id: Volume ID
If you’re using Volumes for any of your organization’s apps, you’ll be able to query these series, derived from the LSize and Data% of the volume’s thin LV.

Postgres - pg_

If you have a Postgres database hosted on Fly.io, you’ll automatically get the following series, published via postgres_exporter:

Custom Metrics

For further customization beyond built-in metrics, Fly apps can expose a metrics endpoint we’ll automatically scrape every 15 seconds and send the results to Prometheus.

Configuration

Add a [metrics] section to your application’s fly.toml:
If your app uses multiple processes, you can add multiple [[metrics]] sections, each with its own set of processes:

Instrumentation

Instrument your app and expose your metrics on 0.0.0.0. There are many supported client libraries as well as off-the-shelf exporters able to return Prometheus-formatted metrics.

Authentication

Authenticating to the Prometheus API can be achieved a few different ways, depending on the level of access you want your token to have.

Fly Access Token

As in the earlier example, a full access token can be generated with flyctl auth token and then passed as a bearer token in the Authorization header. The header looks like:

Fly org-restricted or read-only token

This kind of token or “macaroon” can be scoped to a single organization or configured to only allow read operations, which can be safer than using a full-blown read-write token that grants access to all organizations under your account.

Generating tokens

Create an org-restricted token:
Create a read-only org-restricted token:
These tokens look like this once generated: FlyV1 fm2_lJPECAAAAAAAAC7txBAzYI6PRWhHLT...(a lot of base64-encoded text).

Using tokens

Use the correct scheme based on token type:
  • Bearer <token> → for flyctl auth token.
  • FlyV1 <token> → for all tokens created with fly tokens create.
Example with a token created via fly tokens create: