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

# Configure Uplink

> The Uplink settings that operators change most, with their environment variables, flags, and defaults.

Set Uplink settings as environment variables. Many settings also have a flag, and a flag overrides its environment variable. Run `uplink -h` for every flag and its environment variable. Uplink also reads more variables that are not on this page. They are for use with Agent Golf support.

| Installation | Where to set them |
| - | - |
| systemd | `/etc/uplink/uplink.env`, then `sudo systemctl restart uplink`. |
| Docker | An `-e` option. Remove the container and run it again. |
| Helm chart | A `config` value, for example `--set-string config.UPLINK_LOG_LEVEL=debug`. See [Install the new release](https://docs.agent.golf/uplink/upgrade.md#install-the-new-release) to keep your other values. The chart sets some variables itself, for example the `OTLP_HTTP_*`, `OTLP_GRPC_*`, `OTLP_ADMIN_*`, and `OTLP_TLS_*` variables, and `config` does not accept them. See [Install and start Uplink](https://docs.agent.golf/uplink/install.md#install-and-start-uplink). |

## Uplink key

See [Create an Uplink key](https://docs.agent.golf/uplink/install.md#create-an-uplink-key).

| Environment variable | Flag | Default | Purpose |
| - | - | - | - |
| `AGENTGOLF_UPLINK_KEY` | | Empty | The Uplink key. It has no flag, so the key does not show in the process list. |
| `AGENTGOLF_UPLINK_KEY_FILE` | `-uplink-key-file` | Empty | A file that holds the Uplink key, for example a mounted Secret. When empty, Uplink uses the file `uplink-key` in the state directory if it exists. |
| `AGENTGOLF_WORKSPACE_ID` | `-workspace-id` | Empty | Optional. Uplink stops with an error when the key belongs to another workspace or to an organization. The ID is in [Workspace settings](https://docs.agent.golf/account/workspace.md). Leave it empty for the key of an organization. |
| `AGENTGOLF_CREDS_FILE` | `-creds-file` | `~/.ag-uplink/prod/creds.json` | The credentials file of Uplink. The default `uplink-key` file is in the same directory. |
| `AGENTGOLF_API_BASE_URL` | `-agentgolf-api-base-url` | `https://api.agent.golf` | The Agent Golf API that Uplink uses. Keep the default. Give `uplink backup` and `uplink restore` the same value as Uplink. |

Set `AGENTGOLF_UPLINK_KEY` or `AGENTGOLF_UPLINK_KEY_FILE`, not both.

## OpenTelemetry listener

The defaults below are the defaults of the binary. For the binds of the container image and the Helm chart, see [Listeners and default binds](https://docs.agent.golf/uplink/network.md#listeners-and-default-binds). For TLS, see [Secure the OpenTelemetry listener](https://docs.agent.golf/uplink/network.md#secure-the-opentelemetry-listener).

| Environment variable | Default | Purpose |
| - | - | - |
| `OTLP_HTTP_HOST` | `127.0.0.1` | The address that the OTLP listener binds. |
| `OTLP_HTTP_PORT` | `4318` | The OTLP listener port. When it is not set, Uplink uses the `PORT` variable, so a `PORT` in the environment moves the listener. |
| `OTLP_GRPC_HOST` | `127.0.0.1` | The address that the OTLP gRPC listener binds. |
| `OTLP_GRPC_PORT` | Empty (off) | The OTLP gRPC listener port. Empty starts no gRPC listener. |
| `OTLP_TLS_CERT_FILE`, `OTLP_TLS_KEY_FILE` | Empty (plain HTTP) | The PEM certificate chain and key for TLS on the OTLP listeners. Set both or neither. |
| `OTLP_ADMIN_HOST`, `OTLP_ADMIN_PORT` | `127.0.0.1`, `4319` | The admin listener for `/healthz`, `/readyz`, and `/metrics`. |
| `OTLP_REQUEST_TIMEOUT_SECS` | `30` | The request timeout of all listeners, in seconds. |
| `MAX_OTLP_REQUEST_BYTES` | `23068672` (22 MiB) | The largest OTLP request body. 22 MiB is also the maximum. Uplink answers a larger body with `413`. |
| `MAX_OTLP_IN_FLIGHT_BYTES` | `268435456` (256 MiB) | The memory that the OTLP requests in progress can hold. Above it, Uplink answers `429`. It must be at least `MAX_OTLP_REQUEST_BYTES`. See [Sizing](https://docs.agent.golf/uplink/install.md#sizing). |
| `MAX_OTLP_NATS_WIRE_BYTES` | `31457280` (30 MiB) | The largest raw batch that Uplink stores, with its metadata, in bytes. 30 MiB is also the maximum. |
| `PUBLISH_TIMEOUT_MS` | `2000` | How long Uplink waits, in milliseconds, until its internal store confirms a raw batch. |

## Storage

Uplink keeps its data in the [state directory](https://docs.agent.golf/uplink/overview.md#state-directory).

| Environment variable | Flag | Default | Purpose |
| - | - | - | - |
| `UPLINK_STORE_DIR` | `-store-dir` | A subfolder of the state directory `~/.ag-uplink/<environment>/` | Where Uplink keeps session data. It must be on a persistent, encrypted disk on a local file system. With a custom `AGENTGOLF_API_BASE_URL`, Uplink has no state directory, so set this value and `AGENTGOLF_CREDS_FILE`. Uplink does not start without them. |
| `UPLINK_NATS_MAX_FILE_STORE` | | 75% of the free disk when Uplink starts | The storage limit of the buffers in bytes. It must be a positive byte count: Uplink does not start with `0` or an empty value. The session database has no limit. |
| `UPLINK_RECORD_STORE_THREADS` | `-record-store-threads` | `2` | The compaction threads of the session database. |
| `UPLINK_RECORD_STORE_MAX_OPEN_FILES` | `-record-store-max-open-files` | `1024` | The files of the session database that Uplink keeps open. Memory and file descriptors grow with it. |
| `MAX_OTLP_RAW_AGE_SECS` | | `172800` (48 hours) | Uplink deletes raw telemetry that it did not process in this time. `0` is no limit. Otherwise, at least `120`. |
| `MAX_OTLP_RAW_BYTES` | | The smaller of 5 GiB and half the storage limit | The largest backlog of raw telemetry. At the limit, Uplink deletes the oldest raw batches first. `-1` is no limit. Otherwise, at least `31457280` (30 MiB). When half the storage limit is less than 30 MiB, the default is no limit. |
| `OTLP_RAW_CAPTURE` | | `false` | `true` also keeps a copy of each raw batch for 7 days, at most 1 GiB. The storage limit must have 1 GiB free. |

A change of the raw telemetry settings takes effect at the next start. See [Alerts](https://docs.agent.golf/uplink/monitoring.md#alerts) for the effect of these limits.

From Uplink 0.1.32, Uplink keeps the stored sessions in an embedded database in the `records` directory of the store directory. The storage limit applies only to the buffers. The database grows with the stored history, so watch the free disk. The instance page shows the total storage and its split. See [Disk space](https://docs.agent.golf/uplink/install.md#disk-space).

## Local API

The local API is off by default in the binary and the container image. The Helm chart turns it on. For its settings, see [Local API](https://docs.agent.golf/uplink/local-api.md).

## Health reports, logs, and traces

| Environment variable | Flag | Default | Purpose |
| - | - | - | - |
| `UPLINK_METRICS_PUSH` | `-metrics-push` | `true` | Send health reports to Agent Golf for the **Uplink** section of the dashboard. The local API advertised URL travels in these reports, so Uplink does not start with `false` and an advertised URL. It does not stop the [usage totals](https://docs.agent.golf/getting-started/data-boundary.md#what-uplink-sends). |
| `UPLINK_METRICS_FLUSH_INTERVAL` | `-metrics-flush-interval` | `60s` | The interval between health reports. The minimum is `5s`. Keep it at two minutes or less. See [In the dashboard](https://docs.agent.golf/uplink/monitoring.md#in-the-dashboard). |
| `UPLINK_LOG_LEVEL` | `-log-level` | `info` | The lowest level that Uplink writes to its log and sends to your collector: `trace`, `debug`, `info`, `warn`, or `error`. |
| `RUST_LOG` | | `info` | The log level of the Uplink engines. Use one level name, such as `debug`. An engine record must also pass `UPLINK_LOG_LEVEL`. |
| `OTEL_EXPORTER_OTLP_ENDPOINT` | | Empty | Your OTLP collector, for the logs and traces of Uplink itself. See [Monitoring](https://docs.agent.golf/uplink/monitoring.md#send-logs-and-traces-to-your-collector). |
| `OTEL_EXPORTER_OTLP_LOGS_ENDPOINT`, `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` | | Empty | The collector for one signal. It replaces `OTEL_EXPORTER_OTLP_ENDPOINT` for that signal. |
| `OTEL_EXPORTER_OTLP_PROTOCOL`, `OTEL_EXPORTER_OTLP_LOGS_PROTOCOL`, `OTEL_EXPORTER_OTLP_TRACES_PROTOCOL` | | Empty | Empty or `http/protobuf`. For a signal with an export endpoint, Uplink does not start with another protocol. |
| `OTEL_LOGS_EXPORTER` | | `otlp` | `none` turns off the log export. Uplink accepts only `otlp` or `none`. |

## Startup, shutdown, and memory

| Environment variable | Flag | Default | Purpose |
| - | - | - | - |
| `UPLINK_NATS_READY_TIMEOUT` | | `10s` | How long Uplink waits at start until its embedded message server accepts connections. |
| `UPLINK_NATS_PORT` | | `4222` | The internal port of the embedded message server, on `127.0.0.1`. `-1` uses a random free port. See [Listeners and default binds](https://docs.agent.golf/uplink/network.md#listeners-and-default-binds). |
| `UPLINK_SHUTDOWN_TIMEOUT` | `-shutdown-timeout` | `30s` | The time that Uplink has to stop after `SIGTERM`. Keep it below the stop timeout of your service manager, for example `TimeoutStopSec` in systemd. |
| `GOMEMLIMIT` | | Dynamic | A soft memory limit, for example `4GiB`. When empty, Uplink sets a limit from its live memory use, at least 2.5 GiB and at most half the memory that it can use. |
| `UPLINK_RECORD_STORE_CACHE_BYTES` | `-record-store-cache-bytes` | `134217728` (128 MiB) | The cache of the session database in bytes. Its write buffers count against it. This memory is outside `GOMEMLIMIT`. |
| `UPLINK_RECORD_STORE_WRITE_BUFFER_BYTES` | `-record-store-write-buffer-bytes` | `67108864` (64 MiB) | The write buffer memory of the session database in bytes. At this size, the database writes the buffers to disk. |
| `MALLOC_ARENA_MAX`, `GLIBC_TUNABLES` | | `4` arenas | On Linux, the glibc malloc arenas of the Uplink engines. Uplink uses 4 arenas when `MALLOC_ARENA_MAX` is not set and `GLIBC_TUNABLES` has no `glibc.malloc.arena_max` entry. |


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