Skip to main content

A library for monitoring and reporting resource usage in containerized applications

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.1.tar.gz (9.5 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.1-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: resource_reporter-0.1.1.tar.gz
  • Upload date:
  • Size: 9.5 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.1.tar.gz
Algorithm Hash digest
SHA256 3e27045b0dd7d559a42f85c289e5125d1f5a5639159dad1392bdc8c4a99b3147
MD5 6cb367dedb7d81ba87354ad6592707d9
BLAKE2b-256 65e1a0072afadab251d60a47fe5df1cfc2bd71cef0a55670df1fb54e11834073

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for resource_reporter-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c30ea502c8704e5095b7add8f20f3f7f0dd2ba61286cbae2ed8160128e6b8f4c
MD5 996ed44323fdabf2cac3eb07ebaa9362
BLAKE2b-256 2a8168611c8fc6491ec9645c183e3ccb60afde263b329f5f2b63990088255d54

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