CloudWatch Logs Insights¶
Purpose¶
The logs:errors task runs the standard BetterFleet Manage Core error-log query against AWS CloudWatch Logs Insights from the command line.
It is intended for developer and operator investigation when the AWS web console would otherwise be used to search recent critical or error-like log messages.
Results are saved to a gitignored file by default so they can be handed to local tools such as Codex without dumping production logs into the terminal.
Usage¶
Run the default query against ecs-logs-bf-manage-core in eu-west-2 for the last 48hrs:
The command prints the saved artifact path when it completes. By default, text output is written under:
Select a predefined region and period:
mise run logs:errors -- --region eu-west-2 --period 48hrs
mise run logs:errors -- --region ap-southeast-2 --period 24hrs
mise run logs:errors -- --region ca-central-1 --period 12hrs
The direct script interface is also available:
Choose an explicit output file when you want a stable path for another tool:
mise run logs:errors -- --region eu-west-2 --period 48hrs --output scratch/log-insights-errors/latest-manage-core-errors.txt
Save machine-readable output instead:
Options¶
--region: one ofap-southeast-2,eu-west-2,us-west-1, orca-central-1.--period: one of12hrs,24hrs, or48hrs.--log-group: defaults toecs-logs-bf-manage-core.--output: writes results to the given file path. Parent directories are created automatically.--json: writes a JSON object containing query metadata, statistics, and result rows.--poll-interval: seconds betweenget-query-resultspolling attempts.
The script converts the selected time period into UTC epoch startTime and endTime, starts the Logs Insights query with aws logs start-query, then polls aws logs get-query-results until the query reaches Complete, Failed, Cancelled, or Timeout.
Human-readable files show the timestamp, log stream, and message for each result. Failed, cancelled, timed-out, or invalid option cases exit non-zero.