stackdriver监控api客户端库
google-cloud-monitoring的Python项目详细描述
Stackdriver Monitoring API:管理stackdriver监视数据和 配置。大多数项目必须与stackdriver帐户关联, 除了个别方法页面上提到的一些例外。
快速启动
要使用此库,首先需要执行以下步骤:
- Select or create a Cloud Platform project.
- Enable billing for your project.
- Enable the Stackdriver Monitoring API.
- Setup Authentication.
安装
使用pip在virtualenv中安装此库。virtualenv是 创建独立的python环境。它解决的基本问题是 依赖项和版本,以及间接权限。
使用virtualenv,无需系统即可安装此库 安装权限,且不会与已安装的系统发生冲突 依赖关系。
支持的python版本
python=3.5
不推荐的python版本
python==2.7。Python2.7支持将于2020年1月1日取消。
Mac/Linux
pip install virtualenv
virtualenv <your-env>
source <your-env>/bin/activate
<your-env>/bin/pip install google-cloud-monitoring
窗口
pip install virtualenv
virtualenv <your-env>
<your-env>\Scripts\activate
<your-env>\Scripts\pip.exe install google-cloud-monitoring
预览
MetricServiceClient
fromgoogle.cloudimportmonitoring_v3client=monitoring_v3.MetricServiceClient()name=client.project_path('[PROJECT]')# Iterate over all resultsforelementinclient.list_monitored_resource_descriptors(name):# process elementpass# Or iterate over results one page at a timeforpageinclient.list_monitored_resource_descriptors(name).pages:forelementinpage:# process elementpass
下一步
- 阅读stackdriver监视api的Client Library Documentation 查看客户端上的其他可用方法。
- 阅读Product documentation了解有关产品的更多信息,并查看 如何引导。