A library for monitoring modeled metrics with Google Cloud Monitoring
Project description
Modeled Metrics Monitoring Library
A Python library for monitoring modeled metrics with Google Cloud Monitoring.
Overview
This library provides a Python interface for working with Google Cloud Monitoring metric descriptors and writing metrics. It queries the Google Cloud Monitoring API to retrieve metric descriptors.
Key Features
- Direct API Integration: Queries Google Cloud Monitoring API for metric descriptors
- Type Safety: Uses Google's protobuf
MetricDescriptorobjects - Flexible Metric Writing: Supports all metric value types (BOOL, INT64, DOUBLE, STRING, DISTRIBUTION)
- Error Handling: Comprehensive exception handling for Google Cloud API errors
Usage
Development
# Install in development mode
pip install -e .
# Run the example
python -m modeled_metrics_monitoring.run
Building and Distribution
# Build the package
./build.sh
# Install the built package
pip install dist/*.whl
Using the Library
from modeled_metrics_monitoring import get_metric_descriptor_by_type, write_metric
# Get a metric descriptor by type
descriptor = get_metric_descriptor_by_type(
"custom.googleapis.com/contextual-data-monitoring/modeled-metrics-ml-ops/vertex_pipeline/foot_traffic/feature_null_ratio"
)
# Write a metric
write_metric(
descriptor,
0.1,
metric_labels={
"feature_group_id": "temporal",
"feature_group_revision": "r0_1",
"feature_id": "is_weekend"
}
)
# Or write a metric using the type string directly
write_metric(
"custom.googleapis.com/contextual-data-monitoring/modeled-metrics-ml-ops/vertex_pipeline/foot_traffic/feature_null_ratio",
0.1,
metric_labels={
"feature_group_id": "temporal",
"feature_group_revision": "r0_1",
"feature_id": "is_weekend"
}
)
Architecture
- Terraform: Uses YAML files from
monitoring-metrics-definitions/metric-descriptors/*.yamlto create metric descriptors in Google Cloud Monitoring - Python Library: Queries Google Cloud Monitoring API directly to retrieve metric descriptors
- Separation of Concerns: Terraform handles infrastructure (creating metric descriptors), Python library handles runtime operations (querying and writing metrics)
This approach ensures that the Python library is always working with the current state of metric descriptors in Google Cloud Monitoring, while Terraform manages the infrastructure definitions.
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
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 unacast_modeled_metrics_monitoring-0.1.0.tar.gz.
File metadata
- Download URL: unacast_modeled_metrics_monitoring-0.1.0.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb0f77cd7352b1226433969be0b9ba4805f2c6d6c691a3d6ba8ff887ce81bfc6
|
|
| MD5 |
887585af0224f3e08af9cf48301506b3
|
|
| BLAKE2b-256 |
b566e9b484326d71c38ec2ee2f12d0e8cb90e8ec24165fb167345c1735f7f9e1
|
File details
Details for the file unacast_modeled_metrics_monitoring-0.1.0-py3-none-any.whl.
File metadata
- Download URL: unacast_modeled_metrics_monitoring-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a551ba5bb44d369083b7a81d1896fbb683aeddda0804d91122d2b7ffdad1673
|
|
| MD5 |
8f1b2088fb6f37b42643c4c6e9d64c33
|
|
| BLAKE2b-256 |
6d074e8321a61931c642c386732369228bee563399494cdd8500549063cbe476
|