Skip to main content

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):

  1. CLI arguments
  2. Environment variables (PAPERTRAIL_*)
  3. Local config (./paperctl.toml)
  4. Home config (~/.paperctl.toml)
  5. XDG config (~/.config/paperctl/config.toml)

Environment Variables

  • PAPERTRAIL_API_TOKEN - API token (required)
  • PAPERTRAIL_DEFAULT_LIMIT - Default event limit
  • PAPERTRAIL_DEFAULT_OUTPUT - Default output format
  • PAPERTRAIL_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

Author

Jonathan Moss (jmoss@mozilla.com)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

paperctl-0.1.0.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

paperctl-0.1.0-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

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

Hashes for paperctl-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2ea0bf93432f4a365f8c0f73c2ec0a53fcf5f0351281fc18e0733f69fd0f786e
MD5 03d75fbbd7c015b45f40f0aeccd6b376
BLAKE2b-256 59a0e1a09053db456a881b262c1662b0b26ccede10d6c6241236225acd9158af

See more details on using hashes here.

Provenance

The following attestation bundles were made for paperctl-0.1.0.tar.gz:

Publisher: release.yml on jwmossmoz/paperctl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for paperctl-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 06634ac42ee3624cd95418e780d6ea9dcaa0fac1577f16342cb782e5a3b76221
MD5 234f992110e90004d1697cee19ed3c9a
BLAKE2b-256 e0b360e9a8336122356670c726d8d31ce8aa2dd4b71c358eb1a9c8c6dd47c755

See more details on using hashes here.

Provenance

The following attestation bundles were made for paperctl-0.1.0-py3-none-any.whl:

Publisher: release.yml on jwmossmoz/paperctl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page