如何从 google.cloud.monitoring_v3 将参数传递给 list_time_series 方法?
Posted
技术标签:
【中文标题】如何从 google.cloud.monitoring_v3 将参数传递给 list_time_series 方法?【英文标题】:how to pass the aruguments to list_time_series method from google.cloud.monitoring_v3? 【发布时间】:2021-05-26 10:54:28 【问题描述】:for iteration in range(2160): # iterate back in time over 90 days
results = client.list_time_series(
name,
'metric.type = "appengine.googleapis.com/http/server/response_count"',
interval,
monitoring_v3.ListTimeSeriesRequest.TimeSeriesView.FULL)
当我执行我的代码时,它会抛出一个错误,
File "d:\intern\GCP\app_engine.py", line 44, in collect_metric_data
results = client.list_time_series(
TypeError: list_time_series() takes from 1 to 2 positional arguments but 5 were given
但 list_time_series 方法可以接受超过 2 个参数。
def list_time_series(request: metric_service.ListTimeSeriesRequest=None, name: str=None, filter: str=None, interval: common.TimeInterval=None, view: metric_service.ListTimeSeriesRequest.TimeSeriesView=None, retry: retries.Retry=gapic_v1.method.DEFAULT, timeout: float=None, metadata: Sequence[Tuple[str, str]]=())
我找不到那里有什么问题。帮我解决这个问题。
【问题讨论】:
【参考方案1】:无法正确识别位置参数。您可以手动定义它们以便识别它们。有关要传递的值的更多详细信息,请参阅list_time_series 参考。
results = client.list_time_series(
name=name, #value must be projects/[PROJECT_ID_OR_NUMBER]
filter='metric.type = "appengine.googleapis.com/http/server/response_count"',
interval=interval,
view=monitoring_v3.ListTimeSeriesRequest.TimeSeriesView.FULL)
【讨论】:
以上是关于如何从 google.cloud.monitoring_v3 将参数传递给 list_time_series 方法?的主要内容,如果未能解决你的问题,请参考以下文章
如何将数据从回收器适配器发送到片段 |如何从 recyclerview 适配器调用片段函数
如何从服务器获取和设置 android 中的 API(从服务器获取 int 值)?如何绑定和实现这个