title: Google Cloud Monitoring Api - 400 One or more TimeSeries could not be written Duplicate TimeSeries encountered
body: <p>I am trying to push multiple data points to a timeseries ,  but every time I go to create  the next data point it pulls the previous iteration  along the current iteration. for example below</p>
  <pre><code>metric {
    type: &quot;custom.googleapis.com/test/Cost_time&quot;
  }
  resource {
    type: &quot;global&quot;
    labels {
      key: &quot;project_id&quot;
      value: &quot;project-id-name&quot;
    }
  }
  points {
    interval {
      end_time {
        seconds: 1594058659
      }
    }
    value {
      double_value: 0.044661431106760574
    }
  }
  
  [metric {
    type: &quot;custom.googleapis.com/test/Cost_Time&quot;
  }
  resource {
    type: &quot;global&quot;
    labels {
      key: &quot;project_id&quot;
      value: &quot;project-id-name&quot;
    }
  }
  points {
    interval {
      end_time {
        seconds: 1594058659
      }
    }
    value {
      double_value: 0.044661431106760574
    }
  }
  ]
  metrics are successfully sent
  FINISHED &lt;- works perfectly fine here
  this is the iterator: 1
  This the response keys: 0.0004929316673951689
  Here is the result: 0.0004929316673951689
  metric {
    type: &quot;custom.googleapis.com/test/Cost_Time&quot;
  }
  resource {
    type: &quot;global&quot;
    labels {
      key: &quot;project_id&quot;
      value: &quot;project -id-name&quot;
    }
  }
  points {
    interval {
      end_time {
        seconds: 1594058660
      }
    }
    value {
      double_value: 0.0004929316673951689
    }
  }
  
  [metric {
    type: &quot;custom.googleapis.com/test/Cost_Time&quot;
  }
  resource {
    type: &quot;global&quot;
    labels {
      key: &quot;project_id&quot;
      value: &quot;project-id-name&quot;
    }
  }
  points {
    interval {
      end_time {
        seconds: 1594058659
      }
    }
    value {
      double_value: 0.044661431106760574 &lt;- duplicate is found here
    }
  }
  , metric {
    type: &quot;custom.googleapis.com/test/Cost_Time&quot;
  }
  resource {
    type: &quot;global&quot;
    labels {
      key: &quot;project_id&quot;
      value: &quot;project-id-name&quot;
    }
  }
  points {
    interval {
      end_time {
        seconds: 1594058660
      }
    }
    value {
      double_value: 0.0004929316673951689
    }
  }
  ]
  </code></pre>
  <p>here is python code im using to iterate through a list of dictionary keys</p>
  <pre><code> response_keys = list(response.keys())
      print(response_keys)
      for k in range(len(response_keys)):
          print(&quot;this is the iterator: &quot; + str(k))
          print(&quot;This the response keys: &quot; + str(response_keys[k]))
          getresp = get_time_series(response_keys[k])
          timeseries.append(getresp)
          print(timeseries)
          client.create_time_series(&quot;projects/project-name&quot;, timeseries)
          print(&quot;Cost metrics are successfully sent&quot;)
          print(&quot;FINISHED&quot;)
  </code></pre>
  <p>here the method Im using to create a time series</p>
  <pre><code>def get_time_series(result):
      series = monitoring_v3.types.TimeSeries()
      series.metric.type = 'custom.googleapis.com/test/Cost'
      series.resource.type = 'global'
      series.resource.labels['project_id'] = &quot;project-name&quot;
      points = series.points.add()
      points.interval.end_time.seconds = int(time.time())
      points.value.double_value = result
      return series
  </code></pre>
  <p>I have read and followed the documentation but my progress with this has come to a halt . Anyone know what I'm missing here?</p>
  <p>Here is the full Stacktrace :</p>
  <pre><code>Traceback (most recent call last):
    File &quot;/Users/malcode/PycharmProjects/untitled/venv/lib/python3.7/site-packages/google/api_core/grpc_helpers.py&quot;, line 57, in error_remapped_callable
      return callable_(*args, **kwargs)
    File &quot;/Users/malcode/PycharmProjects/untitled/venv/lib/python3.7/site-packages/grpc/_channel.py&quot;, line 826, in __call__
      return _end_unary_response_blocking(state, call, False, None)
    File &quot;/Users/malcode/PycharmProjects/untitled/venv/lib/python3.7/site-packages/grpc/_channel.py&quot;, line 729, in _end_unary_response_blocking
      raise _InactiveRpcError(state)
  grpc._channel._InactiveRpcError: &lt;_InactiveRpcError of RPC that terminated with:
      status = StatusCode.INVALID_ARGUMENT
      details = &quot;One or more TimeSeries could not be written: Field timeSeries[1] had an invalid value: Duplicate TimeSeries encountered. Only one point can be written per TimeSeries per request.: timeSeries[1]&quot;
      debug_error_string = &quot;{&quot;created&quot;:&quot;@1594133230.854639000&quot;,&quot;description&quot;:&quot;Error received from peer ipv4:172.217.12.202:443&quot;,&quot;file&quot;:&quot;src/core/lib/surface/call.cc&quot;,&quot;file_line&quot;:1056,&quot;grpc_message&quot;:&quot;One or more TimeSeries could not be written: Field timeSeries[1] had an invalid value: Duplicate TimeSeries encountered. Only one point can be written per TimeSeries per request.: timeSeries[1]&quot;,&quot;grpc_status&quot;:3}&quot;
  &gt;
  
  The above exception was the direct cause of the following exception:
  
  Traceback (most recent call last):
    File &quot;/Users/malcode/PycharmProjects/untitled/cost.py&quot;, line 108, in &lt;module&gt;
      print(main())
    File &quot;/Users/malcode/PycharmProjects/untitled/cost.py&quot;, line 103, in main
      client.create_time_series(&quot;projects/project-id-name&quot;, timeseries)
    File &quot;/Users/malcode/PycharmProjects/untitled/venv/lib/python3.7/site-packages/google/cloud/monitoring_v3/gapic/metric_service_client.py&quot;, line 1060, in create_time_series
      request, retry=retry, timeout=timeout, metadata=metadata
    File &quot;/Users/malcode/PycharmProjects/untitled/venv/lib/python3.7/site-packages/google/api_core/gapic_v1/method.py&quot;, line 143, in __call__
      return wrapped_func(*args, **kwargs)
    File &quot;/Users/malcode/PycharmProjects/untitled/venv/lib/python3.7/site-packages/google/api_core/retry.py&quot;, line 286, in retry_wrapped_func
      on_error=on_error,
    File &quot;/Users/malcode/PycharmProjects/untitled/venv/lib/python3.7/site-packages/google/api_core/retry.py&quot;, line 184, in retry_target
      return target()
    File &quot;/Users/malcode/PycharmProjects/untitled/venv/lib/python3.7/site-packages/google/api_core/timeout.py&quot;, line 214, in func_with_timeout
      return func(*args, **kwargs)
    File &quot;/Users/malcode/PycharmProjects/untitled/venv/lib/python3.7/site-packages/google/api_core/grpc_helpers.py&quot;, line 59, in error_remapped_callable
      six.raise_from(exceptions.from_grpc_error(exc), exc)
    File &quot;&lt;string&gt;&quot;, line 3, in raise_from
  google.api_core.exceptions.InvalidArgument: 400 One or more TimeSeries could not be written: Field timeSeries[1] had an invalid value: Duplicate TimeSeries encountered. Only one point can be written per TimeSeries per request.: timeSeries[1]
  
  
   
   
  </code></pre>