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-1.0.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-1.0.0-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

File details

Details for the file paperctl-1.0.0.tar.gz.

File metadata

  • Download URL: paperctl-1.0.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-1.0.0.tar.gz
Algorithm Hash digest
SHA256 987783b75057402a63755d244a207f968a79d617b832f83e8adb715daae63f42
MD5 51a0bd449d27f480d11200d97ed2e684
BLAKE2b-256 fd4112f8c4090b906b6de7e272c418987d473290460b5e367d371b59e77dc589

See more details on using hashes here.

Provenance

The following attestation bundles were made for paperctl-1.0.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-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: paperctl-1.0.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-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a498639de8828610fa4b41e0ce8c32f10ef4381e296243e1dc9063124f94c434
MD5 a1be72eaaca04d01716955a5eb1e4564
BLAKE2b-256 59decdfca86e946ca7f08e2faa6de17fadb2ec22441ab1b178ca460ea020e05d

See more details on using hashes here.

Provenance

The following attestation bundles were made for paperctl-1.0.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