Google Sign-In Required

Use your company Google account to access the BetterFleet private content.

Back to private home

BetterFleet Support Private
Skip to content
BetterFleet Dev Wiki
CloudWatch Logs Insights
Initializing search
    bf-dev
    • Home
    • Operations
    bf-dev
    • Home
      • Operations
      • Onboarding Runbook
      • Daily Operations Runbook
      • Troubleshooting
      • Testing Guide
        • Operations Tooling
        • CloudWatch Logs Insights
          • Purpose
          • Usage
          • Options
          • Query
        • Code Indexing
        • Customer CMS user export
    • Purpose
    • Usage
    • Options
    • Query
    1. Home
    2. Operations
    3. Tooling
    Operations Platform Reliability & Safety Resilience & Security general

    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:

    mise run logs:errors
    

    The command prints the saved artifact path when it completes. By default, text output is written under:

    scratch/log-insights-errors/
    

    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:

    scripts/log-insights-errors --region eu-west-2 --period 48hrs
    

    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:

    mise run logs:errors -- --json --output scratch/log-insights-errors/latest-manage-core-errors.json
    

    Options¶

    • --region: one of ap-southeast-2, eu-west-2, us-west-1, or ca-central-1.
    • --period: one of 12hrs, 24hrs, or 48hrs.
    • --log-group: defaults to ecs-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 between get-query-results polling 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.

    Query¶

    fields @timestamp, @message, @logStream, @log
    | filter @message like "CRITICAL"
        or @message like "Traceback"
        or @message like "RuntimeWarning"
        or @message like "ERROR:"
    | sort @timestamp desc
    | limit 2000
    
    Made with Material for MkDocs
    BFDev Docs Assistant
    New conversation?
    Ask one focused question at a time, this helps the assistant provide accurate answers about what's been implemented in BetterFleet.