You need to enable JavaScript to run this app.
Cloud Monitor

Cloud Monitor

Copy page
Download PDF
SDK reference
Python usage examples
Copy page
Download PDF
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.​
Prerequisites​
  • Python SDK 2.7 or later has been installed. Run python --version to check the current Python version.​
SDK download link​
Python SDK download link: volcengine-python-sdk.​
Install the SDK​
You can use one of the following methods to install the SDK.​
Method 1​
Use the pip command to install the SDK.​
​
pip install volcengine-python-sdk​
​
Method 2​
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.​
Sample code​
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()​
# Specify your ak.​
configuration.ak = "Your AK"​
# Specify your sk.​
configuration.sk = "Your SK"​
# Specify the region that you want to access.​
configuration.region = "cn-beijing"​
​
try:​
api_instance = volcenginesdkcloudmonitor.CLOUDMONITORApi(volcenginesdkcore.ApiClient(configuration))​
resp = api_instance.get_metric_data(volcenginesdkcloudmonitor.GetMetricDataRequest(​
start_time=1671783***, end_time=1671786***, namespace="***", sub_namespace="***",​
metric_name="***",​
period="***s",​
instances=[​
volcenginesdkcloudmonitor.InstanceForGetMetricDataInput(​
dimensions=[​
volcenginesdkcloudmonitor.DimensionForGetMetricDataInput(​
name="ResourceID",​
value="eip-2d6hpp6bm0tts58oz*****",​
)​
]​
)​
]​
))​
pprint(resp)​
except ApiException as e:​
print("Exception when calling GetMetricData: %s\n" % e)​
​
​
Last updated: 2026.07.10 14:02:23