- Documentation
Cloud Monitor
SDK reference
Python usage examples
SDK reference
Python usage examples
Python usage examples
This topic describes the download link, installation method, and sample code of the Cloud Monitor Python SDK to help you quickly understand how to use the SDK to call APIs.
- Python SDK 2.7 or later has been installed. Run python --version to check the current Python version.
You can use one of the following methods to install the SDK.
Use the pip command to install the SDK.
pip install volcengine-python-sdk
Run the python setup.py install --user command to install the SDK for the specified user.
Run the sudo python setup.py install command to install the SDK for all users.
Create a GetMetricData.py file and add the following code to query the time series data aggregated for the specified metric within the specified time range.
from pprint import pprint
import volcenginesdkcore
import volcenginesdkcloudmonitor
from volcenginesdkcore.rest import ApiException
if __name__ == '__main__':
configuration = volcenginesdkcore.Configuration()
configuration.ak = "Your AK"
configuration.sk = "Your SK"
configuration.region = "cn-beijing"
api_instance = volcenginesdkcloudmonitor.CLOUDMONITORApi(volcenginesdkcore.ApiClient(configuration))
resp = api_instance.get_metric_data(volcenginesdkcloudmonitor.GetMetricDataRequest(
start_time=1671783***, end_time=1671786***, namespace="***", sub_namespace="***",
volcenginesdkcloudmonitor.InstanceForGetMetricDataInput(
volcenginesdkcloudmonitor.DimensionForGetMetricDataInput(
value="eip-2d6hpp6bm0tts58oz*****",
except ApiException as e:
print("Exception when calling GetMetricData: %s\n" % e)
Last updated: 2026.07.10 14:02:23