Following logs with keenauth logs tail

keenauth logs tail follows the environment logs (sign-ins, sessions, tokens, MFA, attack protection) while you work, like tail -f. It prints the most recent records first, oldest first, then checks for new records at a fixed interval and prints them as they appear. Press Ctrl-C to stop; the command then exits with code 0.

The command reads the same records as keenauth logs list and needs the same permission (logs:read). It works with an API key and with a keenauth login session.

Usage

keenauth logs tail --type authentication. --user usr_01j9z3k4m5n6p7q8r9s0t1v2w3
Flag Description
--type Log type prefix, for example authentication. or session.created. Comma separated or repeated, at most 20; a record matching any of them is shown.
--user Only records of this user (usr_…).
--org Only records of this organization (org_…).
--limit Number of recent records printed before following, 1 to 100. Default: 20.
--interval Time between two checks, from 1s to 60s. Default: 5s.
--output, -o table, json or yaml. Without the flag the CLI prints a table on a terminal and JSON otherwise.

An invalid filter or interval stops the command with code 2 before any request is sent.

Output

keenauth logs tail --type authentication.failed -o json | jq -r '.ip_country'

The IP address, user agent and identifier hint appear only if your credential has the permissions described in the logs API.

How it follows

The logs API returns the newest records first and has no wait parameter, so the command polls. After the first page, each check asks for the records at or after the newest time it has printed and skips the records it has already printed, so no record is shown twice. A check follows the result pages until it has every new record, up to 2,000 records per check. Records older than the retention window of your plan are not returned.

Exit codes

Code Meaning
0 Stopped with Ctrl-C.
1 A server error or a network failure.
2 Usage error: an invalid filter, limit, interval or output format. No request was sent.
3 The credential is missing, or the server answered 401 or 403.
4 The plan does not include the feature (403 with plan_feature_unavailable).