> ## Documentation Index
> Fetch the complete documentation index at: https://docs.use.observer/llms.txt
> Use this file to discover all available pages before exploring further.

# Deploy on Fly.io

> Launch the agent on your own Fly.io account from the agent repository's fly.toml.

The Observer Agent runs on your own Fly.io account as a small
always-on machine. It makes outbound HTTPS calls to Observer and
listens on no public port. Your platform's pricing applies.

## Before you start

* Create the agent in Observer: **Agents**, **Add agent**, then
  **Cloud platforms**. Copy the key. Observer shows it once.
* Install [flyctl](https://fly.io/docs/flyctl/install/) and sign in to
  your Fly account.

## Deploy

`fly launch --from` clones the agent repository into the current
directory, which must be empty:

```bash theme={null}
mkdir observer-agent && cd observer-agent
fly launch --from https://github.com/useobserver/agent --copy-config --no-deploy
fly secrets set AGENT_KEY="obs_live_..."
fly deploy
```

`fly launch` picks an app name and a region, which you can change when
it asks, and reads the repository's `fly.toml`: one `shared-cpu-1x`
machine with 256 MB of memory, a volume at `/data` for the
[local queue](https://docs.use.observer/agent/concepts/local-queue.md), and no services, so
nothing is exposed to the internet. The volume keeps queued readings
across a redeploy.

Run later commands (`fly logs`, `fly deploy`, `fly secrets set`) from
the same directory. To change the key, for example after a
[key rotation](https://docs.use.observer/agent/guides/rotate-agent-key.md), run
`fly secrets set AGENT_KEY=...` again. Set other
[environment variables](https://docs.use.observer/agent/reference/environment-variables.md), such
as `PROMETHEUS_SERVER_URL`, the same way or under `[env]` in
`fly.toml`.

## Check that it connected

The Add agent screen shows **Connected** within a minute of the agent
starting, and the Agents page marks the agent as **running**. If it
does not, read the logs:

```bash theme={null}
fly logs
```

The agent logs every failed call to Observer with the reason. The most
common cause is a wrong or replaced `AGENT_KEY`.

## Upgrades

`fly.toml` runs `ghcr.io/useobserver/agent:1`, which moves to each new
1.x release. Run `fly deploy` again to pick up a new release.

## Remove

```bash theme={null}
fly apps destroy <app-name>
```

This deletes the machine and its volume. Delete the agent in Observer
(**Agents**) too if you no longer need it.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.