Problem writing multiple values to google cloud metric

80 views Asked by At

I am trying to write an amount of values to a metric at one time without success



client = monitoring_v3.MetricServiceClient()
project_name = f"projects/{project_id}"

series = monitoring_v3.TimeSeries()
series.metric.type = "custom.googleapis.com/my_metric" 
series.resource.type = "gce_instance"
series.resource.labels["instance_id"] = "1234567890123456789"
series.resource.labels["zone"] = "us-central1-c"
series.metric.labels["TestLabel"] = "My Label Data"
now = time.time()
seconds = int(now)
nanos = int((now - seconds) * 10**9)
interval = monitoring_v3.TimeInterval(
    {"end_time": {"seconds": seconds, "nanos": nanos}}
)
point = monitoring_v3.Point({"interval": interval, "value": {"double_value": value}})
series.points = [point]
self.time_series.append(series) 

I always add series to time_series and at the end run a function that sends this array

self.client.create_time_series(name=self.project_name,time_series=self.time_series)
        
        

it lets me update the metric with only one value, what's the problem?

I tried updating the metric with many values at once and expected it to work

0

There are 0 answers