Skip to main content

A comprehensive monitoring library for real-time resource tracking and remote management of containerized applications with support for metrics reporting, asynchronous event notifications, and command listening via Google PubSub

Project description

Resource Reporter

A Python library for monitoring and reporting resource usage in containerized applications, with support for asynchronous event reporting and command listening.

Features

  • Regular resource usage reporting (CPU, memory, network, GPU)
  • Asynchronous event reporting
  • Command listening via Google PubSub for remote control of containers
  • Support for graceful shutdown and restart

Installation

Basic Installation

pip install resource-reporter

With GPU Support

pip install resource-reporter[gpu]

Quick Start

from resource_reporter import ResourceReporter

# Initialize the reporter
reporter = ResourceReporter(
    metrics_endpoint_url="http://monitoring-service/api/metrics",
    events_endpoint_url="http://monitoring-service/api/events",
    interval=30,
    consumer_id="consumer-1",
    group_consumer="production"
)

# Start reporting
reporter.start()

# Report an event
reporter.async_report_event({
    "status": 200,
    "error_code": 0,
    "error_message": "",
    "result": {"processed": True},
    "stats_data": {"duration_ms": 120},
    "task_id": "task-123"
})

# Update job stats
reporter.update_job_stats({
    "processed": 1000,
    "errors": 5
})

# Stop the reporter when done
reporter.stop()

Documentation

Environment Variables

The Resource Reporter library uses several environment variables for configuration. While most parameters can be passed directly to the constructor, environment variables provide a convenient way to configure the reporter, especially in containerized environments.

Required Environment Variables

None of the environment variables are strictly required, as all configuration can be passed directly to the constructor. However, the following are commonly used:

Optional Environment Variables

Variable Description Default
GROUP_CONSUMER Group identifier for the consumer "default"
API_KEY API key for authentication with metrics and events endpoints None
GOOGLE_APPLICATION_CREDENTIALS Path to Google Cloud credentials JSON file None

Google Cloud Authentication

For PubSub command listening functionality, the reporter requires Google Cloud authentication. There are several ways to provide this:

  1. Service Account JSON (recommended for non-GCP environments):
    export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account-key.json
    

License MIT

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

resource_reporter-0.1.3.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

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

resource_reporter-0.1.3-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file resource_reporter-0.1.3.tar.gz.

File metadata

  • Download URL: resource_reporter-0.1.3.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for resource_reporter-0.1.3.tar.gz
Algorithm Hash digest
SHA256 af5d2d3c699e7efccfb4da26a51d2e0f3e12238f28e3fde055b9b24fd5da5d27
MD5 381b2df60f143e8a3d35127fbffa95e6
BLAKE2b-256 cd4deecce105b56530cb26b692d31676081423b81c6827a81c57688f4af6bf60

See more details on using hashes here.

File details

Details for the file resource_reporter-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for resource_reporter-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b755bc09921a101b728bbb5806474c4e623275ad8f0a593a0f4da20eaf6767dc
MD5 4122d28eadbc4ff386e3c91174e7dff4
BLAKE2b-256 ac583556d25de4a586ce173bf80f243dc37348948904785762aa806366e16e59

See more details on using hashes here.

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