Logs Read
Read log entries from Google Cloud Logging.
Purpose
Retrieve log entries based on a filter. This is the primary tool for investigating past events and errors.
Inputs
- •
project(optional): The Google Cloud project ID to read logs from. - •
filter(optional): A valid Cloud Logging filter string. Defaults to empty (all logs). - •
limit(optional): Maximum number of entries to return. Defaults to 20. Max 1000. - •
order(optional): Sort order of entries (ascordesc). Defaults todesc(newest first). - •
freshness(optional): Only read entries as old as this duration (e.g.,1h,5h,1d). - •
bucket(optional): The log bucket to read from. - •
view(optional): The log view to read from.
Behavior
- •Validate that
limitdoes not exceed 1000. - •Construct the command with provided flags:
gcloud logging read "[FILTER]" --project=[PROJECT] --limit=[LIMIT] --order=[ORDER] --format=json. - •If
projectis not provided, use the active project fromgcp-context. - •Append
--freshness=[FRESHNESS]if provided. - •Append
--bucket=[BUCKET]and--view=[VIEW]if provided. - •Ensure the command is scoped to the target project.
Output
Returns a JSON list of log entries.