confluent logs fetch
Description
Fetch logs from a log source for a single resource. Run confluent logs source list to see the available log sources, and confluent logs source describe <source> for the search fields and returned fields of one.
confluent logs fetch <resource-id> [flags]
Flags
--source string REQUIRED: The log source to query, for example "cluster-health". Run "confluent logs source list" for the available log sources.
--since string Relative time window ending now, for example 1h, 24h or 7d. Cannot be combined with --start-time or --end-time.
--start-time string Window start, in ISO 8601 UTC format (for example 2026-08-20T00:00:00Z).
--end-time string Window end, in ISO 8601 UTC format. Defaults to now when --start-time is set.
--search strings A comma-separated list of "field=value" search filters, validated against the log source. Repeating a field means OR (for example level=ERROR,level=WARN).
--search-text string Full-text search within log messages, where the log source supports it.
--tail int Return only the most recent N entries (maximum 1000).
--next Fetch the next page of the previous identical query.
--output-file string Append the results to this file as JSON lines.
--environment string Environment ID.
--cluster string Kafka cluster ID, where the resource type requires it. Defaults to the active Kafka cluster.
-o, --output string Specify the output format as "human", "json", or "yaml". (default "human")
Global Flags
-h, --help Show help for this command.
--unsafe-trace Equivalent to -vvvv, but also log HTTP requests and responses which might contain plaintext secrets.
-v, --verbose count Increase verbosity (-v for warn, -vv for info, -vvv for debug, and -vvvv for trace).
Examples
Fetch cluster health events for one Kafka cluster from the last hour.
confluent logs fetch lkc-123456 --source cluster-health --since 1h
Fetch only ERROR events of a given type from the last 3 days, newest 100 entries.
confluent logs fetch lkc-123456 --source cluster-health --since 3d --search level=ERROR,event_type=SERVICE_MAINTENANCE --tail 100
Fetch ERROR and WARN entries containing the text “latency” and append them to a file as JSON lines.
confluent logs fetch lkc-123456 --source cluster-health --since 24h --search level=ERROR,level=WARN --search-text "latency" --output-file events.jsonl
See Also
confluent logs - Query logs from Confluent Cloud log sources.