AgentSkillsCN

Logging Read

日志读取

SKILL.md

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 (asc or desc). Defaults to desc (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

  1. Validate that limit does not exceed 1000.
  2. Construct the command with provided flags: gcloud logging read "[FILTER]" --project=[PROJECT] --limit=[LIMIT] --order=[ORDER] --format=json.
  3. If project is not provided, use the active project from gcp-context.
  4. Append --freshness=[FRESHNESS] if provided.
  5. Append --bucket=[BUCKET] and --view=[VIEW] if provided.
  6. Ensure the command is scoped to the target project.

Output

Returns a JSON list of log entries.

References