Tencent Cloud Monitor SDK for Python

raw JSON →
3.1.92 verified Sat May 09 auth: no python

Official Tencent Cloud SDK for the Cloud Monitor (CM) service. Provides APIs for querying monitoring data, setting alarms, and managing dashboard. Current version 3.1.92. Releases are frequent, often monthly, but breaking changes are rare. Part of the larger tencentcloud-sdk-python ecosystem.

pip install tencentcloud-sdk-python-monitor
error ModuleNotFoundError: No module named 'tencentcloud.monitor'
cause Missing dependency or wrong import path. The package tencentcloud-sdk-python-monitor may not be installed, or you are trying to import the module for the first time without the common package.
fix
Run: pip install tencentcloud-sdk-python-monitor tencentcloud-sdk-python-common
error ImportError: cannot import name 'MonitorClient' from 'tencentcloud.monitor'
cause The import path is incomplete. You need to include the API version.
fix
Use: from tencentcloud.monitor.v20180724 import monitor_client
error TencentCloudSDKException: [InvalidParameter] The metric name is invalid
cause The provided metric name is incorrect or not available in the specified region.
fix
Use the correct metric name from the Tencent Cloud Monitor documentation. For example, cpu_usage for CVM.
error AttributeError: module 'tencentcloud.monitor.v20180724.models' has no attribute 'DescribeMonitorDataRequest'
cause The models module may have a slightly different class name due to version differences.
fix
Check the exact class name in the API docs. Often it's DescribeMonitorDataRequest but might be other camelCase variants.
gotcha Import paths must include the API version (v20180724). Without it, the import fails silently or raises ModuleNotFoundError.
fix Use `from tencentcloud.monitor.v20180724 import monitor_client` instead of `from tencentcloud.monitor import monitor_client`.
breaking Migrating from SDK v2 to v3 changed the package name and import structure. v2 used `tencentcloud-sdk-python` monolithic package.
fix Install the sub-package (`tencentcloud-sdk-python-monitor`) and update imports to versioned paths.
deprecated Some older APIs (e.g., `DescribeBasicAlarmList`) are deprecated. Use the newer equivalents.
fix Check the official API documentation for the latest methods.
gotcha Region must be explicitly set. If not provided, defaults to empty string causing request failures.
fix Always set the region parameter when creating the client, e.g., `MonitorClient(cred, 'ap-guangzhou')`.

Minimal authenticated client creation and a call to DescribeMonitorData.

import os
from tencentcloud.common import credential
from tencentcloud.monitor.v20180724 import monitor_client, models

# Replace with your credentials
cred = credential.Credential(
    os.getenv('TENCENTCLOUD_SECRET_ID', ''),
    os.getenv('TENCENTCLOUD_SECRET_KEY', '')
)
client = monitor_client.MonitorClient(cred, 'ap-guangzhou')

# Example: describe base metrics
req = models.DescribeMonitorDataRequest()
req.MetricName = 'cpu_usage'
# Set other required fields...
resp = client.DescribeMonitorData(req)
print(resp)