Modern CLI tool for querying Papertrail logs
Project description
paperctl
A modern Python CLI tool for downloading logs from Papertrail. Built with Typer, httpx, and Pydantic.
Installation
pip install paperctl
Or install 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 system:
# Pull last hour of logs to stdout
paperctl pull web-1
# Save to file
paperctl pull web-1 --output logs.txt
# Pull specific time range
paperctl pull web-1 --since -24h --until -1h
# Search within logs
paperctl pull web-1 --query "error" --output errors.txt
# Export as JSON or CSV
paperctl pull web-1 --format json --output logs.json
paperctl pull web-1 --format csv --output logs.csv
Features
- Simple log downloading: Target a system by name and pull logs locally
- Flexible time parsing:
-1h,-30m,1 day ago, ISO timestamps - Multiple output formats: text, JSON, CSV
- Automatic pagination: Handles large log volumes automatically
- Progress indicators: Visual feedback during downloads
- Rate limit handling: Automatic retry with backoff
Commands
pull
Download logs from a system.
paperctl pull <system> [OPTIONS]
Options:
-o, --output PATH Output file (default: stdout)
--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
search
Advanced search across systems and groups.
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
Manage systems.
paperctl systems list # List all systems
paperctl systems show <id> # Show system details
groups
Manage groups.
paperctl groups list # List all groups
paperctl groups show <id> # Show group with systems
archives
Manage 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 priority (highest to lowest):
- CLI arguments
- Environment variables (
PAPERTRAIL_*) - Local config (
./paperctl.toml) - Home config (
~/.paperctl.toml) - XDG config (
~/.config/paperctl/config.toml)
Environment Variables
PAPERTRAIL_API_TOKEN- API token (required)PAPERTRAIL_DEFAULT_LIMIT- Default event limitPAPERTRAIL_DEFAULT_OUTPUT- Default output formatPAPERTRAIL_TIMEOUT- API request timeout
Config File Format
api_token = "your_token_here"
default_output = "text"
default_limit = 1000
timeout = 30.0
Time Parsing
paperctl supports multiple time formats:
- Relative:
-1h,-30m,-7d,1h,2d - Natural language:
1 hour ago,2 days ago - ISO 8601:
2024-01-01T00:00:00Z - Special:
now
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
MIT License - 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-0.1.0.tar.gz.
File metadata
- Download URL: paperctl-0.1.0.tar.gz
- Upload date:
- Size: 13.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ea0bf93432f4a365f8c0f73c2ec0a53fcf5f0351281fc18e0733f69fd0f786e
|
|
| MD5 |
03d75fbbd7c015b45f40f0aeccd6b376
|
|
| BLAKE2b-256 |
59a0e1a09053db456a881b262c1662b0b26ccede10d6c6241236225acd9158af
|
Provenance
The following attestation bundles were made for paperctl-0.1.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-0.1.0.tar.gz -
Subject digest:
2ea0bf93432f4a365f8c0f73c2ec0a53fcf5f0351281fc18e0733f69fd0f786e - Sigstore transparency entry: 871348046
- Sigstore integration time:
-
Permalink:
jwmossmoz/paperctl@f61d0dca0bed877e51e5e5051e3f60c7ddb42fde -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/jwmossmoz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f61d0dca0bed877e51e5e5051e3f60c7ddb42fde -
Trigger Event:
push
-
Statement type:
File details
Details for the file paperctl-0.1.0-py3-none-any.whl.
File metadata
- Download URL: paperctl-0.1.0-py3-none-any.whl
- Upload date:
- Size: 23.1 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 |
06634ac42ee3624cd95418e780d6ea9dcaa0fac1577f16342cb782e5a3b76221
|
|
| MD5 |
234f992110e90004d1697cee19ed3c9a
|
|
| BLAKE2b-256 |
e0b360e9a8336122356670c726d8d31ce8aa2dd4b71c358eb1a9c8c6dd47c755
|
Provenance
The following attestation bundles were made for paperctl-0.1.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-0.1.0-py3-none-any.whl -
Subject digest:
06634ac42ee3624cd95418e780d6ea9dcaa0fac1577f16342cb782e5a3b76221 - Sigstore transparency entry: 871348047
- Sigstore integration time:
-
Permalink:
jwmossmoz/paperctl@f61d0dca0bed877e51e5e5051e3f60c7ddb42fde -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/jwmossmoz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f61d0dca0bed877e51e5e5051e3f60c7ddb42fde -
Trigger Event:
push
-
Statement type: