def write_timeseries_value(client, project_resource, custom_metric_type, instance_id, metric_kind):
 now = get_now_rfc3339()
 timeseries_data = {'metric': {'type': custom_metric_type, 'labels': {'environment': 'STAGING'}}, 'resource': {'type': 'gce_instance', 'labels': {'instance_id': instance_id, 'zone': 'us-central1-f'}}, 'points': [{'interval': {'startTime': now, 'endTime': now}, 'value': {'int64Value': get_custom_data_point()}}]}
 request = client.projects().timeSeries().create(name=project_resource, body={'timeSeries': [timeseries_data]})
 request.execute()

def write_timeseries_value ( client , project_resource , custom_metric_type , instance_id , metric_kind ) : now = get_now_rfc3339 ( ) timeseries_data = { 'metric' : { 'type' : custom_metric_type , 'labels' : { 'environment' : 'STAGING' } } , 'resource' : { 'type' : 'gce_instance' , 'labels' : { 'instance_id' : instance_id , 'zone' : 'us-central1-f' } } , 'points' : [ { 'interval' : { 'startTime' : now , 'endTime' : now } , 'value' : { 'int64Value' : get_custom_data_point ( ) } } ] } request = client . projects ( ) . timeSeries ( ) . create ( name = project_resource , body = { 'timeSeries' : [ timeseries_data ] } ) request . execute ( )
write the custom metric obtained by get_custom_data_point at a point in time .