Fetch Logs with the Confluent CLI
Use the confluent logs commands to fetch logs for a Confluent Cloud resource from
one place. Every log source, such as cluster health events or connector logs,
uses the same commands, flags, and output formats.
Requirements
The OrganizationAdmin or EnvironmentAdmin role.
A log source for your resource. Each log source works with one resource type:
Log source
Resource
Resource ID
cluster-healthKafka cluster
lkc-IDconnector-logsConnector
lcc-orclcc-ID
List log sources
To list the log sources you can query, run:
confluent logs source list
Your output should resemble:
Name | Display Name | Resource | ID Prefix | Lookback
-----------------+-----------------------+-----------+-----------+---------
cluster-health | Cluster health events | kafka | lkc | 7d
connector-logs | Connector logs | connector | lcc, clcc | 3d
Describe a log source
To see the search fields, allowed values, and returned fields for a log source,
run confluent logs source describe with the source name:
confluent logs source describe cluster-health
The output lists the resource type, how far back you can query, whether
--search-text is supported, each search field with its allowed values, and
each field that a log record returns. Add -o json or -o yaml to read the
same details in a script.
Fetch logs
To fetch logs, run confluent logs fetch with the resource ID and the
--source flag:
confluent logs fetch <resource-id> --source <log-source> [flags]
The --source flag is required. The command checks the source against the
resource ID and returns an error that names the fix when they don’t match.
The command accepts these flags:
Flag |
Description |
|---|---|
|
The log source to query, such as |
|
A relative time window that ends now, such as |
|
The start of the time window, in UTC, such as
|
|
The end of the time window, in UTC. Defaults to now when you set
|
|
A |
|
Text to search for in log messages, for log sources that support it. |
|
Return only the most recent entries, up to 1,000. |
|
Fetch the next page of the previous identical query. |
|
Append results to a file as JSON lines. |
|
The environment ID. Defaults to the active environment. |
|
The Kafka cluster ID, for resource types that need one. Defaults to the active cluster. |
|
The output format: |
Set the time window
Each log source limits how far back you can query. The Lookback column in
the confluent logs source list output shows the limit. A window that reaches
further back returns an error.
To fetch logs from the last hour, use --since:
confluent logs fetch lkc-abc123 --source cluster-health --since 1h
To fetch logs from a fixed window, use --from and --to:
confluent logs fetch lkc-abc123 --source cluster-health \
--from 2026-12-01T00:00:00Z --to 2026-12-01T12:00:00Z
Filter logs
Filters combine as follows:
Different fields must all match.
A repeated field matches either value.
To fetch only ERROR and WARN entries for one event type, run:
confluent logs fetch lkc-abc123 --source cluster-health --since 24h \
--search level=ERROR,level=WARN --search event_type=SERVICE_MAINTENANCE
To search the log messages for a phrase, use --search-text. Wildcards such
as * and ? match across the text fields:
confluent logs fetch lcc-123456 --source connector-logs --since 24h \
--search level=ERROR --search-text "discon*"
Limit and page results
To return only the most recent entries, use --tail:
confluent logs fetch lkc-abc123 --source cluster-health --since 7d --tail 10
To get the next page of a query, run the same command with --next. The CLI
stores the last query, so the flags must match. When no pages remain, the CLI
prints No more pages for this query.
confluent logs fetch lkc-abc123 --source cluster-health --since 7d --next
Choose an output format
The default human output is a table of the default columns for the log
source. To get every field of each record, use -o json or -o yaml.
To append the records to a file as JSON lines, use --output-file. The CLI
prints nothing when the command succeeds.
confluent logs fetch lcc-123456 --source connector-logs --since 24h \
--search level=ERROR --output-file errors.jsonl
Fetch cluster health logs
To fetch the ERROR events for a cluster from the last hour, run:
confluent logs fetch lkc-abc123 --source cluster-health --since 1h \
--search level=ERROR
Your output should resemble:
Found 1 log entry for cluster-health on lkc-abc123:
Timestamp | Level | Event Type | Message
-------------------------+-------+-------------------------+------------------
2026-12-01T09:41:12Z | ERROR | SERVICE_ISSUE_DETECTED | Elevated latency
Fetch connector logs
To fetch the ERROR logs for a connector from the last 24 hours, run:
confluent logs fetch lcc-123456 --source connector-logs --since 24h \
--search level=ERROR --search-text "example error"
Your output should resemble:
Found 1 log entry for connector-logs on lcc-123456:
Timestamp | Level | Task ID | Message
-------------------------+-------+---------+----------------------------
2026-12-01T08:42:10Z | ERROR | task-0 | Connection was lost.
Troubleshoot errors
The command checks your flags before it sends a request. These errors name the fix:
--source is required: add--sourcewith a name fromconfluent logs source list.is not a search field: runconfluent logs source describeto see the valid search fields and values.does not match log source: use a resource ID that fits the log source.--since cannot be used with --from or --to: use one kind of window.rate limit exceeded: wait for the number of seconds that the error shows, and run the command again.