Modern CLI tool for querying Papertrail logs
Project description
paperctl
Download logs from Papertrail. Built with Typer, httpx, and Pydantic.
Installation
Using uv (recommended):
uv tool install paperctl
Or with pip:
pip install paperctl
From source:
git clone https://github.com/jwmossmoz/paperctl.git
cd paperctl
uv pip install -e .
Quick Start
Set your Papertrail API token:
export PAPERTRAIL_API_TOKEN="your_token_here"
Pull logs from a single system:
paperctl pull web-1 # Last hour to stdout
paperctl pull web-1 --output logs.txt # Save to file
paperctl pull web-1 --since -24h # Custom time range
Pull from multiple systems in parallel:
# Download from three systems at once
paperctl pull web-1,web-2,web-3 --output logs/
# Search across multiple systems
paperctl pull web-1,web-2,db-1 --query "error" --output errors/
# Works with any combination
paperctl pull prod-*,staging-* --since -1h --output recent/
When you specify multiple systems, paperctl downloads them in parallel with automatic rate limiting (Papertrail allows 25 requests per 5 seconds). Each system gets its own file in the output directory.
What It Does
- Downloads logs from one or more Papertrail systems
- Handles pagination automatically (no manual limit setting)
- Respects API rate limits (25 requests per 5 seconds)
- Runs parallel downloads when pulling from multiple systems
- Parses relative times like
-1hor2 days ago - Outputs as text, JSON, or CSV
Commands
pull
Download logs from systems.
paperctl pull <system>[,<system>...] [OPTIONS]
Arguments:
<system> System name(s) or ID(s), comma-separated
Options:
-o, --output PATH Output file (single system) or directory (multiple)
--since TEXT Start time (default: -1h)
--until TEXT End time (default: now)
-f, --format TEXT Output format: text|json|csv (default: text)
-q, --query TEXT Search query filter
Examples:
# Single system
paperctl pull web-1
paperctl pull web-1 --output logs.txt
paperctl pull web-1 --query "error" --since -24h
# Multiple systems (parallel)
paperctl pull web-1,web-2,web-3 --output logs/
paperctl pull prod-api,prod-worker --query "500" --output errors/
search
Search logs with filters.
paperctl search [QUERY] [OPTIONS]
Options:
-s, --system TEXT Filter by system name or ID
-g, --group TEXT Filter by group name or ID
--since TEXT Start time
--until TEXT End time
-n, --limit INTEGER Maximum events
-o, --output TEXT Output format
-F, --file PATH Write to file
systems
List systems or show details.
paperctl systems list # List all systems
paperctl systems show <id> # Show system details
groups
List groups or show details.
paperctl groups list # List all groups
paperctl groups show <id> # Show group with systems
archives
Download historical archives.
paperctl archives list # List available archives
paperctl archives download <filename> # Download archive
config
Manage configuration.
paperctl config show # Show current config
paperctl config init # Initialize config file
Configuration
Configuration is loaded from (highest priority first):
- CLI arguments
- Environment variable:
PAPERTRAIL_API_TOKEN - Local config:
./paperctl.toml - Home config:
~/.paperctl.toml - XDG config:
~/.config/paperctl/config.toml
Create ~/.paperctl.toml:
api_token = "your_token_here"
timeout = 30.0 # Optional: API timeout in seconds
Time Formats
Relative times:
-1h,-30m,-7d(ago)1h,2d(future)
Natural language:
1 hour ago,2 days ago
ISO 8601:
2024-01-01T00:00:00Z
Special:
now
Rate Limiting
Papertrail's API allows 25 requests per 5 seconds. When pulling from multiple systems, paperctl automatically:
- Runs downloads in parallel
- Tracks requests across all systems
- Throttles to stay under the limit
- Retries with backoff on 429 errors
You don't need to worry about rate limits or pagination. Just specify what you want and paperctl handles the rest.
Development
# Install with dev dependencies
uv pip install -e ".[dev]"
# Run tests
uv run pytest
# Run linters
uv run ruff check .
uv run mypy src
# Format code
uv run ruff format .
# Build package
uv build
# Install pre-commit hooks
uv run prek install
License
Mozilla Public License 2.0 - see LICENSE for details.
Links
- GitHub: https://github.com/jwmossmoz/paperctl
- PyPI: https://pypi.org/project/paperctl/
- Papertrail API: https://www.papertrail.com/help/http-api/
Author
Jonathan Moss (jmoss@mozilla.com)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file paperctl-1.2.0.tar.gz.
File metadata
- Download URL: paperctl-1.2.0.tar.gz
- Upload date:
- Size: 18.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
25547bb37cb6a7fdfa29d69b99ad93af4562394304a1fd3770337d5008a68b50
|
|
| MD5 |
74456a3751bdeaf6fe1517a0b1a59dcb
|
|
| BLAKE2b-256 |
5f598fadf208c8ac6c1d43fbb03ddc0f1e21763a1949ba7a67254ac266b56351
|
Provenance
The following attestation bundles were made for paperctl-1.2.0.tar.gz:
Publisher:
release.yml on jwmossmoz/paperctl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
paperctl-1.2.0.tar.gz -
Subject digest:
25547bb37cb6a7fdfa29d69b99ad93af4562394304a1fd3770337d5008a68b50 - Sigstore transparency entry: 871415189
- Sigstore integration time:
-
Permalink:
jwmossmoz/paperctl@9ab412a9fc78c0c539be3a1317a114970e788f7d -
Branch / Tag:
refs/tags/v1.2.0 - Owner: https://github.com/jwmossmoz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9ab412a9fc78c0c539be3a1317a114970e788f7d -
Trigger Event:
push
-
Statement type:
File details
Details for the file paperctl-1.2.0-py3-none-any.whl.
File metadata
- Download URL: paperctl-1.2.0-py3-none-any.whl
- Upload date:
- Size: 29.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81cce0d178f3faa09b81752d2ebb310db223cac5711f7177beb92028fbdd02ff
|
|
| MD5 |
6c8e755ce4a11f5ba811f10fa65905fb
|
|
| BLAKE2b-256 |
c58febf67a5e1d7851afd94378b4e4f2ec9ba39dd44c97d90bb81d10ac5af6c7
|
Provenance
The following attestation bundles were made for paperctl-1.2.0-py3-none-any.whl:
Publisher:
release.yml on jwmossmoz/paperctl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
paperctl-1.2.0-py3-none-any.whl -
Subject digest:
81cce0d178f3faa09b81752d2ebb310db223cac5711f7177beb92028fbdd02ff - Sigstore transparency entry: 871415193
- Sigstore integration time:
-
Permalink:
jwmossmoz/paperctl@9ab412a9fc78c0c539be3a1317a114970e788f7d -
Branch / Tag:
refs/tags/v1.2.0 - Owner: https://github.com/jwmossmoz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9ab412a9fc78c0c539be3a1317a114970e788f7d -
Trigger Event:
push
-
Statement type: