Rohit Prabu
Rohit Prabu

Reputation: 284

how to pass the aruguments to list_time_series method from google.cloud.monitoring_v3?

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)

when i execute my code, it throws an error,

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

but list_time_series method can take more than 2 arguments.

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]]=())

i could not find what is wrong there. help me to fix this.

Upvotes: 1

Views: 1072

Answers (1)

Ricco D
Ricco D

Reputation: 7287

The positional parameters are not being recognized properly. You can define them manually for them to be recognized. See the list_time_series reference for more details on what values to pass.

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)

Upvotes: 1

Related Questions