aws_logs_tail
Tail CloudWatch Logs for a log group to fetch recent events as JSON, oldest first, with optional time window and filter pattern.
Instructions
Tail CloudWatch Logs for a log group. Wraps 'aws logs tail' (not the raw FilterLogEvents API) so you get the same server-side time parsing and event-grouping the CLI uses. Returns recent events as JSON, oldest first. At most maxEvents events come back (default 500, ceiling 10000); when the window held more, the OLDEST are dropped so the newest survive, truncated is true, and totalEvents reports how many the window actually held. Does NOT stream -- run once to fetch the window, then call again with a later since. The cap bounds the RESPONSE, not the scan: 'aws logs tail' still drains the whole window server-side, so on a busy group narrow via filterPattern or a smaller since to make the call itself cheaper.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| since | No | Window to tail: '<number><s|m|h|d|w>'. Default '10m'. Example: '30m', '1h', '3d'. Must be greater than zero and at most 30 days -- 'aws logs tail' drains the whole window server-side. | |
| region | No | Override session region for this call. | |
| profile | No | Override session profile for this call. | |
| maxEvents | No | Maximum events to return (1-10000). Default 500. Events are returned oldest-first; when the window held more than this, the OLDEST are dropped and the newest kept, with truncated=true and totalEvents naming the full count. Bounds the RESPONSE only -- 'aws logs tail' has already drained the whole window server-side by the time the cap applies, so narrow 'since' or add a 'filterPattern' to make the call itself cheaper. | |
| timeoutMs | No | Timeout in milliseconds. Default 60000 (60s). Raise for large windows. | |
| logGroupName | Yes | Log group name, e.g. '/aws/lambda/my-fn' or '/aws/ecs/my-service' (no leading 'logs/'). A full log-group ARN ('arn:aws:logs:us-east-1:123456789012:log-group:/aws/lambda/my-fn', with or without a trailing ':*') is also accepted -- the group name is extracted from it. | |
| filterPattern | No | CloudWatch Logs filter pattern. E.g. 'ERROR', '"stack trace"', '[timestamp, request_id, level = ERROR, ...]'. | |
| logStreamNames | No | Restrict to specific stream names. Overrides the default (all streams in the group). | |
| logStreamNamePrefix | No | Restrict to streams with this prefix. Mutually exclusive with logStreamNames. |