Skip to content

Change application telemetry settings with Fleet | Logfire

Change what a running application records and sends: its sampling rate, minimum log level, redaction and scrubbing, and which signals it exports. You change these from Logfire, with no restart or redeploy.

Each application takes its settings from an SDK policy. A policy sets only the settings you choose; every other setting stays as the application configured it (“Application controlled”). See Change policies.

Before you start

  • Your application already sends data to Logfire, with a write token in its environment. Fleet doesn’t change how it sends data: it changes the SDK’s settings.
  • You can load a small Fleet package into the application, as shown below for each language.

Connect an application

  1. In Fleet management, open SDKs and select Add application.

  2. Enter the application’s name, which becomes its OTEL_SERVICE_NAME, and choose what it uses. Select Get setup instructions.

    The Connect an application dialog with an application name and a choice of setup

  3. Install Fleet support and load it, as Logfire shows for your setup:

Requires Python 3.11+ and Logfire 5.5.0 or a later 5.x release. If you are upgrading from 4.x, read the 5.x upgrade notes first.

Terminal
pip install --upgrade 'logfire[fleet]'

Add fleet=True to your logfire.configure() call. Keep its other arguments and your instrumentation calls:

import logfire

logfire.configure(
    service_name='checkout-api',  # the application name you entered in Fleet
    fleet=True,
)

Setting LOGFIRE_FLEET=true in the environment does the same without a code change. The policy then applies to everything the SDK sends, on every exporter, the console included. configure() never raises for Fleet: without the fleet extra or without a Fleet endpoint (OTEL_OPAMP_ENDPOINT or FleetOptions(endpoint=...)), it warns with LogfireFleetWarning and the SDK runs with its own settings, so you can deploy the code before adding the Fleet environment variables. To set the connection in code instead of the environment, pass fleet=FleetOptions(...) from logfire.fleet. See the Python Logfire guide for the full reference.

On Logfire 5.1 to 5.4, install 'logfire-fleet-otel[logfire]' and replace logfire.configure(...) with logfire_fleet_otel.configure_logfire(...), using the same arguments. See the Python Logfire guide.

  1. Save the Fleet connection key from this Add application setup in your secret manager. Logfire shows it once: you can’t view it again after closing setup. Set these environment variables before starting the application:

    VariableValue
    OTEL_OPAMP_ENDPOINTUS: wss://logfire-us.pydantic.dev/v1/opamp. EU: wss://logfire-eu.pydantic.dev/v1/opamp. Use your project’s region.
    OTEL_OPAMP_HEADERSAuthorization=Bearer%20<Fleet connection key>. Replace <Fleet connection key> with the key from setup. %20 is the encoded space between Bearer and the key, required by OpenTelemetry’s header format.
    OTEL_SERVICE_NAMEThe application name you entered in Fleet, for example checkout-api. This names the application in Fleet.

    For self-hosted Logfire, use your Logfire host with /v1/opamp, replacing https:// with wss://: for example, wss://logfire.example.com/v1/opamp. Your operator can set a different URL, so if the Add application setup shows one, use that.

    In a terminal, Logfire’s setup commands prompt for the key without showing it. In production, set the variables in your deployment instead.

  2. Start the application, and select Check connection.

The connection key only manages settings. Your application keeps sending telemetry with its existing write token. Each language has a full guide in pydantic/opamp-clients, including frameworks and deployment examples.

In code

In the Fleet setup, choose In my code under Where does your application set up OpenTelemetry? for Python with OpenTelemetry or Node.js. With manage(), your application keeps its own OpenTelemetry setup, and Fleet places its controls in front of every exporter that setup has:

  • Applied: redaction, scrubbing, minimum log level, rate limits and which signals are exported.
  • Kept in your code: the sampler and the instrumentations. A policy that changes sampling or instrumentations reports Failed for this application, naming the setting, and the application logs a warning at start.

The connection still comes from OTEL_OPAMP_ENDPOINT and OTEL_OPAMP_HEADERS. Call manage() once, after your setup: with no SDK set up, it warns and the application runs unmanaged. For full control, including sampling, use the launcher (opentelemetry-instrument or --import) or, in Python, logfire_fleet_otel.configure(). The Python and Node.js guides cover manage() in full.

Check the connection

Within a few seconds of starting, the setup shows the application as connected and its policy as applied:

The setup's last step, showing the application connected and its policy applied on one instance

The SDKs tab then lists the application with its connection, health, policy status and SDK policy. One row covers every running instance of the application.

The SDKs tab listing one connected application with its SDK policy applied

Try a policy change

  1. Open the application’s SDK policy from the SDKs tab or Policies.
  2. Set Minimum log level to Warn.
  3. Select Review policy, then publish it.

Within seconds the application stops sending info logs to the Live view, with no restart or deploy. Set it back to Application controlled to undo.

Troubleshooting

SymptomCheck
The application never connectsCheck that the Fleet package loads before your application starts, and that OTEL_OPAMP_ENDPOINT and OTEL_OPAMP_HEADERS are set in the application’s environment. Its logs name connection and authentication errors.
Connected, but Policy status shows FailedOpen the application in SDKs. It reports which setting it couldn’t apply and why. An application set up in code can’t take sampling or instrumentation changes.
A setting shows as unsupportedNot every setup supports every setting. Unsupported clients are left out of a rollout’s preview.
No telemetry arrivesFleet doesn’t send telemetry. Check the application’s write token and region settings.
Node.js prints MetadataLookupWarning at startOpenTelemetry’s Google Cloud resource detector found no GCP metadata server, so it is harmless outside GCP. To skip the cloud detectors, set OTEL_NODE_RESOURCE_DETECTORS=env,host,os,process,serviceinstance.

Next steps

  • Change policies: sampling rules, redaction, scrubbing and exports, and how to roll out a change to a few instances first.
  • Scrubbing: what Logfire redacts by default.